/*
 * The Super Admin Workbench look (super-admin-panel: kit/tokens.css --wb-*, the Sidebar, workbench/theme.ts).
 * Light by default, dark on the viewer's pick, as in the panel. Values copied, not linked: this page is its own site.
 */
:root {
  --rail: #1a2636;          /* strength-900 */
  --rail-2: #233247;        /* strength-800 */
  --tile: #32d882;          /* stamina */
  --tile-ink: #1a2636;      /* on-stamina */

  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e1e4eb;
  --line-2: #d3d8e1;
  --ink: #1b2533;
  --label: #4a5769;
  --muted: #677386;
  --faint: #9aa3b1;
  --track: #eef0f4;
  --green: #1fae66;
  --yellow: #c98c05;
  --red: #d8285a;
  --blue: #2f6fd6;
  --soft-green: #e1f5ea;
  --soft-yellow: #fcf1d6;
  --soft-red: #fde7ed;
  --on-green: #04130b;
  --shadow: 0 1px 2px 0 rgb(35 50 71 / .06), 0 1px 3px 0 rgb(35 50 71 / .04);

  --sans: Inter, system-ui, sans-serif;
  --mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --rail: #08090c;
  --rail-2: #12161d;
  --bg: #0a0c10;
  --card: #12161d;
  --line: #1d232c;
  --line-2: #2a313c;
  --ink: #e4e7ec;
  --label: #aab3c5;
  --muted: #8b93a0;
  --faint: #5b6370;
  --track: #161b23;
  --green: #32d882;
  --yellow: #fbbb17;
  --red: #ed3163;
  --blue: #4994f4;
  --soft-green: #11291d;
  --soft-yellow: #2c2410;
  --soft-red: #2e1219;
  --shadow: none;
  color-scheme: dark;
}

[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 13px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; color: inherit; }
code, kbd { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- Shell */
.shell { height: 100%; display: flex; }
.rail { width: 256px; flex: none; background: var(--rail); color: #fff; display: flex; flex-direction: column; min-height: 0; }
.rail-brand { height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 20px; flex: none; }
.tile { width: 32px; height: 32px; flex: none; border-radius: 8px; background: var(--tile); color: var(--tile-ink); display: inline-flex; align-items: center; justify-content: center; }
.tile svg { width: 18px; height: 18px; }
.rail-name { display: flex; flex-direction: column; line-height: 1.2; }
.rail-name b { font-size: 14px; font-weight: 700; }
.rail-name small { font: 500 10px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: rgb(255 255 255 / .4); }

.rail-search { padding: 0 12px 12px; border-bottom: 1px solid rgb(255 255 255 / .1); display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid rgb(255 255 255 / .1); background: rgb(255 255 255 / .05); border-radius: 8px; padding: 6px 6px 6px 10px; }
.search:focus-within { border-color: rgb(255 255 255 / .35); }
.search svg { width: 15px; height: 15px; flex: none; color: rgb(255 255 255 / .4); }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: #fff; font: 13px var(--mono); }
.search input::placeholder { color: rgb(255 255 255 / .35); font-family: var(--sans); }
.search kbd { font-size: 10px; color: rgb(255 255 255 / .4); border: 1px solid rgb(255 255 255 / .1); border-radius: 4px; padding: 0 4px; }
.rail-domain { font: 11px var(--mono); color: rgb(255 255 255 / .35); padding-left: 2px; overflow-wrap: anywhere; }
.rail-actions, .rail-foot { display: flex; gap: 6px; }
.rail-btn { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; border: 1px solid rgb(255 255 255 / .12); background: transparent; color: rgb(255 255 255 / .75); border-radius: 6px; padding: 5px 8px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.rail-btn:hover { background: rgb(255 255 255 / .06); color: #fff; border-color: rgb(255 255 255 / .3); }

.rail-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 12px; }
.rail-label { padding: 0 12px; margin-bottom: 6px; font: 500 10px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: rgb(255 255 255 / .3); }
.rail-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rail-nav li button { width: 100%; text-align: left; border: 0; background: transparent; color: rgb(255 255 255 / .7); border-radius: 8px; padding: 7px 12px; font: 12.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-nav li button:hover { background: rgb(255 255 255 / .05); color: #fff; }
.rail-nav li button[aria-current="true"] { background: var(--tile); color: var(--tile-ink); font-weight: 600; }
.rail-note { margin: 10px 12px 0; font-size: 11px; color: rgb(255 255 255 / .3); }
.rail-foot { padding: 12px; border-top: 1px solid rgb(255 255 255 / .1); }

/* ---------- Content */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 20px 24px; gap: 14px; min-height: 0; }
.topbar { display: grid; gap: 6px; }
.crumbs { display: flex; gap: 6px; font-size: 12px; color: var(--muted); }
.crumbs b { color: var(--ink); font-weight: 600; }
.addr-title { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.addr-title code { font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 500; color: var(--label); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
.chip.offline { color: var(--red); border-color: var(--red); }
.chip.offline .dot { background: var(--red); animation: none; }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.card-hd { min-height: 44px; box-sizing: border-box; padding: 8px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.card-hd .n { margin-left: 6px; font: 500 11px var(--mono); color: var(--faint); }

/* Workbench buttons: small, bordered, rounded-md. */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 4px 10px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--track); }
.btn[aria-pressed="true"] { background: var(--track); border-color: var(--line-2); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--soft-red); border-color: var(--red); }
.btn.solid-danger { background: var(--red); border-color: var(--red); color: #fff; }

.msgs { flex: 1; overflow-y: auto; }
.msg { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; grid-template-columns: 8px 1fr auto; gap: 2px 8px; }
.msg:hover { background: var(--track); }
.msg.on { background: var(--soft-green); box-shadow: inset 3px 0 0 var(--green); }
.msg .u { grid-row: 1 / 3; width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; }
.msg.unread .u { background: var(--green); }
.msg .from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg:not(.unread) .from { font-weight: 500; }
.msg .time { font: 11px var(--mono); color: var(--faint); white-space: nowrap; }
.msg .subj { grid-column: 2 / 4; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.unread .subj { color: var(--ink); }

.tag { display: inline-block; border-radius: 4px; padding: 0 6px; font: 600 10.5px/18px var(--mono); text-transform: uppercase; letter-spacing: .03em; vertical-align: 1px; white-space: nowrap; }
.tag.ext { background: var(--soft-yellow); color: var(--yellow); }
.tag.ok { background: var(--soft-green); color: var(--green); }

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 24px; color: var(--muted); }
.empty b { color: var(--ink); font-weight: 600; font-size: 14px; }
.empty code { background: var(--track); padding: 2px 8px; border-radius: 4px; color: var(--ink); word-break: break-all; font-size: 12px; }

.v-hd { padding: 16px 20px 12px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.v-subj { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; text-wrap: balance; }
.v-meta { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12px; }
.v-meta dt { color: var(--label); }
.v-meta dd { margin: 0; font: 12px var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.v-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.v-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--card); padding: 4px 12px; font-size: 12px; font-weight: 500; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-selected="true"] { background: var(--track); color: var(--ink); font-weight: 600; }
.atts { display: flex; flex-wrap: wrap; gap: 6px; }
.att { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 500; color: var(--ink); text-decoration: none; }
.att:hover { background: var(--track); }
.att span { font: 11px var(--mono); color: var(--faint); }
.note { border-radius: 6px; padding: 6px 10px; font-size: 12px; background: var(--soft-yellow); color: var(--yellow); }
.confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--soft-red); color: var(--ink); border-radius: 6px; padding: 6px 10px; font-size: 12.5px; }
.confirm span { flex: 1 1 180px; }
.back { display: none; justify-self: start; }
.hd-tools { display: flex; align-items: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--track); color: var(--ink); font-weight: 600; }
.layout-seg button { padding: 3px 10px; }
/* Full: the list fills the width; an opened email takes the whole card until "← Inbox" or Esc. */
main.full { grid-template-columns: 1fr; }
main.full:not(.reading) .viewer { display: none; }
main.full.reading .list { display: none; }
main.full .back { display: inline-flex; }
main.full .v-hd { padding-inline: 28px; }

.v-body { flex: 1; min-height: 0; overflow: auto; background: var(--track); display: flex; justify-content: center; padding: 16px; }
.v-body iframe { border: 0; background: #fff; width: 100%; height: 100%; min-height: 420px; border-radius: 8px; box-shadow: var(--shadow); }
.v-body.phone iframe { width: 375px; flex: none; }
.v-body pre { margin: 0; width: 100%; align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 var(--mono); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px; box-sizing: border-box; }

/* ---------- Sign-in */
.lock { position: fixed; inset: 0; z-index: 20; background: var(--rail); display: flex; align-items: center; justify-content: center; padding-inline: 16px; }
.lock-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 12px; padding: 28px 24px; display: grid; gap: 12px; box-sizing: border-box; box-shadow: 0 4px 12px -2px rgb(0 0 0 / .3); }
.lock-card h1 { margin: 0; font-size: 18px; font-weight: 700; }
.lock-card p { margin: 0; color: var(--muted); }
.err { color: var(--red); font-size: 12.5px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--rail); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 12.5px; max-width: calc(100vw - 32px); box-shadow: 0 4px 12px -2px rgb(0 0 0 / .25); }

/* ---------- Phone: the rail becomes a top bar, list and viewer take turns */
@media (max-width: 860px) {
  .shell { flex-direction: column; height: auto; min-height: 100%; }
  .rail { width: auto; }
  .rail-brand { padding: 0 16px; }
  .rail-search { padding: 0 16px 12px; }
  .rail-nav { padding: 10px 16px; max-height: 130px; }
  .rail-nav ul { display: flex; flex-wrap: wrap; gap: 4px; }
  .rail-nav li button { width: auto; padding: 4px 10px; }
  .rail-note { display: none; }
  .rail-foot { padding: 10px 16px; }
  .content { padding: 16px; }
  .crumbs { display: none; }
  main { grid-template-columns: 1fr; }
  .card { min-height: 60vh; }
  main.reading .list { display: none; }
  main:not(.reading) .viewer { display: none; }
  .back { display: inline-flex; }
  .layout-seg { display: none; }
  .v-body { padding: 8px; }
}
