/* 三种样式：a 黑金双栏 / b 浅色双栏 / c 黑金单栏验证码优先 */
:root { color-scheme: dark; }
body[data-style="a"], body[data-style="c"] {
  --bg: #0c0c0e; --bg2: radial-gradient(1200px 600px at 80% -10%, rgba(212,175,55,.10), transparent 60%);
  --card: #151518; --card2: #1c1c20; --line: #2a2a30; --text: #ececee; --muted: #8d8d96;
  --gold: #d4af37; --gold2: #f0d27a; --on-gold: #17130a; --danger: #ff7a6b;
  --active: rgba(212,175,55,.10); --chip: rgba(212,175,55,.14);
}
body[data-style="b"] {
  color-scheme: light;
  --bg: #f4f3ef; --bg2: none;
  --card: #ffffff; --card2: #f6f5f1; --line: #e4e2dc; --text: #1c1c1e; --muted: #85837d;
  --gold: #1c1c1e; --gold2: #1c1c1e; --on-gold: #ffffff; --danger: #c9372c;
  --active: #f1efe8; --chip: #efe9d6;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg2), var(--bg); background-attachment: fixed; color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; color: inherit; }
.muted { color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
body[data-style="b"] .card { box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04); }

.primary {
  border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 600;
  background: linear-gradient(180deg, var(--gold2), var(--gold)); color: var(--on-gold);
}
body[data-style="b"] .primary { background: var(--gold); }
.primary:disabled { opacity: .6; cursor: default; }
.primary.small { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 9px; padding: 6px 12px; color: var(--text); }
.ghost:hover { border-color: var(--muted); }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .2px; min-width: 0; }
.brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none;
  background: #141416; color: var(--gold); border: 1px solid rgba(212,175,55,.45); font-weight: 800;
}
body[data-style="b"] .brand-mark { background: #1c1c1e; color: #f0d27a; border-color: #1c1c1e; }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 18px; gap: 22px; }
.login-card { width: min(460px, 100%); padding: 28px; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.sub { margin: 0 0 18px; color: var(--muted); }
.field { display: flex; align-items: center; gap: 8px; background: var(--card2); border: 1px solid var(--line); border-radius: 11px; padding: 4px 4px 4px 12px; }
.field:focus-within { border-color: var(--gold); }
.field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: 14px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 9px 0; }
.field .ghost { border: 0; font-size: 13px; color: var(--muted); }
.login-card .primary { width: 100%; margin-top: 14px; padding: 13px; font-size: 15px; }
.error { margin: 12px 0 0; color: var(--danger); font-size: 13px; }
.tips { margin: 18px 0 0; padding: 14px 0 0 18px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 12.5px; }
.tips li { margin: 3px 0; }

/* ---------- 收件箱 ---------- */
.app { max-width: 1180px; margin: 0 auto; padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 14px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.status { color: var(--muted); font-size: 12.5px; margin-right: 4px; }
.status.bad { color: var(--danger); }

.code-card { padding: 16px 20px; display: flex; flex-direction: column; gap: 6px; border-color: rgba(212,175,55,.35); background: linear-gradient(135deg, rgba(212,175,55,.10), transparent 55%), var(--card); }
body[data-style="b"] .code-card { border-color: var(--line); background: var(--card); }
.code-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.code-meta .label { color: var(--gold); font-weight: 600; }
body[data-style="b"] .code-meta .label { color: var(--muted); }
.code-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.code { font: 700 34px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 6px; color: var(--gold2); }
body[data-style="b"] .code { color: var(--text); }
.code-card.waiting { flex-direction: row; align-items: center; gap: 10px; color: var(--muted); border-color: var(--line); background: var(--card); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.panes { display: grid; grid-template-columns: 380px 1fr; gap: 14px; min-height: 0; }
.list-pane { overflow: hidden; display: flex; flex-direction: column; max-height: calc(100vh - 210px); min-height: 420px; }
.pane-head { display: flex; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.item { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; outline: 0; }
.item:hover, .item:focus-visible { background: var(--card2); }
.item.active { background: var(--active); box-shadow: inset 3px 0 0 var(--gold); }
.item-top { display: flex; align-items: center; gap: 8px; }
.from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.item.unseen .from { font-weight: 700; }
.time { color: var(--muted); font-size: 12px; flex: none; }
.chip { border: 0; border-radius: 6px; padding: 1px 7px; font: 600 12px ui-monospace, Menlo, monospace; background: var(--chip); color: var(--gold2); flex: none; }
body[data-style="b"] .chip { color: #7a5c00; }
.subject { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; margin-right: 6px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); }
.preview { margin-top: 2px; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; margin: 0; }

.reader-pane { padding: 18px 20px; min-height: 420px; max-height: calc(100vh - 210px); overflow: auto; display: flex; flex-direction: column; }
.reader-pane .empty { margin: auto; }
.reader-pane article { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.back { display: none; align-self: flex-start; }
#r-subject { margin: 0; font-size: 18px; line-height: 1.35; }
.r-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; font-size: 13px; }
.r-code { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 10px; background: var(--chip); font: 600 15px ui-monospace, Menlo, monospace; align-self: flex-start; }
#r-frame { flex: 1; width: 100%; min-height: 380px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
#r-text { white-space: pre-wrap; word-break: break-word; margin: 0; font: 13.5px/1.6 inherit; font-family: inherit; }

.toast { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 20; padding: 9px 16px; border-radius: 10px; background: #222226; color: #fff; border: 1px solid rgba(212,175,55,.4); box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: 13.5px; }

.style-switch { position: fixed; right: 14px; bottom: 14px; z-index: 30; display: flex; gap: 6px; align-items: center; padding: 6px 8px; border-radius: 12px; background: rgba(20,20,22,.92); color: #ddd; font-size: 12px; border: 1px solid #333; }
.style-switch button { border: 1px solid #3a3a40; background: transparent; border-radius: 8px; padding: 4px 9px; font-size: 12px; color: #ddd; }
.style-switch button.on { background: #d4af37; color: #17130a; border-color: #d4af37; }

/* ---------- C：单栏，验证码最大 ---------- */
body[data-style="c"] .app { max-width: 640px; }
body[data-style="c"] .code-card { padding: 26px 22px; align-items: center; text-align: center; gap: 12px; }
body[data-style="c"] .code-meta { flex-direction: column; align-items: center; gap: 2px; }
body[data-style="c"] .code-row { flex-direction: column; gap: 14px; }
body[data-style="c"] .code { font-size: 46px; letter-spacing: 10px; }
body[data-style="c"] #copy { min-width: 200px; padding: 12px; font-size: 15px; }
body[data-style="c"] .code-card.waiting { flex-direction: row; justify-content: center; }
body[data-style="c"] .panes { grid-template-columns: 1fr; }
body[data-style="c"] .reader-pane { display: none; }
body[data-style="c"] .app.reading .reader-pane { display: flex; max-height: none; }
body[data-style="c"] .app.reading .list-pane { display: none; }
body[data-style="c"] .list-pane { max-height: none; min-height: 0; }
body[data-style="c"] .back { display: inline-block; }

/* ---------- 手机：所有样式都变单栏 ---------- */
@media (max-width: 820px) {
  .app { padding: 12px 12px 32px; gap: 10px; }
  .status { display: none; }
  .panes { grid-template-columns: 1fr; }
  .reader-pane { display: none; }
  .app.reading .reader-pane { display: flex; max-height: none; }
  .app.reading .list-pane { display: none; }
  .list-pane { max-height: none; min-height: 0; }
  .back { display: inline-block; }
  .code { font-size: 30px; letter-spacing: 5px; }
  body[data-style="c"] .code { font-size: 40px; letter-spacing: 8px; }
  #r-frame { min-height: 60vh; }
}
