:root {
  --page: #101313;
  --paper: #171b1b;
  --paper-soft: #1c2221;
  --paper-deep: #121716;
  --line: #303837;
  --line-dark: #46504d;
  --ink: #f2f4ee;
  --muted: #929c96;
  --muted-strong: #c2cbc3;
  --accent: #d7f26a;
  --accent-soft: rgba(215, 242, 106, .11);
  --teal: #57d3c9;
  --teal-dark: #8fe8dc;
  --blue: #8ebcff;
  --gold: #f1c967;
  --success: #b7ed90;
  --danger: #ff8c83;
  --shadow: 0 24px 70px rgba(0, 0, 0, .26);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--page); }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    var(--page);
  background-size: 48px 48px;
  font-family: Inter, "Microsoft YaHei", "Segoe UI", sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.page-shell { width: min(1380px, calc(100% - 30px)); min-height: 100vh; margin: 0 auto; }

.topbar {
  min-height: 108px;
  display: grid;
  grid-template-columns: 330px minmax(320px, 1fr) 110px;
  gap: 22px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.brand-block { display: flex; align-items: center; gap: 14px; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; color: #172007; background: var(--accent); border-radius: 8px; font-size: 21px; font-weight: 900; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 34px; line-height: 1.05; letter-spacing: 0; }
.brand-block p { margin-top: 5px; color: var(--muted); font-size: 12px; }
.announcement {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  color: #f4d98b;
  background: #242019;
  border: 1px solid #9c7c34;
  border-radius: 10px;
  box-shadow: 0 14px 30px rgba(0,0,0,.2);
  font-size: 13px;
  line-height: 1.45;
}
.announcement-label { flex: 0 0 auto; padding: 7px 10px; color: #172007; background: var(--accent); border-radius: 8px; font-weight: 900; }
.connection-pill { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; color: var(--success); background: var(--paper); border: 1px solid #527e72; border-radius: 22px; font-size: 12px; font-weight: 700; }
.connection-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(183,237,144,.08); }

.tabs { width: max-content; display: flex; margin: 22px 0 18px; padding: 4px; background: var(--paper); border: 1px solid var(--line-dark); border-radius: 28px; }
.tab { min-width: 104px; height: 40px; padding: 0 20px; color: var(--muted); background: transparent; border: 0; border-radius: 22px; font-size: 13px; font-weight: 700; }
.tab:hover { color: var(--muted-strong); background: var(--accent-soft); }
.tab.is-active { color: #172007; background: var(--accent); box-shadow: 0 5px 15px rgba(215,242,106,.15); }

main { padding-bottom: 34px; }
.workspace-section { overflow: hidden; margin-bottom: 16px; background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--teal); border-radius: 7px; box-shadow: var(--shadow); }
.workspace-section:nth-of-type(2) { border-top-color: var(--blue); }
.section-header { min-height: 108px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 16px 14px; }
.section-tag { display: inline-block; padding: 5px 9px; color: var(--teal-dark); background: rgba(87,211,201,.12); border-radius: 12px; font-size: 11px; font-weight: 800; }
h2 { margin-top: 11px; color: var(--ink); font-size: 20px; letter-spacing: 0; }
.section-header p { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.section-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.button { min-height: 38px; padding: 0 14px; border-radius: 7px; font-size: 13px; font-weight: 700; }
.button.secondary { color: var(--muted-strong); background: var(--paper-soft); border: 1px solid var(--line-dark); }
.button.secondary:hover { color: var(--ink); border-color: var(--teal); background: var(--accent-soft); }
.button.primary { color: #172007; background: var(--accent); border: 1px solid var(--accent); box-shadow: 0 7px 14px rgba(215,242,106,.12); }
.button.primary:hover { background: #e4fa91; }
.button:disabled { cursor: wait; opacity: .55; }

.account-workbench { display: grid; grid-template-columns: 305px minmax(0, 1fr); gap: 12px; padding: 0 16px 16px; }
.account-sidebar { min-height: 248px; overflow: hidden; border: 1px solid var(--line-dark); border-radius: 7px; background: var(--paper-deep); }
.sidebar-heading { height: 45px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; color: var(--muted-strong); border-bottom: 1px solid var(--line); font-size: 12px; }
.sidebar-heading b { min-width: 25px; padding: 5px 7px; color: #172007; background: var(--accent); border-radius: 14px; text-align: center; }
.account-list { max-height: 248px; overflow: auto; }
.account-item { width: 100%; display: grid; grid-template-columns: 28px 1fr; gap: 8px; padding: 13px 12px; color: var(--ink); background: transparent; border: 0; border-left: 3px solid transparent; text-align: left; }
.account-item:hover { background: #202725; }
.account-item.is-active { background: rgba(87,211,201,.1); border-left-color: var(--teal); }
.account-number { color: var(--muted); font-size: 12px; font-weight: 800; text-align: center; }
.account-item strong { display: block; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.account-item small { display: block; margin-top: 5px; color: var(--teal); font-size: 11px; font-weight: 700; }
.account-item small.failed { color: var(--danger); }
.account-editor { min-width: 0; }
.account-editor textarea { width: 100%; min-height: 210px; padding: 15px; color: var(--muted-strong); background: #121817; border: 2px solid #397d78; border-radius: 9px; outline: 0; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 14px; line-height: 1.75; box-shadow: inset 0 1px 5px rgba(0,0,0,.22); }
.account-editor textarea::placeholder { color: #687671; }
.account-editor textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(215,242,106,.1); }
.editor-footer { min-height: 28px; display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; padding: 7px 10px; color: var(--muted); background: var(--paper-soft); border-radius: 5px; font-size: 11px; }
.editor-footer #parseStatus { color: var(--teal); font-weight: 700; }

.mail-section { border-top-color: var(--blue) !important; }
.mail-heading { min-height: 78px; }
.mail-heading h2 { margin-top: 0; }
.search-input { width: min(310px, 40%); height: 40px; padding: 0 12px; color: var(--ink); background: var(--paper-soft); border: 1px solid var(--line-dark); border-radius: 7px; outline: 0; }
.search-input::placeholder { color: #6d7b76; }
.search-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(142,188,255,.1); }
.mail-workbench { display: grid; grid-template-columns: minmax(370px, 1fr) minmax(390px, 1.28fr); gap: 12px; padding: 0 16px 16px; }
.mail-list, .mail-detail { min-height: 280px; overflow: auto; border: 1px solid var(--line-dark); border-radius: 7px; background: var(--paper-deep); }
.mail-list { max-height: 360px; }
.mail-item { width: 100%; display: block; padding: 13px 12px; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--line); text-align: left; }
.mail-item:hover { background: #202725; }
.mail-item.is-active { background: rgba(87,211,201,.1); }
.mail-item-head { display: flex; justify-content: space-between; gap: 12px; }
.mail-item strong { overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.mail-item time { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.mail-item-meta { display: flex; gap: 8px; margin-top: 7px; color: var(--muted); font-size: 11px; }
.mail-badge { padding: 3px 6px; color: var(--teal); background: rgba(87,211,201,.12); border-radius: 9px; }
.mail-badge.unread { color: var(--danger); background: rgba(255,140,131,.12); }
.mail-item-preview { overflow: hidden; margin-top: 8px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.mail-detail { max-height: 360px; }
.detail-header { padding: 16px; border-bottom: 1px solid var(--line); }
.detail-header small { color: var(--teal); font-weight: 700; }
.detail-header h3 { margin: 7px 0 0; color: var(--ink); font-size: 18px; }
.detail-body { padding: 16px; color: var(--muted-strong); font-size: 13px; line-height: 1.8; }
.otp-box { margin-top: 14px; padding: 13px 16px; background: linear-gradient(120deg, #1d302e, #1a252f); border: 1px solid #397d78; border-radius: 7px; }
.otp-box span { display: block; color: var(--muted); font-size: 11px; }
.otp-box strong { display: block; margin-top: 2px; color: var(--teal); font-size: 43px; letter-spacing: 0; line-height: 1.05; }
.detail-actions { display: flex; gap: 10px; margin-top: 16px; }
.detail-placeholder, .empty-state { display: grid; min-height: 230px; place-items: center; padding: 20px; color: #71817b; font-size: 12px; text-align: center; line-height: 1.7; }
.empty-state small { color: #64736e; }

.token-panel { border-top-color: var(--gold) !important; }
.token-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0 16px 16px; }
.token-summary > div { padding: 16px; background: var(--paper-soft); border: 1px solid var(--line); border-radius: 6px; }
.token-summary span, .token-summary strong { display: block; }
.token-summary span { color: var(--muted); font-size: 11px; }
.token-summary strong { margin-top: 7px; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.result-box { min-height: 100px; margin: 0 16px 16px; padding: 14px; color: var(--muted); background: var(--paper-soft); border: 1px dashed var(--line-dark); border-radius: 6px; font-size: 12px; line-height: 1.7; }
code { color: var(--muted-strong); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.hidden { display: none !important; }
.footer { min-height: 52px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); border-top: 1px solid var(--line); font-size: 10px; letter-spacing: .1em; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 5; max-width: min(360px, calc(100% - 44px)); padding: 12px 15px; color: #172007; background: var(--accent); border-radius: 7px; box-shadow: 0 12px 25px rgba(0,0,0,.3); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr auto; gap: 12px; padding: 18px 0; }
  .announcement { grid-column: 1 / -1; grid-row: 2; }
  .connection-pill { grid-column: 2; grid-row: 1; }
}
@media (max-width: 720px) {
  .page-shell { width: min(100% - 20px, 620px); }
  h1 { font-size: 27px; }
  .section-header, .mail-heading { align-items: flex-start; flex-direction: column; }
  .section-actions { width: 100%; }
  .section-actions .button { flex: 1; }
  .account-workbench, .mail-workbench { grid-template-columns: 1fr; }
  .account-sidebar { min-height: auto; }
  .account-list { max-height: 180px; }
  .mail-list, .mail-detail { max-height: none; }
  .search-input { width: 100%; }
  .token-summary { grid-template-columns: 1fr; }
  .editor-footer { align-items: flex-start; flex-direction: column; }
}