/* Clapiletics admin — shares the native app's dark performance palette. */
:root {
  color-scheme: dark;
  --bg: #090c0e;
  --bg-top: #182025;
  --surface: #14191d;
  --surface-2: #1b2126;
  --surface-3: #242b31;
  --stroke: rgba(255, 255, 255, .07);
  --stroke-2: rgba(255, 255, 255, .13);
  --text: #f3f6f8;
  --text-2: #8e9aa4;
  --text-3: #5d6973;
  --blue: #33a1ff;
  --blue-soft: rgba(51, 161, 255, .14);
  --green: #54e078;
  --green-soft: rgba(84, 224, 120, .13);
  --amber: #ffbd47;
  --amber-soft: rgba(255, 189, 71, .13);
  --red: #ff615c;
  --red-soft: rgba(255, 97, 92, .13);
  --radius: 16px;
  --radius-small: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body { margin: 0; min-height: 100vh; background: linear-gradient(180deg, var(--bg-top) 0, var(--bg) 480px) fixed; }
a { color: var(--blue); }
code { white-space: nowrap; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; background: var(--surface-3); padding: 2px 6px; border-radius: 6px; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
p { margin: 0; }

/* Controls */
button, input, select, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer; border: 1px solid var(--stroke-2); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 9px 16px; font-weight: 600; font-size: 14px; line-height: 1.2;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
button:hover { background: var(--surface-3); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
button.primary { background: #fff; color: #000; border-color: #fff; }
button.primary:hover { background: #dfe6ea; }
button.ghost { background: transparent; }
button.danger { color: var(--red); }
button.danger:hover { background: var(--red-soft); border-color: transparent; }
button.small { padding: 6px 12px; font-size: 13px; }
button.wide { width: 100%; justify-content: center; padding: 13px; font-size: 15px; }
.icon-button { border: 0; background: transparent; padding: 6px 10px; color: var(--text-2); border-radius: 8px; }
.icon-button:hover { background: var(--surface-3); color: var(--text); }
button svg { width: 16px; height: 16px; flex: none; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); }
input, select, textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; background: var(--surface-2);
  border: 1px solid var(--stroke-2); border-radius: var(--radius-small); color: var(--text); font-size: 14px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
input[type=checkbox] { display: inline; width: auto; margin: 0 8px 0 0; accent-color: var(--blue); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.form-grid { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; color: var(--text); font-weight: 500; }
.form-error { color: var(--red); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }
.muted { color: var(--text-2); }
.hint { color: var(--text-3); font-size: 13px; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.mark { width: 26px; height: 26px; border-radius: 50%; border: 4px solid #fff; position: relative; flex: none; }
.mark::after { content: ""; position: absolute; left: -4px; right: -4px; top: 7px; height: 4px; background: var(--green); }
.badge { font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--blue); background: var(--blue-soft); padding: 3px 7px; border-radius: 6px; }

/* Sign in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--stroke); border-radius: 24px; padding: 36px; display: grid; gap: 18px; }
.brand-large { font-size: 19px; margin-bottom: 8px; }
.signin-card h1 { font-size: 30px; font-weight: 900; text-transform: uppercase; letter-spacing: -.01em; }

/* Shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px; padding: 24px 16px; border-right: 1px solid var(--stroke); background: rgba(9, 12, 14, .55); }
.sidebar .brand { padding: 4px 10px; }
nav { display: grid; gap: 2px; }
.nav-group { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); padding: 18px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 14px; }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current=page] { background: var(--surface-3); color: var(--text); }
.nav-item[aria-current=page] svg { color: var(--blue); }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 800; color: #000; background: var(--amber); border-radius: 999px; padding: 1px 7px; }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; padding: 0 8px; }
.account { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 13px; color: var(--text-2); }
.account span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #fff, var(--blue)); color: #000; font-weight: 900; font-size: 13px; flex: none; }
img.avatar { object-fit: cover; background: var(--stroke); }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar.large { width: 56px; height: 56px; font-size: 22px; }
.profile-head { margin-bottom: 16px; }
.profile-list { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; margin: 0; font-size: 14px; }
.profile-list dt { color: var(--text-2); }
.profile-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.profile-list dd.unset { color: var(--text-3); font-weight: 400; }

main { padding: 36px 44px 64px; min-width: 0; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 0 auto 28px; max-width: 1240px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--text-2); margin-bottom: 6px; }
.page-header h1 { font-size: 36px; font-weight: 900; text-transform: uppercase; letter-spacing: -.015em; line-height: 1.05; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.content { max-width: 1240px; margin: 0 auto; display: grid; gap: 28px; }

/* Cards & sections */
.card { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 22px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.section-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-label h2 { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.section-label span { font-size: 12px; color: var(--text-3); font-weight: 600; }
.card > .section-label { margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; align-content: start; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius); padding: 18px 20px; display: grid; gap: 6px; text-decoration: none; color: inherit; }
a.kpi:hover { border-color: var(--stroke-2); }
.kpi-label { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.kpi-value { font-size: 38px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 13px; color: var(--text-3); }
.tone-blue { color: var(--blue); }
.tone-green { color: var(--green); }
.tone-amber { color: var(--amber); }
.tone-red { color: var(--red); }

/* Chart */
.chart { min-height: 200px; }
.chart svg { display: block; }
.chart .bar { fill: var(--blue); }
.chart .bar.today { fill: var(--green); }
.chart .grid-line { stroke: rgba(255, 255, 255, .06); }
.chart text { fill: var(--text-3); font-size: 11px; font-family: inherit; }

/* Lists */
.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--stroke); min-width: 0; }
.list-row:first-child { border-top: 0; padding-top: 0; }
.list-row:last-child { padding-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row small { color: var(--text-2); font-size: 13px; }
.list-value { font-weight: 800; font-variant-numeric: tabular-nums; }
.rank { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 800; flex: none; }
.empty { color: var(--text-3); font-size: 14px; padding: 8px 0; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-2); display: grid; gap: 8px; justify-items: center; }
.empty-state strong { color: var(--text); font-size: 16px; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.toolbar .search { flex: 1 1 260px; max-width: 420px; position: relative; }
.toolbar .search input { margin: 0; padding-left: 38px; border-radius: 999px; }
.toolbar .search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); }
.toolbar select { width: auto; margin: 0; border-radius: 999px; }
.toolbar .spacer { flex: 1; }
.toolbar .count { color: var(--text-3); font-size: 13px; font-weight: 600; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 999px; padding: 3px; }
.segmented button { border: 0; background: transparent; color: var(--text-2); padding: 7px 14px; font-size: 13px; }
.segmented button[aria-pressed=true] { background: #fff; color: #000; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); padding: 14px 16px; border-bottom: 1px solid var(--stroke); white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid var(--stroke); vertical-align: middle; }
td:not(:first-child) { white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, .02); }
tr.linked { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.actions button + button { margin-left: 6px; }
.cell-title { font-weight: 650; }
.cell-sub { color: var(--text-2); font-size: 13px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.is-archived td { color: var(--text-3); }
tr.is-archived .cell-title { color: var(--text-2); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.blue { color: var(--blue); background: var(--blue-soft); }
.pill.green { color: var(--green); background: var(--green-soft); }
.pill.amber { color: var(--amber); background: var(--amber-soft); }
.pill.red { color: var(--red); background: var(--red-soft); }
.pill.plain::before { display: none; }
.you { font-size: 11px; font-weight: 800; color: var(--text-3); margin-left: 6px; text-transform: uppercase; letter-spacing: .08em; }

/* Media */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.media-card { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.media-card .media-body { padding: 16px; display: grid; gap: 8px; flex: 1; }
.media-card .media-body strong { font-weight: 650; }
.media-card .media-actions { padding: 0 16px 16px; display: flex; gap: 8px; }
.media-preview { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: #05080a; border: 0; }
audio.media-preview { aspect-ratio: auto; height: 54px; margin: 16px 16px 0; width: calc(100% - 32px); background: transparent; }

/* Studio */
.draft { display: grid; gap: 12px; padding: 18px 0; border-top: 1px solid var(--stroke); }
.draft:first-child { border-top: 0; padding-top: 0; }
.draft-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.draft-head strong { font-weight: 650; }
.draft textarea { min-height: 110px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Dialogs */
dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--stroke-2); border-radius: 20px; background: var(--surface); color: var(--text); }
dialog.wide { width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .62); backdrop-filter: blur(3px); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--stroke); }
.dialog-head h2 { font-size: 18px; font-weight: 800; }
.dialog-body { padding: 20px 24px; overflow: auto; display: grid; gap: 16px; }
dialog .form-error { padding: 0 24px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--stroke); }
fieldset { border: 1px solid var(--stroke-2); border-radius: 14px; padding: 16px; margin: 0; display: grid; gap: 14px; min-width: 0; }
legend { font-weight: 800; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); padding: 0 6px; }
.plan-item { background: var(--surface-2); border-color: var(--stroke); }
.weekday-options { display: flex; gap: 8px; flex-wrap: wrap; }
.weekday { display: inline-flex; align-items: center; padding: 7px 14px; border: 1px solid var(--stroke-2); border-radius: 999px; color: var(--text); cursor: pointer; }
.weekday:has(input:checked) { background: #fff; border-color: #fff; color: #000; }
.weekday:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
.weekday input { position: absolute; opacity: 0; pointer-events: none; }
[data-progression] { font-variant-numeric: tabular-nums; }
.plan-session > .form-row:first-of-type { grid-template-columns: minmax(0, 2fr) repeat(2, minmax(80px, 1fr)); }
.callout { background: var(--amber-soft); color: var(--amber); border-radius: 12px; padding: 12px 14px; font-size: 13px; }
.facts { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; }

/* Settings */
.model-list { display: grid; margin: 6px 0 20px; }
.model-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; align-items: center; padding: 14px 0; border-top: 1px solid var(--stroke); }
.model-row:first-child { border-top: 0; }
.model-row strong { display: block; font-weight: 650; }
.model-row .hint { display: block; margin-top: 2px; }
.model-row input, .model-row select { margin-top: 0; }
.model-choice { display: grid; gap: 8px; }
@media (max-width: 860px) { .model-row { grid-template-columns: 1fr; gap: 8px; } }

/* Coaches */
.coach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.coach-card { background: var(--surface); border: 1px solid var(--stroke); border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; display: flex; flex-direction: column; }
.coach-card:hover { border-color: var(--stroke-2); }
.coach-body { padding: 16px 18px 18px; display: grid; gap: 6px; }
.coach-body strong { font-size: 17px; font-weight: 800; }
.portrait { display: grid; place-items: center; object-fit: cover; background: linear-gradient(135deg, var(--surface-3), #0e1316); color: var(--text-2); font-weight: 900; border-radius: 50%; width: 44px; height: 44px; font-size: 15px; flex: none; }
.portrait.large { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 0; font-size: 44px; }
.portrait.hero { width: 100%; height: auto; aspect-ratio: 1; border-radius: 14px; font-size: 64px; }
.portrait-hero { margin-bottom: 14px; }
.portrait-options { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.portrait-option { padding: 0; border-radius: 12px; overflow: hidden; border: 2px solid transparent; background: none; }
.portrait-option img { width: 56px; height: 56px; object-fit: cover; display: block; }
.portrait-option[aria-pressed=true] { border-color: var(--green); }
.reference-options { display: flex; gap: 10px; flex-wrap: wrap; }
.reference-option { display: grid; gap: 4px; justify-items: center; }
.reference-option small { color: var(--text-3); font-size: 12px; padding: 6px 0; }
.reference-option label { position: relative; border-radius: 12px; overflow: hidden; border: 2px solid var(--stroke-2); cursor: pointer; }
.reference-option label:has(input:checked) { border-color: var(--green); }
.reference-option label:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
.reference-option input { position: absolute; top: 6px; left: 6px; margin: 0; }
.reference-option img { width: 64px; height: 64px; object-fit: cover; display: block; }
.inline-upload { display: flex; align-items: flex-end; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--stroke); }
.inline-upload label { flex: 1; }
.profile-fields { display: grid; gap: 14px; }
.code-editor { min-height: 560px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; line-height: 1.6; tab-size: 2; }
#agent-form section { display: grid; gap: 14px; }
.prompt-preview { margin-top: 14px; max-height: 520px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; line-height: 1.55; background: var(--surface-3); border-radius: 12px; padding: 14px 16px; color: var(--text-2); }
.steps { margin: 0 0 12px; padding-left: 20px; display: grid; gap: 8px; color: var(--text-2); }
.steps strong { color: var(--text); }
.profile-fields p { margin-top: 4px; white-space: pre-line; }
.card-head { padding: 22px 22px 16px; display: grid; gap: 12px; border-bottom: 1px solid var(--stroke); }
.card-head section .section-label { margin-bottom: 6px; }
.back-link, .small-link { font-size: 13px; font-weight: 600; text-decoration: none; align-self: center; margin-right: 6px; }
.video-brief { display: flex; gap: 14px; align-items: center; }

/* Exercise AI */
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; }
.field-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; min-height: 28px; }
.field input, .field textarea, .ai-brief textarea { margin-top: 0; }
button.ai-button { padding: 5px 11px; font-size: 12px; color: var(--blue); background: var(--blue-soft); border-color: transparent; gap: 6px; }
button.ai-button:hover { background: rgba(51, 161, 255, .22); }
button.ai-button svg { width: 14px; height: 14px; }
textarea.short { min-height: 80px; }
.ai-brief { display: grid; gap: 6px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--stroke); }
.ai-brief textarea { background: var(--surface); }
.ai-filled { border-color: rgba(51, 161, 255, .55); }
.ai-direction { background: transparent; }
.dialog-actions .spacer { flex: 1; }
.cell-title .pill { margin-left: 8px; }
.coach-media { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--stroke); }
.coach-media > .section-label { margin-bottom: 0; }
.coach-media-list { display: grid; }
.coach-media-row { display: grid; grid-template-columns: minmax(140px, .9fr) minmax(0, 1.2fr) minmax(0, 1.5fr); gap: 16px; align-items: start; padding: 14px 0; border-top: 1px solid var(--stroke); }
.coach-media-coach { display: flex; align-items: center; gap: 10px; min-width: 0; }
.coach-media-coach strong { display: block; font-weight: 650; }
.coach-media-coach small { display: block; color: var(--text-3); font-size: 12px; }
.coach-media-cell { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.coach-media-cell .cell-body { display: grid; gap: 6px; justify-items: start; min-width: 0; }
.cell-error { display: block; color: var(--red); font-size: 12px; overflow-wrap: anywhere; }
.thumb { display: grid; place-items: center; width: 72px; height: 96px; object-fit: cover; border-radius: 10px; background: #05080a; border: 1px solid var(--stroke); color: var(--text-3); flex: none; }
.thumb.wide { width: 136px; height: 96px; }
.thumb svg { width: 22px; height: 22px; }
.generate-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.generate-grid textarea { min-height: 236px; }
.coach-picker { gap: 2px; padding: 10px; max-height: 320px; overflow: auto; }
.coach-option { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; color: var(--text); font-weight: 600; cursor: pointer; }
.coach-option:hover { background: var(--surface-2); }
.coach-option input { margin: 0; }
.coach-option .portrait { width: 32px; height: 32px; font-size: 12px; }
.coach-option small { display: block; color: var(--text-3); font-weight: 500; font-size: 12px; }
@media (max-width: 760px) {
  .generate-grid, .coach-media-row { grid-template-columns: 1fr; }
}

/* Studio agent */
.agent-chat { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; height: calc(100vh - 190px); min-height: 520px; }
.thread-list { display: flex; flex-direction: column; min-height: 0; padding: 18px 12px; }
.thread-list .section-label { padding: 0 8px; }
.threads { display: grid; gap: 2px; align-content: start; overflow: auto; min-height: 0; }
.threads.is-busy a { pointer-events: none; opacity: .55; }
.thread { display: flex; align-items: center; gap: 2px; border-radius: 10px; }
.thread a { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; text-decoration: none; color: var(--text-3); font-size: 12px; }
.thread a strong { display: block; color: var(--text); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread a:hover, .thread[aria-current=page] a { background: var(--surface-2); }
.thread .icon-button { opacity: 0; padding: 4px 8px; font-size: 12px; }
.thread:hover .icon-button, .thread .icon-button:focus-visible { opacity: 1; }
.chat-panel { display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; overflow: auto; padding: 24px 28px; display: flex; flex-direction: column; gap: 20px; }
.bubble { max-width: min(760px, 92%); line-height: 1.6; font-size: 14.5px; min-width: 0; }
.bubble.user { align-self: flex-end; background: var(--surface-3); padding: 10px 15px; border-radius: 18px 18px 6px 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.assistant { align-self: flex-start; display: grid; gap: 12px; }
.markdown { display: grid; gap: 10px; overflow-wrap: anywhere; }
.transcript { display: flex; flex-direction: column; gap: 18px; padding: 22px; max-height: 72vh; overflow: auto; }
.transcript-message { display: grid; gap: 6px; justify-items: start; }
.transcript-message.user { justify-items: end; }
.transcript-message time { font-size: 11.5px; color: var(--text-3); }
.message-attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.transcript-message.user .message-attachments { justify-content: flex-end; }
.chat-media { display: block; height: 220px; width: auto; max-width: 100%; object-fit: cover; border-radius: 14px; background: #05080a; border: 0; }
.chat-audio { width: min(320px, 100%); height: 40px; }
.markdown ul, .markdown ol { margin: 0; padding-left: 22px; display: grid; gap: 4px; }
.markdown code { white-space: normal; }
.tool-steps { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--stroke); border-radius: 14px; background: var(--surface-2); }
.tool-step { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; }
.tool-step > div { display: grid; gap: 2px; min-width: 0; }
.tool-step span:not(.spin):not(.step-mark) { color: var(--text); font-weight: 600; }
.tool-step small { color: var(--text-2); }
.tool-step.failed small { color: var(--red); }
.step-mark { width: 16px; height: 16px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--green-soft); color: var(--green); font-size: 10px; font-weight: 900; margin-top: 1px; }
.step-mark.error { background: var(--red-soft); color: var(--red); }
.spin { width: 16px; height: 16px; flex: none; border: 2px solid var(--stroke-2); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; margin-top: 1px; }
@keyframes spin { to { transform: rotate(360deg); } }
.refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
button.ref-chip { padding: 3px 10px; font-size: 12px; background: var(--blue-soft); color: var(--blue); border-color: transparent; }
button.ref-chip:hover { background: rgba(51, 161, 255, .22); }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: typing 1.2s ease-in-out infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.chat-empty { margin: auto; max-width: 560px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.chat-empty strong { font-size: 20px; font-weight: 800; }
.chat-mark { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue); }
.chat-mark svg { width: 26px; height: 26px; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.suggestions button { white-space: normal; text-align: left; }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--stroke); }
.composer textarea { margin: 0; min-height: 44px; max-height: 200px; resize: none; line-height: 1.45; }
.composer button { flex: none; }
@media (max-width: 900px) {
  .agent-chat { grid-template-columns: 1fr; height: auto; }
  .thread-list { max-height: 220px; }
  .chat-panel { height: 72vh; }
  .chat-log { padding: 18px 16px; }
}

/* Public legal pages */
.legal { max-width: 720px; margin: 0 auto; padding: 48px 24px 80px; display: grid; gap: 16px; }
.legal h1 { font-size: 34px; font-weight: 900; text-transform: uppercase; }
.legal h2 { font-size: 18px; font-weight: 800; margin-top: 16px; }
.legal p, .legal li { color: var(--text-2); line-height: 1.65; }
.legal strong { color: var(--text); }
.legal ul { margin: 0; padding-left: 20px; display: grid; gap: 8px; }

/* Toast */
.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(440px, calc(100vw - 48px)); background: var(--surface-3); border: 1px solid var(--stroke-2); color: var(--text); padding: 14px 18px; border-radius: 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, .5); font-size: 14px; z-index: 10; }
.toast.error { border-color: rgba(255, 97, 92, .5); }

@media (max-width: 1100px) {
  .split, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; border-right: 0; border-bottom: 1px solid var(--stroke); }
  nav { display: flex; overflow-x: auto; order: 3; width: 100%; gap: 4px; }
  .nav-group { display: none; }
  .nav-item { white-space: nowrap; padding: 8px 12px; }
  .sidebar-footer { margin: 0 0 0 auto; display: flex; align-items: center; padding: 0; }
  .account span:last-child { display: none; }
  main { padding: 24px 16px 48px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header h1 { font-size: 28px; }
  .grid-2 { grid-template-columns: 1fr; }
  td, th { padding: 12px; }
}

/* Audio cues */
.cue-table td:not(:first-child) { min-width: 220px; }
.cue-table td:first-child { white-space: normal; min-width: 160px; }
.cue-table input { margin-top: 0; }
.form-foot { padding: 16px 22px 22px; border-top: 1px solid var(--stroke); }
.cue-status { display: flex; align-items: center; gap: 12px; }
.cue-status .grow { flex: 1; min-width: 0; }
.cue-status strong { display: block; font-weight: 650; }
.cue-status small { color: var(--text-2); font-size: 13px; }
.voice-preview, .recording audio { width: 100%; height: 40px; }
.recording { display: grid; gap: 6px; }
.default-cues { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--stroke); }
.inline-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--stroke); }
#coach-voice section { display: grid; gap: 14px; }
#coach-voice .section-label { margin-bottom: 0; }
small.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }

.clip-table td.clip-text { white-space: normal; min-width: 260px; }
.clip-table td.clip-text small { display: block; margin-top: 4px; }
.clip-table td:first-child { white-space: normal; min-width: 150px; }
.clip-table audio { display: block; width: 240px; height: 36px; }
.clip-table audio + .pill { margin-top: 6px; }
#cue-clips { margin-top: 20px; }
#cue-clips .card-head .segmented { justify-self: start; }
#cue-clips .card-head .toolbar { gap: 8px; }
.cue-lang { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 6px; }
.cue-lang + .cue-lang { margin-top: 6px; }
.lang-tag { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; color: var(--text-3); }

/* Translations */
.term-table td:nth-child(2) { min-width: 240px; }
.term-table input { margin-top: 0; }
.term-table .cell-sub, .term-table .cell-error { margin-top: 4px; }
.translation-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.translation-bar .spacer { flex: 1; }
.translation-field { display: grid; gap: 8px; min-width: 0; }
.translation-field .row-actions { align-items: center; }
.translation-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.translation-state { display: inline-flex; align-items: center; gap: 8px; }
.translation-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.translation-head { margin-bottom: -8px; }
.translation-field input, .translation-field textarea { margin-top: 0; }
.english-text { padding: 10px 12px; border-radius: var(--radius-small); background: var(--surface-2); border: 1px solid var(--stroke); color: var(--text-2); font-size: 14px; white-space: pre-line; overflow-wrap: anywhere; max-height: 240px; overflow: auto; }
.translation-section { border: 1px solid var(--stroke-2); border-radius: 14px; padding: 0 16px; min-width: 0; }
.translation-section summary { display: flex; align-items: center; gap: 10px; padding: 14px 0; cursor: pointer; list-style: none; font-weight: 800; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }
.translation-section summary::-webkit-details-marker { display: none; }
.translation-section summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(-45deg); transition: transform .15s; }
.translation-section[open] summary::after { transform: rotate(45deg); }
.translation-section summary .pill { letter-spacing: 0; text-transform: none; }
.translation-section > .form-grid { padding: 4px 0 16px; }
@media (max-width: 760px) { .translation-pair { grid-template-columns: 1fr; } }
