/* The portal's styles (decision 0063). Tokens on :root; dark mode from the OS unless the toggle stamped a theme. */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --border: #e3e2dc;
  --border-strong: #cfcec7;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #75746e;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: #e4eefb;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e9e8e3;
  --good: #0a7f0a;
  --bad: #c23434;
  --warn: #9a6a00;
  --good-soft: #e3f3e3;
  --bad-soft: #f8e4e4;
  --warn-soft: #fbf0d6;
  --shadow: 0 1px 2px rgba(20, 20, 15, .05), 0 1px 1px rgba(20, 20, 15, .03);
  --radius: 14px;
  --radius-sm: 9px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #222220;
    --border: #2d2d2a;
    --border-strong: #3c3c38;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #93928a;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-soft: #17283d;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2a2a27;
    --good: #4cc24c;
    --bad: #ec7070;
    --warn: #f0b43a;
    --good-soft: #15291a;
    --bad-soft: #2f1a1a;
    --warn-soft: #2e2512;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #222220;
  --border: #2d2d2a;
  --border-strong: #3c3c38;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --text-3: #93928a;
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-soft: #17283d;
  --series-1: #3987e5;
  --series-2: #d95926;
  --grid: #2a2a27;
  --good: #4cc24c;
  --bad: #ec7070;
  --warn: #f0b43a;
  --good-soft: #15291a;
  --bad-soft: #2f1a1a;
  --warn-soft: #2e2512;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent-ink); }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 20px 14px;
  border-right: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; font-weight: 650; letter-spacing: -.01em; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent);
  display: grid; place-items: center; color: #fff;
}
.brand-mark svg { width: 16px; height: 16px; }
.brand small { display: block; font-weight: 500; color: var(--text-3); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500; white-space: nowrap;
}
.nav a svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.nav-sep { margin: 10px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }
.who { font-size: 13px; color: var(--text-2); padding: 0 6px; overflow: hidden; text-overflow: ellipsis; }
.who b { color: var(--text); font-weight: 600; }

.main { min-width: 0; padding: 22px 28px 48px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.topbar h1 { font-size: 22px; line-height: 1.2; margin: 0 auto 0 0; letter-spacing: -.02em; font-weight: 680; }
.topbar .sub { display: block; font-size: 13px; font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-top: 2px; }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button {
  border: 0; background: transparent; padding: 5px 10px; border-radius: 7px; cursor: pointer;
  color: var(--text-2); font-size: 13px; font-weight: 550;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); outline: 1px solid var(--border); }
.select, .input {
  height: 34px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 14px;
}
.input { width: 100%; height: 40px; }
.select:focus-visible, .input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.custom-range { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-2); }
.custom-range input { height: 34px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); }
.btn {
  height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; font-weight: 560; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-danger { color: var(--bad); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.icon-btn { width: 34px; padding: 0; justify-content: center; }
.icon-btn svg { width: 17px; height: 17px; }

/* ---- content ---- */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); margin-bottom: 14px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); min-width: 0;
}
.card h2 { font-size: 14px; font-weight: 620; margin: 0; letter-spacing: -.005em; }
.card-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.card-head { flex-wrap: wrap; }
.card-head .hint { font-size: 12px; color: var(--text-3); margin-right: auto; }
.card-head h2:last-child { margin-right: auto; }
.tile .label { font-size: 13px; color: var(--text-2); font-weight: 520; display: flex; gap: 6px; align-items: center; }
.tile .value { font-size: 28px; font-weight: 680; letter-spacing: -.025em; margin-top: 6px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 15px; font-weight: 560; color: var(--text-2); letter-spacing: 0; }
.tile .foot { margin-top: 8px; font-size: 12px; color: var(--text-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; font-weight: 600; font-size: 12px; background: var(--surface-2); color: var(--text-2); }
.delta.up-good, .delta.down-good { background: var(--good-soft); color: var(--good); }
.delta.up-bad, .delta.down-bad { background: var(--bad-soft); color: var(--bad); }
.delta svg { width: 10px; height: 10px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px 16px; }
.stat .k { font-size: 12px; color: var(--text-3); }
.stat .v { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.note { font-size: 12px; color: var(--text-3); margin: 10px 0 0; }
.banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--text); font-size: 13px; margin-bottom: 14px; border: 1px solid var(--border);
}
.banner svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--accent-ink); }

/* ---- charts ---- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--series-1); }
.chart .bar.s2 { fill: var(--series-2); }
.chart .bar.dim { opacity: .35; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.s2 { stroke: var(--series-2); }
.chart .area { fill: var(--series-1); opacity: .10; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .dot.s2 { fill: var(--series-2); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .cross { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 120px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9px; padding: 7px 10px;
  font-size: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .12); white-space: nowrap;
}
.tip .t { color: var(--text-3); margin-bottom: 3px; }
.tip .r { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tip .r b { margin-left: auto; padding-left: 12px; }
.key { width: 9px; height: 9px; border-radius: 3px; display: inline-block; background: var(--series-1); flex: none; }
.key.s2 { background: var(--series-2); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); align-items: center; }
.legend span { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.legend { flex-wrap: wrap; }
.toggle-table { font-size: 12px; }

.funnel { display: flex; flex-direction: column; gap: 10px; }
.hbars .funnel-row { grid-template-columns: minmax(64px, max-content) 1fr minmax(96px, max-content); }
.hbars .funnel-row .name { text-transform: none; }
.hbars .funnel-row .val small { display: block; margin-left: 0; font-size: 11px; }
.glance .tile .value { font-size: 25px; }
.hbars .funnel-bar { opacity: .75; }
.hbars .funnel-bar.top { opacity: 1; }
.section-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 4px 2px 10px; }
.section-head h2 { font-size: 13px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); margin: 0; }
.section-head .hint { font-size: 12px; color: var(--text-3); }
.grid + .section-head, .card + .section-head { margin-top: 22px; }
.grid + .grid, .card + .grid, .grid + .card { margin-top: 14px; }
.glance .tile .foot span:last-child { min-width: 0; }
table.data td .pill { margin-left: 6px; }
.funnel-row { display: grid; grid-template-columns: 88px 1fr 92px; align-items: center; gap: 10px; font-size: 13px; }
.funnel-row .name { color: var(--text-2); font-weight: 520; text-transform: capitalize; }
.funnel-track { height: 26px; background: var(--surface-2); border-radius: 7px; overflow: hidden; }
.funnel-bar { height: 100%; background: var(--series-1); border-radius: 7px; min-width: 3px; }
.funnel-bar.zero { min-width: 0; }
.funnel-row .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.funnel-row .val small { color: var(--text-3); font-weight: 500; margin-left: 4px; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 8px; padding: 34px 16px; color: var(--text-3); min-height: 180px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2);
}
.empty svg { width: 30px; height: 30px; opacity: .7; }
.empty b { color: var(--text-2); font-weight: 600; font-size: 14px; }
.empty span { font-size: 13px; max-width: 340px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; color: var(--text-3); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.data td { padding: 8px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
table.data .r { text-align: right; }
.table-wrap { overflow-x: auto; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill svg { width: 11px; height: 11px; }
.sev { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- forms ---- */
.form { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
.field label { display: block; font-size: 13px; font-weight: 560; margin-bottom: 5px; color: var(--text-2); }
.checks { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; }
.msg { font-size: 13px; padding: 8px 12px; border-radius: 9px; }
.msg.err { background: var(--bad-soft); color: var(--bad); }
.msg.ok { background: var(--good-soft); color: var(--good); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.inline-form .input { height: 32px; width: auto; flex: 1 1 160px; }

/* ---- login ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { margin-bottom: 18px; padding: 0; }
.auth-card h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
.auth-card p { margin: 0 0 18px; color: var(--text-3); font-size: 14px; }
.auth-card .btn { height: 40px; width: 100%; justify-content: center; }
.auth-foot { margin-top: 14px; font-size: 12px; color: var(--text-3); text-align: center; }

.skeleton { height: 120px; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ---- small screens ---- */
@media (max-width: 1100px) {
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side { min-width: 0; }
  .side {
    position: sticky; top: 0; z-index: 10; height: auto; padding: 10px 16px 0; gap: 8px;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .side .brand { padding: 0; }
  .nav { flex-direction: row; overflow-x: auto; gap: 2px; margin: 0 -16px; padding: 0 12px 8px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  /* #97: a fade on the edge that has more tabs behind it (JS sets more-right / more-left from the scroll position) */
  .nav.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 44px), transparent); }
  .nav.more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 44px), transparent);
    mask-image: linear-gradient(to left, #000 calc(100% - 44px), transparent); }
  .nav.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 44px, #000 calc(100% - 44px), transparent);
    mask-image: linear-gradient(to right, transparent, #000 44px, #000 calc(100% - 44px), transparent); }
  .nav a { flex: none; }
  .nav a { padding: 7px 10px; font-size: 14px; }
  .nav a svg { display: none; }
  .nav-sep { display: none; }
  .side-foot { display: none; }
  .main { padding: 16px 16px 40px; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .topbar h1 { font-size: 20px; width: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile .value { font-size: 23px; }
  .card { padding: 14px; }
  .funnel-row { grid-template-columns: 70px 1fr 74px; }
  /* the phone header is the tab row only; the title row carries the controls: creator + theme + account, then the
     range buttons full width */
  .side { padding-top: 6px; }
  .side .brand { display: none; }
  .controls { width: 100%; }
  .controls .select { flex: 1 1 0; min-width: 0; order: 1; }
  .controls .icon-btn { order: 1; }
  .controls #theme { margin-left: auto; }
  .seg { order: 2; flex: 1 1 100%; }
  .seg button { flex: 1 1 0; padding: 7px 4px; }
  .custom-range { order: 3; flex: 1 1 100%; flex-wrap: wrap; }
  .custom-range input { flex: 1 1 120px; min-width: 0; }
  .glance .tile .value { font-size: 22px; }
  .tile .foot { font-size: 11.5px; }
  .section-head .hint { flex-basis: 100%; }
  table.data { font-size: 12.5px; }
  table.data td, table.data th { padding-left: 6px; padding-right: 6px; }
}
@media (min-width: 861px) { .mobile-only { display: none !important; } }
@media (forced-colors: active) {
  .chart .bar, .funnel-bar { fill: CanvasText; background: CanvasText; }
}

/* ---- the minimal Stars page ---- */
.hero-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hero .value { font-size: 34px; margin-top: 4px; }
.hero .foot { margin-top: 10px; }
.seg-sm button { padding: 4px 10px; font-size: 12.5px; }
.summary { margin: 12px 0 0; font-size: 13px; color: var(--text-2); }
.more { margin-top: 18px; }
.more > summary { cursor: pointer; font-size: 14px; font-weight: 580; color: var(--text-2); padding: 6px 2px; list-style: none; display: inline-flex; gap: 6px; align-items: center; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: "▸"; font-size: 11px; transition: transform .15s; }
.more[open] > summary::before { transform: rotate(90deg); }
.more[open] > summary { margin-bottom: 10px; }
@media (max-width: 860px) {
  .hero-row { grid-template-columns: 1fr; gap: 10px; }
  .hero { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; }
  .hero .label { grid-column: 1; }
  .hero .value { grid-column: 1; font-size: 28px; }
  .hero .foot { grid-column: 2; grid-row: 1 / span 2; margin: 0; flex-direction: column; align-items: flex-end; }
  .card-head .seg-sm { order: 0; flex: none; }
  .card-head .seg-sm button { flex: none; }
}
@media (prefers-reduced-motion: reduce) { .more > summary::before { transition: none; } }

/* ---- admin & team lists (one row per person / client; actions wrap under the name on a phone) ---- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-main { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.list-main b { font-weight: 600; overflow-wrap: anywhere; }
.list-main .muted { font-size: 13px; overflow-wrap: anywhere; }
.list-extra { flex: 1 1 100%; min-width: 0; }
.list-extra:empty { display: none; }
.sublist { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
.sub-row { display: flex; justify-content: space-between; gap: 12px; }
.form .select { width: 100%; height: 40px; }
@media (max-width: 860px) {
  .list-row .row-actions { flex: 1 1 100%; justify-content: flex-start; }
  .list-row .row-actions .btn, .inline-form .btn, .inline-form .input { height: 40px; }
}

/* ---- the Bot page (one 3-way switch, one status line, one short form) ---- */
.seg-big { display: flex; width: 100%; max-width: 420px; }
.seg-big button { flex: 1 1 0; min-height: 42px; font-size: 15px; padding: 8px 6px; }
.bot-status { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--text-3); }
.dot.good { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.ladder { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.ladder .input { padding: 0 6px; min-width: 0; }
/* #97: 5 inputs do not fit a 375 px phone with large system fonts: 3 + 2 (an em query follows the font size) */
@media (max-width: 40em) {
  .ladder { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ladder .input { font-size: 16px; }
}
.refused ul { margin: 4px 0 0; padding-left: 18px; }
.refused li { overflow-wrap: anywhere; }
.pair { display: flex; align-items: center; gap: 8px; }
.pair .input { flex: 1 1 0; min-width: 0; }
.field-hint { display: block; font-size: 12px; color: var(--text-3); margin-top: 4px; }
.invalid, .invalid .input { border-color: var(--bad) !important; outline: 1px solid var(--bad); border-radius: 9px; }
.btn-lg { height: 42px; padding: 0 22px; }
.checks input { width: 18px; height: 18px; }
.checks label { min-height: 40px; }
@media (max-width: 860px) {
  .card .seg-big { order: 0; flex: none; }
}

/* ---- Chats (S3, #93): list + chat side by side on desktop, one at a time on a phone ---- */
.chats { display: grid; grid-template-columns: minmax(250px, 340px) minmax(0, 1fr); gap: 14px; align-items: start; }
.chat-side { padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.chat-list { display: flex; flex-direction: column; max-height: calc(100vh - 190px); overflow-y: auto; }
.chat-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 8px 8px; border: 0;
  border-bottom: 1px solid var(--border); background: none; text-align: left; cursor: pointer; border-radius: 8px;
}
.chat-row:last-child { border-bottom: 0; }
.chat-row:hover { background: var(--surface-2); }
.chat-row[aria-current="true"] { background: var(--accent-soft); }
.chat-who { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.chat-who b, .chat-who .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-who .muted { font-size: 13px; }
.chat-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 12px; flex: none; }
.flagdot { font-size: 13px; line-height: 1; }
.chat-pane { padding: 0; display: flex; flex-direction: column; min-height: 50vh; }
.chat-pane > .empty, .chat-pane > .skeleton { margin: 16px; }
.chat-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.msgs { display: flex; flex-direction: column; gap: 6px; padding: 14px; overflow-y: auto; max-height: calc(100vh - 290px); min-height: 200px; }
.msgs .earlier { align-self: center; }
.day { align-self: center; font-size: 11px; color: var(--text-3); margin: 8px 0 2px; }
.bubble {
  max-width: 82%; padding: 8px 11px; border-radius: 15px; font-size: 14px; line-height: 1.4;
  overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.bubble .txt { white-space: pre-wrap; }
.bubble.fan { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 5px; }
.bubble.her { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 5px; }
.bubble.human { outline: 1.5px dashed var(--accent); outline-offset: -1.5px; }
.bubble .you { font-size: 11px; font-weight: 650; color: var(--accent-ink); text-transform: uppercase; letter-spacing: .05em; }
.bubble .ts { font-size: 11px; color: var(--text-3); align-self: flex-end; }
.bubble .offer { font-size: 12px; font-weight: 600; color: var(--accent-ink); }
.bubble img, .bubble video { display: block; max-width: 100%; max-height: 260px; border-radius: 10px; object-fit: cover; }
.media-ph {
  padding: 18px 14px; border-radius: 10px; background: var(--surface); border: 1px dashed var(--border-strong);
  color: var(--text-3); font-size: 13px; text-align: center;
}
.event { align-self: center; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.event.good { background: var(--good-soft); color: var(--good); }
.chat-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border); background: var(--surface); border-radius: 0 0 var(--radius) var(--radius);
}
.chat-bar .bar-row { display: flex; align-items: center; gap: 8px; }
.chat-bar .grow { flex: 1 1 auto; }
.chat-bar .btn { min-height: 40px; }
.chat-bar .dots { width: 44px; font-size: 20px; line-height: 1; }
.chat-bar .say { display: flex; gap: 8px; align-items: flex-end; }
.chat-bar .say textarea { flex: 1 1 auto; min-width: 0; }
textarea.input { height: auto; min-height: 40px; padding: 9px 10px; resize: vertical; line-height: 1.35; font: inherit; }
.menu {
  position: absolute; right: 12px; bottom: calc(100% - 4px); z-index: 20; min-width: 220px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; padding: 4px; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.menu button { min-height: 44px; padding: 0 12px; border: 0; background: none; text-align: left; border-radius: 8px; cursor: pointer; font-size: 14px; }
.menu button:hover { background: var(--surface-2); }
.menu-note { padding: 10px 12px; font-size: 13px; }
.sheet-back {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .38); padding: 0;
}
.sheet {
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; background: var(--surface); color: var(--text);
  border-radius: 18px 18px 0 0; padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.sheet .card-head { margin-bottom: 0; }
.sheet .seg-big { max-width: none; order: 0; flex: none; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sheet-actions .btn { min-height: 42px; padding: 0 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 13px; cursor: pointer; max-width: 100%; text-align: left;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
@media (min-width: 861px) {
  .sheet-back { align-items: center; padding: 16px; }
  .sheet { border-radius: 16px; }
}
@media (max-width: 860px) {
  .chats { grid-template-columns: minmax(0, 1fr); }
  .chats.open .chat-side { display: none; }
  .chats:not(.open) .chat-pane { display: none; }
  .chat-list { max-height: none; overflow: visible; }
  .msgs { max-height: none; overflow: visible; }
  .chat-pane { min-height: 0; }
  .bubble { max-width: 88%; }
}
@media (forced-colors: active) {
  .chip[aria-pressed="true"], .flagdot { outline: 2px solid CanvasText; }
}

/* ---- Models (S4, #95): the add-model steps, the set form ---- */
.steps { display: flex; gap: 6px; list-style: none; margin: 0 0 14px; padding: 0; flex-wrap: wrap; }
.steps li { flex: 1 1 0; min-width: 64px; padding: 6px 8px; border-radius: 8px; font-size: 12.5px; font-weight: 600; text-align: center; background: var(--surface-2); color: var(--text-3); }
.steps li.on { background: var(--accent); color: #fff; }
.steps li.done { color: var(--text); }
.textarea { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; font: inherit; }
.items { display: grid; gap: 12px; margin: 6px 0 10px; }
.item-box { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 4px; min-width: 0; }
.item-head { display: flex; justify-content: space-between; align-items: center; min-height: 40px; }
.item-box input[type="file"] { max-width: 100%; height: auto; padding: 8px; }
.set-form { display: grid; gap: 4px; min-width: 0; }
.wizard-nav { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.wizard-nav .btn { min-height: 42px; }
.row-actions a.btn { display: inline-flex; align-items: center; text-decoration: none; }
