/* Meta Agent — the sorting case.
   Every project is a pigeonhole; every DM/comment is a piece of mail; anything that needs the
   owner is registered mail (needs a signature) and money is insured mail (declares its value).
   One family (Barlow), condensed caps only on enamel label plates. */

@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url(/admin/fonts/Barlow-400.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url(/admin/fonts/Barlow-500.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url(/admin/fonts/Barlow-600.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 700; font-display: swap; src: url(/admin/fonts/Barlow-700.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 600; font-display: swap; src: url(/admin/fonts/BarlowCondensed-600.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url(/admin/fonts/BarlowCondensed-700.woff2) format('woff2'); }

:root {
  color-scheme: light;
  --ground: #e2e6e7;
  --case: #f5f7f7;
  --case-2: #eceff0;
  --frame: #33424a;
  --rule: #c9d0d3;
  --rule-strong: #96a3a9;
  --ink: #111b22;
  --ink-2: #3c4a53;
  --muted: #55636c;
  --action: #1f4fcf;
  --action-fill: #1f4fcf;
  --action-soft: #dfe6fb;
  --cancel: #b02a21;
  --cancel-fill: #b02a21;
  --cancel-soft: #f8e1de;
  --franked: #1f6e45;
  --franked-soft: #dbefe3;
  --insured: #f2b705;
  --insured-ink: #2a2100;
  --postmark: #3d3a63;
  --chart: #1f4fcf;
  --chart-wash: rgba(31, 79, 207, 0.10);
  --grid: #dbe0e2;
  --hole-shadow: inset 0 10px 12px -10px rgba(17, 27, 34, 0.28);
  --lift: 0 1px 2px rgba(17, 27, 34, 0.08), 0 6px 16px -8px rgba(17, 27, 34, 0.22);
  --focus: 0 0 0 2px var(--case), 0 0 0 4px var(--action);
  --r: 6px;
  --acc: #1f4fcf;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0e1316; --case: #172026; --case-2: #121a1f; --frame: #3c4b54;
    --rule: #28343b; --rule-strong: #4a5961; --ink: #e5ebed; --ink-2: #b3bfc5; --muted: #93a2a9;
    --action: #8eabff; --action-fill: #3862d8; --action-soft: #1e2a4a;
    --cancel: #ff8f80; --cancel-fill: #c0392e; --cancel-soft: #3a1d1a;
    --franked: #74d3a0; --franked-soft: #15301f; --insured: #f2c14e; --insured-ink: #241b00;
    --postmark: #bdb8ec; --chart: #5f86f2; --chart-wash: rgba(95, 134, 242, 0.14); --grid: #222d34;
    --hole-shadow: inset 0 10px 12px -10px rgba(0, 0, 0, 0.6);
    --lift: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 18px -8px rgba(0, 0, 0, 0.7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0e1316; --case: #172026; --case-2: #121a1f; --frame: #3c4b54;
  --rule: #28343b; --rule-strong: #4a5961; --ink: #e5ebed; --ink-2: #b3bfc5; --muted: #93a2a9;
  --action: #8eabff; --action-fill: #3862d8; --action-soft: #1e2a4a;
  --cancel: #ff8f80; --cancel-fill: #c0392e; --cancel-soft: #3a1d1a;
  --franked: #74d3a0; --franked-soft: #15301f; --insured: #f2c14e; --insured-ink: #241b00;
  --postmark: #bdb8ec; --chart: #5f86f2; --chart-wash: rgba(95, 134, 242, 0.14); --grid: #222d34;
  --hole-shadow: inset 0 10px 12px -10px rgba(0, 0, 0, 0.6);
  --lift: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 18px -8px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font: 400 15px/1.5 'Barlow', system-ui, sans-serif;
  font-feature-settings: 'kern', 'liga';
  min-height: 100vh;
}
a { color: var(--action); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 600; text-wrap: balance; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, 'JetBrains Mono', Menlo, monospace; font-size: 0.86em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--case); border-bottom: 2px solid var(--frame);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand .mark { width: 28px; height: 28px; }
.brand b { font: 700 1.05rem/1 'Barlow Condensed', sans-serif; letter-spacing: 0.06em; text-transform: uppercase; }
.brand small { display: block; font-size: 0.72rem; color: var(--muted); letter-spacing: 0.02em; margin-top: 2px; }
.topbar .spacer { flex: 1; }
.suite-nav { display: flex; gap: 2px; margin-left: 14px; padding: 3px; border: 1px solid var(--rule); border-radius: 999px; }
.suite-nav a { font: 600 0.78rem/1 'Barlow', sans-serif; letter-spacing: 0.02em; color: var(--muted); text-decoration: none; padding: 7px 11px; border-radius: 999px; }
.suite-nav a:hover { color: var(--ink); }
.suite-nav a[aria-current] { color: var(--ink); background: var(--case-2); }
.login .suite-sso { width: 100%; justify-content: center; margin-top: 4px; }
.login .or { text-align: center; font-size: 0.8rem; margin: 12px 0 2px; }
.iconbtn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r);
  border: 1px solid var(--rule); background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background 160ms ease-out, color 160ms ease-out;
}
.iconbtn:hover { background: var(--case-2); color: var(--ink); }

/* ---------- postmark (datestamp of the last push) ---------- */
.postmark { display: flex; align-items: center; gap: 6px; color: var(--postmark); }
.postmark svg { width: 54px; height: 54px; }
.postmark .wavy { width: 40px; height: 30px; }
.postmark text { fill: currentColor; font-family: 'Barlow Condensed', sans-serif; font-weight: 700; }
.postmark.stale { color: var(--cancel); }
@media (max-width: 520px) { .suite-nav { margin-left: 6px; } .suite-nav a { padding: 7px 8px; } .brand b { font-size: 0.92rem; } .brand small { display: none; } .postmark .wavy { display: none; } .postmark svg { width: 46px; height: 46px; } }

/* ---------- page frame ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 16px 64px; }
.lede { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.lede p { color: var(--ink-2); font-size: 1.05rem; max-width: 60ch; margin-top: 6px; }
.lede strong { color: var(--ink); }

/* ---------- the sorting case (overview) ---------- */
.case {
  display: grid; gap: 2px; background: var(--frame); border: 2px solid var(--frame); border-radius: 4px;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) { .case { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .case { grid-template-columns: repeat(3, 1fr); } }
.hole {
  position: relative; display: flex; flex-direction: column; gap: 14px; min-height: 196px;
  padding: 14px 16px 16px; background: var(--case); box-shadow: var(--hole-shadow);
  color: var(--ink); text-decoration: none; transition: background 180ms ease-out;
}
a.hole:hover { background: color-mix(in oklab, var(--case) 88%, var(--acc)); }
.hole.empty {
  min-height: 150px;
  background:
    repeating-linear-gradient(135deg, transparent 0 9px, color-mix(in oklab, var(--rule) 55%, transparent) 9px 10px),
    var(--case-2);
}
.plate {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; max-width: 100%;
  padding: 4px 10px 3px; border-radius: 3px; background: var(--acc); color: #fff;
  font: 700 0.95rem/1.2 'Barlow Condensed', sans-serif; letter-spacing: 0.07em; text-transform: uppercase;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.plate span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plate.big { font-size: 1.35rem; padding: 6px 14px 5px; }
.hole.empty .plate { background: color-mix(in oklab, var(--acc) 45%, var(--rule-strong)); }
.hole .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pieces { display: grid; gap: 6px; }
.piece { display: flex; align-items: center; gap: 10px; font-size: 0.95rem; }
.piece .n { font-weight: 700; font-size: 1.15rem; min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
.piece.zero { color: var(--muted); }
.piece.zero .n { font-weight: 500; }
.foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 10px; }
.foot b { color: var(--ink-2); font-weight: 600; }
.hole .why { color: var(--ink-2); max-width: 34ch; }
.hole .go { display: inline-flex; align-items: center; gap: 6px; color: var(--action); font-weight: 600; }
@media (max-width: 639px) { .hole { min-height: 0; } .hole.empty { min-height: 0; gap: 10px; } }

/* ---------- labels / stamps ---------- */
.reg {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px 0 2px; border: 1.5px solid var(--ink);
  border-radius: 3px; font: 700 0.72rem/1.5 'Barlow Condensed', sans-serif; letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--case); color: var(--ink); white-space: nowrap;
}
.reg::before {
  content: 'R'; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 2px;
  background: var(--action-fill); color: #fff; font-size: 0.78rem; letter-spacing: 0;
}
.reg.insured { background: var(--insured); color: var(--insured-ink); border-color: var(--insured-ink); }
.reg.insured::before { content: '$'; background: var(--insured-ink); color: var(--insured); }
.stamp {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; border: 1.5px solid currentColor; border-radius: 3px;
  font: 700 0.72rem/1.55 'Barlow Condensed', sans-serif; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
  color: var(--ink-2);
}
.stamp.p1 { color: var(--cancel); }
.stamp.p2 { color: var(--action); }
.stamp.ok { color: var(--franked); }
.stamp.demo { color: var(--postmark); border-style: double; border-width: 3px; padding: 0 7px; transform: rotate(-4deg); }
.chan {
  display: inline-grid; place-items: center; min-width: 26px; height: 20px; padding: 0 4px; border-radius: 3px;
  background: var(--case-2); border: 1px solid var(--rule); color: var(--ink-2);
  font: 700 0.68rem/1 'Barlow Condensed', sans-serif; letter-spacing: 0.06em;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 14px;
  border-radius: var(--r); border: 1px solid var(--rule-strong); background: var(--case); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 160ms ease-out, border-color 160ms ease-out, transform 120ms ease-out;
}
.btn:hover { background: var(--case-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--action-fill); border-color: var(--action-fill); color: #fff; }
.btn.primary:hover { background: color-mix(in oklab, var(--action-fill) 86%, #000); }
.btn.danger { color: var(--cancel); border-color: color-mix(in oklab, var(--cancel) 55%, var(--rule)); }
.btn.danger:hover { background: var(--cancel-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--action); padding: 0 8px; }
.btn.ghost:hover { background: var(--action-soft); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 0.9rem; }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.55; cursor: not-allowed; }

/* ---------- project masthead ---------- */
.masthead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 18px; }
.masthead .back { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-2); text-decoration: none; font-weight: 500; width: 100%; font-size: 0.92rem; }
.masthead .back:hover { color: var(--ink); }
.masthead .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-2); font-size: 0.92rem; align-items: center; }
.health { display: inline-flex; align-items: center; gap: 6px; }
.health.bad { color: var(--cancel); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--franked); flex: none; }
.health.bad .dot { background: var(--cancel); }

/* ---------- console: tab rail + panel ---------- */
.console { display: grid; gap: 18px; }
@media (min-width: 1000px) { .console { grid-template-columns: 210px minmax(0, 1fr); align-items: start; } }
.tabs {
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  position: sticky; top: 60px; z-index: 10; background: var(--frame); border: 2px solid var(--frame); border-radius: 4px;
  margin: 0 -16px; border-left: 0; border-right: 0; border-radius: 0;
}
.tabs::-webkit-scrollbar { display: none; }
@media (min-width: 1000px) {
  .tabs { flex-direction: column; top: 84px; margin: 0; border: 2px solid var(--frame); border-radius: 4px; overflow: visible; }
}
.tab {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--case-2); color: var(--ink-2);
  text-decoration: none; font-weight: 500; white-space: nowrap; flex: none; transition: background 160ms ease-out, color 160ms ease-out;
}
.tab:hover { background: var(--case); color: var(--ink); }
.tab[aria-current="page"] { background: var(--case); color: var(--ink); font-weight: 700; box-shadow: inset 0 -3px 0 var(--acc); }
@media (min-width: 1000px) { .tab[aria-current="page"] { box-shadow: inset 4px 0 0 var(--acc); } }
.tab .count { margin-left: auto; font-size: 0.8rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; padding-left: 6px; }
.tab .count.hot { color: #fff; background: var(--action-fill); border-radius: 10px; padding: 0 7px; min-width: 20px; text-align: center; }
.panel:focus { box-shadow: none; }
.panel { background: var(--case); border: 2px solid var(--frame); border-radius: 4px; padding: 20px 18px 28px; min-width: 0; }
@media (max-width: 999px) { .panel { padding: 16px 14px 24px; } }
.panel > section + section { margin-top: 30px; }
.sect-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 12px; }
.sect-head p { color: var(--muted); font-size: 0.9rem; }

/* ---------- lists (mail pieces) ---------- */
.list { display: grid; border-top: 1px solid var(--rule); }
.item {
  display: grid; gap: 4px; padding: 12px 4px; border-bottom: 1px solid var(--rule); color: var(--ink);
  text-decoration: none; background: transparent; text-align: left; border-left: 0; border-right: 0; border-top: 0; width: 100%; cursor: pointer;
}
.item:hover { background: var(--case-2); }
.item[aria-current="true"] { background: var(--action-soft); }
.item .top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.item .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.item .when { margin-left: auto; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.item .sum { color: var(--ink-2); font-size: 0.93rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.item .tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.unread { width: 8px; height: 8px; border-radius: 50%; background: var(--action-fill); flex: none; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  min-height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--rule-strong); background: transparent;
  color: var(--ink-2); font-weight: 500; cursor: pointer; transition: background 160ms ease-out;
}
.chip:hover { background: var(--case-2); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--case); border-color: var(--ink); }

/* ---------- inbox split ---------- */
.split { display: grid; gap: 0; }
@media (min-width: 1180px) { .split { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 20px; } }
.thread { display: grid; gap: 12px; align-content: start; }
.thread-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.msgs { display: grid; gap: 10px; }
.msg { max-width: 78%; padding: 9px 12px; border-radius: 4px; background: var(--case-2); border: 1px solid var(--rule); overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.us { justify-self: end; background: var(--action-soft); border-color: color-mix(in oklab, var(--action) 30%, var(--rule)); }
.msg time { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 4px; white-space: normal; }
.window { font-size: 0.85rem; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.window.closed { color: var(--cancel); }
.back-btn { display: none; }
@media (max-width: 1179px) {
  .split.has-thread .list-col { display: none; }
  .split:not(.has-thread) .thread { display: none; }
  .back-btn { display: inline-flex; }
}
.draftbox { border: 1px dashed var(--rule-strong); border-radius: var(--r); padding: 12px; display: grid; gap: 8px; background: var(--case); }
.draftbox p { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- registered mail (approvals) ---------- */
.reglist { display: grid; gap: 14px; }
.letter {
  position: relative; display: grid; gap: 10px; padding: 14px 16px 16px; background: var(--case);
  border: 1px solid var(--rule-strong); border-radius: 4px; box-shadow: var(--lift); overflow: hidden;
}
.letter.money { border-color: color-mix(in oklab, var(--insured) 70%, var(--rule-strong)); }
.letter .head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.letter .kind { font-weight: 700; }
.letter .when { margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.letter .preview {
  white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px 12px; background: var(--case-2);
  border-radius: 4px; border: 1px solid var(--rule); font-size: 0.97rem;
}
.letter .filed { font-size: 0.88rem; color: var(--ink-2); display: grid; gap: 2px; }
.letter .filed b { font-weight: 600; color: var(--ink); }
.declared { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; padding: 8px 12px; border-radius: 4px; background: color-mix(in oklab, var(--insured) 18%, var(--case)); }
.declared .v { font-size: 1.25rem; font-weight: 700; }
.declared .lim { font-size: 0.85rem; color: var(--ink-2); }
.declared .over { color: var(--cancel); font-weight: 700; }
details.params summary { cursor: pointer; color: var(--ink-2); font-size: 0.88rem; font-weight: 500; }
details.params dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 8px 0 0; font-size: 0.86rem; }
details.params dt { color: var(--muted); }
details.params dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.edit textarea, .composer textarea {
  width: 100%; min-height: 96px; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--rule-strong);
  background: var(--case); resize: vertical; line-height: 1.45;
}
.edit textarea:focus, .composer textarea:focus, .field input:focus { outline: none; box-shadow: var(--focus); }
.letter .err { color: var(--cancel); font-size: 0.9rem; font-weight: 600; }
.cancel-mark {
  position: absolute; right: 12px; top: 8px; width: 112px; height: 112px; pointer-events: none; color: var(--franked);
  opacity: 0.9; transform: rotate(-12deg);
}
.cancel-mark.rejected { color: var(--cancel); }
.cancel-mark text { fill: currentColor; font-family: 'Barlow Condensed', sans-serif; font-weight: 700; }
@media (prefers-reduced-motion: no-preference) {
  .cancel-mark { animation: stamp 260ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  @keyframes stamp {
    from { opacity: 0; transform: rotate(-4deg) scale(1.5); filter: blur(2px); }
    to { opacity: 0.9; transform: rotate(-12deg) scale(1); filter: blur(0); }
  }
}
.letter.signed .actions, .letter.signed .edit { display: none; }
.letter.signed { background: color-mix(in oklab, var(--franked-soft) 45%, var(--case)); }
.letter.rejected { background: color-mix(in oklab, var(--cancel-soft) 45%, var(--case)); }
.queued { font-weight: 600; color: var(--franked); }
.letter.rejected .queued { color: var(--cancel); }

/* ---------- figures docket ---------- */
.docket { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--rule); border-radius: 4px; }
@media (min-width: 720px) { .docket { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.fig { padding: 12px 14px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); display: grid; gap: 2px; }
.fig .l { font-size: 0.85rem; color: var(--ink-2); }
.fig .v { font-size: 1.6rem; font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
.fig .d { font-size: 0.85rem; color: var(--muted); }
.fig .d.up { color: var(--franked); }
.fig .d.down { color: var(--cancel); }

/* ---------- content ---------- */
.posts { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.post { display: grid; grid-template-rows: auto 1fr auto; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; background: var(--case); }
.post .thumb { aspect-ratio: 4 / 5; background: var(--case-2); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.post .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post .body { padding: 10px 12px; display: grid; gap: 6px; align-content: start; }
.post .cap { font-size: 0.92rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.post .metrics { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 8px 12px; border-top: 1px solid var(--rule); font-size: 0.84rem; color: var(--ink-2); }
.post .metrics b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 4px; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th { font-weight: 600; color: var(--ink-2); background: var(--case-2); font-size: 0.85rem; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
@media (max-width: 640px) { td .mono { display: none; } }
td.long { white-space: normal; min-width: 220px; overflow-wrap: anywhere; }

/* ---------- charts ---------- */
.multiples { display: grid; gap: 0; grid-template-columns: 1fr; border: 1px solid var(--rule); border-radius: 4px; }
@media (min-width: 760px) { .multiples { grid-template-columns: 1fr 1fr; } }
.plot { padding: 14px 14px 8px; border-bottom: 1px solid var(--rule); position: relative; }
@media (min-width: 760px) { .plot:nth-child(odd) { border-right: 1px solid var(--rule); } }
.plot h3 { font-size: 0.95rem; font-weight: 600; color: var(--ink-2); }
.plot .big { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
.plot svg { display: block; width: 100%; height: 150px; overflow: visible; touch-action: pan-y; }
.plot .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plot .area { fill: var(--chart-wash); stroke: none; }
.plot .gridl { stroke: var(--grid); stroke-width: 1; }
.plot .tick { fill: var(--muted); font-size: 11px; font-family: 'Barlow', sans-serif; }
.plot .cross { stroke: var(--rule-strong); stroke-width: 1; }
.plot .pt { fill: var(--chart); stroke: var(--case); stroke-width: 2; }
.tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--case); padding: 5px 9px; border-radius: 4px;
  font-size: 0.82rem; white-space: nowrap; box-shadow: var(--lift); transform: translate(-50%, -110%); z-index: 3;
}
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: minmax(90px, 34%) minmax(0, 1fr); gap: 10px; align-items: center; font-size: 0.9rem; }
.bar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.bar .track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar .fill { height: 18px; background: var(--chart); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar .val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--action); cursor: pointer; font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- digest (markdown from the agent) ---------- */
.digest { display: grid; gap: 8px; max-width: 72ch; }
.digest h4 { margin: 8px 0 0; font-size: 1rem; }
.digest ul { margin: 0; padding-left: 20px; display: grid; gap: 3px; }

/* ---------- ask ---------- */
.convo { display: grid; gap: 16px; margin-bottom: 18px; }
.qa { display: grid; gap: 8px; }
.qa .q { justify-self: end; max-width: 82%; background: var(--action-soft); border-radius: 4px; padding: 9px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.qa .a { max-width: 88%; background: var(--case-2); border: 1px solid var(--rule); border-radius: 4px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.qa .a.waiting { color: var(--muted); font-style: italic; }
.qa .by { font-size: 0.78rem; color: var(--muted); }
.qa .q + .by { justify-self: end; }
.composer { display: grid; gap: 8px; }
.composer .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }

/* ---------- settings / connect ---------- */
.steps { counter-reset: s; display: grid; gap: 0; border-top: 1px solid var(--rule); }
.step { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 4px 12px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.step .mk {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--rule-strong); display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem; color: var(--ink-2);
}
.step.done .mk { background: var(--franked); border-color: var(--franked); color: var(--case); }
.step .tx { display: grid; gap: 6px; min-width: 0; }
.step .tx p { color: var(--ink-2); max-width: 70ch; }
.cmd { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--case-2); border: 1px solid var(--rule); border-radius: 4px; min-width: 0; }
.cmd code { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; }
.perms { display: flex; flex-wrap: wrap; gap: 6px; }
.perms code { font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; padding: 2px 7px; border-radius: 3px; background: var(--case-2); border: 1px solid var(--rule); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 0.92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.voice { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--case-2); border: 1px solid var(--rule); border-radius: 4px; padding: 12px; max-width: 75ch; }
.rule-auto { color: var(--franked); font-weight: 600; }
.rule-deny { color: var(--cancel); font-weight: 600; }

/* ---------- empty / loading / error ---------- */
.empty-state { display: grid; gap: 8px; justify-items: start; padding: 22px 4px; color: var(--ink-2); max-width: 62ch; }
.empty-state h3 { color: var(--ink); }
.skel { display: grid; gap: 10px; }
.skel i { display: block; height: 14px; border-radius: 3px; background: linear-gradient(90deg, var(--case-2), var(--rule), var(--case-2)); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) { .skel i { animation: shimmer 1.4s linear infinite; } }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel i:nth-child(2) { width: 80%; } .skel i:nth-child(3) { width: 60%; }
.banner { padding: 10px 14px; border-radius: 4px; border: 1px solid var(--rule-strong); background: var(--case); display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.banner.err { border-color: var(--cancel); color: var(--cancel); background: var(--cancel-soft); }
.banner.demo { border-color: var(--postmark); color: var(--postmark); }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--case);
  padding: 10px 16px; border-radius: 6px; box-shadow: var(--lift); z-index: 50; max-width: calc(100vw - 32px);
}

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(400px, 100%); background: var(--case); border: 2px solid var(--frame); border-radius: 4px; padding: 26px 22px; display: grid; gap: 16px; box-shadow: var(--hole-shadow); }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 0.92rem; }
.field input { min-height: 44px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--rule-strong); background: var(--case); }
.form-err { color: var(--cancel); font-weight: 600; min-height: 1.4em; }

/* ---------- read pages (privacy, terms, connect) ---------- */
.doc { max-width: 72ch; margin: 0 auto; padding: 32px 16px 80px; display: grid; gap: 14px; }
.doc h1 { font-size: 2rem; }
.doc h2 { margin-top: 18px; }
.doc p, .doc li { color: var(--ink-2); line-height: 1.65; }
.doc ul, .doc ol { margin: 0; padding-left: 22px; display: grid; gap: 4px; }
footer.site { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 24px 16px 40px; }
footer.site a { color: var(--ink-2); }

/* ---------- Connect with RVRS ---------- */
.connect-cta { border: 1px solid var(--rule-strong); border-radius: var(--r); padding: 16px 18px; margin: 16px 0 24px; background: var(--case); }
.connect-cta h2 { margin-top: 0; }
.connect-cta select { min-height: 36px; border-radius: var(--r); border: 1px solid var(--rule-strong); background: var(--paper, transparent); color: var(--ink); padding: 0 8px; }
.small { font-size: 0.9rem; }
.result-list { list-style: none; padding: 0; }
.result-list li { padding: 6px 0; border-bottom: 1px solid var(--rule); }

/* studio services (Google health) */
.studio-head { margin: 28px 0 10px; font: 700 0.95rem/1.2 'Barlow Condensed', sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.case.studio { grid-template-columns: 1fr; }
.hole.wide { min-height: 0; }
.findings { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.findings li { display: flex; align-items: baseline; gap: 8px; font-size: 0.93rem; overflow-wrap: anywhere; }
.domains { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 0.88rem; }
