:root {
  --bg: #f6f7f9; --panel: #ffffff; --line: #e3e6eb; --text: #1b1f27; --muted: #6b7380;
  --accent: #2f6fed; --accent-text: #ffffff; --sel: #eef3ff; --err: #c8333a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1a1e26; --line: #2a303b; --text: #e6e9ef; --muted: #8d95a3;
    --accent: #4d86f7; --accent-text: #ffffff; --sel: #1f2a40; --err: #ff6b72;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; }
button {
  background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px;
  padding: 9px 16px; cursor: pointer;
}
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); padding: 6px 12px; }
button:disabled { opacity: .6; cursor: default; }
input {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
}
input:focus { outline: none; border-color: var(--accent); }

/* login */
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px 24px; display: flex; flex-direction: column; gap: 12px;
}
.login h1 { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.login .hint { color: var(--muted); font-size: 13px; margin: -4px 0 6px; }
.login .error { color: var(--err); font-size: 13px; min-height: 18px; }

/* inbox */
.shell { height: 100%; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.top .addr { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.top .count { color: var(--muted); font-size: 13px; }
.body { flex: 1; display: flex; min-height: 0; }
.list { width: 380px; flex-shrink: 0; overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel); }
.item { padding: 11px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.item:hover { background: var(--bg); }
.item.active { background: var(--sel); }
.item .row1 { display: flex; gap: 8px; justify-content: space-between; }
.item .from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.item .subj { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.empty { color: var(--muted); padding: 32px 16px; text-align: center; }
.view { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.view-head { padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.view-head h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; word-break: break-word; }
.view-head .meta { color: var(--muted); font-size: 13px; word-break: break-all; }
.view-head .back { display: none; margin-bottom: 10px; }
.view-body { flex: 1; min-height: 0; overflow: auto; background: #ffffff; }
.view-body iframe { width: 100%; height: 100%; border: 0; display: block; background: #ffffff; }
.view-body pre { margin: 0; padding: 16px 20px; white-space: pre-wrap; word-break: break-word; color: #1b1f27; font: 14px/1.5 system-ui, sans-serif; }

@media (max-width: 760px) {
  .list { width: 100%; border-right: 0; }
  .view { display: none; }
  .shell.reading .list { display: none; }
  .shell.reading .view { display: flex; }
  .view-head .back { display: inline-block; }
}
