:root {
  --bg: #000;
  --fg: #ededed;
  --dim: #6e6e6e;
  --line: #1f1f1f;
  --line-hi: #3a3a3a;
  --panel: rgba(8, 8, 8, .88);
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }
html { background: var(--bg); color-scheme: dark; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--fg);
  font: 12.5px/1.6 var(--mono); letter-spacing: .01em;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--fg); color: var(--bg); }
a { color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--line-hi); transition: border-color .2s; }
a:hover { border-color: var(--fg); }
[hidden] { display: none !important; }
.dim { color: var(--dim); }
b { font-weight: 700; }

/* interface chrome is lowercase; user content (subjects, messages) keeps its case */
.brand, .nav, .foot, .btn, .chip, .link, .h, .lbl, .badge, .tbl th, .hdrs dt, .field > span:first-child,
.title:not(.msg-subj), .big, .stat span, .crumbs, .live, .flash .tag, .boot, .navbtn, .box-meta, .quota-edit,
.inbox-head .sub, .tbl td:not(.mono), .hdrs.ui dd { text-transform: lowercase; }

/* ---------- background: drifting grid + scanlines ---------- */
.grid {
  position: fixed; inset: -64px; z-index: -2; pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 32px 32px;
  animation: drift 24s linear infinite;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 15%, transparent 70%);
}
@keyframes drift { to { transform: translate(32px, 32px); } }
.scan {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.02) 0 1px, transparent 1px 3px);
}
.scan::after {
  content: ""; position: absolute; left: 0; right: 0; height: 90px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,.03), transparent);
  animation: sweep 8s linear infinite;
}
@keyframes sweep { from { top: -90px; } to { top: 100%; } }

/* ---------- chrome ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px clamp(16px, 3vw, 32px); border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,.82); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 10;
  animation: drop .5s var(--ease) both;
}
.brand { font-size: 13px; font-weight: 700; letter-spacing: .08em; border: 0; display: flex; align-items: center; gap: 8px; }
.brand .dim { font-weight: 400; margin-left: -2px; }
.brand .blk { width: 7px; height: 13px; background: var(--fg); animation: blink 1.1s steps(1) infinite; }
.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav a, .navbtn {
  border: 1px solid transparent; padding: 3px 9px; font: inherit; font-size: 11px; letter-spacing: .08em;
  color: var(--dim); background: none; cursor: pointer; transition: color .2s, border-color .2s, background .2s;
}
.nav a:hover, .navbtn:hover { color: var(--fg); border-color: var(--line-hi); }
.nav a.on { color: var(--bg); background: var(--fg); }
.nav form { margin: 0; }

.main { flex: 1; width: 100%; max-width: 920px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 32px) 48px; }
.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 8px clamp(16px, 3vw, 32px); border-top: 1px solid var(--line);
  font-size: 10px; letter-spacing: .12em; color: var(--dim);
}
.pulse { display: inline-block; width: 5px; height: 5px; background: var(--fg); margin-right: 5px; animation: pulse 1.6s ease-in-out infinite; vertical-align: 1px; }
@keyframes pulse { 50% { opacity: .15; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- typography ---------- */
.title { font-size: clamp(16px, 2.6vw, 20px); line-height: 1.25; letter-spacing: .04em; margin: 0 0 16px; font-weight: 700; overflow-wrap: anywhere; }
.h { font-size: 11px; letter-spacing: .12em; margin: 0 0 10px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.h.small { margin-top: 18px; color: var(--dim); }
.idx { color: var(--bg); background: var(--fg); padding: 0 4px; font-weight: 700; }
.sub { color: var(--dim); margin: 0 0 12px; font-size: 11.5px; }
.hint { color: var(--dim); font-size: 11px; margin: -4px 0 10px; }
.lbl { font-size: 10px; letter-spacing: .14em; color: var(--dim); }
.cursor { animation: blink 1s steps(1) infinite; }
[data-type].typing::after { content: "_"; animation: blink .7s steps(1) infinite; }

/* ---------- panels ---------- */
.panel {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  padding: clamp(12px, 2vw, 18px); margin-bottom: 14px;
  animation: rise .6s var(--ease) both;
  transition: border-color .3s;
}
.panel:hover { border-color: var(--line-hi); }
.panel::before, .panel::after { content: ""; position: absolute; width: 6px; height: 6px; border: 1px solid var(--fg); transition: width .4s var(--ease), height .4s var(--ease); }
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.panel:hover::before, .panel:hover::after { width: 18px; height: 18px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.cols > .panel { margin-bottom: 0; }
.cols + .panel, .cols + section { margin-top: 14px; }
.main > *:nth-child(2) { animation-delay: .05s; }
.cols > *:nth-child(2) { animation-delay: .1s; }
.panel + .panel { animation-delay: .15s; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 10px; }
.field > span:first-child { display: block; font-size: 10px; letter-spacing: .14em; color: var(--dim); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input:not([type]) {
  width: 100%; background: #000; color: var(--fg); border: 1px solid var(--line-hi);
  padding: 7px 9px; font: inherit; font-size: 12.5px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus { border-color: var(--fg); box-shadow: 0 0 0 1px var(--fg), 0 0 16px rgba(255,255,255,.06); }
input::placeholder { color: #3d3d3d; }
input[type=number] { width: 72px; }
.addr-row { display: flex; align-items: stretch; }
.addr-row b { display: flex; align-items: center; padding: 0 9px; border: 1px solid var(--line-hi); border-left: 0; color: var(--dim); font-weight: 400; white-space: nowrap; }
.addr-row .btn { margin-left: 6px; }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; cursor: pointer; font-size: 11.5px; }
.check input { appearance: none; width: 12px; height: 12px; border: 1px solid var(--fg); margin: 0; cursor: pointer; }
.check input:checked { background: var(--fg); box-shadow: inset 0 0 0 2px #000; }

input[type=range] { appearance: none; width: 100%; height: 18px; background: transparent; margin: 2px 0 10px; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 1px; background: var(--line-hi); }
input[type=range]::-moz-range-track { height: 1px; background: var(--line-hi); }
input[type=range]::-webkit-slider-thumb { appearance: none; width: 9px; height: 15px; background: var(--fg); margin-top: -7px; border: 0; transition: transform .15s; }
input[type=range]::-moz-range-thumb { width: 9px; height: 15px; background: var(--fg); border: 0; }
input[type=range]:active::-webkit-slider-thumb { transform: scaleX(1.5); }
input[type=range]:focus { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 2px #000, 0 0 0 3px var(--fg); }

.lifespan { display: flex; justify-content: space-between; align-items: baseline; }
.big { font-size: 15px; font-weight: 700; letter-spacing: .04em; }
.presets { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }

/* ---------- buttons ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  color: var(--bg); background: var(--fg); border: 1px solid var(--fg);
  padding: 7px 12px; cursor: pointer; overflow: hidden; white-space: nowrap;
  transition: color .25s, background .25s, transform .1s;
}
.btn::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(0,0,0,.18) 50%, transparent 70%); transform: translateX(-120%); transition: transform .6s var(--ease); }
.btn:hover::after { transform: translateX(120%); }
.btn:hover { background: #000; color: var(--fg); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .chip:focus-visible, .navbtn:focus-visible, .nav a:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }
.btn.wide { width: 100%; padding: 8px; }
.btn.sm { padding: 3px 8px; font-size: 10.5px; font-weight: 400; }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--line-hi); }
.btn.ghost:hover { border-color: var(--fg); background: var(--fg); color: var(--bg); }
.btn.danger { background: transparent; color: var(--fg); border-color: var(--line-hi); }
.btn.danger:hover { background: var(--fg); color: #000; border-color: var(--fg); animation: glitch .3s steps(2) 1; }
.btn[disabled] { opacity: .5; pointer-events: none; }
@keyframes glitch { 25% { transform: translate(-2px, 1px); } 50% { transform: translate(2px, -1px); } 75% { transform: translate(-1px, 0); } }
a.btn { border-bottom-width: 1px; }
.chip { font: inherit; font-size: 10.5px; letter-spacing: .06em; padding: 2px 7px; background: transparent; color: var(--dim); border: 1px solid var(--line-hi); cursor: pointer; transition: all .2s; }
.chip:hover { color: var(--fg); border-color: var(--fg); }
.chip.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.link { background: none; border: 0; color: var(--dim); font: inherit; font-size: 11px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--fg); }

/* ---------- flash ---------- */
.flash { border: 1px solid var(--line-hi); padding: 7px 11px; margin-bottom: 14px; font-size: 12px; animation: flashin .5s var(--ease) both; background: #050505; }
.flash.ok { border-color: var(--fg); }
.flash.err { border-style: dashed; border-color: var(--fg); }
.flash .tag { font-weight: 700; }
.flash.err .tag { background: var(--fg); color: #000; padding: 0 3px; }
@keyframes flashin { 0% { opacity: 0; clip-path: inset(0 100% 0 0); } 100% { opacity: 1; clip-path: inset(0 0 0 0); } }

/* ---------- auth gate ---------- */
.gate { max-width: 340px; margin: 6vh auto 0; }
.boot { color: var(--dim); font: inherit; font-size: 11px; margin: 0 0 14px; white-space: pre-wrap; min-height: 4.5em; }
.boot .ok { color: var(--fg); }
.form .h { font-size: 13px; letter-spacing: .16em; margin-bottom: 14px; }
.gate .sub { margin: 12px 0 0; text-align: center; }
.center { text-align: center; margin-top: 10px; }

/* ---------- mailbox cards ---------- */
.boxes { display: grid; gap: 6px; }
.box {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px 14px; align-items: center;
  border: 1px solid var(--line); padding: 8px 11px; background: #030303;
  animation: rise .45s var(--ease) both; transition: border-color .2s, transform .2s;
}
.box:hover { border-color: var(--line-hi); transform: translateX(2px); }
.box:nth-child(2) { animation-delay: .04s; } .box:nth-child(3) { animation-delay: .08s; } .box:nth-child(4) { animation-delay: .12s; } .box:nth-child(n+5) { animation-delay: .16s; }
.box-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.box-addr { font-size: 12.5px; font-weight: 700; border: 0; overflow-wrap: anywhere; }
.box-meta { display: grid; gap: 4px; font-size: 11px; color: var(--dim); }
.box-meta b { color: var(--fg); font-weight: 400; }
.box-act { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.box-act form { margin: 0; }
.badge { font-size: 9.5px; letter-spacing: .1em; padding: 0 5px; border: 1px solid var(--line-hi); color: var(--dim); white-space: nowrap; }
.badge.on { border-color: var(--fg); color: var(--fg); }
.box.perm .badge { color: var(--fg); border-color: var(--fg); }
.bar { display: block; height: 1px; background: var(--line-hi); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--fg); transition: width 1s linear; }
.cred, .quota-edit { grid-column: 1 / -1; }
.cred { border-top: 1px dashed var(--line-hi); padding-top: 8px; animation: flashin .4s var(--ease) both; }
.cred dl { margin: 0; }
.quota-edit { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.quota-edit input { padding: 2px 6px; font-size: 11.5px; width: 64px; }
.quota-edit.inline { grid-column: auto; }
.empty { color: var(--dim); margin: 0; font-size: 11.5px; }

/* ---------- key/value ---------- */
.hdrs { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin: 0 0 6px; font-size: 12px; }
.hdrs dt { color: var(--dim); font-size: 10px; letter-spacing: .12em; padding-top: 2px; }
.hdrs dd { margin: 0; overflow-wrap: anywhere; }
.hdrs dd .btn { margin-left: 6px; }
.secret { background: var(--fg); color: var(--bg); padding: 0 4px; }

/* ---------- inbox ---------- */
.crumbs { margin-bottom: 12px; font-size: 11px; letter-spacing: .08em; animation: rise .4s var(--ease) both; }
.crumbs a { color: var(--dim); border: 0; }
.crumbs a:hover { color: var(--fg); }
.inbox-head { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.inbox-head .title { margin: 2px 0 6px; }
.inbox-head .sub { margin-bottom: 6px; }
.inbox-head .cred { grid-column: 1 / -1; }
.addr-big { font-size: clamp(15px, 2.6vw, 19px); }
.live { margin-left: auto; font-size: 10px; color: var(--dim); font-weight: 400; }
.msgs { list-style: none; margin: 0; padding: 0; }
.msg a { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto; gap: 12px; padding: 7px 8px; border: 0; border-bottom: 1px solid var(--line); font-size: 12px; transition: background .15s, padding .2s; }
.msg a:hover { background: #0c0c0c; padding-left: 12px; }
.msg.unread a { font-weight: 700; }
.msg.unread .m-from::before { content: "■ "; }
.msg.new { animation: newmsg 1.2s var(--ease) both; }
@keyframes newmsg { 0% { background: var(--fg); color: var(--bg); } 100% { background: transparent; } }
.m-from, .m-subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-time { color: var(--dim); font-size: 11px; white-space: nowrap; }
.msg-subj { font-size: clamp(14px, 2.4vw, 17px); }
.tabs { display: flex; gap: 4px; margin: 12px 0 8px; }
.mailframe { width: 100%; height: 60vh; min-height: 320px; border: 1px solid var(--line-hi); background: #fff; display: block; }
.mailtext { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 12px; background: #050505; border: 1px solid var(--line); padding: 12px; margin: 12px 0; max-height: 70vh; overflow: auto; }
.atts { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 4px; font-size: 12px; }
.right { text-align: right; margin: 0; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.row-between .h { margin: 0; }

/* ---------- invites ---------- */
.reveal { border-color: var(--fg); }
.code-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0 10px; }
.code { font-size: clamp(13px, 2.4vw, 16px); font-weight: 700; letter-spacing: .1em; padding: 4px 10px; border: 1px dashed var(--fg); animation: pulse 2.4s ease-in-out 3; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { text-align: left; font-size: 9.5px; letter-spacing: .12em; color: var(--dim); font-weight: 400; padding: 5px 8px; border-bottom: 1px solid var(--line-hi); white-space: nowrap; }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tbody tr { transition: background .15s; }
.tbl tbody tr:hover { background: #0a0a0a; }
.tbl form { margin: 0; display: inline; }

/* ---------- admin ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px; margin-bottom: 14px; }
.stat { border: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 2px; animation: rise .5s var(--ease) both; }
.stat b { font-size: 20px; line-height: 1.1; }
.stat span { font-size: 9.5px; letter-spacing: .12em; color: var(--dim); }
.stat:nth-child(2) { animation-delay: .06s; } .stat:nth-child(3) { animation-delay: .12s; } .stat:nth-child(4) { animation-delay: .18s; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.actions form { margin: 0; }
.log { list-style: none; margin: 0; padding: 0; font-size: 11px; max-height: 360px; overflow: auto; }
.log li { padding: 4px 0; border-bottom: 1px solid #111; overflow-wrap: anywhere; }
.danger-zone { border-style: dashed; }

/* ---------- small screens ---------- */
@media (max-width: 680px) {
  .box { grid-template-columns: 1fr; }
  .box-act { justify-content: flex-start; }
  .inbox-head { grid-template-columns: 1fr; }
  .msg a { grid-template-columns: 1fr auto; gap: 2px 10px; }
  .m-subj { grid-column: 1 / -1; grid-row: 2; color: var(--dim); }
  .nav { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
