:root, :root[data-theme="dark"] {
  --bg: #121212;
  --fg: #e8eaed;
  --muted: #9aa0a6;
  --card: #1c1c1e;
  --acc: #8ab4f8;
  --acc-ink: #003258;
  --err: #f28b82;
  --line: #2a2a33;
  --field: #0c0c10;
}
:root[data-theme="light"] {
  --bg: #f8f9fa;
  --fg: #1a1c1e;
  --muted: #5f6368;
  --card: #ffffff;
  --acc: #1a73e8;
  --acc-ink: #ffffff;
  --err: #b3261e;
  --line: #dadce0;
  --field: #ffffff;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.45 system-ui, sans-serif; }
.panel { max-width: 24rem; margin: 3rem auto; padding: 1.5rem; background: var(--card); border-radius: 12px; }
#login h1 { margin: 0; font-size: 1.75rem; font-weight: 600; letter-spacing: -0.02em; }
#login .lead { margin: 0.4rem 0 1rem; color: var(--muted); }
label { display: block; margin: 0.75rem 0; }
input, textarea { width: 100%; padding: 0.5rem 0.6rem; background: var(--field); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; }
button { background: var(--acc); color: var(--acc-ink); border: 0; padding: 0.55rem 0.9rem; border-radius: 6px; font-weight: 600; cursor: pointer; }
button.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
#login button { display: block; width: 100%; margin: 0.45rem 0; }
a.download {
  display: block;
  text-align: center;
  background: var(--acc);
  color: var(--acc-ink);
  text-decoration: none;
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  font-weight: 600;
  margin: 0.5rem 0 1rem;
}
.muted { color: var(--muted); }
.lead { max-width: 40rem; margin: 0 0 1rem; }
.field-help { margin: -0.4rem 0 0.75rem; font-size: 0.85rem; }
h2 { margin: 0 0 0.35rem; }
.err { color: var(--err); min-height: 1.2em; }
header { display: flex; gap: 1rem; align-items: center; padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: var(--bg); }
header strong { font-size: 1.15rem; letter-spacing: -0.02em; }
nav { display: flex; gap: 0.4rem; flex: 1; flex-wrap: wrap; }
nav button { background: var(--card); color: var(--fg); }
nav button.on { background: var(--acc); color: var(--acc-ink); }
main { padding: 1.25rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
.card { background: var(--card); padding: 0.75rem; border-radius: 8px; overflow: hidden; }
.card img { width: 100%; height: 120px; object-fit: cover; display: block; background: var(--bg); }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); }
[hidden] { display: none !important; }
a { color: var(--acc); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.stats .card h3 { margin: 0 0 0.35rem; font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stats .card p { margin: 0; word-break: break-word; }
.pill { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; }
.pill.on { background: var(--acc); color: var(--acc-ink); }
.pill.off { background: var(--line); color: var(--muted); }
.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin: 0 0 1rem; }
.toolbar input[type="search"], .toolbar input[type="text"] { flex: 1; min-width: 10rem; }
.split { display: flex; min-height: 62vh; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.split-side { width: 240px; border-right: 1px solid var(--line); overflow: auto; }
.split-main { flex: 1; overflow: auto; padding: 1rem; display: flex; flex-direction: column; }
.list-row { display: block; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--line); cursor: pointer; color: inherit; text-decoration: none; }
.list-row:hover, .list-row.on { background: var(--field); }
.list-row .sub { color: var(--muted); font-size: 0.85rem; }
.mail-shell { display: flex; min-height: 70vh; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.mail-nav { width: 160px; padding: 0.75rem; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.35rem; }
.mail-nav button { width: 100%; text-align: left; }
.mail-list { width: min(340px, 40%); border-right: 1px solid var(--line); overflow: auto; }
.mail-read { flex: 1; padding: 1.1rem 1.25rem; overflow: auto; }
.mail-row { padding: 0.75rem 0.9rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.mail-row.unread { font-weight: 700; }
.mail-row.on { background: var(--field); }
.mail-from { color: var(--muted); font-size: 0.85rem; font-weight: 500; }
.mail-body { white-space: pre-wrap; margin-top: 1rem; line-height: 1.55; }
.compose { position: fixed; right: 1.25rem; bottom: 1.25rem; width: min(440px, calc(100vw - 2rem)); max-height: min(560px, 80vh); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.35); padding: 0.9rem; display: flex; flex-direction: column; z-index: 30; }
.compose h3 { margin: 0 0 0.5rem; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.86); display: flex; align-items: center; justify-content: center; z-index: 40; }
.lightbox img, .lightbox video { max-width: 94vw; max-height: 88vh; }
.lightbox .close { position: absolute; top: 0.75rem; right: 1rem; }
.file-table { width: 100%; }
.now-playing { margin: 0.5rem 0 1rem; width: 100%; }
.now-playing-name { margin: 0 0 0.4rem; }
.empty { color: var(--muted); padding: 5rem 1.25rem; text-align: center; font-size: 1.05rem; }
.dropzone { border: 1px dashed var(--line); border-radius: 10px; padding: 1.1rem; text-align: center; color: var(--muted); margin-bottom: 1rem; }
.dropzone.over { border-color: var(--acc); color: var(--fg); background: var(--field); }
.mail-head { display: flex; gap: 0.75rem; align-items: baseline; flex-wrap: wrap; margin-bottom: 0.75rem; }
.mail-head h2 { margin: 0; }
.mail-search { flex: 1; min-width: 12rem; max-width: 28rem; }
.mail-row { display: grid; grid-template-columns: 1fr auto; gap: 0.15rem 0.75rem; }
.mail-row .mail-from { grid-column: 1; }
.mail-row .mail-date { grid-column: 2; grid-row: 1; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.mail-row .mail-subj { grid-column: 1 / -1; }
.mail-row .mail-snip { grid-column: 1 / -1; color: var(--muted); font-size: 0.85rem; font-weight: 400; }
.mail-addr { font-family: ui-monospace, monospace; }
.compose textarea { min-height: 10rem; resize: vertical; }
.vault-list { display: grid; gap: 0.6rem; margin-top: 1rem; }
.vault-card { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.vault-card .meta { flex: 1; min-width: 12rem; }
.lightbox-bar { position: absolute; left: 1rem; right: 1rem; bottom: 1rem; display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.track-on { background: var(--field); }
.dev-cmd { font-family: ui-monospace, monospace; min-height: 7rem; margin: 0.75rem 0 1rem; }
@media (max-width: 860px) {
  .mail-shell, .split { flex-direction: column; min-height: 70vh; }
  .mail-nav { width: 100%; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .mail-nav button { width: auto; }
  .mail-list { width: 100%; max-height: 36vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .split-side { width: 100%; max-height: 30vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .compose { left: 0.75rem; right: 0.75rem; width: auto; }
}
