/* Kynship OS shell. Design system ported from kynship-os-design/mockups
   (S1 Today / S9 Components); tokens are the locked palette in the brief. */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@600;700&family=Manrope:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{background:var(--page);color:var(--ink);font-family:Manrope,'Segoe UI',system-ui,sans-serif;font-size:14px;line-height:1.4;-webkit-font-smoothing:antialiased}
:focus-visible{outline:2px solid var(--signal);outline-offset:2px}
/* An inline SVG sits on the text baseline, which left every icon about 2px
   above the centre of its button. */
.btn svg,.open svg,.chip svg{display:block}
[data-theme-icon]{display:flex;align-items:center;justify-content:center}
/* Component display rules (.chip is inline-flex) outrank the browser's
   [hidden] rule, so el.hidden would otherwise do nothing. */
[hidden]{display:none!important}

/* ── Shell layout ─────────────────────────────────────────────────────── */
/* Rail and chat widths are variables so collapsing is one animated property
   change rather than a re-render. Nothing here depends on beating an inline
   style: the markup carries classes, not display rules. */
.app{
  --rail-w:232px; --rail-w-collapsed:56px;
  --chat-w:360px; --chat-w-collapsed:44px;
  display:grid;height:100vh;overflow:hidden;position:relative;
  grid-template-columns:var(--rail-w) minmax(0,1fr) var(--chat-w);
  grid-template-rows:56px minmax(0,1fr);
  grid-template-areas:'rail top chat' 'rail main chat';
  transition:grid-template-columns 300ms cubic-bezier(.22,.7,.28,1);
}
.app.rail-collapsed{--rail-w:var(--rail-w-collapsed)}
.app.chat-collapsed{--chat-w:var(--chat-w-collapsed)}

.rail{grid-area:rail;border-right:1px solid var(--line);display:flex;flex-direction:column;
      padding:12px;gap:4px;min-height:0;overflow-y:auto;overflow-x:hidden}
.topbar{grid-area:top;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:10px;
        padding:0 24px;min-width:0}
.main{grid-area:main;overflow:auto;padding:20px 24px;display:flex;flex-direction:column;gap:14px;
      min-height:0;min-width:0;scroll-behavior:smooth}
/* Flex children shrink by default, so on a page taller than the viewport the
   first panels were squeezed to nothing instead of the area scrolling. */
.main > *{flex-shrink:0}
/* On a very wide screen a row of four numbers spread across 2,500px is harder
   to read than the same row at a sane width, so the content stops growing and
   centres itself while the shell stays fluid. */
.main > *{max-width:2000px;width:100%;margin-inline:auto}
/* Numbers belong together: without this the four figures on a card drift to
   opposite ends of a 4K row and stop reading as one set. */
.row-card .nums{max-width:1180px}
.chat{grid-area:chat;border-left:1px solid var(--line);display:flex;flex-direction:column;
      min-height:0;min-width:0;overflow:hidden}

/* Collapsed rail: everything that needs width is marked, not guessed. */
.app.rail-collapsed .rail-label,
.app.rail-collapsed .rail-wide{display:none!important}
.app.rail-collapsed .nav a{justify-content:center;padding:0}
.app.rail-collapsed .rail{padding:12px 8px;align-items:center}

/* Collapsed chat: the body goes, a 44px rail with the reopen control stays. */
.chat-rail{display:none;flex-direction:column;align-items:center;gap:10px;padding:10px 0}
.app.chat-collapsed .chat-body{display:none!important}
.app.chat-collapsed .chat-rail{display:flex}
.chat-rail .rail-caption{writing-mode:vertical-rl;font-size:11px;font-weight:600;
                         color:var(--muted);letter-spacing:.02em;white-space:nowrap}

/* Wallboard is a mode someone chooses for a screen on a wall, not something a
   large monitor triggers: a 27-inch desktop wants the full interface. */
.app.wallboard{--rail-w:var(--rail-w-collapsed);--chat-w:var(--chat-w-collapsed)}
.app.wallboard .rail-label,.app.wallboard .rail-wide,
.app.wallboard .chat-body,.app.wallboard .wallboard-hide{display:none!important}
.app.wallboard .chat-rail{display:flex}
.app.wallboard .main{padding:24px 28px;gap:16px}
.app.wallboard .h1{font-size:36px}
.app.wallboard .row-card .display.num{font-size:22px}

/* Narrow screens collapse the chat by necessity rather than by choice. */
@media (max-width:1280px){
  /* The column stays narrow at this width whatever the user chooses; when they
     open the panel it floats over the content instead of squeezing it. */
  .app{--chat-w:var(--chat-w-collapsed)}
  .app:not(.chat-collapsed) .chat{position:fixed;top:56px;right:0;bottom:0;
    width:min(360px,92vw);z-index:45;background:var(--panel);
    box-shadow:-10px 0 30px rgba(1,7,54,.18)}
  :root[data-theme="dark"] .app:not(.chat-collapsed) .chat{box-shadow:-10px 0 30px rgba(0,0,0,.45)}
}
@media (max-width:900px){
  .app{--rail-w:var(--rail-w-collapsed);grid-template-columns:var(--rail-w) minmax(0,1fr) 0}
  .app .rail-label,.app .rail-wide{display:none!important}
  .app .nav a{justify-content:center;padding:0}
  .chat{display:none}
  .main{padding:16px}
  .topbar{padding:0 16px;gap:8px}
}

/* ── Design system ───────────────────────────────────────────────────── */
.app{font-family:Manrope,'Segoe UI',system-ui,sans-serif;font-size:14px;line-height:1.4;color:var(--ink);background:var(--page);-webkit-font-smoothing:antialiased;box-sizing:border-box;overflow:hidden;position:relative}
.app *{box-sizing:border-box}
:root, :root[data-theme="light"]{--page:#FFFFFF;--panel:#FFFFFF;--line:#C5C1C1;--line-soft:#E2DFDF;--ink:#0D1C42;--muted:#5E6A88;--faint:#8B93A8;--accent:#22396F;--accent-ink:#FFFFFF;--signal:#1DCED8;--signal-ink:#0E9AA3;--signal-tint:rgba(29,206,216,.16);--emph:#FCF1D0;--emph-tint:#FFF8E4;--emph-ink:#0D1C42;--neg:#B9534E;--neg-tint:rgba(185,83,78,.12);--ok:#1F9D57;--ok-tint:rgba(31,157,87,.13);--warn:#C8890B;--warn-tint:rgba(200,137,11,.15);--hover:rgba(13,28,66,.04);--chart-primary:#22396F;--chart-secondary:rgba(34,57,111,.18);--chart-forecast:#8B93A8;--track:#E2DFDF;--user-bubble:#22396F;--user-bubble-ink:#FFFFFF}
:root[data-theme="dark"]{--page:#00041C;--panel:#0A1738;--line:rgba(34,57,111,.6);--line-soft:rgba(34,57,111,.45);--ink:#FFFFFF;--muted:#C5C1C1;--faint:#8F97B3;--accent:#1DCED8;--accent-ink:#010736;--signal:#1DCED8;--signal-ink:#1DCED8;--signal-tint:rgba(29,206,216,.16);--emph:#FCF1D0;--emph-tint:rgba(252,241,208,.12);--emph-ink:#FCF1D0;--neg:#E38680;--neg-tint:rgba(227,134,128,.16);--ok:#34D399;--ok-tint:rgba(52,211,153,.16);--warn:#FBBF24;--warn-tint:rgba(251,191,36,.16);--hover:rgba(255,255,255,.04);--chart-primary:#1DCED8;--chart-secondary:rgba(29,206,216,.22);--chart-forecast:#8F97B3;--track:rgba(197,193,193,.22);--user-bubble:#1DCED8;--user-bubble-ink:#010736}
a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}
.btn,.btn:hover,.open,.open:hover,.nav a,.nav a:hover{text-decoration:none}
.display{font-family:Poppins,Manrope,sans-serif;font-weight:600}
.num{font-variant-numeric:tabular-nums}
.mono{font-family:'JetBrains Mono',ui-monospace,monospace;font-size:11px}
.panel{background:var(--panel);border:1px solid var(--line);border-radius:8px}
.panel-h{display:flex;align-items:center;justify-content:space-between;height:36px;padding:0 14px;border-bottom:1px solid var(--line-soft)}
.panel-t{font-family:Poppins,sans-serif;font-weight:600;font-size:14px}
.label{font-size:11px;font-weight:600;color:var(--muted);letter-spacing:.02em;text-transform:uppercase;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.muted{color:var(--muted)}.faint{color:var(--faint)}
.kpi{font-family:Poppins,sans-serif;font-weight:600;font-size:24px;line-height:1.1;font-variant-numeric:tabular-nums}
.h1{font-family:Poppins,sans-serif;font-weight:600;font-size:32px;line-height:1;margin:0}
.h2{font-family:Poppins,sans-serif;font-weight:600;font-size:20px;line-height:1.1;margin:0}
.h3{font-family:Poppins,sans-serif;font-weight:600;font-size:16px;line-height:1.2;margin:0}
.chip{display:inline-flex;align-items:center;gap:5px;height:22px;padding:0 8px;border-radius:999px;font-size:11px;font-weight:600;border:1px solid var(--line);color:var(--ink);white-space:nowrap;background:transparent}
.chip .dot{width:6px;height:6px;border-radius:999px;background:var(--faint)}
.chip-healthy{background:var(--ok-tint);border-color:transparent;color:var(--ink)}.chip-healthy .dot{background:var(--ok)}
.chip-hold{background:var(--emph-tint);border-color:transparent;color:var(--ink)}.chip-hold .dot{background:var(--warn)}
.chip-watch{background:var(--warn-tint);border-color:transparent;color:var(--ink)}.chip-watch .dot{background:var(--warn)}
.chip-critical{background:var(--neg-tint);border-color:transparent;color:var(--neg)}.chip-critical .dot{background:var(--neg)}
.chip-emph{background:var(--emph);border-color:transparent;color:#0D1C42}
.chip-signal{background:var(--signal-tint);border-color:transparent}
.chip-mono{font-family:'JetBrains Mono',monospace;font-weight:500;font-size:10.5px;height:20px;padding:0 6px;color:var(--muted)}
.chip-disabled{color:var(--faint);border-style:dashed}
.fresh{display:inline-flex;align-items:center;gap:5px;font-size:11px;color:var(--muted);font-variant-numeric:tabular-nums;white-space:nowrap}
.fresh .dot{width:6px;height:6px;border-radius:999px;background:var(--signal)}
.fresh.stale .dot{background:var(--faint)}.fresh.stale{color:var(--faint)}
.btn{display:inline-flex;align-items:center;gap:6px;height:32px;padding:0 12px;border-radius:6px;font-size:13px;font-weight:600;border:1px solid var(--line);background:var(--panel);color:var(--ink);cursor:pointer;font-family:inherit;white-space:nowrap}
.btn:hover{background:var(--hover)}
.btn-primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}.btn-primary:hover{background:var(--accent);opacity:.92}
.btn-sm{height:26px;padding:0 9px;font-size:12px}
.btn-icon{width:32px;padding:0;justify-content:center}
.open{display:inline-flex;align-items:center;gap:4px;font-size:12px;font-weight:600;color:var(--accent);white-space:nowrap;background:none;border:0;padding:0;font-family:inherit;cursor:pointer}
.open svg{width:13px;height:13px}
.tbl{width:100%;border-collapse:collapse;font-size:13px}
.tbl th{text-align:left;font-size:11px;font-weight:600;color:var(--muted);letter-spacing:.02em;text-transform:uppercase;padding:8px 10px;border-bottom:1px solid var(--line);background:var(--panel);white-space:nowrap;position:sticky;top:0;z-index:1}
.tbl td{padding:8px 10px;border-bottom:1px solid var(--line-soft);vertical-align:middle;white-space:nowrap}
.tbl tr:last-child td{border-bottom:0}
.tbl tr:hover td{background:var(--hover)}
.tbl tr.selected td{background:var(--emph-tint)}
.tbl .r{text-align:right;font-variant-numeric:tabular-nums}
.tbl th.sorted{color:var(--ink)}
.compact .tbl th{padding:5px 8px}.compact .tbl td{padding:5px 8px;font-size:12.5px}
.seg{display:inline-flex;border:1px solid var(--line);border-radius:6px;overflow:hidden;height:32px}
.seg button,.seg>a{height:100%;padding:0 12px;white-space:nowrap;font-size:12px;font-weight:600;border:0;background:transparent;color:var(--muted);font-family:inherit;cursor:pointer;border-right:1px solid var(--line);display:inline-flex;align-items:center;text-decoration:none}
.seg button:last-child,.seg>a:last-child{border-right:0}
.seg button.on,.seg>a.on{background:var(--accent);color:var(--accent-ink)}
.seg-sm{height:26px}.seg-sm button,.seg-sm>a{padding:0 9px;font-size:11.5px}
.tabs{display:flex;gap:4px;border-bottom:1px solid var(--line);height:40px;align-items:stretch}
.tab-link{position:relative;display:inline-flex;align-items:center;padding:0 12px;font-size:13px;font-weight:500;color:var(--muted);background:none;border:0;font-family:inherit;cursor:pointer}
.tab-link.active{color:var(--ink);font-weight:600}
.tab-link.active::after{content:"";position:absolute;left:12px;right:12px;bottom:-1px;height:2px;background:var(--accent);border-radius:2px}
.tab-link.disabled{color:var(--faint);cursor:default}
.nav{display:flex;flex-direction:column;gap:2px}
.nav a{display:flex;align-items:center;gap:10px;height:36px;padding:0 10px;border-radius:6px;font-size:13px;font-weight:500;color:var(--ink);text-decoration:none}
.nav a:hover{background:var(--hover);text-decoration:none}
.nav a.active{background:color-mix(in srgb,var(--accent) 12%,transparent);color:var(--accent);font-weight:600}
.nav a svg{width:16px;height:16px;flex:0 0 16px}
.nav .sub a{height:30px;padding-left:36px;font-size:13px}
.nav .sub a .hd{width:6px;height:6px;border-radius:999px;margin-left:auto}
.bar{height:6px;border-radius:999px;background:var(--track);position:relative;overflow:visible}
.bar .fill{height:100%;border-radius:999px;background:var(--accent)}.bar .fill.ok{background:var(--ok)}.bar .fill.mid{background:var(--warn)}.bar .fill.bad{background:var(--neg)}
.bar .tick{position:absolute;top:-3px;width:2px;height:12px;background:var(--ink);opacity:.6;border-radius:1px}
.delta{font-size:12px;font-weight:600;font-variant-numeric:tabular-nums;color:var(--muted);white-space:nowrap}
.delta.up{color:var(--signal-ink)}.delta.down{color:var(--neg)}
.alert{display:flex;gap:6px;align-items:baseline;font-size:12.5px;line-height:1.3;color:var(--ink)}
.alert::before{content:"";width:5px;height:5px;border-radius:999px;background:var(--muted);flex:0 0 5px;position:relative;top:-2px}
.alert.hot::before{background:var(--neg)}
.moving{font-size:12.5px;line-height:1.35;padding:6px 10px;border-radius:6px;background:var(--emph-tint);color:var(--ink);border:1px solid color-mix(in srgb,var(--emph) 45%,transparent)}
.moving b{font-weight:700}
.skeleton{background:linear-gradient(90deg,var(--track) 25%,transparent 50%,var(--track) 75%);background-size:200% 100%;animation:sk 1.2s infinite;border-radius:4px}
@keyframes sk{to{background-position:-200% 0}}
.bottomnav{display:none;grid-area:nav;border-top:1px solid var(--line);align-items:stretch;justify-content:space-around;background:var(--panel)}
.bottomnav a{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;font-size:10.5px;font-weight:600;color:var(--muted);flex:1;text-decoration:none}
.bottomnav a.active{color:var(--accent)}.bottomnav a svg{width:18px;height:18px}
@media (prefers-reduced-motion:reduce){.app *{animation:none!important;transition:none!important}}
.input{height:32px;padding:0 10px;border-radius:6px;border:1px solid var(--line);background:var(--panel);color:var(--ink);font-size:13px;font-family:inherit;display:flex;align-items:center;gap:8px}
.input .ph{color:var(--faint)}
.kbd{font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--muted);border:1px solid var(--line);border-radius:4px;padding:1px 4px;margin-left:auto}
.msg-user{align-self:flex-end;max-width:86%;padding:8px 12px;border-radius:8px;background:var(--user-bubble);color:var(--user-bubble-ink);font-size:13px;line-height:1.4}
.msg-agent{max-width:94%;display:flex;flex-direction:column;gap:6px}
.msg-agent .body{padding:8px 12px;border-radius:8px;background:var(--panel);border:1px solid var(--line);font-size:13px;line-height:1.45}
.msg-agent .src{font-size:11px;color:var(--faint);font-variant-numeric:tabular-nums}
.msg-agent .src b{font-weight:600;color:var(--muted)}
.mini{width:100%;border-collapse:collapse;font-size:12px;margin-top:6px}
.mini th{text-align:left;font-size:10.5px;color:var(--muted);font-weight:600;padding:3px 6px;border-bottom:1px solid var(--line-soft)}
.mini td{padding:3px 6px;border-bottom:1px solid var(--line-soft)}.mini tr:last-child td{border-bottom:0}
.sugg{display:inline-flex;align-items:center;height:26px;padding:0 10px;border-radius:999px;border:1px solid var(--line);font-size:12px;font-weight:500;color:var(--ink);background:var(--panel);white-space:nowrap;cursor:pointer;font-family:inherit}
.sugg:hover{background:var(--hover)}
.toast{display:flex;align-items:center;gap:10px;padding:10px 14px;border-radius:8px;background:var(--ink);color:var(--page);font-size:13px;font-weight:500;box-shadow:0 8px 24px rgba(1,7,54,.25)}
:root[data-theme="dark"] .toast{background:#FFFFFF;color:#0D1C42}
.toast .act{margin-left:auto;font-weight:700;color:var(--signal)}
:root[data-theme="dark"] .toast .act{color:#0E9AA3}
.tile{padding:9px 14px;display:flex;flex-direction:column;gap:4px;min-width:0}
.tile .val{font-family:Poppins,sans-serif;font-weight:600;font-size:22px;line-height:1.1;font-variant-numeric:tabular-nums;white-space:nowrap}
.tile.stale{opacity:.55}
.compact .tile{padding:8px 12px;gap:4px}.compact .tile .val{font-size:20px}
.compact .row-card{padding:8px 12px}
.thumb{background:var(--track);border-radius:4px;flex:0 0 auto;position:relative;overflow:hidden}
/* The diagonal is a placeholder for an empty frame, so it is drawn only when
   there is no media in it. It used to paint over every real preview, which is
   why a loaded image still read as a flat coloured block. */
.thumb:not(:has(img,video))::after{content:"";position:absolute;inset:0;
  background:linear-gradient(135deg,transparent 45%,rgba(13,28,66,.08) 45.5%,rgba(13,28,66,.08) 55%,transparent 55.5%)}
/* The media fills its frame wherever a thumb appears, not only inside an ad
   card. Scoping this to .creative-row let every preview added elsewhere render at
   its natural size: a 1280x885 landing-page screenshot laid out full width. */
.thumb img,.thumb video{width:100%;height:100%;object-fit:cover;display:block;
                        position:relative;z-index:0}
/* A preview whose file has gone is hidden rather than left as a broken icon;
   the frame behind it reads as "no image" on its own. */
.thumb img[data-broken]{display:none}
:root[data-theme="dark"] .thumb:not(:has(img,video))::after{background:linear-gradient(135deg,transparent 45%,rgba(255,255,255,.08) 45.5%,rgba(255,255,255,.08) 55%,transparent 55.5%)}
.persona{padding:12px 14px;display:flex;flex-direction:column;gap:6px}
.empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;text-align:center;padding:36px 24px;border:1px dashed var(--line);border-radius:8px}
.hr{height:1px;background:var(--line-soft)}
.modal-bg{position:fixed;inset:0;z-index:60;background:rgba(1,7,54,.5);backdrop-filter:blur(2px);display:flex;align-items:flex-start;justify-content:center;padding:72px 16px 24px;overflow:auto;animation:fade-in 160ms ease}
:root[data-theme="dark"] .modal-bg{background:rgba(0,0,0,.62)}
.brief-row{display:grid;grid-template-columns:150px minmax(0,1fr) auto;gap:14px;align-items:start;padding:10px 0;border-bottom:1px solid var(--line-soft)}
.brief-row:last-child{border-bottom:0}

/* Today's table layout is the dense alternative to the cards, so its rows stay
   one line tall: an alert that wraps to four lines is the card view again. */
.tbl td .alert{max-width:100%}
.tbl td .alert span{display:block}

/* A panel sits in a grid column: its contents scroll rather than widening it,
   otherwise one long table drags the whole row out of alignment. */
.panel{min-width:0;overflow:hidden}

/* ── States the component sheet specifies and the first build left unstyled ── */

/* A disabled control has to look disabled: without this a dead button is
   pixel-identical to a live one, which is how the date range shipped. */
.btn:disabled,.btn[disabled],.btn.disabled{opacity:.45;cursor:not-allowed}
.btn:disabled:hover,.btn[disabled]:hover{background:var(--panel)}
.seg button:disabled{opacity:.45;cursor:not-allowed}

/* Sortable column headers. */
.tbl th.sortable{cursor:pointer;user-select:none}
.tbl th.sortable:hover{color:var(--ink)}
.tbl th.sorted{color:var(--ink)}
.tbl th.sorted::after{content:"";display:inline-block;margin-left:5px;border-left:3px solid transparent;border-right:3px solid transparent;border-top:4px solid currentColor;vertical-align:middle}
.tbl th.sorted.asc::after{border-top:0;border-bottom:4px solid currentColor}

/* Density. The sheet documents comfortable and compact; .compact rules were
   ported in the first build but nothing ever set the class. */
.compact .panel-h{height:32px}
.compact .kpi{font-size:21px}
.compact .main{gap:10px}

/* Motion: hover and expand only, per the brief. Inside the reduced-motion
   guard further down, which switches all of this off. */
.btn,.chip,.sugg,.nav a,.tab-link,.tbl tr,.open{transition:background-color 140ms ease,color 140ms ease,border-color 140ms ease,opacity 140ms ease}

/* Toast: one live region, bottom centre, above everything. */
.toast-host{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);display:flex;flex-direction:column;gap:8px;z-index:50;pointer-events:none}
.toast-host .toast{pointer-events:auto;animation:toast-in 160ms ease}
@keyframes toast-in{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}

/* The unread dot used by the bell and the collapsed chat rail. */
.has-unread{position:relative}
.has-unread::after{content:"";position:absolute;top:4px;right:4px;width:7px;height:7px;border-radius:999px;background:var(--signal);box-shadow:0 0 0 1.5px var(--panel)}



/* ── Modal ────────────────────────────────────────────────────────────── */
/* An opaque surface above everything: the first version inherited the panel's
   background but sat inside the scrolling column, so rows painted over it. */
.modal-bg > .modal{background:var(--panel);box-shadow:0 18px 48px rgba(1,7,54,.28);
                   animation:modal-in 180ms cubic-bezier(.2,.8,.3,1);position:relative;z-index:1}
:root[data-theme="dark"] .modal-bg > .modal{box-shadow:0 18px 48px rgba(0,0,0,.5)}
body.modal-open{overflow:hidden}
@keyframes modal-in{from{opacity:0;transform:translateY(-8px) scale(.985)}to{opacity:1;transform:none}}
@keyframes fade-in{from{opacity:0}to{opacity:1}}

/* ── Motion and feedback ──────────────────────────────────────────────── */
/* Panels settle in on first paint rather than snapping, which makes a
   server-rendered page feel deliberate instead of abrupt. */
@keyframes rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.app .main > *{animation:rise 260ms cubic-bezier(.2,.8,.3,1) both}
.app .main > *:nth-child(1){animation-delay:0ms}
.app .main > *:nth-child(2){animation-delay:40ms}
.app .main > *:nth-child(3){animation-delay:80ms}
.app .main > *:nth-child(4){animation-delay:120ms}
.app .main > *:nth-child(n+5){animation-delay:150ms}

.row-card,.panel{transition:border-color 140ms ease,box-shadow 180ms ease,transform 180ms ease}
.row-card:hover{border-color:color-mix(in srgb,var(--accent) 35%,var(--line));
                box-shadow:0 2px 10px rgba(1,7,54,.07)}
:root[data-theme="dark"] .row-card:hover{box-shadow:0 2px 14px rgba(0,0,0,.35)}
.tile{transition:transform 160ms ease,border-color 140ms ease}
.tile:hover{transform:translateY(-1px);border-color:color-mix(in srgb,var(--accent) 30%,var(--line))}
.sugg:active,.btn:active{transform:translateY(1px)}
.expander svg{transition:transform 160ms ease}

/* Route progress: a thin line under the top bar while the next page loads, so
   a click always produces something within a frame. */
.progress{position:fixed;top:0;left:0;height:3px;width:0;z-index:80;opacity:0;
          background:linear-gradient(90deg,#0E9AA3,var(--signal));
          box-shadow:0 0 10px 1px rgba(29,206,216,.75),0 0 3px rgba(14,154,163,.9);
          transition:width 200ms ease,opacity 200ms ease}
.progress.on{opacity:1}

/* Skeletons while something is genuinely pending. */
.skeleton-line{height:12px;border-radius:4px;background:linear-gradient(90deg,var(--track) 25%,transparent 50%,var(--track) 75%);background-size:200% 100%;animation:sk 1.2s infinite}
.thinking{display:inline-flex;gap:4px;align-items:center}
.thinking i{width:5px;height:5px;border-radius:999px;background:var(--muted);display:block;
            animation:blink 1.2s infinite}
.thinking i:nth-child(2){animation-delay:.18s}
.thinking i:nth-child(3){animation-delay:.36s}
@keyframes blink{0%,60%,100%{opacity:.25}30%{opacity:1}}

/* Charts draw themselves in once, which reads as the data arriving. */
@keyframes draw{from{stroke-dashoffset:var(--len,600)}to{stroke-dashoffset:0}}
.app .main svg polyline[stroke-width="2"]{stroke-dasharray:var(--len,1400);
  animation:draw 900ms cubic-bezier(.3,.7,.3,1) both}

@media (prefers-reduced-motion:reduce){
  .app .main > *,.modal-bg,.modal-bg > .modal,.app .main svg polyline[stroke-width="2"]{animation:none!important}
  .app,.row-card,.panel,.tile,.progress{transition:none!important}
}

/* Rail furniture that used to carry inline styles. */
.rail-tools{display:flex;flex-direction:column;gap:6px;padding:0 10px}
.rail-brand{display:flex;align-items:center;gap:6px;height:40px;padding:0 8px;margin-bottom:8px}
.rail-logo{display:flex;align-items:center;gap:8px;color:var(--ink);text-decoration:none}
/* Collapsed, the mark sits centred on top with the control beneath it,
   so the rail reads as a column rather than a squeezed header row. */
.app.rail-collapsed .rail-brand{flex-direction:column;height:auto;gap:8px;padding:0;margin-bottom:12px}
.app.rail-collapsed .rail-logo{justify-content:center}
.app.rail-collapsed .rail-toggle{margin:0}
.rail-toggle{height:26px;width:26px;border:0;color:var(--muted);margin-left:auto}
.avatar{width:26px;height:26px;border-radius:999px;background:var(--emph);color:#0D1C42;
        display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;margin-left:auto}
.chat-body{display:flex;flex-direction:column;min-height:0;flex:1}
.chat .btn-icon[data-toggle]{height:26px;width:26px;border:0;color:var(--muted)}
.app.rail-collapsed .rail-toggle{margin:0 auto}
.app.rail-collapsed .rail-brand{justify-content:center;padding:0}

/* Route curtain: while the next page is on its way the current one is held
   behind a blur so a second click cannot land on a control that is about to
   disappear. */
.curtain{position:fixed;inset:0;z-index:70;display:none;align-items:center;justify-content:center;
         background:color-mix(in srgb,var(--page) 72%,transparent);backdrop-filter:blur(3px)}
.curtain.on{display:flex;animation:fade-in 120ms ease}
.curtain .spinner{width:26px;height:26px;border-radius:999px;border:2px solid var(--line);
                  border-top-color:var(--signal);animation:spin 700ms linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* The panel opens with a slide rather than appearing all at once. The column
   width carries the movement; the contents fade in behind it. The body is
   still display:none when collapsed, because leaving it in the layout at 44px
   is what made its text wrap one character per line. */
@keyframes panel-in{from{opacity:0;transform:translateX(18px)}to{opacity:1;transform:none}}
.app:not(.chat-collapsed):not(.wallboard) .chat-body{animation:panel-in 300ms ease-out both}
.chat-rail{animation:fade-in 220ms ease-out both}
@media (prefers-reduced-motion:reduce){
  .chat-body,.chat-rail,.curtain.on{animation:none}
}

/* The wordmark sits a shade lower than the mark so their optical centres line
   up; the mark's weight is higher than its box. */
.wordmark{font-size:15px;margin-top:2px}
.avatar{object-fit:cover}

/* Who is signed in on the left, the two controls on the right. Collapsed, only
   the theme button survives, so it centres like every other rail icon. */
.rail-account{display:flex;align-items:center;gap:8px;padding:0 4px;height:36px}
.rail-account .avatar{flex:0 0 auto}
.rail-account .rail-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.rail-account .btn-icon{height:28px;width:28px;flex:0 0 auto}
.app.rail-collapsed .rail-account{justify-content:center;padding:0}

/* Ad cards. The creative is the point, so the thumb keeps a 4:5 frame whether
   the file behind it is a still or a video; a video paints its own first frame
   rather than needing a poster generated on a machine that lacks the file. */
.creative-row{display:grid;grid-template-columns:64px minmax(0,1fr) auto;gap:4px 14px;align-items:start;
        padding:14px;border-bottom:1px solid var(--line-soft);color:var(--ink);
        text-decoration:none;position:relative}
/* The title link covers the card so the whole row is clickable, while the Ask
   button sits above it and keeps its own click. */
.creative-row .stretch::after{content:"";position:absolute;inset:0}
.creative-row .ask-pill{position:relative;z-index:1}
.creative-row:last-of-type{border-bottom:0}
.creative-row:hover{background:var(--hover)}
.creative-row .thumb{background:var(--track);border-radius:6px;
               position:relative;overflow:hidden;display:block}

.thumb .play{position:absolute;right:2px;bottom:2px;width:14px;height:14px;border-radius:999px;
                     background:rgba(1,7,54,.66);color:#fff;display:flex;align-items:center;justify-content:center}
.creative-body{display:flex;flex-direction:column;gap:6px;min-width:0}
.creative-head{display:flex;align-items:center;gap:8px;min-width:0}
.creative-rank{font-size:16px;font-weight:700;color:var(--accent);background:var(--signal-tint);
        border-radius:6px;padding:1px 8px;flex:none}
.creative-name{font-size:12.5px;font-weight:600;color:var(--ink);text-decoration:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1}
.creative-angle{font-size:13px;color:var(--ink);overflow:hidden;text-overflow:ellipsis;
              white-space:nowrap;min-width:0}
.creative-chips{display:flex;flex-wrap:wrap;gap:5px}
.chip-tag{background:var(--track);border-color:transparent;font-weight:500;color:var(--ink)}
.chip-weak{background:var(--neg-tint);border-color:transparent;font-weight:500;color:var(--neg)}
.creative-figure{display:flex;flex-direction:column;align-items:flex-end;gap:2px;white-space:nowrap}
.creative-figure b{font-size:22px;line-height:1.1}
.creative-figure .faint{font-size:12px}
.creative-figure b.above,.aida-bar b.above{color:var(--ok)}
.creative-figure b.near,.aida-bar b.near{color:var(--warn)}
.creative-figure b.below,.aida-bar b.below{color:var(--neg)}
/* Per-ad AIDA bars: the fill is the ad, the dark tick the account average and
   the grey tick the industry average, all on one scale per column. */
.creative-bars{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px 12px;margin-top:4px}
.aida-bar{display:flex;flex-direction:column;gap:2px;min-width:0;font-size:11px}
.aida-bar>.faint{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.aida-bar b{font-size:13px}
.aida-track{position:relative;height:6px;border-radius:999px;background:var(--track);margin-top:3px}
.aida-track .fill{position:absolute;left:0;top:0;bottom:0;border-radius:999px;background:var(--faint)}
.aida-track .fill.above{background:var(--ok)}.aida-track .fill.near{background:var(--warn)}.aida-track .fill.below{background:var(--neg)}
.aida-track .mark{position:absolute;top:-3px;bottom:-3px;width:2px;margin-left:-1px;border-radius:1px}
.mark.account{background:var(--ink)}
.mark.industry{background:var(--faint)}
.aida-legend i.mark{position:static;display:inline-block;width:2px;height:11px;margin:0}
@media (max-width:640px){.creative-row{grid-template-columns:48px minmax(0,1fr)}
  .creative-row .thumb{width:48px!important;height:60px!important}
  .creative-figure{grid-column:2;align-items:flex-start}
  .creative-bars{grid-template-columns:repeat(2,minmax(0,1fr))}}
.performer-sort{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.performer-floor{display:flex;align-items:center;gap:6px;margin-left:auto;font-size:12px}
.performer-floor .input{width:80px;height:26px}
@media (max-width:640px){.performer-floor{margin-left:0}}

/* The summary strip above the cards: facts on the left, provenance on the
   right, and it keeps that shape down to a phone by wrapping as one group. */
.summary-strip{display:flex;align-items:center;gap:8px 18px;flex-wrap:wrap;padding:10px 14px}
.summary-end{display:flex;align-items:center;gap:8px;margin-left:auto}
@media (max-width:640px){.summary-end{margin-left:0}}

/* Saved conversations, listed above the log rather than in a popover: the
   panel is already narrow and a popover inside it would be a box in a box. */
.threads{border-bottom:1px solid var(--line-soft);max-height:232px;overflow:auto;
         display:flex;flex-direction:column;background:var(--hover)}
.threads .thread{display:flex;flex-direction:column;gap:2px;align-items:flex-start;
                 padding:8px 14px;border:0;background:none;cursor:pointer;text-align:left;
                 color:var(--ink);font:inherit;border-bottom:1px solid var(--line-soft)}
.threads .thread:last-child{border-bottom:0}
.threads .thread:hover{background:var(--panel)}
.threads .thread-t{font-size:12.5px;font-weight:600;overflow:hidden;text-overflow:ellipsis;
                   white-space:nowrap;max-width:100%}
.threads .thread-m{font-size:11px;color:var(--muted)}
.threads .thread{position:relative}
.thread-watch{position:absolute;right:10px;top:9px;border:1px solid var(--line);
              background:var(--panel);color:var(--muted);border-radius:999px;
              font:inherit;font-size:10px;line-height:1;padding:3px 7px;cursor:pointer;
              opacity:0;transition:opacity 140ms ease}
.threads .thread:hover .thread-watch,.thread-watch:focus-visible,.thread-watch.on{opacity:1}
.thread-watch.on{border-color:var(--signal);color:var(--signal-ink)}
.threads .empty{margin:12px 14px}
.chat-body .btn-sm{height:24px;padding:0 8px;font-size:11.5px}

/* The ask affordance on a card: present but quiet, and only fully visible on
   hover or focus, because it must not compete with the numbers it sits beside. */
.ask-pill{border:1px solid var(--line);background:var(--panel);color:var(--muted);
         border-radius:999px;font:inherit;font-size:10.5px;line-height:1;padding:3px 7px;
         cursor:pointer;opacity:0;transition:opacity 140ms ease,color 140ms ease}
.creative-row:hover .ask-pill,.ask-pill:focus-visible{opacity:1}
.ask-pill:hover{color:var(--ink);border-color:var(--accent)}
@media (hover:none){.ask-pill{opacity:1}}

/* A value the tagger justified: the reasoning is a hover away, and the dotted
   rule is the only hint that there is more to read. */
.has-why{text-decoration:underline dotted var(--line);text-underline-offset:3px;cursor:help}

/* A control that opens a short list, built on details/summary so it needs no
   JavaScript and closes on Escape by itself. */
.picker{position:relative}
/* The open menu has to beat the cards below it, and a z-index inside the
   picker cannot do it. Every direct child of .main carries `animation: rise
   ... both`, which gives each one its own stacking context, so the block
   holding the cards paints over the block holding the controls whatever the
   picker does inside its own. The lift has to happen on that outer block,
   and only while the menu is open so it never sits over anything else. */
.picker[open]{z-index:40}
.main > *:has(.picker[open]){position:relative;z-index:40}
.picker>summary{list-style:none;cursor:pointer;display:inline-flex;align-items:center}
.picker>summary::-webkit-details-marker{display:none}
.picker[open]>summary{background:var(--hover)}
.picker-menu{position:absolute;top:calc(100% + 4px);right:0;z-index:1;min-width:186px;
             box-shadow:0 8px 24px rgba(1,7,54,.14);overflow:hidden}
.picker-row{display:flex;align-items:center;gap:8px;padding:6px 12px;font-size:12.5px;
            color:var(--ink);text-decoration:none}
.picker-row:hover{background:var(--hover)}
.picker-row.on{font-weight:600}
.picker-tick{width:12px;color:var(--signal-ink);font-size:11px}

/* Ad against landing page: two by two rather than one long strip. The creative
   pair holds the first cell at a size you can actually read, and the three
   readings fill the rest. Below a laptop it stacks, because two columns of
   prose at phone width is worse than one. */
.match-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 18px;align-items:start}
.match-media{display:flex;gap:8px;align-items:flex-start}
@media (max-width:1100px){.match-grid{grid-template-columns:minmax(0,1fr)}}

/* The library's own creative, scrolling sideways rather than wrapping into a
   wall: it is a sample, not an index. */
.library-strip{display:flex;gap:8px;padding:10px 14px 4px;overflow-x:auto;
               scrollbar-width:thin}
.library-strip .thumb{flex:0 0 auto}
/* Creative header: the week's numbers beside the account's AIDA averages
   against its vertical and every Kynship brand. */
.creative-kpis{grid-column:span 4;display:flex;flex-direction:column;justify-content:center;padding:6px 16px}
.aida-avg{grid-column:span 8;min-width:0}
@media (max-width:1100px){.creative-kpis,.aida-avg{grid-column:span 12}}
.kpi-line{display:flex;align-items:baseline;justify-content:space-between;gap:10px;padding:10px 0;font-size:12.5px}
.kpi-line+.kpi-line{border-top:1px solid var(--line-soft)}
.kpi-big{font-size:20px;font-weight:600}
.kpi-big.above{color:var(--ok)}.kpi-big.near{color:var(--warn)}.kpi-big.below{color:var(--neg)}
.aida-who small{display:block;font-size:10.5px;color:var(--faint)}
.aida-legend{display:flex;flex-wrap:wrap;gap:4px 12px;font-size:11.5px}
.aida-legend span{display:inline-flex;align-items:center;gap:5px}
.aida-legend i{width:12px;height:3px;border-radius:2px;background:var(--faint)}
.aida-legend i.above{background:var(--ok)}.aida-legend i.near{background:var(--warn)}.aida-legend i.below{background:var(--neg)}
.aida-grid{display:grid;grid-template-columns:110px repeat(4,minmax(0,1fr));gap:8px;align-items:center;padding:12px 14px}
.aida-who{font-size:12.5px}
.aida-cell{display:flex;flex-direction:column;gap:2px;padding:6px 10px;border:1px solid var(--line-soft);border-radius:6px;font-size:11.5px}
.aida-cell b{font-size:14px}
.aida-cell.above b{color:var(--ok)}.aida-cell.near b{color:var(--warn)}.aida-cell.below b{color:var(--neg)}
.aida-edit{padding:0 14px 12px}
.aida-edit summary{cursor:pointer;font-size:11.5px}
.aida-edit form{display:flex;flex-wrap:wrap;align-items:flex-end;gap:10px;margin-top:8px}
.aida-edit label{display:flex;flex-direction:column;gap:3px;font-size:11px}
.aida-edit .input{width:130px}
