/* tempmail — airmail theme */
:root {
  --paper: #e9eef4;
  --surface: #ffffff;
  --surface-2: #f4f7fa;
  --ink: #1b2330;
  --muted: #5b6676;
  --line: #d5dde7;
  --blue: #2a529b;
  --blue-soft: #e3ebf8;
  --red: #c0352a;
  --red-soft: #fbe9e7;
  --focus: #2a529b;
  --shadow: 0 1px 2px rgba(27, 35, 48, .06), 0 8px 24px rgba(27, 35, 48, .06);
  --sans: "Familjen Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --stripe: repeating-linear-gradient(-45deg, var(--red) 0 14px, transparent 14px 22px,
                                      var(--blue) 22px 36px, transparent 36px 44px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f141b; --surface: #171e28; --surface-2: #1d2531; --ink: #e5eaf1;
    --muted: #97a3b4; --line: #2a3442; --blue: #86a9ea; --blue-soft: #1f2c44;
    --red: #f07b6f; --red-soft: #3a2224; --focus: #86a9ea;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f141b; --surface: #171e28; --surface-2: #1d2531; --ink: #e5eaf1;
  --muted: #97a3b4; --line: #2a3442; --blue: #86a9ea; --blue-soft: #1f2c44;
  --red: #f07b6f; --red-soft: #3a2224; --focus: #86a9ea;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
a { color: var(--blue); }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.airmail { height: 6px; background: var(--stripe); }

/* ---------- top bar ---------- */
.bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.brand b { color: var(--red); font-weight: 700; }
.bar .spacer { flex: 1; }
.bar nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.bar nav a:hover { color: var(--ink); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  cursor: pointer; font-size: 14px; text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #0f141b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #0f141b; } }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 4px 9px; font-size: 13px; border-radius: 6px; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px;
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg, .btn svg { width: 18px; height: 18px; }

/* ---------- home ---------- */
.home { max-width: 860px; margin: 0 auto; padding: 72px 20px 64px; }
.home h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.08; letter-spacing: -.025em; margin: 0 0 14px; font-weight: 700; }
.home .lede { font-size: 18px; color: var(--muted); max-width: 56ch; margin: 0 0 36px; }
.envelope {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow);
  position: relative; overflow: hidden; padding: 28px 28px 24px;
}
.envelope::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 8px; background: var(--stripe); }
.envelope label { display: block; font-size: 14px; color: var(--muted); margin: 8px 0 10px; }
.addr-field {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 0;
  border-bottom: 2px solid var(--ink); padding-bottom: 6px;
}
.addr-field input {
  flex: 1 1 220px; min-width: 0; border: 0; background: transparent; outline: none;
  font: 600 clamp(26px, 4.6vw, 40px)/1.15 var(--mono); letter-spacing: -.02em; padding: 0;
}
.addr-field input::placeholder { color: var(--line); }
.addr-field .domain { font: 400 clamp(15px, 2.2vw, 20px)/1.2 var(--mono); color: var(--muted); }
.addr-field:focus-within { border-color: var(--blue); }
.envelope .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.how { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 28px; margin-top: 48px; }
.how h2 { font-size: 16px; margin: 0 0 4px; }
.how p { margin: 0; color: var(--muted); font-size: 15px; }

/* ---------- inbox layout ---------- */
.inbox-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.inbox-head .address { font: 600 20px/1.2 var(--mono); letter-spacing: -.01em; overflow-wrap: anywhere; }
.inbox-head .address span { color: var(--muted); font-weight: 400; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 13px; padding: 3px 9px;
  border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.badge.private { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.badge svg { width: 14px; height: 14px; }
.inbox-head .tools { display: flex; gap: 6px; margin-left: auto; align-items: center; }
.live { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: #3a9d5d; display: inline-block; }
.live.paused i { background: var(--muted); }

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.split { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; flex: 1; min-height: 0; }
.list { border-right: 1px solid var(--line); overflow-y: auto; background: var(--surface); }
.list ul { list-style: none; margin: 0; padding: 0; }
.row {
  display: block; width: 100%; text-align: left; border: 0; background: transparent; cursor: pointer;
  padding: 12px 18px 12px 22px; border-bottom: 1px solid var(--line); position: relative;
}
.row:hover { background: var(--surface-2); }
.row[aria-current="true"] { background: var(--blue-soft); }
.row.unread::before { content: ""; position: absolute; left: 9px; top: 18px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.row .top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
.row .from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .subj { font-size: 15px; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.unread .subj { font-weight: 700; }
.row .prev { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .chip { font: 600 12px var(--mono); color: var(--red); border: 1px dashed var(--red); border-radius: 4px; padding: 0 5px; margin-right: 6px; }

.empty { padding: 48px 28px; color: var(--muted); }
.empty h2 { color: var(--ink); font-size: 18px; margin: 0 0 6px; }
.empty .mono { color: var(--ink); background: var(--surface-2); padding: 2px 6px; border-radius: 4px; word-break: break-all; }

.detail { overflow-y: auto; padding: 28px 36px 48px; }
.detail .back { display: none; margin-bottom: 14px; }
.detail h1 { font-size: 24px; line-height: 1.25; letter-spacing: -.015em; margin: 0 0 12px; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 14px; margin: 0 0 18px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-all; }
.msg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }

.stamps { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 18px; }
.stamp {
  display: inline-flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px;
  background: var(--red-soft); border: 2px dashed var(--red); border-radius: 6px;
}
.stamp .val { font: 700 24px/1 var(--mono); letter-spacing: .06em; color: var(--ink); }
.stamp small { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.links { margin: 0 0 20px; padding: 0; list-style: none; display: grid; gap: 6px; }
.links li { display: flex; gap: 8px; align-items: center; min-width: 0; }
.links a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.links .act { font-size: 12px; color: var(--blue); background: var(--blue-soft); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }

.section-title { font-size: 14px; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 0; }
.tab { border: 0; background: none; padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--blue); font-weight: 600; }
.pane { background: var(--surface); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; }
.pane iframe { width: 100%; height: 62vh; border: 0; display: block; background: #fff; border-radius: 0 0 10px 10px; }
.pane pre { margin: 0; padding: 18px; white-space: pre-wrap; word-wrap: break-word; font: 13px/1.55 var(--mono); max-height: 62vh; overflow: auto; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.att { display: inline-flex; gap: 8px; align-items: center; padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-decoration: none; color: var(--ink); font-size: 14px; }
.att small { color: var(--muted); }
.placeholder { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 24px; }

/* ---------- locked ---------- */
.locked { max-width: 440px; margin: 64px auto; background: var(--surface); padding: 28px; border-radius: 14px; box-shadow: var(--shadow); }
.locked h2 { margin: 0 0 6px; }
.field { display: flex; gap: 8px; margin-top: 16px; }
.field input, .input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }

/* ---------- dialog / toast ---------- */
dialog { border: 0; border-radius: 14px; padding: 0; max-width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(15, 20, 27, .45); }
dialog .body { padding: 24px; }
dialog h2 { margin: 0 0 8px; font-size: 20px; }
dialog .keybox { font: 600 15px var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; word-break: break-all; margin: 6px 0 12px; }
dialog .row-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: 8px; font-size: 14px; transition: .18s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- docs / admin ---------- */
.doc { max-width: 820px; margin: 0 auto; padding: 48px 20px 80px; }
.doc h1 { font-size: 34px; letter-spacing: -.02em; margin: 0 0 8px; }
.doc h2 { font-size: 21px; margin: 40px 0 8px; }
.doc h3 { font-size: 16px; margin: 24px 0 6px; }
.doc p, .doc li { max-width: 72ch; }
.doc pre { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; font: 13px/1.6 var(--mono); }
.doc code { font-family: var(--mono); font-size: .92em; background: var(--surface); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; }
.doc pre code { border: 0; padding: 0; background: none; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--surface); }
.doc th, .doc td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.panel { background: var(--surface); border-radius: 12px; padding: 20px 22px; box-shadow: var(--shadow); margin: 16px 0; }

@media (max-width: 760px) {
  .app { height: auto; min-height: 100vh; }
  .split { grid-template-columns: 1fr; flex: none; }
  .list { border-right: 0; }
  .split.has-open .list { display: none; }
  .split:not(.has-open) .detail { display: none; }
  .detail { padding: 18px 16px 40px; }
  .detail .back { display: inline-flex; }
  .inbox-head { padding: 14px 16px; }
  .inbox-head .address { font-size: 16px; }
  .inbox-head .tools { margin-left: 0; width: 100%; }
  .bar { padding: 10px 16px; }
  .home { padding-top: 40px; }
  .envelope { padding: 24px 18px 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
