/* Brocare Studio components and shell. Requires tokens.css.
   Every value comes from a token; the only literals are 0, 1px hairlines and percentages. */

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--surface-ground); -webkit-text-size-adjust: 100%; scroll-padding-block-start: calc(var(--topbar-h) + var(--space-4)); }
body {
  margin: 0; min-height: 100dvh; background: var(--surface-ground); color: var(--text-body);
  font: 400 var(--fs-body)/var(--lh-body) var(--font-body);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--text-strong); margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--text-link); text-decoration-color: var(--sky-300-a35); text-underline-offset: .22em; text-decoration-thickness: 1px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
img, svg { display: block; max-width: 100%; }
::selection { background: var(--blue-500-a45); color: var(--white); }
:focus-visible { outline: var(--focus-width) solid var(--focus-ring); outline-offset: var(--focus-offset); }
input, textarea { caret-color: var(--ice-400); }
* { scrollbar-width: thin; scrollbar-color: var(--line-700) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-700); border-radius: var(--radius-full); border: 3px solid var(--surface-ground); }
.num, [data-num] { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 24px; height: 24px; }

/* Ground: one quiet aurora and fixed grain, no per-section glows */
.ground { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.ground::before { content: ""; position: absolute; inset: -30% -20% auto auto; width: 70vmax; height: 70vmax;
  background: radial-gradient(closest-side, var(--blue-500-a14), transparent 70%); }
.ground::after { content: ""; position: absolute; inset: 0; opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }

.skip { position: fixed; left: var(--space-4); top: var(--space-3); z-index: var(--z-toast); padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
  background: var(--white); color: var(--navy-950); font-weight: 600; transform: translateY(-160%); transition: transform var(--dur-fast) var(--ease-out); }
.skip:focus { transform: none; }

/* ===== Shell ===== */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-4) var(--space-3); background: var(--navy-900-a78); border-inline-end: 1px solid var(--line-soft);
  backdrop-filter: blur(var(--blur-glass)); -webkit-backdrop-filter: blur(var(--blur-glass)); z-index: var(--z-nav); }
.brandmark { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-3) var(--space-4); text-decoration: none; color: var(--text-strong); }
.brandmark img { height: 26px; width: auto; }
.brandmark span { font: 600 var(--fs-small)/1 var(--font-display); color: var(--text-muted); letter-spacing: .02em; padding-inline-start: var(--space-2); border-inline-start: 1px solid var(--line); }
.nav-group { border: 0; margin: 0; padding: 0; }
.nav-group > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; cursor: pointer; border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-3) var(--space-1); font-size: var(--fs-label); letter-spacing: var(--track-label); text-transform: uppercase; font-weight: 600; color: var(--text-dim); }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary .chev { transition: transform var(--dur-fast) var(--ease-out); }
.nav-group[open] > summary .chev { transform: rotate(90deg); }
.nav-item { position: relative; display: flex; align-items: center; gap: var(--space-3); min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-md);
  color: var(--text-muted); text-decoration: none; font-weight: 500; font-size: var(--fs-body); }
.nav-item .icon { color: var(--text-dim); }
.nav-item[aria-current="page"] { color: var(--text-strong); background: var(--surface-selected); box-shadow: inset 0 0 0 1px var(--line-accent); }
.nav-item[aria-current="page"] .icon { color: var(--ice-400); }
.nav-item .count { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--radius-full); display: grid; place-items: center;
  background: var(--state-needs); color: var(--state-needs-text); font: 700 var(--fs-label)/1 var(--font-body); font-variant-numeric: tabular-nums; }
.nav-item .live-dot { margin-inline-start: auto; }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border-top: 1px solid var(--line-soft); }
.side-foot b { display: block; color: var(--text-strong); font-weight: 600; font-size: var(--fs-small); }
.side-foot small { color: var(--text-dim); font-size: var(--fs-label); }

.frame { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: var(--z-sticky); height: var(--topbar-h); display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-6); background: var(--navy-950-a78); border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(var(--blur-glass)); -webkit-backdrop-filter: blur(var(--blur-glass)); }
.top .grow { flex: 1; min-width: 0; }
.top .m-brand, .top .show-phone { display: none; }
.crumb { color: var(--text-dim); font-size: var(--fs-small); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb b { color: var(--text-body); font-weight: 600; }
.view { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--space-6) var(--space-6) var(--space-8); display: grid; gap: var(--space-6); align-content: start; }
.view-transition-main { view-transition-name: main; }

.tabbar { display: none; }

.avatar { width: 32px; height: 32px; border-radius: var(--radius-full); display: grid; place-items: center; flex: none;
  background: linear-gradient(140deg, var(--royal-600), var(--cobalt-700)); color: var(--white); font: 700 var(--fs-label)/1 var(--font-display); }

/* ===== Page head ===== */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
.page-head h1 { font-size: var(--fs-title); line-height: var(--lh-title); letter-spacing: var(--track-heading); font-weight: 700; }
.page-head .lede { color: var(--text-muted); margin-top: var(--space-2); max-width: 62ch; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.section { display: grid; gap: var(--space-4); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.section-head h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 600; letter-spacing: var(--track-heading); }
.section-head .meta { color: var(--text-dim); font-size: var(--fs-small); }
.example-tag { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px 10px; border-radius: var(--radius-full); border: 1px dashed var(--state-off-line);
  color: var(--text-dim); font-size: var(--fs-label); font-weight: 600; white-space: nowrap; }

/* ===== Buttons: liquid metal pills ===== */
.btn { --h: 44px; position: relative; isolation: isolate; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--h); padding: 0 calc(var(--space-5) - 2px) 0 var(--space-5); border-radius: var(--radius-full); border: 1px solid transparent;
  font: 600 var(--fs-body)/1 var(--font-body); white-space: nowrap; text-decoration: none; color: var(--text-strong);
  transition: transform var(--dur-press) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), background-color var(--dur-press) ease, color var(--dur-press) ease; }
.btn .icon { width: 18px; height: 18px; }
.btn.has-icon { padding-inline-start: calc(var(--space-4) + 2px); }
.btn:not(:disabled):active { transform: scale(var(--press-scale)); transition-timing-function: var(--ease-out); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(120deg, var(--royal-600), var(--action-primary-hi) 60%, var(--royal-600)); box-shadow: var(--metal-primary); color: var(--text-on-fill); }
.btn-primary::after { content: ""; position: absolute; inset: 0; z-index: -1; transform: translateX(-120%);
  background: linear-gradient(100deg, transparent 30%, var(--white-a22) 50%, transparent 70%); }
.btn-secondary { background: var(--action-secondary); box-shadow: var(--metal-secondary); }
.btn-ghost { background: transparent; border-color: var(--line-control); color: var(--text-body); }
.btn-quiet { background: transparent; color: var(--text-muted); padding-inline: var(--space-3); }
.btn-icon { --h: 44px; width: var(--h); padding: 0; }
.btn-sm { --h: 36px; font-size: var(--fs-small); padding-inline: var(--space-4); }
.btn-sm.btn-icon { width: 36px; padding: 0; }
.btn-lg { --h: 52px; font-size: var(--fs-read); padding-inline: var(--space-6); }
.btn-block { width: 100%; }
.btn-sm::before, .btn-icon::before { content: ""; position: absolute; inset: -6px; } /* 44px hit area for small buttons */
.btn .kbd { margin-inline-start: var(--space-1); }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { box-shadow: inset 0 1px 0 var(--white-a45), inset 0 -2px 4px var(--navy-950-a45), 0 0 0 1px var(--ice-400-a55), 0 16px 40px -12px var(--blue-500-a85); }
  .btn-primary:hover::after { transform: translateX(120%); transition: transform 900ms var(--ease-out); }
  .btn-secondary:hover { box-shadow: var(--metal-secondary), 0 12px 32px -14px var(--ice-400-a45); }
  .btn-ghost:hover { border-color: var(--line-accent); background: var(--surface-hover); }
  .btn-quiet:hover { color: var(--text-strong); background: var(--surface-hover); }
  .nav-item:hover { color: var(--text-strong); background: var(--surface-hover); }
  .nav-group > summary:hover { color: var(--text-muted); }
}
.btn.is-loading { color: transparent; pointer-events: none; }
.btn.is-loading::before { content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--white-a35); border-top-color: var(--white); animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kbd .icon { width: 12px; height: 12px; stroke-width: 2.25; }
.kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--radius-xs);
  border: 1px solid var(--line); background: var(--surface-inset); color: var(--text-dim); font: 600 11px/1 var(--font-body); }

/* ===== Status pills (blue-only, icon + word, never colour alone) ===== */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--radius-full); border: 1px solid var(--state-queued-line);
  color: var(--state-queued-text); background: transparent; font: 600 var(--fs-label)/1 var(--font-body); white-space: nowrap; }
.pill .icon { width: 14px; height: 14px; stroke-width: 2; }
.pill.live { color: var(--state-live); border-color: var(--state-live-line); background: var(--state-live-tint); }
.pill.needs { color: var(--state-needs-text); border-color: var(--state-needs); background: var(--state-needs); }
.pill.done { color: var(--state-done-text); border-color: var(--state-done-line); background: var(--state-done); }
.pill.failed { color: var(--state-failed-text); border-color: var(--state-failed-line); }
.pill.off { color: var(--state-off-text); border-style: dashed; border-color: var(--state-off-line); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--state-live); flex: none; position: relative; }
.live-dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--state-live); opacity: 0; animation: ping 2s var(--ease-out) infinite; }
@keyframes ping { 0% { transform: scale(.6); opacity: .7; } 100% { transform: scale(1.6); opacity: 0; } }

/* Tags: classification, not state */
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: var(--radius-full); background: var(--surface-inset);
  box-shadow: inset 0 0 0 1px var(--line-soft); color: var(--text-muted); font: 500 var(--fs-label)/1 var(--font-body); white-space: nowrap; }

/* ===== Segmented control and tabs ===== */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-full); background: var(--surface-inset); box-shadow: inset 0 0 0 1px var(--line); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { position: relative; min-height: 36px; padding: 0 var(--space-4); border: 0; border-radius: var(--radius-full); background: transparent;
  color: var(--text-muted); font-weight: 500; font-size: var(--fs-small); white-space: nowrap; display: inline-flex; align-items: center; gap: var(--space-2); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface-raised); color: var(--text-strong); box-shadow: inset 0 0 0 1px var(--line-accent), 0 4px 12px -6px var(--shadow-a80); }
.seg button .n { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--line-soft); overflow-x: auto; scrollbar-width: none; }
.tabs [role="tab"] { position: relative; min-height: 44px; padding: 0; border: 0; background: none; color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.tabs [role="tab"][aria-selected="true"] { color: var(--text-strong); }
.tabs [role="tab"][aria-selected="true"]::after { content: ""; position: absolute; inset: auto 0 -1px; height: 2px; border-radius: 2px; background: var(--blue-500); }
@media (hover: hover) and (pointer: fine) { .seg button:hover, .tabs [role="tab"]:hover { color: var(--text-strong); } }

/* ===== Fields ===== */
.field { display: grid; gap: var(--space-2); }
.field > label, .field-label { font-size: var(--fs-small); font-weight: 600; color: var(--text-muted); }
.input { width: 100%; min-height: 44px; padding: 0 var(--space-4); border-radius: var(--radius-md); border: 1px solid var(--line-control); background: var(--surface-inset);
  color: var(--text-strong); font-size: var(--fs-read); transition: border-color var(--dur-press) ease, background-color var(--dur-press) ease; }
textarea.input { padding: var(--space-3) var(--space-4); min-height: 96px; resize: vertical; line-height: var(--lh-read); }
.input::placeholder { color: var(--text-dim); }
.input:focus { outline: none; border-color: var(--focus-ring); background: var(--navy-950-a85); box-shadow: 0 0 0 3px var(--ice-400-a20); }
.input[aria-invalid="true"] { border-style: dashed; border-color: var(--white); }
.field .help { font-size: var(--fs-small); color: var(--text-dim); }
.field .error { font-size: var(--fs-small); color: var(--white); display: flex; gap: var(--space-2); align-items: center; }
.search { position: relative; }
.search .icon { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.search .input { padding-inline-start: 44px; border-radius: var(--radius-full); }
.toggle { position: relative; width: 48px; height: 28px; border-radius: var(--radius-full); border: 1px solid var(--line-control); background: var(--surface-inset); flex: none; }
.toggle::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--slate-400);
  transition: transform var(--dur-fast) var(--ease-press), background-color var(--dur-fast) ease; }
.toggle[aria-checked="true"] { background: var(--state-live-tint); border-color: var(--state-live-line); }
.toggle[aria-checked="true"]::after { transform: translateX(20px); background: var(--ice-400); }

/* ===== Cards ===== */
.card { position: relative; border-radius: var(--radius-lg); background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(var(--blur-glass)); -webkit-backdrop-filter: blur(var(--blur-glass)); padding: var(--space-5); min-width: 0; border: 1px solid transparent; }
.card.tight { padding: var(--space-4); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: 600; letter-spacing: 0; }
.card-head .meta { color: var(--text-dim); font-size: var(--fs-small); }
a.card, .card.linked { text-decoration: none; color: inherit; transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out); }
@media (hover: hover) and (pointer: fine) { a.card:hover, .card.linked:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px var(--line-accent), var(--elev-hover); } }
.card.approved { background: var(--ice-400-a07); box-shadow: inset 0 0 0 1px var(--state-live-line); }

/* ===== Stat ===== */
.stat { display: grid; gap: var(--space-1); min-width: 0; }
.stat .k { font-size: var(--fs-small); color: var(--text-muted); font-weight: 500; }
.stat .v { font: 700 var(--fs-stat)/var(--lh-stat) var(--font-display); color: var(--text-strong); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .v small { font: 600 var(--fs-small)/1 var(--font-body); color: var(--text-dim); margin-inline-start: var(--space-1); }
.stat .s { font-size: var(--fs-small); color: var(--text-dim); }
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-strip > .stat { padding: var(--space-4) var(--space-5); }
.stat-strip > .stat + .stat { border-inline-start: 1px solid var(--line-soft); }
.meter { height: 6px; border-radius: var(--radius-full); background: var(--surface-inset); box-shadow: inset 0 0 0 1px var(--line-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; width: var(--w, 0%); border-radius: inherit; background: linear-gradient(90deg, var(--royal-600), var(--blue-500)); transform-origin: left; }

/* ===== Lists and rows ===== */
.rows { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.row { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); min-height: 64px;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2); border-radius: var(--radius-md); background: var(--surface-inset); box-shadow: inset 0 0 0 1px var(--line-soft);
  color: inherit; text-decoration: none; transition: background-color var(--dur-press) ease, box-shadow var(--dur-press) ease; }
.row .t { min-width: 0; }
.row .t b { display: block; color: var(--text-strong); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t small { display: block; color: var(--text-dim); font-size: var(--fs-small); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { display: flex; align-items: center; gap: var(--space-2); }
@media (hover: hover) and (pointer: fine) { a.row:hover, button.row:hover { background: var(--surface-hover); } }
button.row { width: 100%; text-align: start; border: 0; font: inherit; }
/* Inside a card, rows are not boxes: no nested cards. Space and a hairline separate them. */
.card .rows { gap: 0; margin-inline: calc(-1 * var(--space-3)); }
.card .row { background: transparent; box-shadow: none; padding-inline: var(--space-3); }
.card .rows > li + li .row, .card .rows > .row + .row { box-shadow: 0 -1px 0 var(--line-soft); }

.thumb { width: 44px; aspect-ratio: 4 / 5; border-radius: var(--radius-sm); overflow: hidden; flex: none; position: relative; background: var(--navy-700); box-shadow: inset 0 0 0 1px var(--white-a08); }
.thumb.reel { aspect-ratio: 9 / 16; width: 36px; }
.thumb .art { position: absolute; inset: 0; }
/* Thumbnail art stand-ins for the mockups; production shows the rendered asset */
.art-carousel { background: radial-gradient(120% 80% at 100% 0%, var(--blue-500-a55), transparent 60%), linear-gradient(165deg, var(--navy-800), var(--navy-950)); }
.art-carousel::after { content: ""; position: absolute; inset: auto 18% 22% 14%; height: 4px; border-radius: 2px; background: var(--white-a75); box-shadow: 0 -8px 0 var(--white-a75), 0 9px 0 var(--mist-300-a45); }
.art-reel { background: radial-gradient(90% 60% at 30% 25%, var(--ice-400-a40), transparent 60%), radial-gradient(80% 70% at 80% 80%, var(--royal-600-a70), transparent 70%), var(--navy-950); }
.art-li { background: var(--platform-canvas-li); }
.art-li::after { content: ""; position: absolute; inset: 22% 18% auto; height: 3px; border-radius: 2px; background: var(--platform-ink-li); box-shadow: 0 7px 0 var(--platform-line-li), 0 14px 0 var(--platform-line-li), 0 21px 0 var(--platform-line-li-2); }
.art-still { background: linear-gradient(160deg, var(--royal-600), var(--navy-950) 75%); }
.art-still::after { content: ""; position: absolute; inset: 30% 16% auto; height: 6px; border-radius: 3px; background: var(--white); box-shadow: 0 10px 0 var(--ice-400); }


/* ===== Table ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
table.t { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
table.t th { text-align: start; font-size: var(--fs-label); text-transform: uppercase; letter-spacing: var(--track-label); color: var(--text-dim); font-weight: 600;
  padding: var(--space-3) var(--space-3); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: var(--space-3); border-bottom: 1px solid var(--line-soft); color: var(--text-body); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t .n { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t th.n { text-align: end; }
table.t td b { color: var(--text-strong); font-weight: 600; }
table.t button.sort { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
table.t button.sort:focus-visible { outline: var(--focus-width) solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }

/* ===== Week strip (calendar cell) ===== */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-2); }
.day { display: grid; align-content: start; gap: var(--space-1); min-height: 92px; padding: 6px; border-radius: var(--radius-md);
  background: var(--surface-inset); box-shadow: inset 0 0 0 1px var(--line-soft); }
.day .d { display: flex; justify-content: space-between; color: var(--text-dim); font-size: var(--fs-label); font-weight: 600; }
.day .d b { color: var(--text-muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.day.today { box-shadow: inset 0 0 0 1px var(--line-accent); }
.day.today .d b { color: var(--text-strong); }
.day.free { background: transparent; box-shadow: none; outline: 1px dashed var(--line); outline-offset: -1px; }
.day .slot { display: grid; gap: 2px; min-width: 0; padding: 4px 5px; border-radius: var(--radius-xs); background: var(--state-done);
  color: var(--text-body); font-size: var(--fs-label); font-weight: 500; }
.day .slot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day .slot .when { display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.day .slot.needs .when { color: var(--state-needs-text); }
.day .slot.needs { background: var(--state-needs); color: var(--state-needs-text); }
.day .slot .icon { width: 12px; height: 12px; stroke-width: 2; }

/* ===== Lanes (Conductor) ===== */
.lanes { display: grid; gap: var(--space-2); }
.lane { display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; align-items: center; gap: var(--space-4); min-height: 48px; }
.lane .name { display: flex; align-items: center; gap: var(--space-2); color: var(--text-body); font-weight: 500; }
.lane .name .icon { color: var(--text-dim); width: 18px; height: 18px; }
.track { position: relative; height: 10px; border-radius: var(--radius-full); background: var(--surface-inset); box-shadow: inset 0 0 0 1px var(--line-soft); overflow: hidden; }
.track > b { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: inherit; background: var(--state-done-line); transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform 600ms var(--ease-out); }
.track > b.live { background: linear-gradient(90deg, var(--blue-500), var(--ice-400), var(--blue-500)); background-size: 200% 100%; animation: sheen var(--dur-sheen) linear infinite; }
.track > b.wait { background: transparent; }
@keyframes sheen { to { background-position: -200% 0; } }
.lane .step { color: var(--text-dim); font-size: var(--fs-small); }

/* ===== Device and platform preview frames ===== */
.device { width: 100%; max-width: 390px; margin-inline: auto; border-radius: 36px; padding: 10px; background: linear-gradient(160deg, var(--navy-700), var(--navy-950));
  box-shadow: inset 0 0 0 1px var(--white-a08), 0 40px 80px -40px var(--blue-500-a55); }
.screen { border-radius: 28px; overflow: hidden; background: var(--white); color: var(--platform-ink-ig); position: relative; }
.screen.dark { background: var(--platform-reel-bg); color: var(--white); }
/* Platform chrome uses neutral greys from the platforms themselves, scoped to .screen only. These are not Studio colours. */
.ig-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; font: 600 13px/1.2 var(--font-body); }
.ig-head .av { width: 32px; height: 32px; border-radius: 50%; padding: 2px; background: var(--navy-950); display: grid; place-items: center; }
.ig-head .av img { width: 26px; height: auto; }
.ig-head small { display: block; font-weight: 400; color: var(--platform-mute); font-size: 11px; }
.ig-head .more { margin-inline-start: auto; color: var(--platform-ink); }
.ig-media { position: relative; aspect-ratio: 4 / 5; background: var(--navy-950); overflow: hidden; }
.ig-actions { display: flex; gap: 14px; padding: 10px 14px 4px; color: var(--platform-ink); }
.ig-actions .icon { width: 24px; height: 24px; }
.ig-actions .save { margin-inline-start: auto; }
.ig-caption { padding: 2px 14px 14px; font: 400 13px/1.45 var(--font-body); color: var(--platform-ink); }
.ig-caption b { font-weight: 600; }
.ig-caption .more { color: var(--platform-mute); }
.dots { display: flex; justify-content: center; gap: 4px; padding: 8px 0 0; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--platform-dot); transition: background-color var(--dur-fast) ease, transform var(--dur-fast) var(--ease-out); }
.dots i.on { background: var(--blue-500); transform: scale(1.15); }
.slides { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.slides::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: start; position: relative; padding: 9% 9% 10%; display: flex; flex-direction: column; justify-content: space-between; color: var(--white);
  background: radial-gradient(120% 80% at 100% 0%, var(--blue-500-a35), transparent 60%), linear-gradient(165deg, var(--navy-800), var(--navy-950)); }
.slide .sn { font: 600 11px/1 var(--font-body); color: var(--mist-300); letter-spacing: .04em; }
.slide h4 { font: 700 clamp(20px, 7.4cqi, 30px)/1.08 var(--font-display); letter-spacing: -.01em; color: var(--white); }
.slide p { font: 400 clamp(12px, 3.6cqi, 15px)/1.45 var(--font-body); color: var(--mist-300); }
.slide .hl { color: var(--ice-400); }
.slide .foot { display: flex; align-items: center; justify-content: space-between; font: 500 11px/1 var(--font-body); color: var(--mist-300); }
.slide .foot img { height: 16px; width: auto; }
.slide-count { position: absolute; top: 10px; inset-inline-end: 10px; z-index: 2; padding: 4px 9px; border-radius: var(--radius-full); background: var(--platform-shade-a55); color: var(--white); font: 600 11px/1 var(--font-body); font-variant-numeric: tabular-nums; }
.ig-media, .reel { container-type: inline-size; }

.reel { position: relative; aspect-ratio: 9 / 16; overflow: hidden; color: var(--white);
  background: radial-gradient(90% 60% at 30% 25%, var(--ice-400-a25), transparent 60%), radial-gradient(80% 70% at 80% 80%, var(--royal-600-a55), transparent 70%), var(--navy-950); }
.reel .caption-burn { position: absolute; inset: 38% 8% auto; text-align: center; font: 800 clamp(18px, 7cqi, 26px)/1.15 var(--font-display); text-shadow: 0 2px 12px var(--platform-shade-a60); }
.reel .caption-burn em { font-style: normal; color: var(--ice-400); }
.reel .rail { position: absolute; inset-inline-end: 10px; bottom: 90px; display: grid; gap: 16px; justify-items: center; font: 600 11px/1 var(--font-body); }
.reel .rail .icon { width: 26px; height: 26px; }
.reel .meta { position: absolute; inset: auto 64px 22px 14px; font: 400 12px/1.45 var(--font-body); }
.reel .meta b { font-weight: 600; display: block; margin-bottom: 4px; }
.reel .bar { position: absolute; inset: auto 0 0; height: 3px; background: var(--white-a25); }
.reel .bar span { display: block; height: 100%; width: 34%; background: var(--white); }
.reel .play { position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--platform-shade-a40); border: 0; color: var(--white); }
.reel .play .icon { width: 28px; height: 28px; transform: translateX(2px); fill: currentColor; }

.li-post { background: var(--white); color: var(--platform-ink-li); font: 400 14px/1.45 var(--font-body); }
.li-head { display: flex; gap: 10px; padding: 12px 14px 6px; }
.li-head .av { width: 44px; height: 44px; border-radius: 6px; background: var(--navy-950); display: grid; place-items: center; flex: none; }
.li-head .av img { width: 38px; height: auto; }
.li-head b { display: block; font-weight: 600; font-size: 14px; }
.li-head small { display: block; color: var(--platform-mute-li); font-size: 12px; line-height: 1.35; }
.li-body { padding: 4px 14px 10px; }
.li-body p + p { margin-top: 10px; }
.li-body .see { color: var(--platform-mute-li); }
.li-doc { margin: 0 0 6px; background: var(--platform-canvas-li); padding: 10px; }
.li-doc .page { aspect-ratio: 4 / 5; border-radius: 4px; overflow: hidden; container-type: inline-size; }
.li-doc .doc-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 2px 0; color: var(--platform-mute-li-3); font: 600 12px/1 var(--font-body); }
.li-react { display: flex; justify-content: space-around; padding: 6px 4px 10px; border-top: 1px solid var(--platform-rule); color: var(--platform-mute-li-2); font: 600 12px/1 var(--font-body); }
.li-react span { display: flex; align-items: center; gap: 6px; padding: 8px; }
.li-react .icon { width: 18px; height: 18px; }

/* ===== Decision bar (approve, change, kill) ===== */
.decide { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: var(--space-3); align-items: center; }
.slide-approve { position: relative; height: 56px; border-radius: var(--radius-full); background: var(--surface-inset); box-shadow: inset 0 0 0 1px var(--line-accent); overflow: hidden; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.slide-approve .fill { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, var(--royal-600-a90), var(--blue-500-a90)); transform-origin: left; transform: scaleX(var(--drag, 0)); }
.slide-approve .label { position: absolute; inset: 0; display: grid; place-items: center; padding-inline-start: 48px; color: var(--text-muted); font-weight: 600; pointer-events: none; }
.slide-approve .thumbknob { position: absolute; top: 4px; inset-inline-start: 4px; width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--white); color: var(--navy-950); box-shadow: 0 6px 16px -6px var(--shadow-a90); transform: translateX(var(--x, 0px)); touch-action: none; cursor: grab; }
.slide-approve .thumbknob:active { cursor: grabbing; }
.slide-approve .thumbknob .icon { width: 22px; height: 22px; stroke-width: 2.25; }
.slide-approve.settling .thumbknob { transition: transform var(--dur-base) var(--ease-press); }
.slide-approve.settling .fill { transition: transform var(--dur-base) var(--ease-out); }
.slide-approve.done { background: var(--ice-400-a14); box-shadow: inset 0 0 0 1px var(--state-live-line); }
.slide-approve.done .label { color: var(--ice-400); padding-inline-start: 0; }

/* ===== Toasts ===== */
.toasts { position: fixed; z-index: var(--z-toast); inset-inline: 0; bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: var(--space-2); pointer-events: none; padding-inline: var(--gutter) var(--gutter-end); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--space-3); min-height: 52px; max-width: min(460px, 100%); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border-radius: var(--radius-full); background: var(--surface-raised); box-shadow: var(--elev-pop); color: var(--text-strong); font-weight: 500;
  transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out); }
.toast .icon { color: var(--ice-400); }
.toast[data-state="enter"] { transform: translateY(16px) scale(.97); opacity: 0; }
.toast[data-state="exit"] { transform: translateY(8px); opacity: 0; transition-duration: var(--dur-exit); }

/* ===== Sheets, modals (native <dialog>) ===== */
dialog { padding: 0; border: 0; background: transparent; color: inherit; max-width: none; max-height: none; }
dialog::backdrop { background: var(--surface-overlay); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal { width: min(560px, calc(100% - 32px)); margin: auto; border-radius: var(--radius-xl); background: var(--surface-card-solid); box-shadow: var(--elev-pop); padding: var(--space-6); overscroll-behavior: contain; }
.sheet { position: fixed; inset: auto 0 0; margin: 0; width: 100%; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--surface-card-solid); box-shadow: var(--elev-sheet); padding: var(--space-2) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom)); }
.sheet .grab { width: 40px; height: 5px; border-radius: var(--radius-full); background: var(--line-700); margin: var(--space-2) auto var(--space-4); }
dialog[open].modal { animation: modal-in var(--dur-sheet) var(--ease-out); }
dialog[open].sheet { animation: sheet-in var(--dur-sheet) var(--ease-out); }
@keyframes modal-in { from { opacity: 0; transform: scale(.96) translateY(8px); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@media (min-width: 768px) {
  .sheet { inset: 0 0 0 auto; width: min(480px, 100%); max-height: none; height: 100dvh; border-radius: var(--radius-xl) 0 0 var(--radius-xl); padding: var(--space-6); }
  .sheet .grab { display: none; }
  @keyframes sheet-in { from { transform: translateX(100%); } }
}

/* ===== Command palette (no open animation: used many times a day) ===== */
.palette { width: min(640px, calc(100% - 32px)); margin: 12vh auto auto; border-radius: var(--radius-xl); background: var(--surface-card-solid); box-shadow: var(--elev-pop); overflow: hidden; }
.palette .search .input { border: 0; border-radius: 0; min-height: 60px; background: transparent; box-shadow: none; border-bottom: 1px solid var(--line-soft); font-size: var(--fs-read); }
.palette .search .input:focus { box-shadow: none; }
.palette ul { list-style: none; margin: 0; padding: var(--space-2); max-height: 50vh; overflow-y: auto; overscroll-behavior: contain; }
.palette .grp { padding: var(--space-3) var(--space-3) var(--space-1); font-size: var(--fs-label); color: var(--text-dim); font-weight: 600; letter-spacing: var(--track-label); text-transform: uppercase; }
.palette [role="option"] { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; padding: 0 var(--space-3); border-radius: var(--radius-md); color: var(--text-body); cursor: pointer; }
.palette [role="option"] .icon { color: var(--text-dim); }
.palette [role="option"][aria-selected="true"] { background: var(--surface-selected); color: var(--text-strong); }
.palette [role="option"] .kbd { margin-inline-start: auto; }
.palette .foot { display: flex; gap: var(--space-4); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line-soft); color: var(--text-dim); font-size: var(--fs-label); }

/* ===== Empty and loading ===== */
.empty { display: grid; justify-items: center; text-align: center; gap: var(--space-3); padding: var(--space-7) var(--space-5); border-radius: var(--radius-lg); outline: 1px dashed var(--line); outline-offset: -1px; }
.empty .glyph { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--royal-600-a25); color: var(--ice-400); }
.empty h3 { font-size: var(--fs-h3); }
.empty p { color: var(--text-muted); max-width: 42ch; }
.skeleton { position: relative; overflow: hidden; border-radius: var(--radius-sm); background: var(--line-700-a35); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, var(--mist-300-a10), transparent); animation: shimmer var(--dur-shimmer) linear infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ===== Charts ===== */
.chart { width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--viz-grid); stroke-width: 1; }
.chart .axis text { fill: var(--viz-axis); font: 500 11px var(--font-body); font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--viz-series); }
.chart .bar.hi { fill: var(--viz-highlight); }
.chart .ref { stroke: var(--viz-reference); stroke-dasharray: 4 4; stroke-width: 1.5; }
.chart .ref-label { fill: var(--viz-reference); font: 600 11px var(--font-body); }
.chart .val { fill: var(--text-muted); font: 600 11px var(--font-body); font-variant-numeric: tabular-nums; }
.chart .val.hi { fill: var(--white); }
.chart .bar:focus { outline: none; stroke: var(--focus-ring); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-4); color: var(--text-muted); font-size: var(--fs-small); }
.legend span { display: inline-flex; align-items: center; gap: var(--space-2); }
.legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--viz-series); }
.legend i.hi { background: var(--viz-highlight); }
.legend i.ref { height: 0; border-top: 2px dashed var(--viz-reference); border-radius: 0; width: 16px; background: none; }

/* ===== Entrance (only on first paint, content visible by default) ===== */
@media (prefers-reduced-motion: no-preference) {
  .js .enter > * { animation: rise var(--dur-sheet) var(--ease-out) both; animation-delay: calc(var(--i, 0) * var(--stagger)); }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ===== Page transitions (cross-document View Transitions, progressive) ===== */
@view-transition { navigation: auto; }
::view-transition-old(main) { animation: vt-out var(--dur-exit) var(--ease-out) both; }
::view-transition-new(main) { animation: vt-in var(--dur-page) var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

/* ===== Responsive shell ===== */
/* Tablet: icon rail */
@media (max-width: 1099px) {
  .shell { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .side { padding: var(--space-3) var(--space-2); align-items: center; }
  .brandmark { padding: var(--space-2) 0 var(--space-4); }
  .brandmark img { height: 18px; }
  .brandmark span, .nav-group > summary, .nav-item .label, .side-foot div, .nav-item:not([data-rail]) { display: none; }
  .nav-group { display: contents; }
  .nav-item { width: 52px; height: 52px; padding: 0; justify-content: center; }
  .nav-item .count { position: absolute; top: 4px; inset-inline-end: 2px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; }
  .nav-item .live-dot { position: absolute; top: 8px; inset-inline-end: 10px; margin: 0; }
  .side-foot { border: 0; padding: var(--space-2) 0; }
  .top { padding: 0 var(--space-5); }
  .view { padding: var(--space-5) var(--space-5) var(--space-7); gap: var(--space-5); }
}
/* Phone: top bar + bottom tab bar */
@media (max-width: 767px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .top { height: 56px; padding: 0 var(--gutter-end) 0 var(--gutter); }
  .top .m-brand { display: flex; align-items: center; }
  .top .show-phone { display: inline-flex; }
  .top .crumb.show-phone { display: block; }
  .top .m-brand img { height: 20px; width: auto; }
  .top .hide-phone { display: none; }
  .view { padding: var(--space-4) var(--gutter-end) calc(var(--tabbar-h) + var(--space-7) + env(safe-area-inset-bottom)) var(--gutter); gap: var(--space-5); }
  .page-head h1 { font-size: 1.625rem; }
  .card { padding: var(--space-4); border-radius: var(--radius-lg); }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip > .stat { padding: var(--space-3) var(--space-4); }
  .stat-strip > .stat:nth-child(3) { border-inline-start: 0; }
  .stat-strip > .stat:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
  .stat .v { font-size: 1.75rem; }
  /* No truncation on the phone: titles and meta wrap instead of ending in an ellipsis */
  .row .t b, .row .t small { white-space: normal; text-wrap: pretty; }
  .lane { grid-template-columns: 1fr auto; gap: var(--space-2) var(--space-3); }
  .lane .track { grid-column: 1 / -1; grid-row: 2; }
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; inset: auto 0 0; z-index: var(--z-nav);
    padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
    background: var(--navy-900-a92); border-top: 1px solid var(--line-soft); backdrop-filter: blur(var(--blur-glass)); -webkit-backdrop-filter: blur(var(--blur-glass)); }
  .tabbar a { position: relative; display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 52px; border-radius: var(--radius-md);
    color: var(--text-dim); text-decoration: none; font: 600 11px/1 var(--font-body); }
  .tabbar a[aria-current="page"] { color: var(--text-strong); }
  .tabbar a[aria-current="page"] .icon { color: var(--ice-400); }
  .tabbar a .count { position: absolute; top: 2px; inset-inline-start: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-full);
    background: var(--state-needs); color: var(--state-needs-text); font: 700 11px/18px var(--font-body); text-align: center; }
  .toasts { bottom: calc(var(--tabbar-h) + var(--space-4) + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot::after, .track > b.live, .skeleton::after { animation: none; }
  .btn-primary::after { display: none; }
  dialog[open].modal, dialog[open].sheet { animation: fade var(--dur-fast) ease; }
  ::view-transition-new(main) { animation: fade var(--dur-fast) ease both; }
  ::view-transition-old(main) { animation: fade var(--dur-exit) ease both reverse; }
  a.card:hover, .card.linked:hover { transform: none; }
}
@keyframes fade { from { opacity: 0; } }
