/* ------------------------------------------------------------------
   取码 —— 沿用 muse-invite 的票根风格
   暖黑 / 灰白纸面,1px 细线,几乎直角。
   唯一的强调色是印章橙红,只用在主按钮、印章、链接和状态上。
------------------------------------------------------------------- */

@font-face { font-family: "Instrument Serif"; src: url("/fonts/InstrumentSerif-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("/fonts/InstrumentSans-Regular.woff2") format("woff2"); font-weight: 400 500; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("/fonts/InstrumentSans-Bold.woff2") format("woff2"); font-weight: 600 800; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/JetBrainsMono-Regular.woff2") format("woff2"); font-weight: 400 500; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/JetBrainsMono-Bold.woff2") format("woff2"); font-weight: 600 800; font-display: swap; }
@font-face { font-family: "Muse Serif SC"; src: url("/fonts/NotoSerifSC-Medium.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

/* 深色(默认) */
:root {
  --bg: #0b0b0a;
  --paper: #151513;
  --paper-2: #1f1e1b;
  --line: #2b2a27;
  --line-strong: #45433e;
  --text: #edebe6;
  --muted: #b0ada5;
  --faint: #94918a;
  --accent: #ff5a26;
  --on-accent: #0b0b0a;
  --accent-ink: #ff6a3d;
  --accent-deep: #b9390f;
  --key-ink: #edebe6;
  --on-key-ink: #0b0b0a;
  --key-ink-deep: #8f8c85;
  --key-hi: rgb(255 255 255 / 0.5);
  --hard: #3a3833;
  --grain-opacity: 0.11;
  color-scheme: dark;

  --font-sans: "Instrument Sans", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --font-display: "Instrument Serif", "Muse Serif SC", "Songti SC", "Noto Serif SC", "Noto Serif CJK SC", serif;
  --font-display-zh: "Muse Serif SC", "Songti SC", "Noto Serif SC", "Noto Serif CJK SC", serif;
  --font-code: "JetBrains Mono", ui-monospace, "PingFang SC", "Noto Sans SC", monospace;
}

/* 浅色:系统是浅色且没手动选深色,或手动选了浅色 */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #ededea; --paper: #fbfbf9; --paper-2: #e3e3df; --line: #d6d5d0; --line-strong: #a9a7a0;
    --text: #151513; --muted: #4f4d48; --faint: #625f59;
    --accent: #ff4f1f; --on-accent: #0b0b0a; --accent-ink: #c2330a; --accent-deep: #a92e0b;
    --key-ink: #24231f; --on-key-ink: #fbfbf9; --key-ink-deep: #000000; --key-hi: rgb(255 255 255 / 0.45);
    --hard: #6f6d67; --grain-opacity: 0.09; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #ededea; --paper: #fbfbf9; --paper-2: #e3e3df; --line: #d6d5d0; --line-strong: #a9a7a0;
  --text: #151513; --muted: #4f4d48; --faint: #625f59;
  --accent: #ff4f1f; --on-accent: #0b0b0a; --accent-ink: #c2330a; --accent-deep: #a92e0b;
  --key-ink: #24231f; --on-key-ink: #fbfbf9; --key-ink-deep: #000000; --key-hi: rgb(255 255 255 / 0.45);
  --hard: #6f6d67; --grain-opacity: 0.09; color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}
/* 颗粒噪点背景 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1.7 -.6'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display-zh);
  font-weight: 500;
  letter-spacing: 0.01em;
  word-break: keep-all;
  line-break: strict;
  text-wrap: balance;
}
h1 { font-size: 34px; line-height: 1.2; }
h2 { font-size: 22px; line-height: 1.3; }
h3 { font-size: 17px; line-height: 1.4; }
p { margin: 0; }
a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }

.mono { font-family: var(--font-code); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }

/* ---------- 页面骨架 ---------- */
.wrap {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px 48px;
}
.wrap.wide { max-width: 760px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display-zh);
  font-size: 19px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}
.brand svg { width: 22px; height: 22px; display: block; }
.mark-fill { fill: var(--accent); }
.lead { margin-top: 10px; }
#login-form { margin-top: 26px; }
.field[data-big] { font-size: 22px; letter-spacing: 0.12em; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 100ms ease, background-color 140ms ease, opacity 120ms ease;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.sm { min-height: 34px; padding: 0 11px; font-size: 13px; font-weight: 500; }
.btn.danger { border-color: var(--accent-ink); color: var(--accent-ink); }
.btn.danger.armed { background: var(--accent-ink); color: var(--paper); }
.btn.ink { background: var(--key-ink); color: var(--on-key-ink); border-color: var(--key-ink); }

/* 主按钮:实体键,右下 6px 厚度,按下整体下沉 */
.key {
  width: calc(100% - 6px);
  min-height: 54px;
  margin-bottom: 6px;
  border: 0;
  border-radius: 2px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 16px;
  box-shadow: 6px 6px 0 0 var(--accent-deep), inset 0 1px 0 0 var(--key-hi);
  transition: transform 70ms ease-out, box-shadow 70ms ease-out, opacity 120ms ease;
}
.key:active:not(:disabled), .key:disabled {
  transform: translate(6px, 6px);
  box-shadow: 0 0 0 0 var(--accent-deep), inset 0 1px 0 0 var(--key-hi);
}
.key.inline { width: auto; padding: 0 22px; }

.linkbtn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  cursor: pointer;
  font-size: inherit;
}

.spin {
  width: 15px; height: 15px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 表单 ---------- */
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* iOS 不会自动放大 */
}
.field:focus { border-color: var(--text); outline: none; }
.field.is-bad { border-color: var(--accent-ink); }
.field.mono { font-family: var(--font-code); letter-spacing: 0.04em; }
textarea.field { min-height: 140px; resize: vertical; line-height: 1.5; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 14px; }

/* 带固定后缀的输入框:m7k2q9xa4d [@qzyd7.com] */
.affix { display: flex; align-items: stretch; }
.affix .field { border-right: 0; min-width: 0; }
.affix .suffix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  background: var(--paper-2);
  color: var(--muted);
  font-family: var(--font-code);
  font-size: 14px;
  border-radius: 0 2px 2px 0;
  white-space: nowrap;
}

.error {
  padding: 10px 12px;
  border-left: 2px solid var(--accent-ink);
  background: var(--paper);
  color: var(--text);
  font-size: 14px;
}

/* ---------- 票根 ---------- */
.ticket {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  box-shadow: 4px 4px 0 0 var(--hard);
  margin-right: 4px;
}
.ticket + .ticket { margin-top: 22px; }
.ticket-main { padding: 14px 16px 20px; }
.ticket-stub { padding: 14px 16px 14px; }

/* 撕口:虚线,两端各咬掉一个半圆 */
.perf {
  position: relative;
  height: 1px;
  margin: 0 14px;
  background-image: linear-gradient(to right, var(--line-strong) 55%, transparent 55%);
  background-size: 7px 1px;
}
.perf::before {
  content: "";
  position: absolute;
  left: -25px;
  right: -25px;
  top: -10px;
  height: 21px;
  background:
    radial-gradient(circle at 10.5px 50%, var(--bg) 9.5px, var(--line-strong) 10px, transparent 10.6px),
    radial-gradient(circle at calc(100% - 10.5px) 50%, var(--bg) 9.5px, var(--line-strong) 10px, transparent 10.6px);
}

/* 印章:文字来自 data-stamp */
.perf[data-stamp]::after {
  content: attr(data-stamp);
  position: absolute;
  right: 10px;
  top: 50%;
  padding: 2px 5px 2px 9px;
  font-family: var(--font-display-zh);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3em;
  line-height: 1.4;
  color: var(--accent-ink);
  background: var(--paper);
  border: 2px solid currentColor;
  outline: 1px solid currentColor;
  outline-offset: 2px;
  border-radius: 3px;
  transform: translateY(-50%) rotate(-7deg);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='40'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.6 2.15'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='40'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.6 2.15'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
}
/* 新到的邮件:印章盖下来(整页唯一的一个自动动画) */
.ticket.is-new .perf[data-stamp]::after { animation: stamp 320ms cubic-bezier(0.3, 1.4, 0.5, 1) 200ms both; }
@keyframes stamp {
  from { opacity: 0; transform: translateY(-50%) rotate(-7deg) scale(1.7); }
  to { opacity: 1; transform: translateY(-50%) rotate(-7deg) scale(1); }
}

/* 票面头部:发件人 + 时间 */
.ticket-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}
.ticket-head .from { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-head time { flex-shrink: 0; font-family: var(--font-code); font-size: 12px; letter-spacing: 0.02em; }
.ticket-subject {
  margin-top: 6px;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* 验证码:等宽大字,每个字符一格,格子之间细竖线 */
.code {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  width: 100%;
  margin-top: 16px;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: none;
  cursor: pointer;
  text-align: center;
  transition: background-color 140ms ease;
}
.code:active { background: var(--paper-2); }
.code span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 68px;
  font-family: var(--font-code);
  font-feature-settings: "zero" 1;
  font-weight: 700;
  font-size: 34px;
  color: var(--text);
  border-left: 1px solid var(--line);
}
.code span:first-child { border-left: 0; }
.code.len-7 span, .code.len-8 span { font-size: 28px; }
/* 空票:下划线格子,像票面上待填的空位 */
.code.is-empty { cursor: default; }
.code.is-empty span { align-items: flex-end; padding-bottom: 14px; color: var(--faint); font-weight: 400; }
.code-hint {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.code-hint .copy { color: var(--accent-ink); font-weight: 500; }
.nocode {
  margin-top: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

/* 较早的邮件:票面小一号,不抢最新那封 */
.ticket.is-older .code span { height: 52px; font-size: 24px; }
.ticket.is-older { box-shadow: 3px 3px 0 0 var(--hard); }

/* 票根:展开正文 */
.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
}
.toggle::after {
  content: "";
  width: 7px; height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 160ms ease;
}
.toggle[aria-expanded="true"]::after { transform: translateY(1px) rotate(-135deg); }
.mail-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  max-height: 60vh;
  overflow-y: auto;
}

/* ---------- 收件状态条 ---------- */
.inbox-head { margin-bottom: 22px; }
.addr {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.addr .mono { font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.live {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}
.dot {
  position: relative;
  width: 7px; height: 7px;
  flex-shrink: 0;
  background: var(--accent);
  border-radius: 1px;
}
.dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 1px solid var(--accent);
  border-radius: 1px;
  animation: pulse 2s ease-out infinite;
}
.dot.is-paused { background: var(--faint); }
.dot.is-paused::after { display: none; }
@keyframes pulse { from { transform: scale(0.7); opacity: 0.6; } to { transform: scale(1.9); opacity: 0; } }

.tg {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.tg.is-bound { border-left: 2px solid var(--accent); }

.foot {
  margin-top: 34px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--faint);
}
.foot p + p { margin-top: 6px; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: 14px;
  z-index: 10;
  transform: translateX(-50%);
  padding: 9px 14px;
  background: var(--key-ink);
  color: var(--on-key-ink);
  border-radius: 2px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  animation: toast-in 200ms cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@keyframes toast-in { from { transform: translate(-50%, -8px); opacity: 0; } }

/* ---------- 后台 ---------- */
.seg {
  display: flex;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  overflow: hidden;
}
.seg button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-left: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 16px;
}
.panel + .panel, .section + .section { margin-top: 18px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.stats div { padding: 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--paper); }
.stats dd { margin: 0; font-family: var(--font-code); font-weight: 700; font-size: 28px; line-height: 1.05; letter-spacing: -0.02em; }
.stats dt { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.stats .is-accent dd { color: var(--accent-ink); }
@media (min-width: 620px) { .stats { grid-template-columns: repeat(3, 1fr); } }

table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line-strong); }
table.list td { padding: 9px 8px 9px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list td.num, table.list th.num { text-align: right; font-family: var(--font-code); }

.results { border-top: 1px solid var(--line); }
.result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  cursor: pointer;
}
.result:hover { background: var(--paper); }
.result[aria-current="true"] { background: var(--paper); box-shadow: inset 2px 0 0 var(--accent); padding-left: 10px; }
.result .mono { font-size: 14px; overflow-wrap: anywhere; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }
.tag {
  padding: 1px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.tag.on { border-color: var(--accent-ink); color: var(--accent-ink); }

dl.kv { display: grid; grid-template-columns: 88px 1fr; gap: 8px 12px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.cards-out { font-family: var(--font-code); font-size: 13px; min-height: 260px; white-space: pre; }
.warn { color: var(--accent-ink); font-size: 13.5px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; }
.radio-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.radio-row input { accent-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
.row > .shrink { flex: 0 0 auto; }
.panel > h3 + * { margin-top: 10px; }
.mail-mini { padding: 12px 0; border-top: 1px solid var(--line); }
.mail-mini .code-inline { font-family: var(--font-code); font-weight: 700; font-size: 20px; color: var(--accent-ink); }
.tab-pane { margin-top: 18px; }
#find-count { margin: 10px 0 6px; }
.actions + p { margin-top: 10px; }
.mail-mini .toggle { margin-top: 6px; }
.mail-mini .code-inline { margin-top: 4px; }
