/* MiniMax H3 Studio — instrument-style UI. Mobile first; colors via variables. */
:root {
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1d2129;
  --surface-3: #262b35;
  --border: #2b313c;
  --border-strong: #3a4250;
  --text: #e8eaef;
  --muted: #a0a8b6;
  --accent: #6ea8ff;
  --accent-ink: #08142b;
  --accent-soft: rgba(110, 168, 255, .14);
  --ok: #4fc68e;
  --warn: #f2b84b;
  --warn-soft: rgba(242, 184, 75, .12);
  --danger: #ff7a7a;
  --danger-soft: rgba(255, 122, 122, .12);
  --focus: #9cc3ff;
  --radius: 12px;
  --radius-sm: 8px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bar-h: 132px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e5e8ed;
  --border: #d9dde4;
  --border-strong: #b9c0cb;
  --text: #15181d;
  --muted: #555e6c;
  --accent: #2563d6;
  --accent-ink: #ffffff;
  --accent-soft: rgba(37, 99, 214, .1);
  --ok: #17794a;
  --warn: #8a5a00;
  --warn-soft: rgba(196, 132, 0, .12);
  --danger: #c22c2c;
  --danger-soft: rgba(194, 44, 44, .08);
  --focus: #2563d6;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font);
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
h1, h2, h3 { margin: 0; font-weight: 650; }
h2 { font-size: 17px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.big { width: 28px; height: 28px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15px; min-width: 0; }
.brand > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); flex: none; border: 0; padding: 0; cursor: default; position: relative; }
.brand-mark::before { content: ""; position: absolute; inset: -13px; }
.topbar-actions { display: flex; gap: 6px; align-items: center; flex: 0 1 auto; min-width: 0; }
.topbar-actions > :not(#statusPill) { flex: none; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px; white-space: nowrap;
}
.pill-strong b { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 7px; font-size: 12px; }
.who-pill .pill-label { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .who-pill .pill-label { display: none; } .who-pill { padding: 0 11px; } }
/* The status text ("Ready · queue 2") gives way first on a narrow screen instead of pushing the bar wider. */
.topbar-actions { min-width: 0; flex: 0 1 auto; }
#statusPill { min-width: 0; flex: 0 1 auto; }
#statusText { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.who-pill[data-state="user"] .ic, .who-pill[data-state="pass"] .ic { color: var(--ok); }
.who-pill[data-state="anonymous"] { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot[data-state="ready"] { background: var(--ok); }
.dot[data-state="loading"] { background: var(--warn); animation: pulse 1.2s infinite; }
.dot[data-state="error"] { background: var(--danger); }
.dot[data-state="busy"] { background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (max-width: 620px) { .brand > span:last-child { display: none; } .pill { padding: 0 10px; } }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; flex: none; }
/* Browser storage: a small bar under the settings gear, and a full one in Settings and Session. */
.settings-btn { position: relative; }
.store-mini { position: absolute; left: 50%; bottom: 5px; transform: translateX(-50%); width: 26px; height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; }
.store-mini > span, .store-bar > span { display: block; height: 100%; width: 0; background: var(--ok); border-radius: inherit; }
.store-bar { height: 10px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin-top: 6px; }
:is(.store-mini, .store-bar)[data-level="high"] > span { background: var(--warn); }
:is(.store-mini, .store-bar)[data-level="full"] > span { background: var(--danger); }
.settings-btn:has(.store-mini[data-level="full"]) { border-color: var(--danger); }
.store-meter .readout { margin-top: 4px; }

/* ---------- banners ---------- */
.banners { display: grid; gap: 8px; padding: 0 16px; }
.banners:empty { display: none; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); font-size: 14px; }
.banner.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: var(--warn-soft); }
.banner.error { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: var(--danger-soft); }
.banner.info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.banner .grow { flex: 1; min-width: 0; }
.banner .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- tabs ---------- */
.tabs { position: sticky; top: 0; z-index: 20; background: var(--bg); padding: 8px 16px 0; border-bottom: 1px solid var(--border); }
.tablist { display: grid; grid-template-columns: repeat(4, 1fr); max-width: 1192px; margin: 0 auto; }
@media (min-width: 960px) { .tablist { grid-template-columns: repeat(4, minmax(0, 140px)); justify-content: start; } }
.tablist [role="tab"] {
  min-height: 46px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 14px; padding: 0 4px;
}
.tablist [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--surface-3); color: var(--text); font-size: 11px; line-height: 18px; }

/* ---------- layout ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); padding: 16px; max-width: 1240px; margin: 0 auto; }
.settings, .output { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); align-content: start; }
.panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; min-width: 0; }
.banners { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) {
  /* Desktop is an app layout: the page itself doesn't scroll; the settings column scrolls above its action bar,
     and the result column scrolls on its own. Nothing in the form can end up under the bar. */
  html, body { height: 100%; }
  body { padding-bottom: 0; display: flex; flex-direction: column; overflow: hidden; }
  .topbar, .banners, .tabs { flex: none; }
  .tabs { position: static; }
  .banners { padding-bottom: 8px; }
  .workspace { flex: 1 1 auto; min-height: 0; width: 100%; grid-template-columns: minmax(380px, 520px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); align-items: stretch; gap: 28px; padding: 20px 24px 20px; }
  .settings { min-height: 0; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; }
  .settings > .panel { overflow-y: auto; overscroll-behavior: contain; min-height: 0; padding: 2px 10px 16px 2px; align-content: start; }
  .output { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 4px 16px 2px; }
  .actionbar { position: static !important; border-radius: var(--radius); border: 1px solid var(--border) !important; }
}

/* ---------- fields ---------- */
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; }
.label, label.label, legend.label, .field > label:first-child { font-weight: 600; font-size: 14px; padding: 0; }
.sublabel { font-size: 13px; color: var(--muted); font-weight: 600; }
.label-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 28px; }
.help { width: 44px; height: 32px; margin-right: -10px; border-radius: 999px; border: 0; background: none; color: var(--muted); font-weight: 700; cursor: pointer; position: relative; }
.help::before { content: ""; position: absolute; inset: 4px 10px; border: 1px solid var(--border-strong); border-radius: 999px; }
.help[aria-expanded="true"] { color: var(--accent); }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.hint.inline { margin-top: 2px; }
textarea, input[type="text"], input[type="url"], input[type="number"], select {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.readout { margin: 0; font-size: 13px; color: var(--muted); font-family: var(--mono); }
.readout b { color: var(--text); font-weight: 600; }

.slider-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.slider-row output { min-width: 64px; text-align: right; font-size: 14px; }
/* Range: custom track with a filled part (--p set by app.js) and a clear thumb, same in every browser */
input[type="range"] { --p: 50%; -webkit-appearance: none; appearance: none; width: 100%; height: 44px; background: transparent; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--accent) 0 var(--p), var(--surface-3) var(--p) 100%); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--accent), 0 1px 3px rgba(0,0,0,.35); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--surface-3); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--focus); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--focus); }
input[type="range"]:disabled { opacity: .5; cursor: not-allowed; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chips::-webkit-scrollbar { display: none; }
.chip, .chips label { position: relative; }
.chip input, .segmented input { position: absolute; opacity: 0; pointer-events: none; }
.chip > span, .chip-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; white-space: nowrap; font-size: 14px;
}
.chip-btn { min-height: 44px; }
.chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
.chip input:focus-visible + span, .segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.chip-btn:disabled { opacity: .45; cursor: not-allowed; }
.chip-btn .ic { width: 16px; height: 16px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.segmented label { position: relative; display: block; }
.segmented span { display: grid; place-items: center; min-height: 40px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 600; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }
.segmented input:disabled + span { opacity: .4; cursor: not-allowed; }
.segmented.compact { width: 100%; }

.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; }
.switch-ui { width: 42px; height: 26px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; flex: none; transition: background .15s; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .switch-ui { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(16px); background: var(--accent-ink); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--focus); outline-offset: 2px; }

.seed-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.seed-row .segmented span { min-height: 44px; }
.seed-row input:disabled { opacity: .5; }

.radio-list { display: grid; gap: 6px; }
.radio-item { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; min-height: 44px; }
.radio-item input { margin-top: 3px; accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.radio-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.summary-row { min-width: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; text-align: left; }
.summary-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.link { color: var(--accent); font-weight: 600; font-size: 14px; flex: none; }

.advanced { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.advanced > summary { list-style: none; min-height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::after { content: "+"; margin-left: auto; color: var(--muted); font-weight: 400; font-size: 20px; }
.advanced[open] > summary::after { content: "–"; }
.advanced > :not(summary) { margin: 0 14px 14px; }
.advanced[open] { display: grid; gap: 14px; padding-bottom: 2px; }
.advanced > summary .muted { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.note { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.note.warn { background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.note.error { background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.note.info { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.note.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }

/* ---------- keyframes ---------- */
.keyframes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.keyframe { position: relative; }
.kf-pick { display: grid; place-items: center; gap: 4px; aspect-ratio: 16/10; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; color: var(--muted); font-size: 13px; text-align: center; padding: 8px; }
.kf-pick:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.kf-pick.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.kf-thumb { position: relative; aspect-ratio: 16/10; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.kf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kf-thumb .tag { position: absolute; left: 6px; top: 6px; }
.kf-remove { position: absolute; right: 4px; top: 4px; width: 36px; height: 36px; border-radius: 999px; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; display: grid; place-items: center; }
.kf-remove::before { content: ""; position: absolute; inset: -4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; position: relative; }
.btn.small::before { content: ""; position: absolute; inset: -4px 0; }
.btn.block { width: 100%; min-height: 52px; font-size: 16px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; filter: none; }
/* A disabled primary keeps AA contrast instead of fading the blue */
.btn.primary:disabled { opacity: 1; background: var(--surface-3); border-color: var(--border-strong); color: var(--muted); }
.btn.busy { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); opacity: 1; cursor: pointer; }
.btn .ic { width: 18px; height: 18px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 auto; }

/* ---------- action bar ---------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--border);
}
.cost { font-size: 13px; color: var(--muted); display: grid; gap: 4px; min-height: 18px; }
.cost b { color: var(--text); font-family: var(--mono); font-weight: 600; }
.cost .warn { color: var(--warn); }
.cost .err { color: var(--danger); }
.cost-line { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.mini-job-btn { display: grid; gap: 6px; width: 100%; background: none; border: 0; padding: 4px 0; cursor: pointer; text-align: left; min-height: 44px; align-content: center; }
.mini-stage { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.mini-bar, .bar { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; position: relative; }
.mini-bar > span, .bar > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 999px; width: 0; transition: width .3s; }
.bar.indet > span, .mini-bar.indet > span { width: 35% !important; animation: indet 1.4s infinite ease-in-out; }
@keyframes indet { 0% { left: -35%; } 100% { left: 100%; } }
.stalled .bar > span, .stalled .mini-bar > span { background: var(--danger); animation: none; }
@media (prefers-reduced-motion: reduce) { .bar.indet > span, .mini-bar.indet > span, .dot { animation: none !important; } }

/* ---------- cards ---------- */
.card, #resultPanel { scroll-margin-top: 68px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--surface-3); color: var(--text); white-space: nowrap; }
.tag.draft { background: var(--warn-soft); color: var(--warn); }
.tag.refined, .tag.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.tag.failed { background: var(--danger-soft); color: var(--danger); }
.tag.running { background: var(--accent-soft); color: var(--accent); }
.tag.take { background: var(--accent-soft); color: var(--accent); }

/* job */
.job h2 { font-size: 15px; }
.job .stage { font-size: 16px; font-weight: 650; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.job .stage .num { font-size: 14px; color: var(--muted); font-weight: 500; }
.job .times { display: flex; gap: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.job .times b { color: var(--text); font-family: var(--mono); font-weight: 600; }
.job.stalled { border-color: var(--danger); }
.stall-box { background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent); border-radius: var(--radius-sm); padding: 12px; font-size: 14px; }
.stall-box strong { color: var(--danger); display: block; margin-bottom: 4px; }
.reconnect { display: inline-flex; gap: 6px; align-items: center; color: var(--warn); font-size: 13px; font-weight: 600; }
.cancel-note { font-size: 12px; color: var(--muted); margin: 0; }
.steps-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.steps-list li { display: flex; gap: 8px; align-items: center; }
.steps-list li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex: none; }
.steps-list li.done::before { background: var(--ok); border-color: var(--ok); }
.steps-list li.now { color: var(--text); font-weight: 600; }
.steps-list li.now::before { background: var(--accent); border-color: var(--accent); }

/* error */
.error-card { border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.error-card.soft { border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); }
.error-card h2 { display: flex; gap: 8px; align-items: center; }
.error-card p { margin: 0; }
.error-card ul { margin: 0; padding-left: 18px; }

/* result */
.player { position: relative; background: #000; border-radius: var(--radius-sm); overflow: hidden; }
.player video, .player img { display: block; width: 100%; max-height: 62vh; object-fit: contain; background: #000; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts .num { font-size: 13px; }
.copy-inline { background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0 6px; min-height: 32px; font-size: 13px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.result-actions .btn { flex: 1 1 140px; min-width: 0; white-space: normal; text-align: center; line-height: 1.2; padding: 6px 10px; }
.result-actions .btn.primary { flex-basis: 100%; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius); display: grid; gap: 6px; justify-items: center; }
.empty strong { color: var(--text); }
.report { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; color: var(--muted); margin: 0; }
details.fold > summary { cursor: pointer; color: var(--muted); font-size: 13px; min-height: 36px; display: flex; align-items: center; }

/* thumbnails (Session, pickers, Take) */
.thumb { width: 64px; aspect-ratio: 16/10; border-radius: 6px; background: var(--surface-3); overflow: hidden; display: block; }
.thumb video, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-size: 13px; }

/* ---------- take ---------- */
.take-head { display: grid; gap: 4px; }
.take-meta { font-size: 13px; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.seg { display: grid; grid-template-columns: 28px 1fr; gap: 10px; position: relative; padding-bottom: 14px; }
.seg::before { content: ""; position: absolute; left: 13px; top: 30px; bottom: 0; width: 2px; background: var(--border); }
.seg:last-child::before { display: none; }
.seg-n { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: 13px; font-weight: 700; z-index: 1; }
.seg-n.refined { background: var(--ok); color: #06180f; }
.seg-n.draft { background: var(--warn); color: #241600; }
.seg-n.failed { background: var(--danger); color: #2a0606; }
.seg-n.running { background: var(--accent); color: var(--accent-ink); }
.seg-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; min-width: 0; }
.seg-top { display: grid; grid-template-columns: 88px 1fr; gap: 10px; align-items: start; }
.seg-top .thumb { width: 88px; }
.seg-prompt { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.seg-info { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
.seg-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-error { font-size: 13px; color: var(--danger); margin: 0; }
.seg.composer .seg-card { border-style: dashed; border-color: var(--border-strong); background: transparent; }
.chain-actions { display: grid; gap: 8px; }
.chain-actions .btn { width: 100%; justify-content: space-between; }
.chain-actions .btn .muted { font-weight: 500; font-size: 13px; }

/* ---------- upscale ---------- */
.dropzone { display: grid; justify-items: center; gap: 6px; padding: 24px 16px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: center; color: var(--text); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.found { display: grid; gap: 10px; }

/* ---------- character ---------- */
.wizard { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; counter-reset: w; }
.wizard li { counter-increment: w; }
.wizard button { width: 100%; min-height: 44px; display: flex; gap: 8px; align-items: center; justify-content: center; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; padding: 0 6px; }
.wizard button::before { content: counter(w); width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 12px; flex: none; }
.wizard button[aria-current="step"] { color: var(--text); border-color: var(--accent); }
.wizard button[aria-current="step"]::before { background: var(--accent); color: var(--accent-ink); }
.wizard button.done::before { background: var(--ok); color: #06180f; content: "✓"; }
.wizard button:disabled { cursor: not-allowed; opacity: .6; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.media-tile { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile .tag { position: absolute; left: 4px; bottom: 4px; font-size: 11px; }
.media-tile .kf-remove { width: 32px; height: 32px; }
.counter { display: flex; justify-content: space-between; align-items: center; font-size: 14px; gap: 8px; flex-wrap: wrap; }
.counter b { font-family: var(--mono); }
.spark { width: 100%; height: 56px; display: block; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; }
.train-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; display: grid; gap: 2px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat b { font-family: var(--mono); font-size: 15px; }

/* ---------- sheets & modals ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.sheet {
  margin: auto 0 0; width: 100%; max-width: 100%; max-height: 88vh; padding: 0; border: 1px solid var(--border); border-bottom: 0;
  border-radius: 18px 18px 0 0; background: var(--surface); overflow: hidden;
}
.sheet[open] { display: grid; grid-template-rows: auto auto 1fr; }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 8px auto 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.sheet-body { overflow-y: auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); display: grid; gap: 12px; align-content: start; }
@media (min-width: 720px) { .sheet { margin: auto; max-width: 560px; border-radius: 18px; border-bottom: 1px solid var(--border); } .sheet-handle { display: none; } }
.modal { width: min(440px, calc(100% - 32px)); border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 20px; }
.modal form { display: grid; gap: 14px; }
.modal p { margin: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-actions .btn { flex: 1 1 140px; }
.cost-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; display: grid; gap: 4px; }
.cost-box b { font-family: var(--mono); }

.slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.slot { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 6px; background: var(--surface-2); }
.slot-top { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.slot-name { font-weight: 600; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-src { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.slot .slider-row { grid-template-columns: auto 1fr 64px; }
.slot .slider-row input[type="number"] { min-height: 36px; padding: 4px 6px; text-align: right; }
.slot.empty { border-style: dashed; color: var(--muted); font-size: 13px; text-align: center; padding: 14px; background: transparent; }
.url-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bar-h) + 16px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 14px; z-index: 60; max-width: calc(100% - 32px); }
@media (min-width: 960px) { .toast { bottom: 24px; } }

.dev-btn { position: fixed; right: 12px; bottom: calc(var(--bar-h) + 12px); z-index: 40; min-height: 44px; min-width: 52px; border-radius: 999px; border: 1px dashed var(--warn); background: var(--surface); color: var(--warn); font-weight: 700; font-size: 12px; cursor: pointer; }
@media (min-width: 960px) { .dev-btn { bottom: 16px; } }
.dev-group { display: grid; gap: 6px; }
.dev-group h3 { font-size: 13px; color: var(--muted); }

/* ---------- take (v2) ---------- */
body[data-tab="take"] #resultPanel { display: none !important; }
@media (max-width: 959px) { body[data-tab="take"] .output { order: -1; } }
/* The Take and Character roots are filled by script: give their children the same rhythm as the static panels */
#takeRoot, #trainRoot { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; align-content: start; }
#takeRoot > .take-intro + .hint { margin-top: -8px; }
.ribbon { margin-top: 4px; }
.take-intro { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.take-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.take-summary-text { display: grid; gap: 2px; min-width: 0; }
.summary-value { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.lock-badge { width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); flex: none; }
.take-editor { display: grid; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.ribbon { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
.seg-row { display: grid; gap: 8px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.seg-row.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.seg-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px; align-items: center; }
.seg-main { display: grid; grid-template-columns: 28px 72px minmax(0, 1fr); gap: 10px; align-items: center; min-height: 56px; padding: 4px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: var(--radius-sm); min-width: 0; color: var(--text); }
.seg-main .thumb { width: 72px; }
.seg-body { display: grid; gap: 4px; min-width: 0; }
.seg-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.seg-main .seg-prompt { font-size: 13px; -webkit-line-clamp: 1; color: var(--text); }
.seg-n.done { background: var(--ok); color: #06180f; }
.seg-n.refining { background: var(--accent); color: var(--accent-ink); }
.tag.done { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.tag.refining { background: var(--accent-soft); color: var(--accent); }
.seg-menu-wrap { position: relative; }
.seg-menu-wrap .icon-btn { border-color: transparent; background: transparent; }
.seg-menu-wrap .icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.seg-menu-wrap .ic { stroke-width: 3.2; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 25; min-width: 240px; max-width: calc(100vw - 48px); display: grid; padding: 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.menu button { min-height: 44px; padding: 0 12px; border: 0; background: none; text-align: left; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--text); }
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.seg-row .seg-error { padding: 0 8px 4px; }
.seg-row > .note { margin: 0 4px 4px; }
.seg-edit { display: grid; gap: 8px; padding: 4px 6px 6px; }
.composer { display: grid; gap: 8px; padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius); min-width: 0; }
.composer-blocked { padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius); font-size: 14px; color: var(--muted); }
.refine-block h2 { font-size: 16px; }
.refine-block .fold select { margin-top: 6px; }
.take-foot { display: flex; justify-content: flex-end; }
.take-player-slot { min-width: 0; }
.take-player summary { cursor: pointer; display: flex; align-items: center; min-height: 32px; list-style: none; gap: 8px; }
.take-player summary::-webkit-details-marker { display: none; }
.take-player summary::after { content: "–"; margin-left: auto; color: var(--muted); font-size: 18px; }
.take-player:not([open]) summary::after { content: "+"; }
.take-flow { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 14px; color: var(--muted); padding: 4px 0; }
.flow-step { padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: 13px; }

/* ---------- scrollbars: thin, rounded, from the theme tokens ---------- */
:root { --scroll-thumb: color-mix(in srgb, var(--muted) 45%, transparent); --scroll-thumb-hover: color-mix(in srgb, var(--muted) 75%, transparent); }
html, .settings > .panel, .output, .sheet-body, textarea, .chips, .menu { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }
.chips::-webkit-scrollbar { display: none; }
@media (min-width: 960px) { .settings > .panel { scrollbar-gutter: stable; } }

/* ---------- backup & video ---------- */
.take-intro-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.menu-file { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--text); }
.menu-file:hover, .menu-file:focus-visible { background: var(--surface-2); }
.start-alt { display: grid; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px; }
.missing-note { align-items: flex-start; }
.missing-note .btn-row { width: 100%; }
.missing-note .btn { flex: 1 1 200px; white-space: normal; text-align: center; line-height: 1.2; padding: 6px 10px; }
.seg-note { margin: 0 4px 4px; }
.nudge { margin-bottom: 4px; }
.nudge .icon-btn { width: 36px; height: 36px; border: 0; background: transparent; }
.tag.video { background: var(--accent-soft); color: var(--accent); }
.seg-n.video { background: var(--accent); color: var(--accent-ink); }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.take-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.export-card .card-head .icon-btn { width: 36px; height: 36px; }
.modal .switch { font-size: 14px; }

/* Take settings editor: even rhythm, aligned sliders */
.take-editor { gap: 18px; padding: 16px; }
.take-editor .chips { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; overflow: visible; }
.take-editor .chip > span { width: 100%; justify-content: center; padding: 0 4px; }
.take-editor .editor-row { gap: 2px; }
.take-editor .slider-row { grid-template-columns: 92px minmax(0, 1fr) 72px; }
.take-editor .readout { padding-left: 104px; }
.take-editor .btn-row { padding-top: 4px; }
@media (max-width: 400px) { .take-editor .readout { padding-left: 0; } }

/* A <legend> sits outside the fieldset's grid gap, so give it its own space above the controls */
fieldset.field > legend { margin-bottom: 8px; }
.take-editor fieldset.field > legend { margin-bottom: 10px; }

/* ---------- LoRA rack: three sources ---------- */
.src-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.src-tabs [role="tab"] { min-height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; }
.src-tabs [role="tab"][aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }
.src-pane { display: grid; gap: 10px; min-width: 0; }
.small-drop { padding: 18px 14px; }
.slot-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.my-loras li { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.ml-text { display: grid; gap: 2px; min-width: 0; }
.my-loras-title { margin: 4px 0 0; }

/* Backup picker and deletes */
.pick-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 4px; max-height: 40vh; overflow-y: auto; }
.pick-row { display: flex; gap: 10px; align-items: center; min-height: 40px; padding: 4px 6px; border-radius: var(--radius-sm); cursor: pointer; min-width: 0; }
.pick-row:hover { background: var(--surface-2); }
.pick-row input { flex: none; width: 18px; height: 18px; accent-color: var(--accent); }
.pick-row .ellipsis { flex: 1; min-width: 0; }
.pick-all { border-bottom: 1px solid var(--border); margin-bottom: 4px; border-radius: 0; }
.danger-text { color: var(--danger, #e5484d); }

/* Drafts and clips of this session, offered where a file would otherwise have to come from the downloads folder. */
.session-picks { margin-top: 6px; }
.session-picks .chip-btn { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; }
.session-picks .chip-btn .ellipsis { min-width: 0; max-width: 22ch; }
#upSession { margin-top: 10px; }

/* ---------- Session sheet (top bar → Session · N) ---------- */
@media (max-width: 560px) { .pill .pill-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } .topbar-actions { gap: 4px; } }
.pill-strong b { min-width: 22px; text-align: center; }
@media (max-width: 719px) { .session-sheet { height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; } }
@media (min-width: 720px) { .session-sheet { max-width: 680px; height: min(86vh, 900px); } }
.session-sheet .sheet-body { padding-bottom: 0; }
.sess-tools { display: grid; gap: 8px; }
.sess-tools-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.chip-btn .num { font-size: 12px; }
.sess-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-width: 0; }
.sess-list.grouped { gap: 14px; }
.sess-group { display: grid; gap: 6px; }
.sess-group h3 { font-size: 13px; }
.sess-card { width: 100%; display: grid; grid-template-columns: auto 72px minmax(0, 1fr) auto; gap: 10px; align-items: center; text-align: left; padding: 6px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; min-height: 56px; color: var(--text); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.sess-card:not(:has(.sess-check)) { grid-template-columns: 72px minmax(0, 1fr) auto; }
.sess-card.is-on { border-color: var(--accent); background: var(--accent-soft); }
.sess-card .thumb { width: 72px; }
.sess-check { width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--accent-ink); }
.sess-card.is-on .sess-check { background: var(--accent); border-color: var(--accent); }
.sess-text { display: grid; gap: 4px; min-width: 0; }
.sess-prompt { font-size: 14px; }
.sess-meta { display: flex; gap: 6px; align-items: center; min-width: 0; font-size: 12px; color: var(--muted); }
.sess-side { display: grid; justify-items: end; gap: 2px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sess-foot { position: sticky; bottom: 0; display: grid; gap: 8px; padding: 12px 0 calc(16px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); margin-top: 4px; }
.select-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.btn.danger:not(.ghost) { border-color: color-mix(in srgb, var(--danger) 50%, var(--border-strong)); }
.del-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: 14px; }

/* ---------- one Session picker everywhere ---------- */
.picker { display: grid; gap: 8px; min-width: 0; }
.picker-filters .chip-btn { min-height: 36px; font-size: 13px; }
.picker-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 300px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.pick-item { width: 100%; display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: center; text-align: left; padding: 6px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); cursor: pointer; min-height: 52px; color: var(--text); }
.pick-item.no-thumb { grid-template-columns: minmax(0, 1fr); padding: 8px 10px; }
.pick-item:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-2); }
.pick-item:disabled { opacity: .55; cursor: not-allowed; }
.pick-text { display: grid; gap: 3px; min-width: 0; font-size: 13px; }
.pick-meta { display: flex; gap: 6px; align-items: center; min-width: 0; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.start-alt .picker { margin-top: 4px; }

/* ---------- Upscale: three steps on one screen ---------- */
.up-step { display: grid; gap: 10px; min-width: 0; }
#upForm { gap: 16px; padding-top: 4px; }
.step-h { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.step-n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 12px; font-weight: 700; flex: none; }
.up-pickers { display: grid; gap: 14px; }
.up-src-row { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 10px; align-items: center; }
.up-src-row .thumb { width: 88px; }
.up-seg-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.up-seg-list li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; }
.note.ok .btn, .note.warn .btn-row { flex: none; }

/* ---------- Take: mode, join line ---------- */
.mode-pick .hint { margin-top: 2px; }
.join-uses { padding: 0; }
.flow-step.is-up { border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); color: var(--ok); }
.flow-step.is-draft { border-color: color-mix(in srgb, var(--warn) 50%, var(--border)); color: var(--warn); }
.take-summary .sublabel .tag { margin-left: 6px; vertical-align: 1px; }
.up-pickers > :empty { display: none; }

/* Training steps below the recommended 1200 */
.hint.warn { color: var(--warn); }
.take-first .keyframes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.take-kf { position: relative; }
/* Dialogs: a grid track sized to the dialog, so a long unbroken line (a prompt) is cut with … instead of
   widening the dialog past the screen. */
.modal form, .pick-list { grid-template-columns: minmax(0, 1fr); }
#confirmBody { min-width: 0; overflow-wrap: anywhere; }
.pick-row .thumb { flex: none; width: 56px; }
.pick-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.pick-text .small { font-size: 12px; }
/* Picking one frame of a video (Take: a last frame from an mp4, cutting a video segment). */
.frame-pick { display: grid; gap: 10px; min-width: 0; }
.frame-video { width: 100%; max-height: 50vh; background: #000; border-radius: var(--radius-sm); }
.rest-note { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
