:root {
  --bg: #0b0f16;
  --bg-2: #0f1520;
  --panel: #131a26;
  --panel-2: #18202e;
  --line: #24303f;
  --line-2: #2e3b4d;
  --text: #e6edf6;
  --muted: #8b98ab;
  --muted-2: #66738a;
  --accent: #6ea8fe;
  --accent-2: #8b7cf6;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --code: #a7f3d0;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(110, 168, 254, .10), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(139, 124, 246, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 22, .82);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.logo {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, #26364f, #16202e);
  border: 1px solid var(--line-2);
  color: var(--accent);
  font-size: 17px;
}
.brand-name { font-weight: 650; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--muted-2); line-height: 1.2; }

.stats { display: flex; gap: 8px; flex-wrap: nowrap; overflow: hidden; }
.stat {
  display: flex; align-items: baseline; gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
.stat b { color: var(--text); font-size: 13px; font-weight: 600; }
.stat.ok b { color: var(--ok); }
.stat.warn b { color: var(--warn); }
.stat.err b { color: var(--err); }
.stat.clickable { cursor: pointer; user-select: none; }
.stat.clickable:hover { border-color: #3c506b; color: var(--text); }
.stat.active { border-color: rgba(251, 191, 36, .55); background: rgba(251, 191, 36, .08); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.search-wrap { position: relative; }
.search-wrap input {
  width: 220px;
  height: 34px;
  padding: 0 12px 0 30px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  outline: none;
  transition: border-color .15s, width .2s;
}
.search-wrap input:focus { border-color: #3d5a83; }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted-2); font-size: 14px; pointer-events: none;
}

.btn {
  height: 34px;
  padding: 0 13px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, #1b2534, #151d29);
  cursor: pointer;
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform .08s, border-color .15s, background .15s;
  font-size: 13px;
}
.btn:hover { border-color: #3c506b; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #3f7ff0, #2f66cf);
  border-color: #4a86f4;
  color: #fff;
}
.btn.ghost { background: transparent; }
.btn.danger { color: #fca5a5; border-color: #522; }
.btn.small { height: 28px; padding: 0 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- layout */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 64px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(15, 21, 32, .55);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px 8px;
  font-size: 11.5px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted-2);
}
.account-list { overflow-y: auto; padding: 0 8px 16px; flex: 1; }

.acc {
  position: relative;
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.acc:hover { background: var(--panel); }
.acc.active { background: var(--panel-2); border-color: var(--line-2); }
.acc.active::before {
  content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px;
  width: 2px; border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(52, 211, 153, .55); }
.dot.error { background: var(--err); }
.dot.reauth { background: var(--warn); }
.dot.new { background: #5c6b82; }

.acc-main { min-width: 0; }
.acc-email {
  font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acc-sub {
  font-size: 11px; color: var(--muted-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; gap: 6px; align-items: center;
}
.acc-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

.badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: #2b4a7a; color: #cfe1ff;
  font-size: 11px; font-weight: 600;
  display: inline-grid; place-items: center;
}

.code-chip {
  font-family: "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(52, 211, 153, .1);
  border: 1px solid rgba(52, 211, 153, .25);
  color: var(--code);
  cursor: pointer;
  white-space: nowrap;
}
.code-chip:hover { background: rgba(52, 211, 153, .2); }
.code-chip.stale { color: #9aa6b8; background: rgba(148, 163, 184, .08); border-color: rgba(148, 163, 184, .2); text-decoration: line-through; }
.code-chip.big { font-size: 22px; padding: 6px 14px; letter-spacing: 1px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.account-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  min-height: 82px;
  background: linear-gradient(180deg, rgba(19, 26, 38, .7), rgba(11, 15, 22, .2));
}
.empty-hint { color: var(--muted-2); font-size: 13px; }
.head-avatar {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 650; font-size: 16px;
  background: linear-gradient(145deg, #2a3b55, #1a2433);
  border: 1px solid var(--line-2);
  color: #bcd2f2;
}
.head-info { min-width: 0; flex: 1; }
.head-email { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.head-meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; margin-top: 2px; }
.head-actions { display: flex; align-items: center; gap: 8px; }

.tabs { display: flex; gap: 4px; padding: 8px 20px 0; border-bottom: 1px solid var(--line); }
.tab {
  border: none; background: none; cursor: pointer;
  padding: 8px 12px 10px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-size: 13px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.pill {
  display: inline-block; min-width: 17px; padding: 0 5px;
  border-radius: 8px; background: #253449; color: #9fb3cc;
  font-size: 10.5px; line-height: 16px; text-align: center;
}

.view { flex: 1; overflow: auto; padding: 12px 20px 40px; min-height: 0; }

/* ---------------------------------------------------------------- message list */
.m-toolbar {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 0 10px;
}
.m-toolbar select, .m-toolbar input {
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0 9px;
  outline: none;
}
.m-toolbar input { flex: 1; max-width: 320px; }
.m-toolbar .spacer { flex: 1; }

.msg {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  margin-bottom: 7px;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .08s;
}
.msg:hover { border-color: #35465c; background: var(--panel-2); }
.msg.unread { border-left: 3px solid var(--accent); }
.msg-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.msg-from { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.msg-subject { font-size: 13px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg.unread .msg-subject { font-weight: 600; }
.msg-preview { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.msg-time { font-size: 11px; color: var(--muted-2); white-space: nowrap; }
.msg-ico { color: var(--muted-2); font-size: 12px; text-align: center; padding-top: 2px; }
.attach-mark { color: #8fb3dd; font-size: 11px; }

/* ---------------------------------------------------------------- codes board */
.codes-wrap { display: grid; gap: 10px; }
.code-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.code-row .cr-email { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code-row .cr-sub { font-size: 11.5px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code-row .cr-time { font-size: 11px; color: var(--muted-2); text-align: right; white-space: nowrap; }
.code-row.expired { opacity: .62; }

/* ---------------------------------------------------------------- drawer */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(3, 6, 11, .55);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
  z-index: 30;
}
.backdrop.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(720px, 92vw);
  background: #0e141f;
  border-left: 1px solid var(--line-2);
  transform: translateX(102%);
  transition: transform .24s cubic-bezier(.22, .8, .3, 1);
  z-index: 40;
  display: flex; flex-direction: column;
  box-shadow: -30px 0 80px rgba(0, 0, 0, .45);
}
.drawer.open { transform: none; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.drawer-title { font-weight: 600; font-size: 14px; }
.drawer-body { padding: 16px 18px 40px; overflow: auto; }

.icon-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.mail-subject { font-size: 17px; font-weight: 650; margin: 2px 0 10px; line-height: 1.35; }
.mail-meta { display: grid; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.mail-meta b { color: var(--text); font-weight: 500; }
.mail-code-box {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(52, 211, 153, .25);
  background: rgba(52, 211, 153, .06);
  margin-bottom: 14px;
}
.mail-code-box .label { font-size: 11px; letter-spacing: .6px; color: var(--muted); text-transform: uppercase; }
.mail-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.65;
  color: #cfdaea;
  background: #0b1119;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  max-height: 46vh;
  overflow: auto;
}
.att-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.links { margin-top: 12px; }
.links-label { font-size: 11px; color: var(--muted-2); margin-bottom: 6px; letter-spacing: .3px; }
.link-chip {
  display: block;
  margin-bottom: 5px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(110, 168, 254, .07);
  border: 1px solid rgba(110, 168, 254, .18);
  color: #a9c8f5;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.link-chip:hover { background: rgba(110, 168, 254, .14); border-color: rgba(110, 168, 254, .35); }
.att {
  font-size: 11.5px; padding: 4px 9px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--line-2);
  color: var(--muted);
}

/* ---------------------------------------------------------------- modal */
.modal {
  position: fixed; inset: 0;
  display: none;
  place-items: center;
  background: rgba(3, 6, 11, .6);
  z-index: 50;
  padding: 24px;
}
.modal.show { display: grid; }
.modal-card {
  width: min(760px, 96vw);
  max-height: 86vh;
  display: flex; flex-direction: column;
  background: #0e141f;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, .55);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 8px;
}
.modal-body textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  background: #0b1119;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  outline: none;
}
.modal-body textarea:focus { border-color: #3d5a83; }
.hint-text { font-size: 12px; color: var(--muted-2); margin: 0 0 8px; }
.hint-text code { background: #16202e; padding: 1px 5px; border-radius: 5px; }

.reauth-code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 34px;
  letter-spacing: 3px;
  text-align: center;
  padding: 16px 12px;
  margin: 10px 0 12px;
  border-radius: 12px;
  border: 1px dashed rgba(110, 168, 254, .4);
  background: rgba(110, 168, 254, .07);
  color: #d6e6ff;
  user-select: all;
}
.reauth-steps { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

.field { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: none; }
.field label { font-size: 13px; }
.field .sub { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.field input[type="number"] {
  width: 92px; height: 30px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); padding: 0 9px; text-align: right;
}

.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px;
  background: #2a3646; border: 1px solid var(--line-2);
  transition: background .15s;
  pointer-events: none;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #cdd8e6; transition: transform .15s;
}
.switch input:checked + span { background: #2f66cf; border-color: #4a86f4; }
.switch input:checked + span::after { transform: translateX(18px); }

/* ---------------------------------------------------------------- toast */
.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 80; }
.toast {
  padding: 9px 16px;
  border-radius: 10px;
  background: #182231;
  border: 1px solid var(--line-2);
  font-size: 12.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
  animation: toast-in .18s ease-out;
}
.toast.ok { border-color: rgba(52, 211, 153, .35); color: #a7f3d0; }
.toast.err { border-color: rgba(248, 113, 113, .4); color: #fecaca; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.muted { color: var(--muted-2); }
.empty { padding: 40px 10px; text-align: center; color: var(--muted-2); font-size: 13px; }
.err-box {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, .3);
  background: rgba(248, 113, 113, .07);
  color: #fecaca;
  font-size: 12.5px;
}
.note-box {
  margin: 8px 0 12px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px dashed var(--line-2);
  color: var(--muted);
  font-size: 12px;
  white-space: pre-wrap;
}
.spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  display: inline-block;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #232e3d; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #314054; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 210px 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
  .search-wrap input { width: 150px; }
  .stats { display: none; }
}

/* ---------------------------------------------------------------- login */
.auth-body {
  overflow: auto;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-wrap { width: 100%; display: grid; place-items: center; }

.auth-card {
  width: min(380px, 100%);
  padding: 26px 26px 20px;
  border-radius: 16px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, #141c29, #0f1520);
  box-shadow: 0 40px 100px rgba(0, 0, 0, .5);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.auth-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 650;
}

.auth-hint {
  margin: 0 0 18px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-field { display: block; margin-bottom: 12px; }
.auth-field > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.auth-field input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: #0b1119;
  outline: none;
  transition: border-color .15s;
}
.auth-field input:focus { border-color: #4a86f4; }

.auth-remember {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 4px 0 14px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.auth-error {
  margin-bottom: 12px;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid rgba(248, 113, 113, .35);
  background: rgba(248, 113, 113, .08);
  color: #fecaca;
  font-size: 12.5px;
}

.auth-submit {
  width: 100%;
  height: 40px;
  justify-content: center;
  font-size: 14px;
}

.auth-foot {
  margin: 16px 0 0;
  font-size: 11.5px;
  color: var(--muted-2);
  line-height: 1.6;
}
.auth-foot code {
  background: #16202e;
  padding: 1px 5px;
  border-radius: 5px;
  color: #a9c8f5;
}
