/* Blanks: the legacy-name layer. Loaded on client, agency and team, before future.css (which loads LAST
   everywhere and holds the real values). Older CSS still says var(--ink), var(--surface) …; those names are
   aliased to --fx-* below, so every page draws from one set of values. The grain + cobalt wash stays only
   where app screens are shown. */
:root {
  color-scheme: light;
  --black: var(--fx-ink); --cobalt: var(--fx-cobalt); --cobalt-text: var(--fx-cobalt-deep); --cobalt-soft: var(--fx-cobalt-soft); --cobalt-line: rgba(201, 100, 66, 0.28);
  --ink: var(--fx-ink); --ink-2: var(--fx-ink-2); --ink-3: var(--fx-ink-3); --ink-4: var(--fx-ink-4);
  --bg: var(--fx-canvas); --side: var(--fx-card); --surface: var(--fx-card); --surface-2: var(--fx-window); --surface-3: var(--fx-sunk); --raised: var(--fx-sunk); --hover: var(--fx-sunk);
  --line: var(--fx-line); --line-2: var(--fx-line-2); --line-3: var(--fx-line-3); --grid: transparent;
  --primary: var(--fx-ink); --primary-hover: var(--fx-ink-hover); --primary-ink: #ffffff; --primary-soft: rgba(31, 30, 29, 0.06);
  /* the agency's brand colour (client.js / team.js set --accent, --accent-ink, --accent-text); cobalt when none */
  --accent: var(--fx-cobalt); --accent-ink: #ffffff; --accent-text: var(--fx-cobalt-deep);
  --accent-soft: color-mix(in srgb, var(--accent) 9%, #fff); --accent-line: color-mix(in srgb, var(--accent) 30%, transparent);
  --teal: var(--fx-cobalt); --teal-2: var(--fx-cobalt-deep); --teal-soft: var(--fx-cobalt-soft);
  /* status: the three dot colours + one error red; soft fills stay neutral (status = dots, never fills) */
  --good: var(--fx-live); --good-soft: var(--fx-sunk); --warn: var(--fx-wait); --warn-soft: var(--fx-sunk);
  --violet: var(--fx-cobalt-deep); --violet-soft: var(--fx-cobalt-soft);
  --bad: var(--fx-bad); --bad-soft: var(--fx-bad-soft);
  /* type, shape, depth, motion */
  --font: var(--fx-sans); --display: var(--fx-sans); --serif: var(--fx-sans); /* the old display serif is retired: only .fx-accent uses --fx-serif */ --mono: var(--fx-mono);
  --r: var(--fx-r-inner); --r-sm: var(--fx-r-inner); --r-lg: var(--fx-r-card);
  --card-radius: var(--fx-r-card); --card-shadow: var(--fx-shadow-card);
  --shadow-sm: var(--fx-shadow-hair); --shadow: var(--fx-shadow-card); --shadow-md: var(--fx-shadow-card); --shadow-lg: var(--fx-shadow-float);
  --ease: var(--fx-ease);
  --gap: 12px;
  /* the texture (cobalt gradient + grain), as a background value for the "screen" areas */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='linear' slope='3.4' intercept='-1.2'/%3E%3CfeFuncG type='linear' slope='3.4' intercept='-1.2'/%3E%3CfeFuncB type='linear' slope='3.4' intercept='-1.2'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  --cobalt-wash:
    radial-gradient(34% 44% at 92% 18%, #ffffff 0%, rgba(255, 255, 255, 0.85) 35%, rgba(255, 255, 255, 0) 75%),
    radial-gradient(46% 36% at 44% 14%, rgba(250, 241, 237, 0.95) 0%, rgba(250, 241, 237, 0) 75%),
    radial-gradient(40% 46% at 34% 70%, rgba(246, 229, 222, 0.9) 0%, rgba(246, 229, 222, 0) 75%),
    radial-gradient(38% 48% at 6% 20%, #b3532a 0%, rgba(179, 83, 42, 0.55) 40%, rgba(179, 83, 42, 0) 75%),
    radial-gradient(46% 54% at 94% 94%, #934423 0%, rgba(147, 68, 35, 0.55) 40%, rgba(147, 68, 35, 0) 75%),
    linear-gradient(135deg, #d77c55 0%, #e9b7a1 50%, #d37046 100%);
}
::selection { background: rgba(201, 100, 66, 0.22); color: inherit; }

/* ── page background: plain, everywhere ── */
/* (2026-11-20) the agency side now gets its world from future.css (porcelain + aurora); client and team stay plain. */
html, body.studio-body, body.team-body { background: var(--bg); }

/* the studio's cards: white, neutral shadow */
@media (min-width: 1024px) {
  body.studio-body #rail, body.studio-body #toolbar, body.studio-body #infoCard, body.studio-body #ideas,
  body.studio-body .make-card, body.studio-body .flow-bar:not(.hidden) { box-shadow: var(--fx-shadow-card); }
  body.studio-body .device { filter: drop-shadow(0 2px 3px rgba(31, 30, 29, 0.18)) drop-shadow(0 16px 26px rgba(31, 30, 29, 0.28)); }
  body .studio .tb.on, body .studio .stage.play .idea-chip.on { background: var(--cobalt-soft) !important; color: var(--ink); }
}

/* ── where app screens (phone mockups) are shown: the cobalt texture behind them ── */
body.studio-body .fh-stage, body.agency-body .pc-phone, body.agency-body .idea-phone {
  background: var(--grain) 0 0 / 220px 220px, var(--cobalt-wash) !important; background-blend-mode: overlay, normal !important;
}
body.studio-body .fh-phone { padding: 4px 4px 0; border-radius: 28px 28px 0 0; background: #111; box-shadow: 0 0 0 1.5px #d4d6da, 0 -6px 22px -14px rgba(0, 0, 0, 0.45); }
body.studio-body .fh-phone iframe { border-radius: 24px 24px 0 0; }

/* ── one card style ── */
.ds-card, body.agency-body .card, body.agency-body .filterbar, body.agency-body .clients-box, body.agency-body .settings-panel, body.agency-body .drop-page, body.agency-body .page-head {
  background: var(--surface); border: 0; border-radius: var(--card-radius); box-shadow: var(--card-shadow);
}
body.agency-body .filterbar, body.agency-body .clients-box, body.agency-body .settings-panel, body.agency-body .drop-page, body.agency-body .page-head { padding: 20px 22px; }
/* cards inside cards stay flat (no double shadow) */
body.agency-body .card .card, body.agency-body .settings-panel .card { box-shadow: 0 0 0 1px var(--line); }

/* ── agency app layout: white sidebar card + the page's cards on the grey background ── */
body.agency-body .shell { padding: var(--gap); gap: var(--gap); align-items: start; }
body.agency-body .side { top: var(--gap); height: calc(100vh - 2 * var(--gap)); border: 0; border-radius: 18px; background: var(--surface); box-shadow: var(--card-shadow); }
body.agency-body .main { background: transparent; box-shadow: none; border-radius: 0; }
/* phones and small tablets: the sidebar is a top bar (menu opens it), never a full-height card above the page (2026-11-18 fix) */
@media (max-width: 900px) { body.agency-body .side { height: auto; } }
body.agency-body .page { padding-top: 0; }
body.agency-body .page > * + * { margin-top: var(--gap); }
body.agency-body .page-head { margin-bottom: 0; }
body.agency-body .tabs { margin-top: var(--gap); padding: 0 12px; border-radius: 14px; background: var(--surface); box-shadow: var(--card-shadow); border-bottom: 0; }
body.agency-body .tabs a.on { border-bottom-color: var(--black); color: var(--ink); }
body.agency-body .auth { padding: var(--gap); gap: var(--gap); }

/* ── two colours: the last hard-coded greens, violets and oranges ── */
body.agency-body .g-setup { background: var(--ink-4); }
body.agency-body .g-wait, body.agency-body .g-wait2 { background: #e9b7a1; }
body.agency-body .g-active, body.agency-body .g-done { background: var(--cobalt); }
body.agency-body .g-review { background: var(--black) !important; }
body.agency-body .nav .count, body.agency-body .count-pill.on { background: var(--cobalt) !important; color: #fff !important; }

/* ── icons: thin lines, no boxes ── */
body.agency-body svg, body.team-body svg { stroke-width: 1.6; }
body.agency-body .empty > .ico, body.agency-body .card.soft > .ico, body.agency-body .kp-ico, body.agency-body .kp-ico.done {
  background: transparent !important; box-shadow: none !important; padding: 0 !important; border-radius: 0 !important; color: var(--ink-2);
}
body.studio-body .hw-nav svg, body.studio-body .hw-top svg, body.studio-body .hw-new svg, body.studio-body .hw-label svg { stroke-width: 1.6 !important; }

/* ── client Home: white sidebar card + flow cards on the grey background ── */
body.studio-body .lib { background: var(--bg); padding: var(--gap); place-items: stretch; }
body.studio-body .lib .hw { height: calc(100dvh - 2 * var(--gap)); gap: var(--gap); background: transparent; box-shadow: none; border-radius: 0; }
body.studio-body .lib .hw-side { border-radius: var(--fx-r-card); background: var(--surface); box-shadow: var(--card-shadow); border: 0; }
body.studio-body .lib .hw-main { padding: 28px 20px 20px; }
body.studio-body .lib .flow-hero { border-radius: var(--card-radius); box-shadow: var(--card-shadow); background: var(--surface); }
body.studio-body .lib .hw-new, body.studio-body .lib .hw-nav button.on { background: var(--cobalt-soft) !important; color: var(--ink); }
body.studio-body .lib .hw-n { color: var(--ink-3); }
body.studio-body .welcome { background: var(--surface); border-radius: 20px; box-shadow: var(--card-shadow); margin: var(--gap); min-height: calc(100dvh - 2 * var(--gap)); }

/* ── team page: header card + page card ── */
body.team-body .t-top { margin: var(--gap); border-radius: var(--fx-r-card); background: var(--surface); box-shadow: var(--card-shadow); }
body.team-body .t-main { margin: 0 auto var(--gap); border-radius: 20px; background: var(--surface); box-shadow: var(--card-shadow); width: min(1120px, calc(100% - 2 * var(--gap))); }

/* agency previews: every client tile's phone area (all statuses) and the "needs you" phones sit on
   the cobalt texture; no per-status pastels, no orange/red card edges */
body.agency-body .cc-stage, body.agency-body .cc-stage[class*="bg-"] {
  background: var(--grain) 0 0 / 220px 220px, var(--cobalt-wash) !important; background-blend-mode: overlay, normal !important; border-bottom: 0;
}

/* last peach leftovers → neutral / cobalt */
body.studio-body .ifc-chip { background: var(--surface-3) !important; color: var(--ink-2) !important; box-shadow: none !important; }
body.studio-body .msg.client .bubble, body.studio-body .bubble.client { background: var(--surface-3); }

/* fixes after the screen tour (2026-11-15): */
/* 1. sign-in pitch: a deeper cobalt (no white haze) so the white text always reads */
/* 2. wrappers whose children are already cards stay flat (no card in a card) */
body.agency-body .settings-panel { background: transparent !important; box-shadow: none !important; padding: 0 !important; }
body.agency-body .settings-panel > * + * { margin-top: var(--gap); }
body.agency-body .settings-panel .card, body.agency-body .settings-panel > section { box-shadow: var(--card-shadow) !important; }

/* AI test results: status is a dot (live / wait / stalled / the error red), never a coloured fill. */
.tag.res { height: 24px; padding: 0 10px; font-weight: 500; background: var(--fx-card); color: var(--fx-ink-2); box-shadow: 0 0 0 1px var(--fx-line-2); }
.tag.res::before { content: ''; width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--fx-stalled); }
.tag.res-ok::before { background: var(--fx-live); }
.tag.res-bad { color: var(--fx-ink); } .tag.res-bad::before { background: var(--fx-bad); }
.tag.res-unsure::before { background: var(--fx-wait); }
.tag.res-off { color: var(--fx-ink-3); }
.tag.res .ico { display: none; }

/* ════ 2026-11-20 restructure (audit SCREENS.md §3–4) ════ */
body.agency-body .page-head h1 { font-weight: 600; letter-spacing: -0.02em; }

/* client workspace: four tabs + one slim "where it stands" strip */
.phases.slim li { gap: 6px; font-size: 12px; }
.phases.slim li i { width: 20px; height: 20px; }
.phases.slim li i .ico { width: 11px; height: 11px; }
.phases.slim li::before { top: 9px; }
.phases.slim li.on i { box-shadow: 0 0 0 4px var(--primary-soft); }

/* Their app: the board */

/* one idea: before → after */
.idea-detail-in { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: start; }
.ba { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: 16px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.ba figure { margin: 0; display: grid; gap: 8px; justify-items: center; }
.ba figcaption { font-size: 12px; font-weight: 600; color: var(--ink); }
.ba figure.after .phone { box-shadow: 0 0 0 2px var(--cobalt), 0 18px 34px -20px rgba(31, 30, 29, 0.35); }
.ba-arrow { color: var(--ink-3); }
.ba-arrow .ico { width: 18px; height: 18px; }
.idea-detail-text { display: grid; gap: 12px; align-content: start; justify-items: start; min-width: 0; }
.idea-detail-text h3 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.idea-detail-text .eyebrow { margin: 0; }
.flags.strong li { padding: 10px 12px; border-radius: var(--fx-r-inner); background: var(--cobalt-soft); }
.flags.strong li .ico { color: var(--cobalt-text); }
.idea-detail-text ol.changes { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: 14px; }
.idea-detail-text ol.changes li span { display: block; }
.idea-detail-text ol.changes small { font-size: 12px; }

/* the base app's controls + the limit */

/* proposals: each idea as before → after */
.prop-idea { flex: 0 0 auto !important; max-width: 380px; }
.prop-idea.flagged { box-shadow: inset 0 0 0 1.5px var(--cobalt) !important; }
.prop-ba { display: flex; align-items: center; gap: 8px; justify-self: center; }
.pba { display: grid; justify-items: center; gap: 4px; }
.pba small { font-size: 12px; font-weight: 600; }
.prop-flagband { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--cobalt-text); background: var(--cobalt-soft); }
.prop-flagband .ico { width: 12px; height: 12px; }

/* conversation: one timeline */

/* project: one place for everything about it */
.link-row { gap: 8px; }
.link-row input { flex: 1; min-width: 0; }
.dec { display: grid; gap: 8px; align-content: start; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.dec p { color: var(--ink-2); }

@media (max-width: 1100px) {
  .idea-detail-in { grid-template-columns: 1fr; }
  .ba { justify-content: center; }
}
@media (max-width: 759px) {
  .phases.slim li span { font-size: 12px; line-height: 1.2; }
  .ba { padding: 12px; gap: 8px; }
  .link-row { flex-wrap: wrap; }
  .link-row input { flex-basis: 100%; }
  .prop-idea { max-width: 100%; }
}
.phases.slim { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.phases.slim li span { overflow-wrap: anywhere; }

/* Home "needs you": the actual changed screen (before → after for a change) */

/* ── client studio (2026-11-20): the mic is a plain line-icon pill, Select is labelled, the title reads ── */
.talk-ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.pt-svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
body.studio-body .talk-btn .orb { display: none !important; }
body.studio-body .talk-btn { padding: 0 16px 0 13px !important; gap: 7px; background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
body.studio-body .talk-btn[data-phase="listening"], body.studio-body .talk-btn[data-phase="speaking"] { background: var(--black); color: #fff; box-shadow: 0 0 0 4px var(--cobalt-soft); animation: talk-live 1.4s ease-in-out infinite; }
@keyframes talk-live { 50% { box-shadow: 0 0 0 7px var(--cobalt-soft); } }
body.studio-body .point-btn.on { background: var(--black); color: #fff; box-shadow: 0 0 0 4px var(--cobalt-soft); }
body.studio-body .proj { font: 600 15px/1.2 var(--fx-sans); color: var(--ink); letter-spacing: -0.01em; }
body.studio-body .ifc-name h2, body.studio-body .stage-title { font-weight: 600; color: var(--ink); }

/* Select: the hint sits where the toolbar / top bar is, never on the phone's notch */
body.studio-body .studio .point-banner { position: fixed; top: 10px; left: 50%; z-index: 60; transform: translateX(-50%); max-width: calc(100vw - 24px); white-space: normal; animation: none; }
body.studio-body .studio:has(#pointBanner:not(.hidden)) #toolbar { visibility: hidden; }
/* below 1024 there is no floating toolbar: the hint sits under the top bar, never on its controls */
@media (max-width: 1023px) { body.studio-body .studio .point-banner { top: 74px; } body.studio-body.is-preview .studio .point-banner { top: 110px; } }
@media (max-width: 759px) { body.studio-body.is-preview .studio .point-banner { top: 96px; } }

/* phone: Talk + Select as labelled pills in one row above a full-width typing bar */
@media (max-width: 759px) {
  body.studio-body .voicebar[data-phase="idle"] .talk-btn, body.studio-body .voicebar[data-phase="working"] .talk-btn { grid-column: 1; grid-row: 4; width: auto; height: var(--fx-h); padding: 0 14px 0 11px !important; justify-content: center; }
  body.studio-body .voicebar[data-phase="idle"] .talk-label, body.studio-body .voicebar[data-phase="working"] .talk-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  body.studio-body .voicebar[data-phase="idle"] .point-btn, body.studio-body .voicebar[data-phase="working"] .point-btn { grid-column: 2; grid-row: 4; }
  body.studio-body .point-btn { width: auto; height: var(--fx-h); padding: 0 14px 0 11px; gap: 7px; }
  body.studio-body .point-btn .point-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  body.studio-body .composer { grid-template-columns: auto auto minmax(0, 1fr); row-gap: 8px; }
  body.studio-body .typebar, body.studio-body .composer:not(:has(.point-btn:not(.hidden))) .typebar { grid-column: 1 / -1; grid-row: 5; }
  body.studio-body .studio .point-banner { top: 60px; font-size: 13px; }
  /* the open chat sheet: a clear edge under its header, so scrolled messages read as scrolled, not covered */
  body.studio-body .rail:not(.collapsed) .rail-head { border-bottom: 1px solid var(--line); background: var(--surface); }
  body.studio-body .rail:not(.collapsed) .msgs { padding-top: 16px; -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 18px); mask-image: linear-gradient(180deg, transparent 0, #000 18px); }
}

/* client Home: the flow cards are mostly the app screen (no empty top half); the sidebar no longer repeats the flows */
body.studio-body .lib .flow-hero { height: 360px; padding: 18px 18px 0; }
body.studio-body .lib .fh-title { font: 600 18px/1.25 var(--fx-sans); letter-spacing: -0.01em; -webkit-line-clamp: 1; max-width: 100%; }
body.studio-body .lib .fh-desc { margin-top: 4px; -webkit-line-clamp: 1; }
body.studio-body .lib .fh-pill { margin-top: 10px; height: 32px; }
body.studio-body .lib .fh-go { height: var(--fx-h-sm); }
body.studio-body .lib .fh-stage { top: 112px; height: auto; }
body.studio-body .lib .fh-phone { width: 214px; height: 330px; margin-top: 16px; }
body.studio-body .lib .fh-phone iframe { transform: scale(0.518); }
body.studio-body .hw-label[data-sec="flows"], body.studio-body #hwFlows { display: none !important; }
body.studio-body .hw-top b { font-family: var(--fx-sans); font-weight: 600; letter-spacing: -0.02em; }
@media (max-width: 900px) { body.studio-body .lib .flow-hero { height: 320px; } body.studio-body .lib .fh-phone { width: 190px; } body.studio-body .lib .fh-phone iframe { transform: scale(0.456); } }
body.studio-body .studio .point-banner { left: 0; right: 0; margin: 0 auto; width: max-content; transform: none; }

/* Empty Home on phone: the three sample phones must not push the page sideways (2026-11-20). */
@media (max-width: 600px) { .first-run { min-width: 0; max-width: 100%; overflow: hidden; }  }
