html {
  -webkit-text-size-adjust: 100%;   /* iOS otherwise inflates text in landscape */
}

:root {
  /* Brand — AISM², from the design system. The ink and paper are the mark's own
     colours and are what the tile, the favicon and the theme-colour use. */
  --brand-ink: #1c1e27; --brand-paper: #faf9f6; --brand-accent: #E85C7A;

  --bg: #0f1115; --panel: #171a21; --panel-2: #1e222b; --border: #2a2f3a;
  --text: #e6e8ec; --muted: #9aa3b2;
  /* --brand-accent is for the MARK ONLY. It is not the UI accent, and must not
     become one: #E85C7A sits 16 units from --danger (#f0616d) in RGB — close
     enough to read as the same colour — so a primary button and a Delete button
     rendered in it were nearly indistinguishable. Interactive blue stays blue;
     red keeps meaning destructive. */
  --accent: #6ea8fe; --accent-2: #7c5cff;
  --ok: #35c28a; --warn: #f0b429; --danger: #f0616d; --radius: 12px;
}
* { box-sizing: border-box; }
/* The `hidden` attribute is only a USER-AGENT rule (`[hidden] { display: none }`),
   so ANY author `display` beats it and the element stays on screen — and this
   file sets `display` on almost every wrapper a conditional field uses
   (`.form label`, `.field`, `.check-group`, `.btn`, `.info-tip`). That is why a
   YouTube visibility picker sat on an Instagram-only instruction and a Reply
   policy on a publishing one, even though both were correctly marked `hidden`:
   nothing in this dashboard's toggling was broken except this. Every
   progressive-enhancement control here (`+`/`×` row buttons, the tool panel, the
   Auto caution) is rendered `hidden` and revealed by script, so the same line is
   what keeps those from showing up unusable when scripting is unavailable. */
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.topbar {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: .8rem 1.5rem; background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; font-weight: 700; font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
/* The mark is the NARROW-screen form of the wordmark, not a companion to it.
   Only one is ever visible — see the 420px rule at the end of this file. */
.brand-mark { display: none; height: 22px; width: auto; }
.brand-word { color: var(--text); letter-spacing: -.01em; }
/* The squared motif: the "2" is the brand accent. This is the only place in the
   UI that colour appears — see --brand-accent. */
.brand-word sup { color: var(--brand-accent); font-size: .62em; top: -.5em; margin-left: 1px; }
.login-brand { text-align: center; font-size: 2rem; }
/* The nav scrolls sideways rather than being clipped when it doesn't fit. */
.topbar nav {
  display: flex; gap: 1.25rem; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; min-width: 0;
}
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { white-space: nowrap; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--text); text-decoration: none; }
.user-box { margin-left: auto; display: flex; align-items: center; gap: .75rem; font-size: .85rem; }
.user-email { color: var(--muted); max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-logout { color: var(--muted); }
.user-logout:hover { color: var(--danger); text-decoration: none; }

/* --- sign-in page --- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2.5rem; width: min(400px, 92vw); text-align: center;
}
.login-sub { color: var(--muted); margin: 0 0 1.5rem; }
.login-btn { display: inline-block; width: 100%; padding: .7rem 1rem; }

main { max-width: 960px; margin: 0 auto; padding: 1.75rem 1.5rem 4rem; }
/* Table pages get the room the rows actually need — 960px clipped the last
   column and forced a horizontal scroll on a desktop with space to spare.
   Prose stays at 960 (and .form at 680) so line length is still readable. */
main.wide { max-width: 1440px; }
/* Legal prose (Terms / Privacy): a comfortable reading measure and a little
   breathing room between sections. */
main.legal { max-width: 46rem; }
main.legal h2 { margin-top: 1.8rem; }
main.legal ul { padding-left: 1.2rem; }
main.legal li { margin: .3rem 0; }
main.legal hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0 1rem; }
.sitefoot { max-width: 960px; margin: 0 auto; padding: 0 1.5rem 2rem; display: flex;
            gap: .5rem; justify-content: center; color: var(--muted); font-size: .85rem; }
.sitefoot a { color: var(--muted); }
.sitefoot a:hover { color: var(--text); }

.flashes { margin-bottom: 1rem; }
.flash { padding: .6rem .9rem; border-radius: 8px; margin-bottom: .5rem; border: 1px solid var(--border); }
.flash-success { background: rgba(53,194,138,.12); border-color: var(--ok); }
.flash-error { background: rgba(240,97,109,.12); border-color: var(--danger); }

/* Overview hero banner. Full content width, letterboxed corners to match the
   card chrome; it IS the page title, so the <h1> is kept for screen readers. */
.hero-banner {
  display: block; width: 100%; height: auto; margin: 0 0 1.6rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,.4);
}

/* Off-screen but still read aloud / indexed — for a heading a visible banner
   already conveys. */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; }
.card-num { font-size: 2rem; font-weight: 700; }
.card-label { color: var(--muted); margin-bottom: .5rem; }

.steps { line-height: 2; }

/* ---- overview dashboard ------------------------------------------------- */
.dash-header { display: flex; align-items: flex-end; justify-content: space-between;
               gap: 1rem 1.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.dash-heading { min-width: 0; }
.dash-title { margin: 0; font-size: 1.5rem; line-height: 1.2; }
.dash-sub { margin: .25rem 0 0; font-size: .9rem; }

.clock-bar { display: flex; gap: .6rem; flex-wrap: wrap; }
.clock { display: flex; flex-direction: column; gap: .1rem;
         background: linear-gradient(180deg, var(--panel-2), var(--panel));
         border: 1px solid var(--border); border-radius: 10px; padding: .5rem .85rem;
         min-width: 7.5rem; }
.clock-label { color: var(--muted); font-size: .68rem; font-weight: 700;
               text-transform: uppercase; letter-spacing: .06em;
               max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock-time { font-size: 1.5rem; font-weight: 700; line-height: 1.1; letter-spacing: .01em;
              font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.clock-date { color: var(--muted); font-size: .74rem; }

.kpis { margin-bottom: 1.4rem; }
.card-num { display: flex; align-items: baseline; gap: .3rem; }
.card-num.accent-num { color: var(--accent); }
.card-sub { font-size: 1rem; font-weight: 500; color: var(--muted); }
.card .chip-row { display: flex; gap: .35rem; margin-top: .4rem; flex-wrap: wrap; }
.card .chip { display: inline-flex; width: 26px; height: 26px; align-items: center; justify-content: center;
              background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; }
.card .chip svg { width: 16px; height: 16px; }

.panel-grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.panel-grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
/* A lone <section class="panel"> is a sibling of the .panel-grid blocks around
   it, and only the GRID carried a bottom margin — so a standalone panel
   (Performance, Recent activity) sat flush against the next section and the two
   borders read as one overlapping box. The gap belongs to the panel itself; a
   panel INSIDE a grid gets none, because the grid's own `gap` already spaces
   it and a margin there would push the tracks apart unevenly. */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
         padding: 1.1rem 1.2rem; min-width: 0; margin-bottom: 1rem; }
.panel-grid > .panel { margin-bottom: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem;
              margin-bottom: .9rem; }
.panel-head h2 { margin: 0; font-size: 1.05rem; }
.empty-hint { color: var(--muted); background: var(--panel-2); border: 1px dashed var(--border);
              border-radius: 8px; padding: .9rem 1rem; margin: 0; }

.chart { display: block; width: 100%; height: auto; }
.chart-axis { display: flex; justify-content: space-between; margin-top: .4rem; }

.stack-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden;
             background: var(--panel-2); border: 1px solid var(--border); }
.stack-seg { height: 100%; }
.seg-ok { background: var(--ok); }
.seg-accent { background: var(--accent); }
.seg-warn { background: var(--warn); }
.seg-muted { background: var(--muted); }
.seg-danger { background: var(--danger); }
.legend { list-style: none; padding: 0; margin: .9rem 0 0; display: flex; flex-wrap: wrap; gap: .3rem 1.1rem; }
.legend li { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .88rem; }
.legend strong { color: var(--text); }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot-ok { background: var(--ok); }
.dot-accent { background: var(--accent); }
.dot-warn { background: var(--warn); }
.dot-muted { background: var(--muted); }
.dot-danger { background: var(--danger); }

.platform-stats { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .7rem; }
.platform-stats li { display: flex; align-items: center; gap: .6rem; }
.pstat-icon { flex: 0 0 auto; display: inline-flex; }
.pstat-icon svg { width: 20px; height: 20px; }
.pstat-name { flex: 0 0 5.5rem; text-transform: capitalize; }
.pstat-bar { flex: 1 1 auto; height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.pstat-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.pstat-count { flex: 0 0 auto; font-weight: 600; min-width: 1.5rem; text-align: right; }

.upcoming { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.upcoming li { display: flex; align-items: center; gap: .7rem; }
.up-when { flex: 0 0 5.5rem; color: var(--muted); font-variant-numeric: tabular-nums; font-size: .9rem; }
.up-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.feed { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.feed li { display: flex; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: none; }
.feed-thumb { flex: 0 0 auto; }
.feed-thumb .thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px;
                     background: var(--panel-2); border: 1px solid var(--border); display: block; }
.feed-thumb .thumb-empty { display: flex; align-items: center; justify-content: center; }
.feed-body { min-width: 0; flex: 1 1 auto; }
.feed-line { display: flex; align-items: center; gap: .5rem; }
.feed-line a { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-meta { display: flex; align-items: center; gap: .3rem; margin-top: .15rem; }
.feed-meta svg { width: 14px; height: 14px; vertical-align: middle; }
.feed-excerpt { margin-top: .25rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis;
                display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---- onboarding (empty / fresh-signup state) ---------------------------- */
.onboarding { }
.onboarding-head { max-width: 46rem; margin-bottom: 1.4rem; }
.onboarding-head h2 { margin: 0 0 .4rem; }
.onboard-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem;
                 grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.onboard-step { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
                padding: 1.3rem 1.2rem 1.4rem; position: relative; display: flex; flex-direction: column;
                gap: .5rem; }
.onboard-num { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center;
               justify-content: center; font-weight: 700; background: rgba(110,168,254,.15);
               color: var(--accent); border: 1px solid var(--accent); }
.onboard-step h3 { margin: .3rem 0 0; font-size: 1.05rem; }
.onboard-step p { flex: 1 1 auto; margin: 0; }
.onboard-step .btn { align-self: flex-start; }

.platform-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.platform-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  min-width: 0; padding: 1rem; display: flex; flex-direction: column; gap: .5rem;
}
/* Capitalize only the platform NAME. Applied to the whole card it also rewrote
   the app labels an operator typed — "from .env (default)" came out as
   "From .Env (Default)". */
.platform-card .platform-name { text-transform: capitalize; }
.platform-name { font-weight: 600; font-size: 1.05rem;
  display: flex; align-items: center; gap: .45rem; }
.connect-option { width: 100%; min-width: 0; max-width: 100%; display: flex; align-items: center; gap: .35rem; overflow: hidden; }
.connect-option-prefix, .connect-option-arrow { flex: 0 0 auto; }
.connect-option-label { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.community-row td { background: rgba(110,168,254,.04); }
.community-form { display: inline-flex; align-items: end; gap: .5rem; margin-right: .5rem; }
.community-form label { display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; color: var(--muted); }
.community-form input { max-width: 20rem; background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; color: var(--text); padding: .35rem .5rem; }

/* Wide tables scroll INSIDE their own box; the page itself never does. */
.table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%;
  border-radius: var(--radius);
}
table { width: 100%; border-collapse: collapse; background: var(--panel);
        border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
table.kv td:first-child { color: var(--muted); width: 40%; }

.btn {
  display: inline-block; padding: .45rem .8rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); cursor: pointer; font-size: .9rem;
  /* A two-word label must not wrap mid-button: it doubles the row height and
     pushes the buttons beside it out of the cell. */
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); color: #0b0e14; border-color: var(--accent); font-weight: 600; }
.btn-danger { color: var(--danger); }
.actions, .row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
/* A row's action cell shrinks to fit its buttons (width:1% + nowrap is the
   classic trick) instead of being squeezed by the data columns — otherwise
   adding a third button, as Clear cooldown does while an account is paused,
   wrapped each one onto its own line and doubled the row height.
   The flex box is an inner div, NOT the <td>: display:flex on a table cell
   drops it out of the table layout entirely and the buttons overlap the
   columns beside them. */
td.actions-cell { width: 1%; white-space: nowrap; }
td.actions-cell .actions { flex-wrap: nowrap; justify-content: flex-end; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
form { margin: 0; }

/* One page header everywhere: title (+ a line saying what the page is for) on
   the left, the page's primary action on the right. It wraps rather than
   squeezing the button off the edge on a phone. */
.page-head {
  display: flex; flex-wrap: wrap; gap: .6rem 1rem;
  align-items: flex-end; justify-content: space-between; margin-bottom: 1.1rem;
}
.page-heading { min-width: 0; }
.page-head h1 { margin: 0; }
.page-sub { margin: .25rem 0 0; font-size: .9rem; }

/* A visible focus ring for keyboard users, and ONLY for them: :focus-visible
   leaves a mouse click unringed, which is why the old outline:none reflexes
   existed. Without this, tabbing through a form on the dark theme is invisible. */
:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}

/* Platform brand marks beside the account count. "3 accounts" doesn't say where
   it posts; these do, in less room than the words. Vertically centred against
   the number rather than sitting on the baseline, and given a touch of opacity
   so they read as metadata and not as buttons. */
.platform-marks { display: inline-flex; align-items: center; gap: .25rem;
  margin-left: .35rem; vertical-align: -.15em; }
.platform-icon { display: block; opacity: .85; flex: none; }
tr:hover .platform-icon { opacity: 1; }

.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .78rem;
         background: var(--panel-2); border: 1px solid var(--border); text-transform: capitalize; }
.badge-live, .badge-published { background: rgba(53,194,138,.15); border-color: var(--ok); color: var(--ok); }
.badge-dry_run, .badge-staged { background: rgba(110,168,254,.15); border-color: var(--accent); color: var(--accent); }
.badge-approval, .badge-approved { background: rgba(240,180,41,.15); border-color: var(--warn); color: var(--warn); }
.badge-failed { background: rgba(240,97,109,.15); border-color: var(--danger); color: var(--danger); }
.badge-rejected { background: var(--panel-2); border-color: var(--border); color: var(--muted); }
.badge-off { color: var(--muted); }

/* On/off state, as a word rather than a tick. "✓ vs —" makes the reader learn a
   key, and neither glyph says which column it belongs to when the row is being
   skimmed; a coloured word is legible at a glance and — unlike colour alone —
   still readable to anyone who cannot tell the two hues apart. */
.state {
  display: inline-block; padding: .12rem .55rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
  border: 1px solid var(--border);
}
.state-on { background: rgba(53,194,138,.16); border-color: var(--ok); color: var(--ok); }
.state-off { background: rgba(154,163,178,.12); color: var(--muted); }

/* Approve form: the button, plus an optional "publish later" datetime beside it.
   The label stays a row (it sits inside .form on some pages, where `.form label`
   would otherwise stack it into a column). */
.approve-form { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.form .approve-form label.schedule-later,
.approve-form label.schedule-later { flex-direction: row; align-items: center; gap: .35rem; }

/* Performance counters — one pill per metric (likes / views / …). Wraps in the
   runs table cell; a little larger on the run-detail page (.metric-lg). */
.metrics { display: flex; flex-wrap: wrap; gap: .25rem .4rem; }
.metric { display: inline-block; padding: .08rem .45rem; border-radius: 999px;
          background: var(--panel-2); border: 1px solid var(--border);
          font-size: .74rem; color: var(--muted); white-space: nowrap; }
.metric b { color: var(--text); font-weight: 700; }
.metrics-cell { min-width: 9rem; }
.metrics-detail { margin: .3rem 0 .5rem; }
.metric-lg { font-size: .9rem; padding: .2rem .6rem; }
.perf-totals { margin-bottom: .6rem; }
.perf-sub { margin: .2rem 0 .4rem; text-transform: uppercase; letter-spacing: .04em; }

.form { display: flex; flex-direction: column; gap: 1.1rem; max-width: 680px; }
.form label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
.form input[type=text], .form input[type=password], .form input[type=datetime-local],
.form input[type=email], .form input[type=number], .form input[type=url],
.form textarea, .form select {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: .55rem .7rem; font: inherit; font-weight: 400;
}
.form textarea { resize: vertical; }
/* The date/time picker indicator renders as a dark glyph on our dark field, so
   invert it — without this the calendar button is invisible. */
.form input[type=datetime-local]::-webkit-calendar-picker-indicator {
  filter: invert(1); opacity: .6; cursor: pointer;
}
.form input[type=datetime-local]::-webkit-calendar-picker-indicator:hover { opacity: 1; }
.hint { color: var(--muted); font-size: .82rem; font-weight: 400; }
.hint-warn { display: block; margin-top: .4rem; color: var(--warn); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.checklist { display: flex; flex-direction: column; gap: .35rem; background: var(--panel-2);
             border: 1px solid var(--border); border-radius: 8px; padding: .6rem .7rem; font-weight: 400; }
.check { flex-direction: row !important; align-items: center; gap: .5rem; font-weight: 400; }
.check.inline { align-self: end; }

/* ---- repeatable field rows (see static/repeat.js) ----------------------- *
 * One row per thing, one input per value, a + to add and an × to drop. This
 * replaces the boxes that asked for several values in one textarea and a
 * grammar to separate them.
 *
 * They sit in a `<div class="field">`, not a <label>: a label associates the
 * whole group with its first input, so clicking the caption would focus a
 * field the caption is not about. */
.repeat { display: flex; flex-direction: column; gap: .4rem; font-weight: 400; }
/* Column captions, so a row of bare inputs still says which value goes where.
   The trailing track matches the × button so the captions line up with the
   fields and not with the button. */
.repeat-head, .repeat-row {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) 2.1rem;
  gap: .4rem; align-items: center;
}
.repeat-head { text-transform: uppercase; letter-spacing: .04em; font-size: .7rem; }
/* A KIND picked from a short list, then the value it applies to (an outreach
   target). The picker needs only its longest word. */
.repeat-kind .repeat-head, .repeat-kind .repeat-row {
  grid-template-columns: minmax(0, .7fr) minmax(0, 1.7fr) 2.1rem;
}
/* Three values per row (a Sora resource: endpoint, model, key). The endpoint is
   a URL and the model a short name, so the tracks are not equal. */
.repeat-3 .repeat-head, .repeat-3 .repeat-row {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, .8fr) minmax(0, 1fr) 2.1rem;
}
.repeat-row > input { min-width: 0; }
.repeat-remove {
  padding: .3rem 0; line-height: 1; font-size: 1.1rem; color: var(--muted);
  justify-content: center;
}
.repeat-remove:hover { color: var(--danger); border-color: var(--danger); }
[data-repeat-add] { align-self: flex-start; }

/* A row that is a saved VALUE rather than an editable pair (the people a
   connection is shared with): the address, then the × pushed to the end. */
.share-row { display: flex; align-items: center; gap: .5rem; }
.share-row .repeat-remove { margin-left: auto; }
.share-form input[type=email] { max-width: 26rem; }

@media (max-width: 560px) {
  /* Two fields side by side under 560px leave ~7 characters each. Stack them
     and drop the captions — the placeholders already say what each one is. */
  .repeat-head { display: none; }
  .repeat-row { grid-template-columns: minmax(0, 1fr) 2.6rem; }
  .repeat-row > input:first-child { grid-column: 1 / -1; }
  /* Three of them side by side is worse still, so every field takes the width
     and the × keeps the narrow track, under the fields it removes. A kind picker
     stacks the same way — the select is the row's first child, so the rule above
     (which names `input`) would leave it in the narrow track. */
  .repeat-3 .repeat-row > input,
  .repeat-kind .repeat-row > select, .repeat-kind .repeat-row > input { grid-column: 1 / -1; }
  .repeat-3 .repeat-remove, .repeat-kind .repeat-remove { grid-column: 2; }
}

/* Accounts inside a checklist, grouped under their platform mark. The heading
   is not a label — clicking it must not toggle anything — so it is a span. */
.check-platform { display: flex; flex-direction: column; gap: .3rem; }
.check-platform + .check-platform { margin-top: .55rem; padding-top: .55rem;
  border-top: 1px solid var(--border); }
.check-platform-head { display: flex; align-items: center; gap: .4rem;
  color: var(--muted); font-size: .74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; }
.check-platform .check { padding-left: .3rem; }

/* --- instruction form: wider column + grouped sections --- */
/* The instruction form has paired grids and a tool picker, so the 680px prose
   cap left it cramped and empty on a desktop. This one form gets more room. */
.form.form-wide { max-width: 900px; }

/* Each logical group is a bordered fieldset. `min-width: 0` stops a wide child
   (tool picker, a table) from forcing the fieldset past the form width. */
.form .form-section {
  border: 1px solid var(--border); border-radius: 12px;
  padding: .5rem 1.15rem 1.15rem; margin: 0; min-width: 0;
  background: var(--panel);
}
.form .form-section > legend {
  padding: 0 .45rem; font-weight: 700; font-size: .82rem;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
/* The fieldset itself isn't the flex container (legend + flex is quirky across
   browsers); an inner wrapper stacks the fields with the form's own rhythm. */
.form-section .section-body { display: flex; flex-direction: column; gap: 1.1rem; }

/* Required marker beside a label. */
.req { color: var(--danger); font-weight: 700; margin-left: .1rem; }

/* `.form label` is flex-COLUMN, so the caption text and any inline marker beside
   it (the required `*`, an "— optional" note) are each their own flex item and
   stack onto separate lines. Grouping the caption in ONE inline item keeps the
   asterisk on the same line as the field name. */
.field-label { display: inline; }

/* A checkbox row that also carries its own hint underneath. */
.check-group { display: flex; flex-direction: column; gap: .3rem; }

/* Select with an inline info-tip trigger sitting beside it. */
.label-row { display: flex; align-items: center; gap: .5rem; }
.label-row select { flex: 1 1 auto; min-width: 0; }

/* Hover/focus info-tip — replaces a permanent block of warning text. */
.info-tip { position: relative; display: inline-flex; flex: 0 0 auto; }
.info-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.3rem; height: 1.3rem; border-radius: 50%;
  border: 1px solid var(--warn); color: var(--warn);
  font-size: .8rem; font-weight: 700; font-style: normal; line-height: 1;
  cursor: help; user-select: none;
}
.info-icon:hover, .info-icon:focus-visible { background: rgba(240,180,41,.15); outline: none; }
.info-tip-body {
  position: absolute; z-index: 30; top: calc(100% + .45rem); right: 0;
  width: max(240px, 24rem); max-width: 78vw;
  background: var(--panel); border: 1px solid var(--warn); border-radius: 8px;
  padding: .6rem .7rem; box-shadow: 0 12px 28px rgba(0,0,0,.45);
  font-size: .82rem; font-weight: 400; line-height: 1.45;
  display: none;                      /* wins over .hint-warn's block; source order */
}
.info-tip:hover .info-tip-body,
.info-tip:focus-within .info-tip-body { display: block; }

/* The edit-page attachments, folded above the settings form. */
.attachments-block { margin: 0 0 1.4rem; }
.attachments-block > summary { cursor: pointer; font-weight: 600; }
.attachments-block .add-file-form { margin-top: 1rem; max-width: 100%; }

/* --- checkbox dropdown (tool picker) --- */
/* A <div class="field"> is a form row that isn't a single <label>, so the
   heading can label a whole control group without wrapping it. */
.field { display: flex; flex-direction: column; gap: .35rem; }
.field-label { font-weight: 600; }

.multiselect { position: relative; }
.multiselect-toggle {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: .55rem .7rem; font: inherit; cursor: pointer; text-align: left;
}
.multiselect-toggle:hover { border-color: var(--accent); }
.multiselect-caret { color: var(--muted); }
.multiselect-panel {
  position: absolute; z-index: 20; top: calc(100% + .3rem); left: 0; right: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0,0,0,.45); overflow: hidden;
}
.multiselect-head {
  display: flex; gap: .5rem; align-items: center; padding: .55rem .6rem;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.multiselect-filter {
  flex: 1 1 10rem; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: .4rem .55rem; font: inherit; font-size: .88rem;
}
.multiselect-bulk { display: flex; gap: .6rem; }
.linkish {
  background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer;
  font: inherit; font-size: .82rem;
}
.linkish:hover { text-decoration: underline; }
.multiselect-list { max-height: 17rem; overflow-y: auto; padding: .35rem 0; }
.multiselect-group + .multiselect-group { border-top: 1px solid var(--border); margin-top: .35rem; }
.multiselect-group-title {
  padding: .45rem .7rem .2rem; font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.multiselect-group-title .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
/* Selector is `.form label.multiselect-option`, not `.multiselect-option`, so it
   outranks `.form label { flex-direction: column }` — that rule is (0,0,1,1) and
   wins over a lone class whatever the source order, which stacked every checkbox
   on top of its own name. */
.form label.multiselect-option {
  display: flex; flex-direction: row; align-items: center; gap: .5rem;
  padding: .3rem .7rem; font-weight: 400; cursor: pointer;
}
.multiselect-option input { flex: 0 0 auto; margin: 0; }
.multiselect-option:hover { background: var(--panel-2); }
.multiselect-option input[data-ms-locked] { accent-color: var(--muted); cursor: default; }
.multiselect-option code { font-size: .85rem; }

/* --- retry a run --- */
.retry-block > summary { color: var(--accent); }
.retry-form { max-width: none; padding: .8rem 0 .2rem; }
.retry-form textarea { min-height: 12rem; }

/* auto-FIT (not auto-fill) so a single card doesn't sit in a narrow column with
   three empty tracks beside it; the max track width stops that one card from
   stretching across a wide screen instead. */
.staged-list {
  display: grid; gap: 1rem; justify-content: start;
  grid-template-columns: repeat(auto-fit, minmax(260px, 380px));
  max-height: 70vh; overflow-y: auto; padding-right: 4px;
}
.staged { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
/* CONTAIN, never cover: a 9:16 reel in a 4:3 box was being cropped — you were
   reviewing a post while unable to see its edges. Letterboxing shows the frame
   the platform will show. */
.staged-media video, .staged-media img {
  width: 100%; display: block; height: 200px; object-fit: contain; background: #000;
}
.text-preview { padding: 2rem; text-align: center; color: var(--muted); background: var(--panel-2); }
/* An engagement reply has no media; instead the top of the card shows the
   comment being answered so the reviewer judges the reply against it. */
.staged-reply-target { height: auto; padding: .9rem; background: var(--panel-2); }
.staged-reply-target blockquote {
  margin: .35rem 0 0; padding-left: .7rem; border-left: 3px solid var(--border);
  white-space: pre-wrap; color: var(--text);
}
.staged-body { padding: .9rem; }
.caption { white-space: pre-wrap; margin: .5rem 0 .9rem; }

@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* --- platform apps page --- */
.tabs { display: flex; gap: .5rem; margin: 1rem 0 1.5rem; flex-wrap: wrap; }
.tab {
  padding: .45rem .9rem; border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); font-size: .9rem;
  display: inline-flex; align-items: center; gap: .4rem;
}
/* Section heading carries the selected platform's mark, aligned to the text. */
.platform-heading { display: flex; align-items: center; gap: .5rem; }
.tab:hover { color: var(--text); text-decoration: none; border-color: var(--accent); }
.tab-active { background: var(--panel-2); color: var(--text); border-color: var(--accent); }
.badge-count {
  background: var(--accent); color: #0b0e14; border-radius: 999px;
  padding: 0 .4rem; font-size: .75rem; font-weight: 700;
}
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 22rem); gap: 2rem; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.split-aside {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; align-self: start; position: sticky; top: 4.5rem;
}
.split-aside h3 { margin-top: 0; }
.split-aside h4 { margin: 1.25rem 0 .4rem; font-size: .9rem; }
.split-aside .steps { padding-left: 1.1rem; color: var(--muted); font-size: .88rem; line-height: 1.6; }
.split-aside .steps li { margin-bottom: .5rem; }
.copyable {
  display: block; word-break: break-all; background: var(--panel-2); padding: .5rem .6rem;
  border-radius: 8px; font-size: .8rem; border: 1px solid var(--border);
}
.note-block { border-left: 2px solid var(--warn); padding-left: .7rem; margin-top: 1rem; }
.split-main .card { margin-bottom: .75rem; }
.split-main hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.btn.small { padding: .3rem .6rem; font-size: .8rem; }

/* --- runs list: filters, sorting, paging --- */
.filters {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem;
}
.filters input[type=search], .filters select {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: .45rem .6rem; font: inherit; font-size: .9rem;
}
.filters input[type=search] { flex: 1 1 18rem; min-width: 12rem; }

/* Sortable column headings. The whole heading is the link — a caret on its own
   is a 3-character hit area, which is a miss on a phone, and the column NAME is
   where everyone clicks. The caret is always in the DOM (transparent until the
   column is active) so changing the sort never shifts the header row sideways. */
th .sort {
  display: inline-flex; align-items: center; gap: .3rem;
  color: var(--muted); white-space: nowrap; border-radius: 6px;
}
th .sort:hover { color: var(--text); text-decoration: none; }
th .sort-active { color: var(--accent); }
.sort-arrow { font-size: .7rem; opacity: 0; transition: opacity .12s ease; }
th .sort:hover .sort-arrow { opacity: .5; }
th .sort-active .sort-arrow { opacity: 1; }
.nowrap { white-space: nowrap; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: center; margin: 1.25rem 0; }

/* --- run detail --- */
.logbox {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  padding: .8rem; white-space: pre-wrap; word-break: break-word; margin: 0 0 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem;
  max-height: 28rem; overflow: auto;
}
.logbox-error { border-color: var(--danger); background: rgba(240,97,109,.08); }
.detail-media video, .detail-media img {
  max-width: 100%; border-radius: 8px; background: #000; max-height: 26rem;
  object-fit: contain;               /* never crop the thing being reviewed */
}
.media-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: .4rem 0 1rem; }

/* ===================================================================== *
 * Small screens
 *
 * Measured problems this fixes, at a 375px viewport:
 *   • the page scrolled sideways by 468px (nav + a 842px-wide table)
 *   • nav items were clipped off the right edge and unreachable
 *   • inputs rendered at 13–14px, so iOS Safari ZOOMS the page on focus
 *     and never zooms back — the single worst thing about the old layout
 *   • tap targets were well under the 44px guideline
 * ===================================================================== */
@media (max-width: 720px) {
  main { padding: 1.25rem 1rem 3rem; }
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.05rem; margin: 1.5rem 0 .6rem; }

  .topbar { gap: .6rem 1rem; padding: .6rem .9rem; }
  .topbar nav { gap: 1rem; order: 3; width: 100%; padding-bottom: .15rem; }
  .topbar nav a { padding: .3rem 0; }
  .user-box { margin-left: auto; font-size: .8rem; }
  .user-email { max-width: 12ch; }

  /* 16px minimum: anything smaller makes iOS zoom in on focus. The typed
     selectors must list every input type the form uses — a bare `input` here
     loses on specificity to the `.form input[type=…]` base rule above. */
  .form input[type=text], .form input[type=password], .form input[type=datetime-local],
  .form input[type=email], .form input[type=number], .form input[type=url],
  .form textarea, .form select,
  .filters input[type=search], .filters select, input, select, textarea {
    font-size: 16px;
  }

  /* Filters stack full-width instead of squeezing onto one line. */
  .filters { flex-direction: column; align-items: stretch; gap: .5rem; }
  .filters input[type=search], .filters select, .filters .btn, .filters button { width: 100%; }
  .filters input[type=search] { flex: none; }

  /* Comfortable tap targets. */
  .btn, .topbar nav a, .tab { min-height: 44px; display: inline-flex;
                              align-items: center; justify-content: center; }
  .btn { padding: .55rem .9rem; }
  .row, .actions { flex-wrap: wrap; }
  .row > form, .row > .btn { flex: 1 1 auto; }

  /* Nothing sticky on a short screen — it eats the viewport. */
  .split-aside { position: static; padding: 1rem; }
  .split { gap: 1.25rem; }

  table { font-size: .85rem; }
  th, td { padding: .5rem .6rem; }
  .table-scroll table { min-width: 34rem; }   /* keep columns legible while scrolling */
  table.kv { min-width: 0; }
  .table-scroll:has(table.kv) table { min-width: 0; }

  .staged-list { grid-template-columns: 1fr; }
  .pager { flex-wrap: wrap; }
  .logbox { font-size: .78rem; max-height: 18rem; }
  .tabs { gap: .4rem; }
  .platform-grid { grid-template-columns: 1fr; }
  .form { max-width: 100%; }
  /* Long ids/paths/URLs must wrap rather than widen the page. */
  .mono, .copyable, .caption { overflow-wrap: anywhere; }
}

@media (max-width: 420px) {
  main { padding: 1rem .75rem 3rem; }
  .brand { font-size: 1.05rem; }
  .table-scroll table { min-width: 30rem; }
  /* Here the topbar also holds the workspace switcher and a scrolling nav, so
     the wordmark gives way to the mark. One or the other, never both. */
  .brand-mark { display: block; }
  .brand-word { display: none; }
}

/* Any TOUCH device gets 16px form controls, not just narrow ones: iPadOS Safari
 * is 768px wide in portrait and zooms on focus for anything smaller, which the
 * max-width:720px block above would have missed. */
@media (pointer: coarse) {
  .form input[type=text], .form input[type=password], .form input[type=datetime-local],
  .form input[type=email], .form input[type=number], .form input[type=url],
  .form textarea, .form select,
  .filters input[type=search], .filters select, input, select, textarea { font-size: 16px; }
  /* The Schedule widget's text box lives in its shadow DOM, out of reach of the
     rule above; it exposes it as part "input" (15px by default: iOS would zoom). */
  cron-ai::part(input) { font-size: 16px; }
  .btn, .tab { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
}

/* --- expandable prompt sections on the run detail --- */
.prompt-block { margin-bottom: .6rem; }
.prompt-block > summary {
  cursor: pointer; padding: .5rem .7rem; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; font-weight: 600;
}
.prompt-block > summary:hover { border-color: var(--accent); }
.prompt-block[open] > summary { border-radius: 8px 8px 0 0; }
.prompt-block > .logbox { border-radius: 0 0 8px 8px; border-top: 0; margin-top: 0; }
.form input[type=file] {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: .5rem; font: inherit; font-weight: 400;
}

/* Workspace switcher in the header. The select must stay 16px on touch like
   every other control (see the pointer:coarse block) or iOS zooms on focus. */
.workspace-switch { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.workspace-switch select {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 6px 8px; max-width: 220px;
}
.workspace-card { padding: 14px 16px; }
.workspace-card h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* A grouped block inside a form (the create page's optional file attachment).
   .form label forces column layout, so the fieldset needs its own framing. */
.form .subform {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  margin: 4px 0 12px; background: var(--panel-2);
}
.form .subform legend { padding: 0 6px; font-weight: 600; }

/* The Schedule widget (the hosted cronai <cron-ai>) in the dashboard's colours.
   Its own dark palette is a deep navy beside our greys; the chip colours (time,
   day, month...) are left as the widget draws them. Page CSS on the element
   outranks the widget's :host rules, which is how it is meant to be themed. */
cron-ai {
  display: block;
  --cai-font: inherit;
  --cai-bg: var(--bg);
  --cai-surface: var(--panel-2);
  --cai-surface-alt: var(--panel);
  --cai-border: var(--border);
  --cai-text: var(--text);
  --cai-muted: var(--muted);
  --cai-faint: #6b7385;
  --cai-accent: var(--accent);
  --cai-accent-soft: rgba(110, 168, 254, .16);
  --cai-on-accent: #0f1115;
  --cai-success: var(--ok);
  --cai-warning: var(--warn);
  --cai-danger: var(--danger);
}
.schedule-field .schedule-zone { margin-top: .2rem; }

/* A button sitting inside a flash message (the stale-run cleanup). */
.flash .inline-form { display: inline-block; margin-left: 8px; }

/* Newest media per instruction, so a run that has quietly gone wrong is visible
   from the list. object-fit: cover is right HERE — a thumbnail is a glance, not
   the thing being reviewed. */
.thumb-cell { width: 1%; padding-right: 0; }
.thumb {
  width: 52px; height: 52px; border-radius: 6px; object-fit: cover;
  background: var(--panel-2); display: block; border: 1px solid var(--border);
}
/* No media (e.g. an engagement run) — our mark as a faint watermark beats a
   bare box. */
.thumb-empty { border-style: dashed; display: flex; align-items: center; justify-content: center; }
.thumb-empty img { width: 58%; height: 58%; opacity: .4; }

/* ===================================================================== *
 * Accounts
 *
 * Was one table plus a second full-width row crammed under each X account
 * (colspan=5), so the destination form read as an orphan of the row above it.
 * A card per account keeps each connection's facts, settings and actions
 * together, and needs no horizontal scroll on a phone.
 * ===================================================================== */
.account-list { display: grid; gap: 1rem; margin-bottom: 1.5rem; }
.account-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
}
.account-head {
  display: flex; flex-wrap: wrap; gap: .5rem 1rem;
  align-items: baseline; justify-content: space-between;
}
.account-who { display: flex; align-items: center; gap: .5rem; }
.account-who strong { font-size: 1.05rem; }
.account-token { color: var(--muted); }

.account-facts { display: flex; flex-wrap: wrap; gap: .3rem 1.6rem; margin: .7rem 0 0; }
.account-facts > div { display: flex; gap: .4rem; }
.account-facts dt { color: var(--muted); margin: 0; }
.account-facts dd { margin: 0; }

.account-section { margin-top: .9rem; border-top: 1px solid var(--border); padding-top: .7rem; }
.account-section > summary { cursor: pointer; }
.account-section .form { margin-top: .7rem; }

.account-actions {
  display: flex; flex-wrap: wrap; gap: .6rem;
  margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--border);
}

/* A cron string is one token, not prose: wrapping it mid-expression
   ("0 6 * *" / "*,0 16 *") is unreadable. Truncate with the full text on hover,
   and show what it MEANS underneath — that is what you came to check. */
.schedule-cell { max-width: 26ch; }
.schedule-raw {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}


/* A third flash state. "Publishing works, but this feature is off" is neither a
   success nor an error, and painting it red sent operators to reconnect
   perfectly healthy accounts. */
.flash-warning { background: rgba(240,180,80,.12); border-color: var(--warn); }

/* Accounts: grouped by platform, because a flat list is where duplicates hide. */
.account-group { display: flex; align-items: center; gap: .4rem; margin: 1.4rem 0 .5rem;
  font-size: 1rem; text-transform: capitalize; }
.account-group .platform-icon { opacity: .9; }
.account-why { margin: 0 0 .5rem; color: var(--muted); }
.account-superseded { opacity: .72; border-style: dashed; }
