/* Knew It Then Studio. Mobile first: phones get a bottom tab bar, tablets an icon rail, desktops a full sidebar. */

/* ---------- design tokens ---------- */

:root {
  color-scheme: light;
  --bg: #faf6ee;
  --surface: #ffffff;
  --surface-2: #f6f1e6;
  --surface-3: #ede5d3;
  --ink: #17151f;
  --ink-2: #5d5866;
  --ink-3: #8b8693;
  --line: #ebe4d5;
  --line-strong: #d8cfbb;
  --accent: #ffb703;
  --accent-strong: #e08600;
  --accent-ink: #2a1c00;
  --accent-soft: #fff1c9;
  --good: #1d8443; --good-soft: #e5f4ea;
  --bad: #c0262d; --bad-soft: #fdecec;
  --info: #21679a; --info-soft: #e6f0f8;
  --warn: #8f5500; --warn-soft: #fff1d1;
  --violet: #5848a8; --violet-soft: #eeebf8;
  /* Sidebar: light in light mode, near-black in dark mode. */
  --nav-bg: #ffffff;
  --nav-line: var(--line);
  --nav-ink: #5d5866;
  --nav-ink-strong: #17151f;
  --nav-muted: #8b8693;
  --nav-hover: rgb(23 21 31 / 5%);
  --nav-active-bg: var(--accent-soft);
  --nav-active-ink: #8a5200;
  --overlay: rgb(23 21 31 / 45%);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgb(23 21 31 / 5%), 0 1px 1px rgb(23 21 31 / 3%);
  --shadow-2: 0 2px 6px rgb(23 21 31 / 6%), 0 10px 28px rgb(23 21 31 / 7%);
  --shadow-3: 0 12px 40px rgb(23 21 31 / 18%);
  --gap: 1rem;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);

  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* Dark mode: theme.js sets data-theme from the saved choice, or from the device when it is "Auto". */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131118;
  --surface: #1c1a23;
  --surface-2: #23202b;
  --surface-3: #2c2935;
  --ink: #f2efe9;
  --ink-2: #b4afbd;
  --ink-3: #8a8594;
  --line: #2d2a36;
  --line-strong: #3e3a48;
  --accent-ink: #1d1400;
  --accent-soft: rgb(255 183 3 / 14%);
  --good: #5cc785; --good-soft: rgb(92 199 133 / 14%);
  --bad: #ff7a7a; --bad-soft: rgb(255 122 122 / 13%);
  --info: #74b9ec; --info-soft: rgb(116 185 236 / 13%);
  --warn: #f5b84d; --warn-soft: rgb(245 184 77 / 13%);
  --violet: #a99cf2; --violet-soft: rgb(169 156 242 / 14%);
  --nav-bg: #0e0c12;
  --nav-line: rgb(255 255 255 / 8%);
  --nav-ink: #c8c4d2;
  --nav-ink-strong: #ffffff;
  --nav-muted: rgb(255 255 255 / 45%);
  --nav-hover: rgb(255 255 255 / 7%);
  --nav-active-bg: rgb(255 183 3 / 15%);
  --nav-active-ink: var(--accent);
  --overlay: rgb(0 0 0 / 60%);
  --shadow-1: 0 1px 2px rgb(0 0 0 / 30%);
  --shadow-2: 0 2px 8px rgb(0 0 0 / 30%), 0 10px 30px rgb(0 0 0 / 25%);
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 1rem; }
body { margin: 0; min-height: 100dvh; background: var(--bg); }
img, video, svg { max-width: 100%; }
a { color: var(--info); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5rem; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.85rem); font-weight: 760; letter-spacing: -0.025em; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 0.98rem; font-weight: 700; }
p { line-height: 1.55; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 5px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
.muted { color: var(--ink-2); }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--ink); }
html { caret-color: var(--accent-strong); scrollbar-color: var(--line-strong) transparent; accent-color: var(--accent-strong); }
::placeholder { color: var(--ink-2); opacity: 0.75; }
.input, .textarea, .table, .stat__value, .stats { font-variant-numeric: tabular-nums; }
.small { font-size: 0.86rem; }
.hidden, [hidden] { display: none !important; }
.text-bad { color: var(--bad); font-weight: 700; }
.text-good { color: var(--good); font-weight: 700; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code, .alert, .comment__text { overflow-wrap: anywhere; }

.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; border-radius: 6px; }

.skip-link { position: absolute; left: 1rem; top: -3rem; z-index: 50; background: var(--ink); color: var(--bg); padding: 0.6rem 1rem; border-radius: var(--r-sm); transition: top 0.15s; }
.skip-link:focus { top: 1rem; }

/* ---------- buttons and forms ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 42px; padding: 0.55rem 1.1rem;
  border: 1px solid transparent; border-radius: var(--r-pill);
  font: inherit; font-size: 0.95rem; font-weight: 650; line-height: 1.2; white-space: nowrap;
  background: var(--ink); color: var(--bg); cursor: pointer; text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, transform 0.08s var(--ease), opacity 0.15s;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn .icon { width: 1.1rem; height: 1.1rem; }
.btn--accent { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 0 var(--accent-strong); }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover { background: var(--surface-2); filter: none; }
.btn--danger { background: var(--surface); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn--danger:hover { background: var(--bad-soft); filter: none; }
.btn--small { min-height: 34px; padding: 0.35rem 0.85rem; font-size: 0.86rem; }
.btn--block { width: 100%; }

.field { display: grid; gap: 0.35rem; margin-bottom: 1rem; min-width: 0; }
.field label, fieldset.field legend { font-weight: 620; font-size: 0.9rem; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; font: inherit; font-size: 16px; color: inherit;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  padding: 0.6rem 0.8rem; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--surface-2); color: var(--ink-2); cursor: not-allowed; }
.input--auto { width: auto; }
.select { appearance: none; padding-right: 2.2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8693' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 1rem; }
.select--small { width: auto; min-height: 36px; padding: 0.3rem 2rem 0.3rem 0.6rem; font-size: 0.88rem; background-position: right 0.5rem center; }
.textarea { min-height: 7rem; resize: vertical; line-height: 1.5; }
.check { display: flex; gap: 0.65rem; align-items: flex-start; margin-bottom: 0.9rem; cursor: pointer; }
.check input { margin-top: 0.2rem; width: 1.15rem; height: 1.15rem; flex: none; accent-color: var(--accent-strong); }
fieldset.field { border: 0; padding: 0; margin: 0 0 1rem; }
fieldset.field legend { margin-bottom: 0.4rem; padding: 0; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent-strong); }

.alert { border-radius: var(--r-md); padding: 0.75rem 0.95rem; font-size: 0.92rem; border: 1px solid transparent; }
.alert a { color: inherit; font-weight: 650; }
.alert--error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 20%, transparent); }
.alert--ok { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 20%, transparent); }
.alert--info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 20%, transparent); }
.card > .alert, .field + .alert { margin-bottom: 1rem; }

/* ---------- app shell ---------- */

.shell { min-height: 100dvh; }
.view { display: block; width: 100%; max-width: 1280px; margin: 0 auto; padding: calc(1rem + env(safe-area-inset-top, 0px)) 1rem calc(var(--tabbar-h) + var(--safe-b) + 2rem); min-width: 0; outline: none; }
.view > * { margin-top: 0; margin-bottom: 0; }
.view > * + * { margin-top: var(--gap); }
.view > .page__head + * { margin-top: 1.25rem; }
.view > h2 { margin-top: 2rem; }

.sidebar { display: none; }

.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 1.05rem; color: inherit; text-decoration: none; letter-spacing: -0.01em; }
.brand__mark { width: 28px; height: 28px; flex: none; }
.brand__text { display: grid; line-height: 1.1; }
.brand__text small { font-weight: 600; font-size: 0.75rem; color: var(--nav-muted); letter-spacing: 0.04em; text-transform: uppercase; }
.brand__dot { width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); box-shadow: inset 0 -4px 0 var(--accent-strong); }

.nav__badge { margin-left: auto; min-width: 1.35rem; height: 1.35rem; padding: 0 0.4rem; display: inline-grid; place-items: center; border-radius: var(--r-pill); background: var(--accent); color: var(--accent-ink); font-size: 0.72rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.nav__dot { position: absolute; top: 8px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--accent-strong); box-shadow: 0 0 0 2px var(--surface); }

/* Phone: bottom tab bar */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar__item {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; font: inherit; font-size: 0.7rem; font-weight: 600; color: var(--ink-2);
  text-decoration: none; cursor: pointer; touch-action: manipulation;
}
.tabbar__item .icon { width: 1.4rem; height: 1.4rem; }
.tabbar__item[aria-current="page"] { color: var(--ink); }
.tabbar__item[aria-current="page"] .icon { stroke-width: 2.3; color: var(--accent-strong); }
.tabbar__item .nav__badge { position: absolute; top: 5px; left: calc(50% + 4px); margin: 0; height: 1.15rem; min-width: 1.15rem; font-size: 0.66rem; box-shadow: 0 0 0 2px var(--surface); }
.tabbar__fab { display: grid; place-items: center; width: 46px; height: 34px; border-radius: var(--r-pill); background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 0 var(--accent-strong); }
.tabbar__fab .icon { stroke-width: 2.4; }
.tabbar__item--create[aria-current="page"] .icon { color: var(--accent-ink); }

/* Phone: "More" bottom sheet */
.sheet {
  margin: auto auto 0; width: 100%; max-width: 560px; max-height: 85dvh; padding: 0.5rem 1rem calc(1rem + var(--safe-b));
  border: 0; border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3);
}
.sheet[open] { animation: sheet-up 0.28s var(--ease); }
.sheet::backdrop { background: var(--overlay); animation: fade-in 0.2s ease; }
.sheet__handle { width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 0.25rem auto 1rem; }
.sheet__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.sheet__item {
  position: relative; display: grid; justify-items: center; gap: 0.4rem; padding: 0.9rem 0.25rem;
  border-radius: var(--r-lg); background: var(--surface-2); color: var(--ink); text-decoration: none; font-size: 0.85rem; font-weight: 600;
}
.sheet__item .icon { width: 1.5rem; height: 1.5rem; color: var(--ink-2); }
.sheet__item[aria-current="page"] { background: var(--accent-soft); }
.sheet__item[aria-current="page"] .icon { color: var(--accent-strong); }
.sheet__item .nav__badge { position: absolute; top: 0.5rem; right: 0.5rem; }
.sheet__footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 0.86rem; color: var(--ink-2); }

@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade-in { from { opacity: 0; } }

/* Tablet: icon rail. Desktop: full sidebar. */
@media (min-width: 821px) {
  .tabbar, .sheet { display: none; }
  .shell { display: grid; grid-template-columns: 76px minmax(0, 1fr); }
  .view { padding: 1.75rem 1.75rem 3rem; }
  .sidebar {
    position: sticky; top: 0; height: 100dvh; overflow-y: auto; overscroll-behavior: contain;
    display: flex; flex-direction: column; gap: 0.25rem; padding: 1rem 0.6rem;
    background: var(--nav-bg); color: var(--nav-ink-strong); scrollbar-width: thin; border-right: 1px solid var(--nav-line);
  }
  .sidebar .brand { justify-content: center; padding: 0.25rem 0 0.75rem; }
  .brand__text, .nav__group, .whoami { display: none; }
  /* Labels stay readable by screen readers while the rail shows icons only. */
  .nav__link span:not(.nav__badge), .sidebar__cta span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .sidebar__cta { min-height: 44px; padding: 0; margin-bottom: 0.5rem; border-radius: var(--r-md); }
  .nav { display: grid; gap: 2px; }
  .nav__link {
    position: relative; display: flex; align-items: center; gap: 0.75rem; justify-content: center;
    min-height: 44px; padding: 0.55rem; border: 0; border-radius: var(--r-md); background: none; width: 100%;
    color: var(--nav-ink); font: inherit; font-size: 0.93rem; font-weight: 550; text-decoration: none; cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
  }
  .nav__link:hover { background: var(--nav-hover); color: var(--nav-ink-strong); }
  .nav__link[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active-ink); }
  .nav__link .nav__badge { position: absolute; top: 3px; right: 3px; height: 1.1rem; min-width: 1.1rem; font-size: 0.65rem; }
  .sidebar__footer { margin-top: auto; padding-top: 0.75rem; border-top: 1px solid var(--nav-line); display: grid; gap: 0.25rem; }
  .nav__group { margin: 1rem 0.75rem 0.3rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--nav-muted); }
}

@media (min-width: 1101px) {
  .shell { grid-template-columns: 248px minmax(0, 1fr); }
  .view { padding: 2rem 2.5rem 4rem; }
  .sidebar { padding: 1.25rem 0.9rem; }
  .sidebar .brand { justify-content: flex-start; padding: 0.25rem 0.5rem 1rem; }
  .nav__group { display: block; }
  .nav__link span:not(.nav__badge), .sidebar__cta span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .brand__text { display: grid; }
  .whoami { display: block; padding: 0 0.6rem 0.25rem; font-size: 0.8rem; color: var(--nav-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar__cta { padding: 0 1rem; }
  .nav__link { justify-content: flex-start; padding: 0.55rem 0.75rem; }
  .nav__link .nav__badge { position: static; height: 1.35rem; min-width: 1.35rem; font-size: 0.72rem; }
}

/* ---------- page header ---------- */

.page__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 0.75rem 1rem; flex-wrap: wrap; }
.page__head h1 { margin: 0; }
.page__head .actions { margin: 0; }
.page__sub { margin: 0.25rem 0 0; color: var(--ink-2); font-size: 0.95rem; }
.back { display: inline-flex; align-items: center; gap: 0.25rem; margin-bottom: 0.35rem; color: var(--ink-2); text-decoration: none; font-size: 0.88rem; font-weight: 600; }
.back:hover { color: var(--ink); }

/* Jump links for long pages (Settings) */
.section-nav { position: sticky; top: 0; z-index: 5; display: flex; gap: 0.4rem; overflow-x: auto; scrollbar-width: none; margin-inline: -1rem; padding: 0.6rem 1rem; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.section-nav::-webkit-scrollbar { display: none; }
@media (min-width: 821px) { .section-nav { margin-inline: 0; padding-inline: 0; } }

/* ---------- cards, stats, grids ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); padding: 1.15rem; min-width: 0; }
.card > h2:first-child, .card > .coach__head:first-child h2 { margin-bottom: 0.75rem; }
.card > :last-child { margin-bottom: 0; }
.card + .card, .card + .split, .split + .card, .split + .split, .card + section, section + .card { margin-top: var(--gap); }
.card--narrow { max-width: 760px; }
.card--link { display: block; color: inherit; text-decoration: none; transition: border-color 0.15s, transform 0.15s var(--ease), box-shadow 0.15s; }
.card--link:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
@media (min-width: 600px) { .card { padding: 1.35rem; } }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--gap); } }
.stats .card { padding: 1rem; }
.stat__value { font-size: 1.6rem; font-weight: 780; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; overflow-wrap: anywhere; }
.stat__value small { font-size: 0.85rem; }
.stat__label { color: var(--ink-2); font-size: 0.84rem; margin-top: 0.2rem; line-height: 1.35; }
.big { font-size: 1.6rem; font-weight: 780; letter-spacing: -0.02em; margin: 0 0 0.25rem; font-variant-numeric: tabular-nums; }

.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: var(--gap); align-items: start; }

/* "Needs you" strip on the overview */
.attention { display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.attention__item { display: flex; align-items: center; gap: 0.85rem; padding: 0.9rem 1rem; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); color: inherit; text-decoration: none; box-shadow: var(--shadow-1); transition: box-shadow 0.15s, border-color 0.15s; }
.attention__item:hover { box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.attention__icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: var(--r-md); background: var(--surface-2); color: var(--ink-2); flex: none; }
.attention__item--hot { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft)), var(--surface); }
.attention__item--hot .attention__icon { background: var(--accent); color: var(--accent-ink); }
.attention__count { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.attention__label { font-size: 0.86rem; color: var(--ink-2); }
.attention__go { margin-left: auto; color: var(--ink-3); }

/* Chips and segmented controls scroll sideways on phones instead of wrapping into tall blocks */
.filters { display: flex; gap: 0.45rem; overflow-x: auto; scrollbar-width: none; margin-inline: -1rem; padding: 0.1rem 1rem; scroll-snap-type: x proximity; }
.filters::-webkit-scrollbar { display: none; }
@media (min-width: 821px) { .filters { flex-wrap: wrap; margin-inline: 0; padding-inline: 0; overflow: visible; } }
.chip { flex: none; scroll-snap-align: start; display: inline-flex; align-items: center; min-height: 36px; padding: 0.35rem 0.9rem; border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--surface); color: var(--ink); font: inherit; font-size: 0.86rem; font-weight: 550; text-decoration: none; text-transform: capitalize; cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--surface-2); }
.chip--active, .chip[aria-current="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.segmented { display: inline-flex; gap: 2px; padding: 3px; max-width: 100%; overflow-x: auto; scrollbar-width: none; background: var(--surface-3); border-radius: var(--r-md); }
.segmented::-webkit-scrollbar { display: none; }
.segmented a { flex: none; padding: 0.35rem 0.75rem; border-radius: 9px; font-size: 0.85rem; font-weight: 550; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.segmented a:hover { color: var(--ink); }
.segmented a.is-active { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: var(--shadow-1); }

/* Video grid */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--gap); } }
.post { display: flex; flex-direction: column; overflow: hidden; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); color: inherit; text-decoration: none; transition: transform 0.2s var(--ease), box-shadow 0.2s; }
.post:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.post__thumb { position: relative; aspect-ratio: 9 / 16; background: var(--surface-3); display: grid; place-items: center; color: var(--ink-2); font-size: 0.85rem; overflow: hidden; }
.post__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.post__thumb .badge { position: absolute; top: 0.5rem; left: 0.5rem; box-shadow: var(--shadow-1); }
.post__body { padding: 0.7rem 0.8rem 0.85rem; display: grid; gap: 0.3rem; }
.post__title { font-weight: 680; font-size: 0.93rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post__meta { font-size: 0.78rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Status badges */
.badge { display: inline-flex; align-items: center; gap: 0.35rem; border-radius: var(--r-pill); padding: 0.18rem 0.6rem; font-size: 0.74rem; font-weight: 700; line-height: 1.3; text-transform: capitalize; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.badge[class*="badge--"]::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--planned { background: var(--violet-soft); color: var(--violet); }
.badge--rendering, .badge--publishing, .badge--running, .badge--queued { background: var(--info-soft); color: var(--info); }
.badge--rendering::before, .badge--publishing::before, .badge--running::before, .badge--queued::before { animation: pulse 1.4s ease-in-out infinite; }
.badge--ready { background: var(--warn-soft); color: var(--warn); }
.badge--approved { background: var(--info-soft); color: var(--info); }
.badge--published, .badge--done { background: var(--good-soft); color: var(--good); }
.badge--rejected { background: var(--surface-3); color: var(--ink-2); }
.badge--failed { background: var(--bad-soft); color: var(--bad); }
@keyframes pulse { 50% { opacity: 0.3; } }

.platforms { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.platform { display: inline-flex; align-items: center; gap: 0.45rem; border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r-pill); padding: 0.3rem 0.75rem; font-size: 0.84rem; font-weight: 550; text-transform: capitalize; }
.platform__dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--line-strong); }
.platform--on .platform__dot { background: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--ink-2); }

/* ---------- post page ---------- */

/* minmax(0, 1fr) + min-width: 0 stop a wide table or long link from stretching the column past the screen. */
.detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.detail > * { min-width: 0; }
.detail .card, .detail summary, .detail p { overflow-wrap: anywhere; }
@media (min-width: 900px) { .detail { grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: 1.75rem; } .detail__media { position: sticky; top: 1.5rem; } }
.detail video, .detail .post__thumb { display: block; width: 100%; border-radius: var(--r-lg); background: #000; }
@media (max-width: 899px) { .detail video, .detail .post__thumb { width: auto; max-width: 100%; max-height: 64dvh; margin-inline: auto; aspect-ratio: 9 / 16; } }
.detail__meta { margin: 0.6rem 0 0; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin: 1rem 0 0; }
.publish-later { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* Sticky Approve / Reject bar on phones */
.action-bar { display: none; }
@media (max-width: 820px) {
  .action-bar {
    position: fixed; z-index: 15; left: 0.75rem; right: 0.75rem; bottom: calc(var(--tabbar-h) + var(--safe-b) + 0.6rem);
    display: flex; gap: 0.5rem; padding: 0.5rem; border-radius: var(--r-pill);
    background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow-3);
    animation: rise 0.3s var(--ease);
  }
  .action-bar .btn { flex: 1; }
  .action-bar .btn--accent { flex: 2; }
  .view:has(.action-bar) { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 6rem); }
}
@keyframes rise { from { transform: translateY(1rem); opacity: 0; } }

.scenes { display: grid; gap: 0.75rem; }
.scene { padding: 0.6rem 0.75rem; border-radius: var(--r-md); background: var(--surface-2); }
.scene__n { font-size: 0.75rem; font-weight: 700; color: var(--ink-2); }
details summary { cursor: pointer; font-weight: 620; margin: 0.25rem 0; list-style-position: outside; }
details.card > summary { margin: 0; }
pre.log { margin: 0; background: #14121a; color: #e6e3ee; padding: 1rem; border-radius: var(--r-md); overflow: auto; max-height: 65dvh; font-family: var(--mono); font-size: 0.78rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }

.cover-box { margin: 0.75rem 0 0; }
.cover-box summary { font-size: 0.9rem; }
.cover-preview { display: block; width: 100%; max-width: 280px; margin-top: 0.5rem; border-radius: var(--r-md); box-shadow: var(--shadow-1); }

/* ---------- tables ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.table th, .table td { text-align: left; padding: 0.65rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr[data-href] { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table-scroll, .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-inline: -0.25rem; }
.table-wrap .table { min-width: 720px; }

/* ---------- expenses and analytics ---------- */

.meter { height: 6px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; margin-top: 0.65rem; }
.meter span { display: block; height: 100%; background: var(--good); border-radius: inherit; transition: width 0.6s var(--ease); }
.meter--warn span { background: var(--accent-strong); }
.meter--over span { background: var(--bad); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 0.5rem; }
.bars__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.bars__col span { width: 100%; max-width: 28px; background: var(--accent); border-radius: 4px 4px 1px 1px; min-height: 2px; transition: background-color 0.15s; }
.bars__col:hover span { background: var(--accent-strong); }
.bars__col small { font-size: 0.62rem; color: var(--ink-3); margin-top: 0.25rem; font-variant-numeric: tabular-nums; }
.coach__head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.coach__head h2 { margin: 0; }
.coach h3 { margin: 1.1rem 0 0.4rem; }
.coach__headline { font-size: 1.1rem; font-weight: 700; margin: 0.25rem 0; }
.coach__list { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.55rem; }
.ideas { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.75rem; }
.idea { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.idea > div { min-width: 0; overflow-wrap: anywhere; }
.idea .actions { margin: 0; flex: none; }
.idea button { flex-shrink: 0; }
.idea--used > div { opacity: 0.55; }
.idea__seed { margin: 0.35rem 0 0.15rem; font-weight: 620; }
.ideas--queue { padding-left: 1.2rem; }
.ideas--queue .idea { padding-bottom: 0.75rem; border-bottom: 1px solid var(--line); }
.ideas--queue .idea:last-child { border-bottom: 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 1rem; margin: 0 0 0.75rem; font-size: 0.9rem; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.retention { margin: 0 0 0.5rem; }
.retention svg { width: 100%; height: 64px; display: block; background: var(--surface-2); border-radius: var(--r-sm); }
.retention__line { fill: none; stroke: var(--accent-strong); stroke-width: 2; vector-effect: non-scaling-stroke; }
.retention__area { fill: var(--accent); opacity: 0.18; stroke: none; }
.revenue-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; align-items: end; margin-bottom: 1rem; }
.revenue-form .field { margin: 0; }
@media (max-width: 600px) { .idea { flex-direction: column; } .idea .actions { flex: auto; } }

/* ---------- ideas and sayings ---------- */

.saying-inline { font-style: italic; margin: 0.2rem 0 0; }
.inline-form { display: grid; grid-template-columns: 2fr 1fr auto; gap: 0.75rem; align-items: end; margin: 1rem 0 0.5rem; }
.inline-form .field { margin: 0; min-width: 0; }
#own-saying-form { grid-template-columns: 1fr auto; }
.sayings { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.75rem; }
.saying { border: 1px solid var(--line); border-radius: var(--r-md); padding: 0.95rem 1rem; background: var(--surface); }
.saying__text { margin: 0 0 0.4rem; font-size: 1.1rem; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; letter-spacing: -0.01em; }
.saying__meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-bottom: 0.4rem; }
.saying .actions { gap: 0.4rem; margin-top: 0.6rem; }
@media (max-width: 600px) { .inline-form, #own-saying-form { grid-template-columns: 1fr; } }

/* ---------- comments ---------- */

.mode { display: flex; justify-content: space-between; gap: 1.25rem; flex-wrap: wrap; }
.mode > div:first-child { flex: 1 1 280px; }
.mode__options { display: grid; gap: 0.25rem; }
.comment { display: grid; gap: 0.65rem; }
.comment__head { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.comment__text { margin: 0; padding: 0.75rem 0.95rem; border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r-md); white-space: pre-wrap; }
.comment__reply { background: var(--good-soft); border-radius: var(--r-md); padding: 0.7rem 0.95rem; }
.comment__reply p { margin: 0.25rem 0 0; white-space: pre-wrap; }
.comment .textarea { min-height: 5rem; }
.comment .actions { margin: 0; }

/* ---------- characters, storyboard, quality ---------- */

.picker { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.picker__item { position: relative; display: grid; justify-items: center; gap: 0.35rem; width: 96px; cursor: pointer; font-size: 0.84rem; font-weight: 550; text-align: center; }
.picker__item img { width: 96px; height: 128px; object-fit: cover; border-radius: var(--r-md); border: 3px solid transparent; background: var(--surface-3); transition: border-color 0.15s, transform 0.15s var(--ease); }
.picker__item input { position: absolute; opacity: 0; pointer-events: none; }
.picker__item input:checked + img { border-color: var(--accent-strong); transform: scale(1.03); }
.picker__item input:focus-visible + img { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.characters { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: var(--gap); }
.character { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 1rem; align-items: start; }
.character__pic, .cast__pic { aspect-ratio: 3 / 4; background: var(--surface-3); border-radius: var(--r-md); overflow: hidden; display: grid; place-items: center; color: var(--ink-2); font-size: 0.8rem; text-align: center; }
.character__pic img, .cast__pic img, .sb-scene__pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.character .textarea { min-height: 7.5rem; }
.character .actions { margin-top: 0.5rem; }
.caption-color { margin: 0 0 0.5rem; }
.swatch { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 50%; margin-right: 0.35rem; vertical-align: -0.05rem; border: 1px solid rgb(0 0 0 / 0.2); }

.storyboard { margin-top: 2.25rem; }
.storyboard > * + * { margin-top: var(--gap); }
.storyboard .page__head { align-items: center; }
.tiers { display: grid; gap: 0.5rem; }
.tier { display: flex; gap: 0.65rem; align-items: flex-start; border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 0.7rem 0.85rem; cursor: pointer; transition: border-color 0.15s, background-color 0.15s; }
.tier span { display: grid; gap: 0.1rem; }
.tier small { color: var(--ink-2); }
.tier:has(input:checked) { border-color: var(--accent-strong); background: var(--accent-soft); }
.tier--over strong { color: var(--ink-2); }
.cast { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 0.9rem; margin-bottom: 1rem; }
.cast .textarea { min-height: 4.5rem; }
.sb-scene { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 1rem; padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
.sb-scene:first-child { padding-top: 0; }
.sb-scene:last-child { border-bottom: 0; padding-bottom: 0; }
.sb-scene__pic { position: relative; display: grid; place-items: center; aspect-ratio: 9 / 16; background: var(--surface-3); border-radius: var(--r-md); overflow: hidden; color: var(--ink-2); font-size: 0.8rem; }
a.sb-scene__pic::after, a.cast__pic::after {
  content: ""; position: absolute; right: 0.35rem; bottom: 0.35rem; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: rgb(0 0 0 / 55%) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7'/%3E%3C/svg%3E") center / 0.85rem no-repeat;
  opacity: 0; transition: opacity 0.15s;
}
@media (hover: none) { a.sb-scene__pic::after, a.cast__pic::after { opacity: 1; } }
a.sb-scene__pic:hover::after, a.cast__pic:hover::after { opacity: 1; }
a.cast__pic { position: relative; }
.sb-scene__fields { min-width: 0; }
.sb-scene__head { display: flex; gap: 0.5rem 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.6rem; }
.sb-scene__head .check { margin: 0; align-items: center; }
.sb-scene__head .check input { margin: 0; }
.sb-scene .textarea { min-height: 3.6rem; }
.lines { display: grid; gap: 0.45rem; margin-bottom: 0.5rem; }
.line { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 0.4rem; align-items: center; }
.line > * { min-width: 0; }
[data-add-line] { justify-self: start; }
@media (max-width: 600px) {
  .character, .cast { grid-template-columns: 84px minmax(0, 1fr); gap: 0.75rem; }
  .sb-scene { grid-template-columns: 72px minmax(0, 1fr); gap: 0.75rem; }
  .line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .line .select--small { width: 100%; }
  .line .input { grid-column: 1 / -1; grid-row: 2; }
  .line:not(:has([data-remove-line])) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

.ig-status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.75rem 0; font-size: 0.9rem; }

/* ---------- loading skeleton, toast, confirm ---------- */

.skeleton { display: grid; gap: var(--gap); }
.skeleton__bar, .skeleton__card { border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%) 0 0 / 200% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton__bar { height: 2rem; width: 45%; border-radius: var(--r-sm); }
.skeleton__row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--gap); }
.skeleton__card { height: 96px; }
.skeleton__card--tall { height: 260px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 1rem); transform: translateX(-50%);
  max-width: min(92vw, 480px); width: max-content; padding: 0.75rem 1.15rem; border-radius: var(--r-pill);
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-3); font-size: 0.92rem; font-weight: 550; text-align: center;
  animation: toast-in 0.25s var(--ease);
}
.view:has(.action-bar) ~ .toast, body:has(.action-bar) .toast { bottom: calc(var(--tabbar-h) + var(--safe-b) + 5.25rem); }
@media (min-width: 821px) { .toast, body:has(.action-bar) .toast { bottom: 1.5rem; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 0.5rem); } }

.confirm { border: 1px solid var(--line); border-radius: var(--r-xl); padding: 1.35rem; max-width: 26rem; width: calc(100% - 2rem); box-shadow: var(--shadow-3); background: var(--surface); color: var(--ink); }
.confirm[open] { animation: pop 0.2s var(--ease); }
.confirm::backdrop { background: var(--overlay); }
.confirm__text { margin: 0 0 1.1rem; line-height: 1.5; }
.confirm__actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }

/* ---------- public pages (sign in, legal) ---------- */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(circle at 50% 0%, var(--accent-soft), transparent 60%), var(--bg); }
.auth__card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-2); padding: 2rem; }
.auth .brand { margin-bottom: 1.5rem; }
.legal { max-width: 720px; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.legal h2 { margin-top: 1.75rem; }
.legal ul, .legal ol { line-height: 1.6; padding-left: 1.25rem; }
.legal__nav { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

/* ---------- touch and motion ---------- */

@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn--small { min-height: 40px; }
  .chip, .segmented a { min-height: 40px; display: inline-flex; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- settings ---------- */

.page__head--section { margin-top: 2rem; align-items: center; }
.page__head--section h2 { margin: 0; }
.details-body { margin-top: 1rem; }
.settings-form h2:not(:first-child) { margin-top: 1.75rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.sticky-save { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 0.75rem); margin-top: 1.5rem; display: flex; justify-content: flex-end; pointer-events: none; }
.sticky-save .btn { pointer-events: auto; box-shadow: var(--shadow-2); }
@media (min-width: 821px) { .sticky-save { bottom: 1rem; } }
.view > .section-nav + * { margin-top: 0.75rem; }
.view > .card[id] { scroll-margin-top: 4rem; }

/* ---------- brand icons ---------- */

.icon--brand { fill: currentColor; stroke: none; }
.icon--facebook { color: #0866ff; }
.icon--instagram { color: #e1306c; }
.icon--youtube { color: #ff0000; }
.icon--tiktok { color: var(--ink); }
.badge--platform { gap: 0.3rem; background: var(--surface-2); color: var(--ink); }
.badge--platform .icon { width: 0.85rem; height: 0.85rem; }
.where { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.where .icon { width: 1rem; height: 1rem; }

/* ---------- overview performance ---------- */

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0 0 1.25rem; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--line); }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.kpi { background: var(--surface); padding: 0.85rem 0.95rem; min-width: 0; }
.kpis .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
@media (min-width: 640px) { .kpis .kpi:last-child:nth-child(odd) { grid-column: auto; } }
.kpi dt { display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; color: var(--ink-2); font-weight: 600; }
.kpi dt .icon { width: 0.95rem; height: 0.95rem; }
.kpi dd { margin: 0.3rem 0 0; font-size: 1.45rem; font-weight: 780; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap; }
.trend { font-size: 0.78rem; font-weight: 700; padding: 0.05rem 0.4rem; border-radius: var(--r-pill); letter-spacing: 0; }
.trend--up { color: var(--good); background: var(--good-soft); }
.trend--down { color: var(--bad); background: var(--bad-soft); }

.performance h3 { margin: 0 0 0.6rem; font-size: 0.9rem; color: var(--ink-2); font-weight: 650; }
.performance__grid { display: grid; gap: 1.25rem; }
@media (min-width: 900px) { .performance__grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 2rem; } }
.bars--compact { height: 120px; }

.platform-list { list-style: none; margin: 0; padding: 0; display: grid; }
.platform-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.75rem 1.25rem; align-items: center; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.platform-row:last-child { border-bottom: 0; }
.platform-row__name { display: flex; align-items: center; gap: 0.65rem; min-width: 0; line-height: 1.3; }
.platform-row__name .icon { width: 1.4rem; height: 1.4rem; }
.platform-row__stat { text-align: right; line-height: 1.3; font-variant-numeric: tabular-nums; }
.platform-row__stat .trend { margin-left: 0.3rem; }
.platform-row__note { grid-column: 2 / -1; text-align: right; }

.top-list { list-style: none; margin: 1.25rem 0 0.75rem; padding: 0; display: grid; gap: 0.4rem; counter-reset: top; }
.top-list a { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.6rem; align-items: center; padding: 0.6rem 0.75rem; border-radius: var(--r-md); background: var(--surface-2); color: inherit; text-decoration: none; }
.top-list a:hover { background: var(--surface-3); }
.top-list .icon { width: 1.1rem; height: 1.1rem; }
.top-list__title { font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-list__stat { font-size: 0.82rem; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .top-list a { grid-template-columns: auto minmax(0, 1fr); } .top-list__stat { grid-column: 2; } }

/* Cards inside grids line up by the grid gap, not the stacked-card margin. */
.stats > .card, .split > .card, .characters > .card, .split > section { margin-top: 0; }
@media (max-width: 699px) {
  .stats > .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .attention__item { padding: 0.75rem 0.9rem; }
  .attention__icon { width: 38px; height: 38px; }
}

/* ---------- per-video channel comparison ---------- */

.table--channels td, .table--channels th { white-space: nowrap; }
.table--channels td:first-child { white-space: normal; min-width: 200px; }
.channel-cell { display: grid; color: inherit; text-decoration: none; line-height: 1.3; }
.channel-cell:hover strong { text-decoration: underline; }
.table--compare td.is-best { font-weight: 750; color: var(--good); }

/* ---------- manager ---------- */

.sheet__item--feature { background: var(--accent-soft); }
.sheet__item--feature .icon { color: var(--accent-strong); }

.manager-cta { display: flex; align-items: center; gap: 0.9rem; padding: 0.95rem 1.1rem; border-radius: var(--r-lg); color: inherit; text-decoration: none; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft)), var(--surface); box-shadow: var(--shadow-1); transition: box-shadow 0.15s; }
.manager-cta:hover { box-shadow: var(--shadow-2); }
.manager-cta__icon, .msg__avatar, .manager-empty__icon { display: grid; place-items: center; flex: none; border-radius: var(--r-md); background: var(--accent); color: var(--accent-ink); }
.manager-cta__icon { width: 42px; height: 42px; }

.chat { display: grid; gap: 0.75rem; max-width: 860px; }
.chat__log { display: grid; gap: 1.1rem; min-height: 40dvh; align-content: start; }
/* Keeps the newest message clear of the sticky message box (and the tab bar on phones). */
.chat__log > * { scroll-margin-bottom: calc(var(--tabbar-h) + 6rem); }
@media (min-width: 821px) { .chat__log > * { scroll-margin-bottom: 6rem; } }
.chat__meta { text-align: center; margin: 0; text-transform: capitalize; }

.msg { display: flex; gap: 0.7rem; align-items: flex-start; min-width: 0; }
.msg--user { justify-content: flex-end; }
.msg__bubble { max-width: min(85%, 560px); padding: 0.7rem 0.95rem; border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg); background: var(--ink); color: var(--bg); line-height: 1.5; overflow-wrap: anywhere; }
.msg__avatar { width: 32px; height: 32px; border-radius: 10px; margin-top: 0.15rem; }
.msg__avatar .icon { width: 1.05rem; height: 1.05rem; }
.msg__body { flex: 1; min-width: 0; display: grid; gap: 0.75rem; }
.msg__cost { margin: 0; font-size: 0.74rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.prose { padding: 0.9rem 1.05rem; border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg); background: var(--surface); border: 1px solid var(--line); line-height: 1.6; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 0.65rem; }
.prose h3 { margin: 1rem 0 0.4rem; font-size: 1rem; color: var(--ink); }
.prose ul, .prose ol { margin: 0 0 0.75rem; padding-left: 1.25rem; display: grid; gap: 0.3rem; }
.prose .table-scroll { margin: 0.25rem 0 0.75rem; }
.prose .table { font-size: 0.86rem; }

.thinking { margin: 0; display: flex; align-items: center; gap: 0.3rem; padding: 0.8rem 1rem; border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg); background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-size: 0.9rem; width: fit-content; }
.thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-strong); animation: bounce 1.2s infinite ease-in-out; }
.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; margin-right: 0.4rem; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-4px); opacity: 1; } }

.proposals { display: grid; gap: 0.6rem; }
.proposal { padding: 0.9rem 1rem; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-1); display: grid; gap: 0.5rem; }
.proposal--high { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.proposal--medium { border-color: color-mix(in srgb, var(--accent-strong) 45%, var(--line)); }
.proposal__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.proposal p { margin: 0; color: var(--ink-2); }
.proposal .actions { margin: 0.15rem 0 0; }
.proposal__facts { margin: 0; display: grid; gap: 0.35rem; font-size: 0.86rem; }
.proposal__facts div { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: 0.5rem; }
.proposal__facts dt { display: flex; align-items: center; gap: 0.3rem; color: var(--ink-2); font-weight: 600; }
.proposal__facts dt .icon { width: 0.9rem; height: 0.9rem; }
.proposal__facts dd { margin: 0; }
.proposal__status { font-size: 0.86rem; font-weight: 650; }
.proposal__status--done { color: var(--good) !important; }
.proposal__status--failed { color: var(--bad) !important; }
.risk { flex: none; font-size: 0.72rem; font-weight: 750; padding: 0.15rem 0.55rem; border-radius: var(--r-pill); white-space: nowrap; }
.risk--low { background: var(--good-soft); color: var(--good); }
.risk--medium { background: var(--warn-soft); color: var(--warn); }
.risk--high { background: var(--bad-soft); color: var(--bad); }

.manager-empty { text-align: center; padding: 1.5rem 0.5rem; display: grid; justify-items: center; gap: 0.5rem; }
.manager-empty__icon { width: 52px; height: 52px; border-radius: var(--r-lg); }
.manager-empty__icon .icon { width: 1.6rem; height: 1.6rem; }
.manager-empty p { max-width: 52ch; margin: 0 0 0.75rem; }
.prompt-list { display: grid; gap: 0.5rem; width: 100%; max-width: 520px; }
@media (min-width: 700px) { .prompt-list { grid-template-columns: 1fr 1fr; max-width: 680px; } }
.prompt { display: flex; align-items: center; gap: 0.6rem; text-align: left; padding: 0.75rem 0.9rem; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 0.92rem; font-weight: 550; cursor: pointer; transition: border-color 0.15s, background-color 0.15s; }
.prompt:hover { border-color: var(--accent-strong); background: var(--accent-soft); }
.prompt .icon { color: var(--accent-strong); }

.composer { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-b) + 0.6rem); z-index: 6; display: flex; gap: 0.5rem; align-items: flex-end; padding: 0.45rem; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2); }
@media (min-width: 821px) { .composer { bottom: 1rem; } }
.composer__input { min-height: 44px; max-height: 200px; border: 0; box-shadow: none !important; resize: none; padding: 0.6rem 0.7rem; background: transparent; }
.composer__send { width: 44px; height: 44px; padding: 0; flex: none; }
.composer__send .icon { width: 1.25rem; height: 1.25rem; }

/* ---------- Spark: voice, links and the floating panel ---------- */

.chat__meta { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.35rem 1.25rem; text-transform: none; }
.chat__toggle { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.chat__toggle input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent-strong); }

.msg__foot { display: flex; align-items: center; gap: 0.75rem; min-height: 1.75rem; }
.msg__speak { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.6rem; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); color: var(--ink-2); font: inherit; font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: border-color 0.15s, color 0.15s; }
.msg__speak:hover { border-color: var(--line-strong); color: var(--ink); }
.msg__speak .icon { width: 0.95rem; height: 0.95rem; }
.msg__speak[aria-pressed="true"] { border-color: var(--accent-strong); color: var(--ink); background: var(--accent-soft); }

.prose__link { display: inline-flex; align-items: center; gap: 0.15rem; font-weight: 650; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.prose__link .icon { width: 0.85em; height: 0.85em; flex: none; }

.composer__mic { display: grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer; transition: background-color 0.15s, color 0.15s; }
.composer__mic:hover { background: var(--surface-2); color: var(--ink); }
.composer__mic .icon { width: 1.25rem; height: 1.25rem; }
.composer__mic.is-listening { background: var(--bad); color: #fff; animation: listening 1.4s ease-out infinite; }
@keyframes listening { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 45%, transparent); } to { box-shadow: 0 0 0 12px transparent; } }

.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; flex: none; padding: 0; border: 0; border-radius: var(--r-md); background: transparent; color: var(--ink-2); cursor: pointer; text-decoration: none; transition: background-color 0.15s, color 0.15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn .icon { width: 1.2rem; height: 1.2rem; }

/* Section links (#/settings?section=budget) flash what they point at. */
.view .card, .view h2, .view h3 { scroll-margin-top: 4.5rem; }
.is-flash { animation: flash 1.8s var(--ease); border-radius: var(--r-md); }
@keyframes flash { 0%, 55% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* Floating button: a round button above the tab bar on phones, a labelled pill on bigger screens. */
.spark-fab {
  position: fixed; z-index: 25; right: 1rem; bottom: calc(var(--tabbar-h) + var(--safe-b) + 0.9rem);
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; width: 52px; height: 52px; padding: 0;
  border: 0; border-radius: var(--r-pill); background: var(--ink); color: var(--bg); font: inherit; font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow-3); transition: transform 0.15s var(--ease), box-shadow 0.15s;
}
.spark-fab .icon { width: 1.4rem; height: 1.4rem; color: var(--accent); }
.spark-fab:hover { transform: translateY(-1px); }
.spark-fab__label { display: none; }
body:has(.action-bar) .spark-fab { bottom: calc(var(--tabbar-h) + var(--safe-b) + 5.25rem); }
body:has(.sticky-save) .spark-fab { bottom: calc(var(--tabbar-h) + var(--safe-b) + 4.6rem); }
body[data-page="spark"] .spark-fab, body.spark-open .spark-fab { display: none; }
@media (min-width: 821px) {
  .spark-fab { right: 1.5rem; bottom: 1.5rem; width: auto; height: 48px; padding: 0 1.15rem 0 1rem; }
  .spark-fab__label { display: inline; }
  body:has(.sticky-save) .spark-fab, body:has(.action-bar) .spark-fab { bottom: 5rem; }
}

/* Panel: full screen on phones, a floating card on the right on bigger screens. */
.spark-panel {
  position: fixed; z-index: 40; inset: 0; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink); animation: sheet-up 0.28s var(--ease);
}
.spark-panel[hidden] { display: none; }
.spark-panel__head { display: flex; align-items: center; gap: 0.6rem; padding: calc(0.6rem + env(safe-area-inset-top, 0px)) 0.6rem 0.6rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.spark-panel__head .msg__avatar { margin: 0; }
.spark-panel__title { flex: 1; min-width: 0; }
.spark-panel__title h2 { margin: 0; font-size: 1rem; line-height: 1.2; }
.spark-panel__title p { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spark-panel__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 1rem 1rem 0; }
.chat--compact { min-height: 100%; grid-template-rows: 1fr auto auto; max-width: none; }
.chat--compact .chat__log { min-height: 0; }
.chat--compact .composer { bottom: 0.6rem; }
.chat--compact .chat__meta { padding-bottom: calc(0.75rem + var(--safe-b)); }
.chat--compact .msg__bubble { max-width: 90%; }
.manager-empty--compact { padding: 1rem 0 0.5rem; }
.manager-empty--compact h2 { font-size: 1.1rem; }
.manager-empty--compact .prompt-list { grid-template-columns: 1fr; }
@media (max-width: 820px) { body.spark-open { overflow: hidden; } }
@media (min-width: 821px) {
  .spark-panel {
    inset: auto 1.5rem 1.5rem auto; width: min(420px, calc(100vw - 3rem)); height: min(720px, calc(100dvh - 3rem));
    border: 1px solid var(--line-strong); border-radius: var(--r-xl); overflow: hidden; box-shadow: var(--shadow-3);
    animation: pop 0.2s var(--ease); transform-origin: bottom right;
  }
  .spark-panel__head { padding-top: 0.6rem; }
}

/* ---------- title and caption helpers ---------- */

.text-field__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.text-field__head label { margin: 0; }
.text-field__suggest .icon { width: 1rem; height: 1rem; color: var(--accent-strong); }
.text-field__meter { margin: 0.35rem 0 0; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.text-field__meter.is-over { color: var(--warn); font-weight: 600; }
.text-field__note { display: flex; gap: 0.35rem; align-items: flex-start; margin: 0.35rem 0 0; color: var(--ink-2); }
.text-field__note .icon { width: 1rem; height: 1rem; flex: none; margin-top: 0.1rem; color: var(--accent-strong); }
.suggestions { display: grid; gap: 0.5rem; margin-top: 0.6rem; padding: 0.75rem; border-radius: var(--r-md); background: var(--surface-2); }
.suggestions p { margin: 0; display: flex; align-items: center; gap: 0.35rem; }
.suggestions .icon { width: 1rem; height: 1rem; }
.suggestions__list { display: grid; gap: 0.4rem; }
.suggestion { white-space: pre-line; text-align: left; padding: 0.6rem 0.8rem; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; line-height: 1.35; cursor: pointer; overflow-wrap: anywhere; transition: border-color 0.15s, background-color 0.15s; }
.suggestion:hover { border-color: var(--accent-strong); }
.suggestion[aria-pressed="true"] { border-color: var(--accent-strong); background: var(--accent-soft); }
.suggestions__more { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.suggestions__more .input { flex: 1 1 14rem; min-width: 0; }
.input--small { min-height: 38px; padding: 0.4rem 0.65rem; font-size: 0.9rem; }
.notes { margin: 0.35rem 0; padding-left: 1.2rem; display: grid; gap: 0.2rem; }
.retry-card p { margin: 0 0 0.75rem; }

/* ---------- Moments ---------- */

.create-kinds { margin-bottom: 0.25rem; }
.create-kinds a { display: inline-flex; align-items: center; gap: 0.4rem; }
.create-kinds .icon { width: 1rem; height: 1rem; }
.create-kinds .muted { font-weight: 400; font-size: 0.78rem; }
.moment-card__body { display: flex; gap: 1rem; align-items: flex-start; }
.moment-card__pic { flex: none; display: block; width: 96px; border-radius: var(--r-md); overflow: hidden; }
.moment-card__pic img { display: block; width: 100%; height: auto; }
.moment-card .facts { margin: 0; flex: 1; min-width: 0; }
.badge--mascot { display: inline-flex; align-items: center; gap: 0.3rem; background: var(--accent-soft); color: var(--ink); margin-bottom: 0.5rem; }
.badge--mascot .icon { width: 0.9rem; height: 0.9rem; color: var(--accent-strong); }
.character--mascot { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.upcoming { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.upcoming li { display: flex; justify-content: space-between; gap: 0.75rem; align-items: center; padding: 0.55rem 0; border-top: 1px solid var(--line); }
.upcoming li:first-child { border-top: 0; }
.upcoming__when { flex: none; font-size: 0.8rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.upcoming__angle { display: block; font-size: 0.82rem; color: var(--ink-2); }

.pick-list { display: grid; gap: 0.4rem; }
.pick-list__item { align-items: flex-start; padding: 0.6rem 0.75rem; border: 1px solid var(--line); border-radius: var(--r-md); }
.pick-list__item > span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pick-list__order { flex: none; min-width: 1.6rem; height: 1.6rem; display: grid; place-items: center; border-radius: 50%; font-weight: 800; font-size: 0.8rem; background: var(--accent); color: var(--accent-ink); }
.pick-list__order:empty { visibility: hidden; }
@media (max-width: 480px) { .create-kinds .muted { display: none; } }

.music-mood { padding: 0.75rem 0; border-top: 1px solid var(--line); }
.music-mood__head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; }
.music-mood__head .actions { margin: 0 0 0 auto; }
.music-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.4rem; }
.music-list li { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.music-list audio { height: 36px; flex: 1 1 14rem; min-width: 0; }

/* ---------- theme switch ---------- */

.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: var(--r-md); background: var(--surface-3); }
.theme-switch button { display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; min-height: 34px; padding: 0.3rem 0.5rem; border: 0; border-radius: 9px; background: none; color: var(--ink-2); font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.theme-switch button .icon { width: 1rem; height: 1rem; }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.sidebar .theme-switch { background: var(--nav-hover); margin: 0 0.1rem 0.4rem; }
.sidebar .theme-switch button { color: var(--nav-ink); }
.sidebar .theme-switch button[aria-pressed="true"] { background: var(--nav-active-bg); color: var(--nav-active-ink); box-shadow: none; }
/* On the icon rail there's only room for icons. */
@media (min-width: 821px) and (max-width: 1100px) {
  .sidebar .theme-switch { grid-template-columns: 1fr; }
  .sidebar .theme-switch span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
.sheet__theme { margin-top: 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: 0.86rem; color: var(--ink-2); font-weight: 600; }
.sheet__theme .theme-switch { flex: 0 1 260px; }

/* ---------- publish results on the video page ---------- */

.publish-results { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.publish-results h3 { margin: 0 0 0.25rem; font-size: 0.9rem; color: var(--ink-2); }
.publish-results > .btn { margin-top: 0.75rem; }
.platform-row--result { grid-template-columns: minmax(0, 1fr) auto; }
.publish-results__error { grid-column: 1 / -1; margin: 0; overflow-wrap: anywhere; }

/* ---------- safety limits ---------- */

@media (min-width: 640px) { .split--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.limits-table td { vertical-align: middle; }
.limits-input { width: 6.5rem; min-height: 38px; padding: 0.35rem 0.6rem; }
#limits-form .btn { margin-top: 0.5rem; }

/* ---------- channel charts (colours validated for colour blindness in both themes) ---------- */

:root { --ch-facebook: #257de0; --ch-instagram: #e24d8b; --ch-youtube: #f47230; }
/* Server charts reuse the validated channel hues: one line each (CPU, memory), sent vs received traffic. */
.chart__swatch--cpu, .chart__swatch--sent { background: var(--ch-facebook); }
.chart__swatch--mem, .chart__swatch--received { background: var(--ch-youtube); }
.chart__line--cpu, .chart__line--sent { stroke: var(--ch-facebook); }
.chart__line--mem, .chart__line--received { stroke: var(--ch-youtube); }
.chart__dot--cpu, .chart__dot--sent { fill: var(--ch-facebook); }
.chart__dot--mem, .chart__dot--received { fill: var(--ch-youtube); }
:root[data-theme="dark"] { --ch-facebook: #338ced; --ch-instagram: #e85a97; --ch-youtube: #d9770d; }

.chart { margin: 0; position: relative; }
.chart__head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.chart__title { font-weight: 700; font-size: 1.05rem; }
.chart__legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; font-size: 0.84rem; color: var(--ink-2); }
.chart__legend li { display: inline-flex; align-items: center; gap: 0.35rem; }
.chart__legend strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.chart__legend .icon { width: 0.95rem; height: 0.95rem; }
.chart__swatch { display: inline-block; width: 14px; height: 3px; border-radius: 2px; flex: none; }
.chart__swatch--facebook { background: var(--ch-facebook); }
.chart__swatch--instagram { background: var(--ch-instagram); }
.chart__swatch--youtube { background: var(--ch-youtube); }
.chart__plot { position: relative; width: 100%; height: 220px; touch-action: pan-y; cursor: crosshair; }
.chart__svg { display: block; overflow: visible; }
.chart__grid { stroke: var(--line); stroke-width: 1; }
.chart__baseline { stroke: var(--line-strong); stroke-width: 1; }
.chart__axis { fill: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart__line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart__line--facebook { stroke: var(--ch-facebook); }
.chart__line--instagram { stroke: var(--ch-instagram); }
.chart__line--youtube { stroke: var(--ch-youtube); }
.chart__dot { stroke: var(--surface); stroke-width: 2; }
.chart__dot--facebook { fill: var(--ch-facebook); }
.chart__dot--instagram { fill: var(--ch-instagram); }
.chart__dot--youtube { fill: var(--ch-youtube); }
.chart__end-label { fill: var(--ink-2); font-size: 12px; font-weight: 600; }
.chart__crosshair { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart__tip { position: absolute; top: 2.4rem; left: 0; z-index: 2; display: grid; gap: 0.2rem; min-width: 9rem; padding: 0.5rem 0.65rem; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2); font-size: 0.8rem; pointer-events: none; }
.chart__tip span { display: flex; align-items: center; gap: 0.4rem; color: var(--ink-2); }
.chart__tip b { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }
.chart__table { margin-top: 0.5rem; font-size: 0.85rem; }
.chart__table summary { color: var(--ink-2); font-weight: 600; }

/* ---------- comic strips ---------- */
.choice-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.4rem; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span { display: inline-flex; align-items: center; min-height: 40px; padding: 0.4rem 1rem; border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--surface); font-size: 0.9rem; font-weight: 600; }
.choice input:checked + span { border-color: var(--accent-strong); background: var(--accent-soft); }
.choice input:focus-visible + span { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.comic-panels { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 1rem; }
.comic-panel { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr); gap: 1rem; align-items: start; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.comic-panel:last-child { border-bottom: 0; padding-bottom: 0; }
.comic-panel__pic { display: block; border-radius: var(--r-md); overflow: hidden; background: var(--surface-3); aspect-ratio: 4 / 5; }
.comic-panel__pic img { display: block; width: 100%; height: 100%; object-fit: cover; }
.comic-panel__pic--empty { display: grid; place-items: center; font-size: 0.8rem; color: var(--ink-2); text-align: center; padding: 0.5rem; }
.comic-panel__title { margin: 0 0 0.5rem; font-size: 0.95rem; }
.comic-panel__words .field { margin-bottom: 0.6rem; }
@media (max-width: 520px) {
  .comic-panel { grid-template-columns: minmax(0, 1fr); }
  .comic-panel__pic { max-width: 260px; }
}

/* The mascot badge spans the card, so the picture keeps its own narrow column. */
.character > .badge--mascot { grid-column: 1 / -1; justify-self: start; max-width: 100%; white-space: normal; }
.character__mascot { margin-bottom: 0.5rem; }

/* ---------- learning loop: playbook and news pulse ---------- */
.playbook { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.playbook__rule { display: flex; gap: 0.75rem; justify-content: space-between; align-items: flex-start; }
.playbook__rule > div { min-width: 0; }
.playbook__rule.is-dropped strong { text-decoration: line-through; color: var(--ink-2); }
.pulse__list { list-style: none; margin: 0.75rem 0 0; padding: 0; display: grid; gap: 0.9rem; }
.pulse__item { display: flex; gap: 0.75rem; justify-content: space-between; align-items: flex-start; padding-bottom: 0.9rem; border-bottom: 1px solid var(--line); }
.pulse__item:last-child { border-bottom: 0; padding-bottom: 0; }
.pulse__item > div { min-width: 0; }
.pulse__item p { margin: 0.3rem 0 0; }
.pulse__item .actions { flex: none; }
@media (max-width: 560px) {
  .pulse__item, .playbook__rule { flex-direction: column; }
}

/* ---------- who's watching ---------- */
.audience .segmented { margin: 0.25rem 0 0.9rem; }
.aud-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 1.25rem 1.75rem; }
.aud-block h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.aud-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.aud-bars li { display: grid; grid-template-columns: minmax(4.5rem, 8.5rem) minmax(0, 1fr) 3.2rem; gap: 0.6rem; align-items: center; font-size: 0.86rem; }
.aud-bars__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.aud-bars__track { height: 10px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.aud-bars__fill { display: block; height: 100%; border-radius: 4px; background: var(--accent-strong); }
.aud-bars__value { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---------- off-server backup ---------- */
.offsite { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.offsite h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.offsite__steps { margin: 0.75rem 0; padding-left: 1.3rem; display: grid; gap: 0.9rem; }
.offsite__steps li.is-done::marker { color: var(--good, #2f8f4e); }
.offsite-pass { display: grid; gap: 0.25rem; max-width: 22rem; margin-top: 0.5rem; }
.offsite-pass .field label { display: grid; gap: 0.25rem; font-size: 0.86rem; }
.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0; }
.inline-form .input { flex: 1 1 12rem; min-width: 0; }

/* Shown after a deploy while an old Studio page is still open. */
.update-bar { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); top: max(0.75rem, env(safe-area-inset-top)); display: flex; gap: 0.75rem; align-items: center; padding: 0.5rem 0.6rem 0.5rem 1rem; border-radius: var(--r-pill); background: var(--ink); color: var(--surface); box-shadow: var(--shadow-2, 0 6px 24px rgba(0,0,0,.2)); font-size: 0.9rem; max-width: calc(100vw - 1.5rem); }
