/* ==========================================================================
   LỘC CHÔM CHỈA · MULTI-MEDIUM CREATIVE STUDIO
   4 Switchable Studio Skins: darkroom | atelier | graphite | saville
   Zero AI-slop: true neutral grounds, 1px hairline seams, flat surfaces,
   contrast >= 4.5:1, tabular figures, stage-first workbench.
   ========================================================================== */

:root,
[data-studio-skin="darkroom"] {
  --bg: #0b0b0c;
  --surface: #121214;
  --surface-2: #18181b;
  --surface-3: #222226;
  --stage-bg: #080809;
  --border: #232327;
  --border-strong: #36363c;
  --ink: #f5f5f2;
  --ink-2: #b4b4ba;
  --ink-3: #8e8e96;
  --primary-bg: #f5f5f2;
  --primary-ink: #0b0b0c;
  --primary-hover: #ffffff;
  --accent: #f06246;
  --accent-soft: rgba(240, 98, 70, 0.14);
  --accent-border: rgba(240, 98, 70, 0.55);
  --ok: #3fc07a;
  --ok-soft: #14261c;
  --warn: #eab308;
  --warn-soft: #292312;
  --danger: #f06478;
  --danger-soft: #2c171b;
  --queued: #7aa7f7;
  --queued-soft: #152136;
  --console-bg: #09090b;
  --console-ink: #d9d9de;
  --shadow-float: 0 18px 44px rgba(0, 0, 0, 0.55);
  --radius-panel: 10px;
  --radius-ctrl: 7px;
  --radius-btn: 999px;
  --shell-pad: 0px;
  --shell-gap: 0px;
  --font-sans: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", Consolas, ui-monospace, monospace;
}

[data-studio-skin="atelier"] {
  --bg: #eceae4;
  --surface: #ffffff;
  --surface-2: #f7f6f2;
  --surface-3: #eceae4;
  --stage-bg: #f5f4ef;
  --border: #dfdcd4;
  --border-strong: #c4bfb4;
  --ink: #161614;
  --ink-2: #484640;
  --ink-3: #636058;
  --primary-bg: #161614;
  --primary-ink: #ffffff;
  --primary-hover: #2c2b27;
  --accent: #1d5fbf;
  --accent-soft: #e9f1fc;
  --accent-border: #8eb2e6;
  --ok: #1f7a49;
  --ok-soft: #e2f5ea;
  --warn: #9a5b08;
  --warn-soft: #fbf1dc;
  --danger: #c02a30;
  --danger-soft: #fce8e9;
  --queued: #1d5fbf;
  --queued-soft: #e9f1fc;
  --console-bg: #141413;
  --console-ink: #e5e5e0;
  --shadow-float: 0 16px 38px rgba(22, 22, 20, 0.16);
  --radius-panel: 12px;
  --radius-ctrl: 6px;
  --radius-btn: 7px;
  --shell-pad: 8px;
  --shell-gap: 8px;
}

[data-studio-skin="graphite"] {
  --bg: #111113;
  --surface: #151518;
  --surface-2: #1c1c20;
  --surface-3: #25252b;
  --stage-bg: #0d0d0f;
  --border: #25252b;
  --border-strong: #3a3a44;
  --ink: #fafafa;
  --ink-2: #b8b8c2;
  --ink-3: #90909c;
  --primary-bg: #38bdf8;
  --primary-ink: #07131d;
  --primary-hover: #64cdfa;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.13);
  --accent-border: rgba(56, 189, 248, 0.5);
  --ok: #34d399;
  --ok-soft: #112821;
  --warn: #facc15;
  --warn-soft: #2a2410;
  --danger: #fb7185;
  --danger-soft: #2c151b;
  --queued: #38bdf8;
  --queued-soft: #102433;
  --console-bg: #0b0b0d;
  --console-ink: #dcdce2;
  --shadow-float: 0 16px 40px rgba(0, 0, 0, 0.58);
  --radius-panel: 0px;
  --radius-ctrl: 5px;
  --radius-btn: 6px;
  --shell-pad: 0px;
  --shell-gap: 0px;
}

[data-studio-skin="saville"] {
  --bg: #0a0a0b;
  --surface: #111112;
  --surface-2: #171719;
  --surface-3: #222225;
  --stage-bg: #070708;
  --border: #202024;
  --border-strong: #34343a;
  --ink: #f2f2ef;
  --ink-2: #b6b6b2;
  --ink-3: #8f8f8b;
  --primary-bg: #f2f2ef;
  --primary-ink: #0a0a0b;
  --primary-hover: #ffffff;
  --accent: #e5a93c;
  --accent-soft: rgba(229, 169, 60, 0.14);
  --accent-border: rgba(229, 169, 60, 0.52);
  --ok: #3fc07a;
  --ok-soft: #13251b;
  --warn: #e5a93c;
  --warn-soft: #292112;
  --danger: #ef6470;
  --danger-soft: #2b1619;
  --queued: #7aa7f7;
  --queued-soft: #141f33;
  --console-bg: #070708;
  --console-ink: #d8d8d4;
  --shadow-float: 0 18px 44px rgba(0, 0, 0, 0.62);
  --radius-panel: 2px;
  --radius-ctrl: 3px;
  --radius-btn: 3px;
  --shell-pad: 0px;
  --shell-gap: 0px;
}

* {
  box-sizing: border-box;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  caret-color: var(--accent);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
}

code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--ink);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* ==================== MOBILE HEADER (<= 860px) ==================== */
.mobile-topbar {
  display: none;
  height: 48px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 60;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  z-index: 65;
}

/* ==================== APP SHELL ==================== */
.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  height: 100vh;
  padding: var(--shell-pad);
  gap: var(--shell-gap);
  overflow: hidden;
}

/* Atelier L-frame inset sheet styling */
[data-studio-skin="atelier"] .sidebar {
  background: transparent;
  border-right: none;
  padding: 12px 10px 10px 16px;
}

[data-studio-skin="atelier"] .main-stage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  overflow: hidden;
}

/* ==================== LEFT STUDIO RAIL ==================== */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 4px;
  flex-shrink: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-ctrl);
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-3);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
}

.nav-group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  padding: 0 6px 2px;
}

.nav-group-head .nav-group-label {
  padding: 0;
}

.rail-link-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
}

.rail-link-btn:hover {
  color: var(--ink);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-ctrl);
  background: transparent;
  color: var(--ink-2);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav-item.active {
  background: var(--surface-3);
  color: var(--ink);
  font-weight: 600;
}

[data-studio-skin="atelier"] .nav-item.active {
  background: var(--surface);
  border-color: var(--border);
}

[data-studio-skin="saville"] .nav-item.active {
  background: transparent;
  border-radius: 0;
  border-bottom: 1px solid var(--ink);
}

.nav-item svg {
  flex-shrink: 0;
  color: var(--ink-3);
}

.nav-item.active svg {
  color: var(--ink);
}

.nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--ink-3);
}

.nav-item.active .nav-count {
  color: var(--ink-2);
}

/* Rail Recent Creations Index */
.rail-recent-group {
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.rail-recent-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  min-height: 0;
}

.rail-recent-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-ctrl);
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
  min-width: 0;
  transition: background 130ms ease, color 130ms ease;
}

.rail-recent-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.rail-recent-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.rail-recent-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-recent-kind {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}

/* Saville 4-color code bar on recent items */
.saville-codebar {
  display: none;
  gap: 2px;
  height: 4px;
  width: 100%;
}

[data-studio-skin="saville"] .saville-codebar {
  display: flex;
}

.saville-codebar span {
  flex: 1;
}

.rail-recent-empty {
  padding: 8px 6px;
  font-size: 12px;
  color: var(--ink-3);
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.engine-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

[data-studio-skin="atelier"] .engine-box {
  background: var(--surface);
}

.engine-head {
  display: flex;
  align-items: center;
  gap: 7px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--ink-3);
  flex-shrink: 0;
}

.status-dot.ok {
  background: var(--ok);
}

.status-dot.warn {
  background: var(--warn);
}

.status-dot.err {
  background: var(--danger);
}

.engine-title {
  font-weight: 600;
  font-size: 12px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.engine-meta {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  white-space: normal;
  overflow-wrap: break-word;
}

.engine-selects {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.engine-selects select {
  height: 30px;
  padding: 0 7px;
  font-size: 12px;
  border-radius: var(--radius-ctrl);
  background: var(--surface);
  border: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 4-Skin Switcher */
.skin-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.skin-box-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  padding: 0 2px;
}

.skin-switcher {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.skin-opt {
  height: 27px;
  padding: 0 6px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color 130ms ease, background 130ms ease, color 130ms ease;
}

[data-studio-skin="atelier"] .skin-opt {
  background: var(--surface);
}

.skin-opt:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.skin-opt.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.icon-btn {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-ctrl);
  border: none;
  background: transparent;
  color: var(--ink-3);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 130ms ease, color 130ms ease;
}

.icon-btn:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.footer-row {
  display: flex;
  gap: 6px;
}

.jobs-trigger {
  flex: 1;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 130ms ease, background 130ms ease;
}

[data-studio-skin="atelier"] .jobs-trigger,
[data-studio-skin="atelier"] .theme-toggle {
  background: var(--surface);
}

.jobs-trigger:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.jobs-trigger-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--ink-3);
}

.pulse-dot.running {
  background: var(--accent);
  animation: pulseRing 1.5s infinite;
}

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(224, 79, 51, 0.5); }
  70% { box-shadow: 0 0 0 5px rgba(224, 79, 51, 0); }
  100% { box-shadow: 0 0 0 0 rgba(224, 79, 51, 0); }
}

.theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease;
}

.theme-toggle:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--ink);
}

/* ==================== MAIN STAGE & TAB CONTAINERS ==================== */
.main-stage {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.tab-view {
  display: none;
  min-height: 0;
  min-width: 0;
  flex: 1;
}

.tab-view.active {
  display: flex;
  flex-direction: column;
}

.page-frame {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 28px 40px;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.view-header h1 {
  margin: 0 0 3px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.024em;
  line-height: 1.2;
}

.view-sub {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.header-actions .btn-ghost {
  height: 36px;
}

/* ==================== CONTROLS & BUTTONS ==================== */
:where(
  input[type="text"],
  input[type="number"],
  input[type="search"],
  input[type="password"],
  select,
  textarea
) {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-ctrl);
  background: var(--surface-2);
  color: var(--ink);
  transition: border-color 130ms ease, background 130ms ease;
}

[data-studio-skin="atelier"] :where(
  input[type="text"],
  input[type="number"],
  input[type="search"],
  input[type="password"],
  select,
  textarea
) {
  background: var(--surface);
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-3);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.search-input {
  width: 220px;
  flex: 0 1 220px;
  height: 36px;
}

.mono-input {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
}

.btn-create {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 16px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--primary-bg);
  background: var(--primary-bg);
  color: var(--primary-ink);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 130ms ease, border-color 130ms ease, transform 110ms ease;
}

.btn-create:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-create:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-create:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-full {
  width: 100%;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 130ms ease, border-color 130ms ease;
}

[data-studio-skin="atelier"] .btn-ghost {
  background: var(--surface);
}

.btn-ghost:hover {
  background: var(--surface-3);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 11px;
  border-radius: var(--radius-ctrl);
  border: 1px solid rgba(240, 100, 120, 0.38);
  background: transparent;
  color: var(--danger);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 130ms ease, border-color 130ms ease;
}

.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-xs {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-create.btn-xs {
  height: 32px;
  padding: 0 13px;
  border-radius: var(--radius-ctrl);
  font-size: 12px;
}

.text-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.text-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

/* ==================== TAB 1: 3-PANE CREATIVE WORKBENCH ==================== */
.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(276px, 21.5vw, 304px);
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.workbench-center {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--stage-bg);
}

/* Workbench Top Bar (48px) */
.workbench-bar {
  height: 48px;
  flex-shrink: 0;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.workbench-bar-left {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 100%;
  min-width: 0;
}

.workbench-h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.medium-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
}

.medium-tab {
  height: 100%;
  padding: 0 12px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 130ms ease, border-color 130ms ease;
}

.medium-tab:hover {
  color: var(--ink);
}

.medium-tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.workbench-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.stage-status-tag {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
}

.segmented {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  flex-shrink: 0;
  padding: 4px;
  border-radius: var(--radius-ctrl);
  background: var(--surface-2);
  border: 1px solid var(--border);
  gap: 3px;
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: calc(var(--radius-ctrl) - 2px);
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 130ms ease, color 130ms ease;
}

.seg-btn.active {
  background: var(--surface-3);
  color: var(--ink);
}

[data-studio-skin="atelier"] .seg-btn.active {
  background: var(--surface);
}

.seg-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
}

/* Stage Panes */
.stage-pane {
  display: none;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
}

.stage-pane.active {
  display: flex;
  flex-direction: column;
}

.medium-stage {
  display: none;
  flex: 1;
  min-height: 0;
}

.medium-stage.active {
  display: flex;
  flex-direction: column;
}

/* Illuminated Center Canvas Desk */
.canvas-desk {
  flex: 1;
  min-height: 0;
  padding: 18px 24px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

[data-studio-skin="saville"] .canvas-desk {
  padding: 24px 32px 18px;
}

/* Artboard Crop Frame (Registration marks appear in Atelier skin) */
.artboard-crop-wrap {
  position: relative;
  padding: 10px;
  border-radius: calc(var(--radius-panel) + 2px);
  background: var(--surface);
  border: 1px solid var(--border);
}

[data-studio-skin="atelier"] .artboard-crop-wrap {
  background: transparent;
  border: none;
  padding: 14px;
}

[data-studio-skin="atelier"] .artboard-crop-wrap::before,
[data-studio-skin="atelier"] .artboard-crop-wrap::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  border-color: var(--border-strong);
  border-style: solid;
  pointer-events: none;
}

[data-studio-skin="atelier"] .artboard-crop-wrap::before {
  top: 0;
  left: 0;
  border-width: 1px 0 0 1px;
}

[data-studio-skin="atelier"] .artboard-crop-wrap::after {
  bottom: 0;
  right: 0;
  border-width: 0 1px 1px 0;
}

[data-studio-skin="saville"] .artboard-crop-wrap {
  background: transparent;
  border: none;
  padding: 0;
}

.frame-mockup {
  position: relative;
  border-radius: calc(var(--radius-ctrl) + 2px);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background-color: #fce2b2;
  color: #2c1e14;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 14px 16px;
  transition: width 180ms ease, height 180ms ease;
}

.frame-mockup.aspect-9-16 {
  width: 224px;
  height: 396px;
}

.frame-mockup.aspect-16-9 {
  width: 480px;
  max-width: 100%;
  height: 270px;
  padding: 14px 18px;
}

.frame-mockup.aspect-1-1 {
  width: 340px;
  max-width: 100%;
  height: 340px;
}

.mockup-progress-track {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(0, 0, 0, 0.22);
  z-index: 4;
}

.mockup-progress-fill {
  height: 100%;
  width: 38%;
}

.mockup-bg-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
}

.mockup-safe-top,
.mockup-center,
.mockup-subtitle-bar {
  position: relative;
  z-index: 2;
}

.mockup-safe-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.mockup-channel {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.mockup-aspect-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  opacity: 0.78;
}

.mockup-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 9px;
  margin: auto 0;
}

.mockup-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
}

.mockup-title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.24;
  max-width: 96%;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.frame-mockup.aspect-16-9 .mockup-title {
  font-size: 19px;
  -webkit-line-clamp: 2;
}

.mockup-art {
  width: 62px;
  height: 62px;
  border-radius: 14px;
  display: grid;
  place-items: center;
}

.frame-mockup.aspect-16-9 .mockup-art {
  width: 48px;
  height: 48px;
}

.mockup-art img {
  width: 78%;
  height: 78%;
}

.mockup-subtitle-bar {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.38;
  padding: 7px 10px;
  border-radius: 7px;
  text-align: center;
}

/* Proportional Scene Rhythm Strip */
.scene-rhythm-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}

.rhythm-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.rhythm-pill b {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
}

.rhythm-pill.lead {
  border-color: var(--accent-border);
  color: var(--ink);
}

/* Quiet Inline Stage Telemetry Strip (No KPI card tiles!) */
.stage-specs {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding-top: 2px;
}

.spec-inline {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
}

.spec-k {
  color: var(--ink-3);
}

.spec-v {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ==================== IMAGE STUDIO CANVAS ==================== */
.image-desk {
  justify-content: space-between;
  gap: 12px;
}

.image-lightbox-wrap {
  flex: 1;
  width: 100%;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-lightbox-wrap img {
  max-width: min(100%, 680px);
  max-height: min(52vh, 460px);
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border-strong);
  object-fit: contain;
  display: block;
}

.artboard-placeholder {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-panel);
  background: var(--surface);
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  max-width: 100%;
}

.artboard-placeholder.aspect-1-1 {
  width: 340px;
  height: 340px;
}

.artboard-placeholder.aspect-4-5 {
  width: 288px;
  height: 360px;
}

.artboard-placeholder.aspect-A4 {
  width: 266px;
  height: 376px;
}

.artboard-placeholder.aspect-16-9 {
  width: 520px;
  height: 292px;
}

.artboard-placeholder.aspect-9-16 {
  width: 230px;
  height: 396px;
}

.placeholder-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}

.placeholder-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.38;
  max-width: 32ch;
}

.placeholder-sub {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.45;
  max-width: 36ch;
}

.image-stage-actions {
  width: 100%;
  max-width: 720px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-radius: var(--radius-ctrl);
  background: var(--surface);
  border: 1px solid var(--border);
}

.image-stage-caption {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-filmstrip {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 0;
}

.film-thumb {
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  padding: 0;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
}

.film-thumb.active {
  border-color: var(--accent);
}

.film-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==================== SLIDE PRESENTATION STAGE ==================== */
.slide-desk {
  justify-content: space-between;
  gap: 12px;
}

.slide-stage-shell {
  flex: 1;
  width: 100%;
  max-width: 760px;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slide-draft-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 410px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border-strong);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #f8f4eb;
  color: #1e1a16;
}

.slide-draft-preview.aspect-4-3 {
  aspect-ratio: 4 / 3;
  max-width: 540px;
}

.slide-draft-top,
.slide-draft-foot {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  opacity: 0.72;
}

.slide-draft-body {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slide-draft-style {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

.slide-draft-body h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.024em;
}

.slide-draft-body p {
  margin: 0;
  font-size: 13px;
  line-height: 1.48;
  opacity: 0.82;
  max-width: 54ch;
}

.slide-live-iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 420px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-ctrl);
  background: var(--console-bg);
}

.slide-toolbar {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.slide-nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slide-counter {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--ink-2);
  min-width: 56px;
  text-align: center;
}

.slide-sorter-strip {
  width: 100%;
  max-width: 760px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.sorter-chip {
  flex-shrink: 0;
  max-width: 165px;
  padding: 5px 9px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sorter-chip.active {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--accent-soft);
}

/* ==================== BOTTOM COMMAND DOCK ==================== */
.command-dock-wrap {
  flex-shrink: 0;
  padding: 12px 18px 14px;
  background: var(--stage-bg);
  border-top: 1px solid var(--border);
}

[data-studio-skin="atelier"] .command-dock-wrap {
  background: var(--surface);
}

.composer-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel);
  padding: 10px 14px 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 140ms ease;
}

[data-studio-skin="atelier"] .composer-box {
  border-color: var(--border);
  background: var(--surface-2);
}

.composer-box:focus-within {
  border-color: var(--accent);
}

.composer-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}

.composer-top-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  flex-shrink: 0;
}

.chip-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  overflow-x: auto;
  min-width: 0;
  scrollbar-width: none;
}

.chip-strip::-webkit-scrollbar {
  display: none;
}

.chip {
  height: 26px;
  padding: 0 9px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease;
}

[data-studio-skin="atelier"] .chip {
  background: var(--surface);
}

.chip:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--ink);
}

.composer-input {
  width: 100%;
  border: none !important;
  background: transparent !important;
  padding: 2px 0 !important;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  min-height: 50px;
  max-height: 180px;
}

.composer-hint {
  font-size: 12px;
  color: var(--ink-3);
}

.composer-hint:empty {
  display: none;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.dock-quiet-meta {
  font-size: 12px;
  color: var(--ink-3);
}

.pill-controls {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.pill-select {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  min-height: 32px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
}

[data-studio-skin="atelier"] .pill-select,
[data-studio-skin="atelier"] .pill-combo,
[data-studio-skin="atelier"] .pill-toggle {
  background: var(--surface);
}

.pill-select:hover,
.pill-select:focus-within,
.pill-combo:hover,
.pill-combo:focus-within {
  border-color: var(--border-strong);
  color: var(--ink);
}

.pill-select select {
  width: auto;
  border: none;
  background: transparent;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.pill-select select option,
.pill-select-inner select option {
  background: var(--surface);
  color: var(--ink);
}

.pill-combo {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  min-height: 32px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface-2);
  overflow: hidden;
}

.pill-trigger,
.pill-select-inner {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.pill-trigger svg:first-child,
.pill-select-inner svg {
  color: var(--ink-3);
}

.pill-select-inner select {
  width: auto;
  border: none;
  background: transparent;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.pill-play-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.pill-play-btn:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.pill-play-btn.playing {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill-play-btn.loading {
  color: var(--accent);
  cursor: wait;
}

.pill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 9px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.pill-toggle:hover,
.pill-toggle.active {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--ink);
}

/* Collapsible Advanced Drawer inside Dock */
.advanced-drawer {
  margin-top: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 240px;
  overflow-y: auto;
}

.adv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.adv-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.field-compact {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.adv-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}

.check-item input,
.check-row input {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 120ms ease, border-color 120ms ease;
}

[data-studio-skin="atelier"] .check-item input,
[data-studio-skin="atelier"] .check-row input {
  background: var(--surface);
}

.check-item input:checked,
.check-row input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check-item input:checked::after,
.check-row input:checked::after {
  content: "";
  width: 8px;
  height: 4.5px;
  border-left: 1.8px solid #ffffff;
  border-bottom: 1.8px solid #ffffff;
  transform: rotate(-45deg) translate(0.5px, -0.5px);
}

[data-studio-skin="graphite"] .check-item input:checked::after,
[data-studio-skin="graphite"] .check-row input:checked::after,
[data-studio-skin="saville"] .check-item input:checked::after,
[data-studio-skin="saville"] .check-row input:checked::after {
  border-color: var(--primary-ink);
}

.adv-prompt-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.adv-prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

/* ==================== RIGHT PROPERTIES INSPECTOR ==================== */
.workbench-inspector {
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.insp-medium {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.insp-medium.active {
  display: flex;
}

.insp-header {
  min-height: 48px;
  flex-shrink: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13px;
}

.insp-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.insp-section {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.insp-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
}

.insp-sec-note {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
}

.insp-mode-desc {
  margin: 0;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.45;
}

/* Compact 2-Column Mode Selector in Inspector */
.mode-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.mode-pill:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.mode-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 9px;
  border-radius: var(--radius-ctrl);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  min-width: 0;
  transition: border-color 130ms ease, background 130ms ease, color 130ms ease;
}

.mode-pill span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-pill:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.mode-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}

.mode-pill-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  flex-shrink: 0;
}

.mode-pill.active .mode-pill-tag {
  color: var(--accent);
}

.mode-options-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.mode-opt-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attached-media-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.attached-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--radius-ctrl);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  color: var(--ink);
}

.attached-pill button {
  background: none;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  font-weight: 700;
  padding: 0 2px;
}

.attached-pill button:hover {
  color: var(--danger);
}

/* Tactile Style Swatch Trigger & Compact Specimen Drawer (Replaces 11-card wall!) */
.active-swatch-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  min-width: 0;
  transition: border-color 130ms ease, background 130ms ease;
}

[data-studio-skin="atelier"] .active-swatch-trigger {
  background: var(--surface);
}

.active-swatch-trigger:hover {
  border-color: var(--accent);
}

.swatch-bars {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.swatch-bars span {
  width: 8px;
  height: 26px;
  border-radius: 2px;
}

.swatch-trigger-info {
  flex: 1;
  min-width: 0;
}

.swatch-trigger-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.swatch-trigger-meta {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.swatch-chevron {
  flex-shrink: 0;
  color: var(--ink-3);
  transition: transform 150ms ease;
}

.active-swatch-trigger[aria-expanded="true"] .swatch-chevron {
  transform: rotate(180deg);
}

.swatch-picker-drawer {
  display: none;
  flex-direction: column;
  gap: 3px;
  max-height: 248px;
  overflow-y: auto;
  padding-top: 4px;
}

.swatch-picker-drawer.open {
  display: flex;
}

.swatch-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--radius-ctrl);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  min-width: 0;
  transition: background 120ms ease, border-color 120ms ease;
}

.swatch-row:hover {
  background: var(--surface-2);
}

.swatch-row.selected {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.swatch-row .swatch-bars span {
  width: 6px;
  height: 20px;
}

.swatch-row-add {
  border: 1px dashed var(--border-strong);
  justify-content: center;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  margin-top: 3px;
}

.swatch-row-add:hover {
  border-color: var(--accent);
  color: var(--ink);
}

/* Inspector Toggles & Lists */
.insp-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}

/* Image Art Style Grid in Inspector */
.creation-mode-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.creation-mode-row .art-chip {
  text-align: center;
  padding: 0 5px;
}

.art-style-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.art-chip {
  min-height: 30px;
  padding: 5px 8px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.art-chip:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.art-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.kv-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kv-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.kv-line span:first-child {
  color: var(--ink-3);
}

.kv-line span:last-child {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.speaker-note-box {
  padding: 9px 10px;
  border-radius: var(--radius-ctrl);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.5;
  white-space: pre-wrap;
}

.raw-json-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  padding: 7px 9px;
  background: var(--surface-2);
}

.raw-json-details summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}

.raw-json-details textarea {
  margin-top: 8px;
}

/* ==================== ACTIVITY STAGE PANE ==================== */
.activity-stage-wrap {
  padding: 18px 22px;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  padding: 16px;
}

.activity-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.activity-head > div:first-child {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.activity-meta {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.activity-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.pipeline-steps {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pstep {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-3);
  font-weight: 500;
}

.pstep-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
}

.pstep.active {
  color: var(--ink);
  font-weight: 700;
}

.pstep.active .pstep-dot {
  border-color: var(--accent);
  background: var(--accent);
  animation: pulseRing 1.4s infinite;
}

.pstep.done {
  color: var(--ok);
}

.pstep.done .pstep-dot {
  border-color: var(--ok);
  background: var(--ok);
}

.raw-log-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  overflow: hidden;
  background: var(--console-bg);
}

.raw-log-details summary {
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-2);
  cursor: pointer;
}

.console-log {
  margin: 0;
  padding: 12px;
  background: var(--console-bg);
  color: var(--console-ink);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: 280px;
}

.qa-compact {
  margin-top: 8px;
  border-radius: var(--radius-ctrl);
  max-height: 160px;
}

/* ==================== BADGES & TAGS ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-neutral {
  background: var(--surface-3);
  color: var(--ink-2);
}

.badge-running {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-queued {
  background: var(--queued-soft);
  color: var(--queued);
}

.badge-done {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.queue-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
}

.queue-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  max-width: 100%;
}

.queue-pill.active {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--accent-soft);
}

.queue-pill-label {
  max-width: 165px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* ==================== POPOVERS (DURATION & VOICE) ==================== */
.duration-popover,
.voice-popover {
  position: fixed;
  z-index: 95;
  width: 318px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}

.voice-popover-head {
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
}

.voice-popover-hint {
  font-weight: 500;
  color: var(--ink-3);
  font-size: 12px;
}

.duration-popover-body {
  padding: 11px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.dur-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dur-group-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}

.dur-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.dur-chip {
  padding: 4px 10px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.dur-chip:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.dur-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--ink);
}

.dur-custom-box {
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dur-custom-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dur-custom-row input {
  flex: 1 1 0;
  min-width: 0;
  height: 32px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.dur-estimate {
  font-size: 12px;
  color: var(--ink-3);
}

.voice-popover-list {
  max-height: 332px;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.voice-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-ctrl);
  border: 1px solid transparent;
}

.voice-row:hover {
  background: var(--surface-2);
}

.voice-row.selected {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.voice-row-main {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  padding: 2px 0;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.voice-row-name {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-cached-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--ok);
  flex-shrink: 0;
}

.voice-row-desc {
  font-size: 12px;
  color: var(--ink-3);
}

.voice-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 27px;
  min-width: 72px;
  padding: 0 8px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.voice-play-btn:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.voice-play-btn.playing,
.voice-play-btn.loading {
  background: var(--primary-bg);
  border-color: var(--primary-bg);
  color: var(--primary-ink);
}

@keyframes spinIcon {
  to { transform: rotate(360deg); }
}

.spin {
  animation: spinIcon 0.9s linear infinite;
}

/* ==================== TAB 2: UNIFIED LIBRARY ==================== */
.videos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.videos-layout.with-inspector {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: start;
}

.videos-layout.with-inspector .video-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: border-color 140ms ease;
}

.video-card:hover {
  border-color: var(--border-strong);
}

.video-card.active {
  border-color: var(--accent);
}

.video-thumb {
  height: 176px;
  background: var(--stage-bg);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.video-thumb img,
.video-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slide-thumb-card {
  width: 100%;
  height: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.slide-thumb-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.24;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.play-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 150ms ease;
}

.video-card:hover .play-overlay {
  opacity: 1;
}

.play-circle {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--primary-bg);
  color: var(--primary-ink);
  display: grid;
  place-items: center;
}

.thumb-badge-tl,
.thumb-badge-br {
  position: absolute;
  background: rgba(10, 10, 11, 0.84);
  color: #f5f5f2;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

.thumb-badge-tl {
  top: 8px;
  left: 8px;
}

.thumb-badge-br {
  bottom: 8px;
  right: 8px;
}

.video-card-body {
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.video-card-body .tag-row {
  margin-top: auto;
  padding-top: 2px;
}

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.32;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.video-card .card-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-slug {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.video-card .card-slug {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
}

/* Video Detail Inspector */
.video-inspector {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  max-height: calc(100vh - 44px);
  overflow-y: auto;
  min-width: 0;
}

.video-inspector > .segmented {
  align-self: flex-start;
}

.inspector-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.inspector-head > div:first-child {
  flex: 1;
  min-width: 0;
}

.inspector-head h2 {
  margin: 0 0 3px;
  font-size: 16.5px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.inspector-meta {
  font-size: 12px;
  color: var(--ink-3);
}

.vtab-pane {
  display: none;
}

.vtab-pane.active {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.theater {
  background: var(--console-bg);
  border-radius: var(--radius-ctrl);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.theater video {
  max-height: 360px;
  max-width: 100%;
  border-radius: 6px;
  background: #000;
}

.sheet-viewer {
  background: var(--console-bg);
  border-radius: var(--radius-ctrl);
  padding: 12px;
  text-align: center;
}

.sheet-viewer img {
  max-width: 100%;
  border-radius: 6px;
}

.inspector-section {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.inspector-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
}

.inline-prompt-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-prompt-row input {
  flex: 1 1 0;
  min-width: 0;
  height: 32px;
}

.inline-prompt-row select {
  height: 32px;
}

.remix-controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.slider-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
}

.slider-field input[type="range"] {
  width: 96px;
  padding: 0;
  border: none;
  accent-color: var(--accent);
}

.danger-zone-row {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* Scene Media Manager */
.media-mgr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.scene-media-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}

.scene-media-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-ctrl);
  background: var(--surface-2);
  border: 1px solid var(--border);
  align-items: center;
}

.scene-media-thumb {
  width: 70px;
  height: 70px;
  border-radius: var(--radius-ctrl);
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  text-align: center;
  padding: 4px;
}

.scene-media-thumb img,
.scene-media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scene-media-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.scene-media-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.scene-media-id {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

.scene-media-desc {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scene-media-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.scene-lottie-sel {
  width: auto;
  height: 28px;
  padding: 0 7px;
  border-radius: var(--radius-ctrl);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 12px;
}

.stock-picker {
  padding: 10px;
  border-radius: var(--radius-ctrl);
  background: var(--surface-2);
  border: 1px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stock-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
}

.stock-results-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  max-height: 220px;
  overflow-y: auto;
}

.stock-hit-btn {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  aspect-ratio: 16 / 10;
}

.stock-hit-btn:hover {
  border-color: var(--accent);
}

.stock-hit-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.stock-hit-meta {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
}

/* ==================== TAB 3 & 4: STYLES & TEMPLATES ==================== */
.style-creator-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  padding: 14px 16px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.style-creator-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.style-creator-hint {
  font-size: 12px;
  color: var(--ink-3);
}

.style-mode-pane {
  display: none;
  flex-direction: column;
  gap: 9px;
}

.style-mode-pane.active {
  display: flex;
}

.style-creator-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.style-creator-row .creator-main-input {
  width: auto;
  flex: 1 1 280px;
  min-width: 200px;
  height: 34px;
}

.creator-id-input {
  width: 170px;
  flex: 0 0 170px;
  height: 34px;
}

.style-creator-row .btn-create,
.prompt-creator-bar .btn-create {
  height: 34px;
  border-radius: var(--radius-ctrl);
}

.dropzone {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-ctrl);
  background: var(--surface-2);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: var(--ink-2);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.dropzone.has-file {
  border-style: solid;
  border-color: var(--ok);
}

.dropzone-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dropzone-text strong {
  font-size: 13px;
  color: var(--ink);
}

.dropzone-text span {
  font-size: 12px;
  color: var(--ink-3);
}

.prompt-creator-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.prompt-creator-bar .creator-main-input {
  width: auto;
  flex: 1 1 280px;
  min-width: 200px;
  height: 34px;
}

.style-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.style-poster-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.style-poster-hero {
  height: 124px;
  padding: 13px 15px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  overflow: hidden;
}

.poster-visual-pill {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.style-poster-hero-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.style-swatch-strip {
  display: flex;
  height: 4px;
  width: 100%;
}

.style-swatch-strip span {
  flex: 1;
}

.style-poster-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  flex: 1;
  min-width: 0;
}

.style-desc {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
  overflow-wrap: break-word;
}

.card-foot-actions {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.template-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.tpl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  min-width: 0;
}

.tpl-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.tpl-head > div:first-child {
  flex: 1;
  min-width: 0;
}

.blueprint-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.blueprint-steps li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.4;
}

.bp-bullet {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--accent);
  margin-top: 7px;
  flex-shrink: 0;
}

/* ==================== MODALS & JOBS DRAWER ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 80;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel);
  width: min(740px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-float);
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.drawer-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-panel);
  width: min(1040px, 100%);
  height: min(84vh, 690px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-float);
}

.jobs-split {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.jobs-list {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
}

.job-row {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-ctrl);
  padding: 9px 10px;
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color 130ms ease, background 130ms ease;
}

.job-row:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.job-row.active {
  border-color: var(--accent);
  background: var(--surface-3);
}

.job-row-top {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.job-row-title {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 12.5px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.job-row-top .badge {
  margin-top: 1px;
}

.job-row-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.jobs-log-pane {
  background: var(--console-bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.drawer-log-head {
  flex-shrink: 0;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.drawer-log-info {
  flex: 1 1 240px;
  min-width: 0;
}

.drawer-log-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.drawer-head-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.drawer-ref-preview {
  flex-shrink: 0;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.drawer-ref-thumb {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--radius-ctrl);
  background: var(--console-bg);
  border: 1px solid var(--border-strong);
}

.drawer-ref-thumb:hover {
  border-color: var(--accent);
}

.drawer-ref-thumb img {
  display: block;
  max-height: 116px;
  max-width: 200px;
  width: auto;
  height: auto;
  border-radius: 4px;
  object-fit: contain;
}

.drawer-ref-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-ref-title {
  font-size: 12.5px;
  font-weight: 700;
}

.drawer-ref-sub {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.4;
}

.drawer-ref-actions {
  margin-top: 3px;
}

.live-action-ticker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  border-radius: var(--radius-ctrl);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  min-width: 0;
}

.live-ticker-text {
  flex: 1;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.trace-feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
}

.trace-item {
  flex-shrink: 0;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-ctrl);
  background: var(--surface);
  border: 1px solid var(--border);
}

.trace-item.active {
  border-color: var(--accent-border);
  background: var(--surface-2);
}

.trace-item.error {
  border-color: rgba(240, 100, 120, 0.45);
}

.trace-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-top: 5px;
  flex-shrink: 0;
  background: var(--ink-3);
}

.trace-item.active .trace-dot {
  background: var(--accent);
  animation: pulseRing 1.4s infinite;
}

.trace-item.done .trace-dot {
  background: var(--ok);
}

.trace-item.error .trace-dot {
  background: var(--danger);
}

.trace-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.trace-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.trace-title {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 700;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.trace-meta {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.trace-detail {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.5;
}

.trace-detail-prose {
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: normal;
  line-height: 1.55;
  margin-top: 3px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trace-detail-prose p {
  margin: 0;
}

.trace-detail-prose h4 {
  margin: 4px 0 1px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

.trace-detail-prose ul,
.trace-detail-prose ol {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.trace-detail-prose strong {
  color: var(--ink);
  font-weight: 700;
}

.jobs-log-pane .console-log {
  max-height: none;
  flex: 1;
  min-height: 0;
}

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-panel);
  padding: 28px 20px;
  text-align: center;
  color: var(--ink-2);
  font-size: 13px;
  grid-column: 1 / -1;
}

/* API Settings & Local Agent Bridge */
.api-key-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.key-label-row {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.key-badge {
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-3);
  flex-shrink: 0;
}

.key-badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.agent-bridge-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 5px 8px;
  border-radius: var(--radius-ctrl);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
}

.agent-bridge-pill:hover {
  border-color: var(--accent);
  color: var(--ink);
}

#agent-bridge-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-bridge-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--ok);
  flex-shrink: 0;
}

.agent-bridge-dot.warn {
  background: var(--warn);
}

.agent-bridge-dot.err {
  background: var(--danger);
}

.agent-status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-radius: var(--radius-ctrl);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 600;
}

.agent-guide-box,
.agent-share-box {
  padding: 12px 14px;
  border-radius: var(--radius-ctrl);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-guide-title {
  font-size: 12px;
  font-weight: 700;
}

.agent-guide-steps {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.modal-sub-caption {
  font-size: 11.5px;
  color: var(--ink-2);
  margin-top: 2px;
}

.agent-status-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.agent-poll-hint {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
}

.agent-modal-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-ctrl);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.agent-tab-btn {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: calc(var(--radius-ctrl) - 2px);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.agent-tab-btn:hover {
  color: var(--ink);
}

.agent-tab-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
}

.agent-tab-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prereq-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prereq-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  text-decoration: none;
}

a.prereq-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.prereq-chip.static {
  color: var(--ink-2);
}

.agent-install-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.agent-os-switch {
  display: inline-flex;
  gap: 4px;
  padding: 2px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.os-chip {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.os-chip.active {
  background: var(--accent);
  color: #fff;
}

.cmd-copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-ctrl);
  background: var(--surface);
  border: 1px solid var(--border-strong);
}

.cmd-copy-code {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--ink);
  user-select: all;
}

.agent-guide-note {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.45;
}

.agent-guide-note a {
  color: var(--accent);
  font-weight: 600;
}

.agent-after-box {
  border-style: dashed;
}

/* ==================== TOASTS ==================== */
.toast-stack {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  z-index: 100;
}

.toast {
  background: var(--surface-3);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  padding: 9px 14px;
  border-radius: var(--radius-ctrl);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-float);
}

.toast.ok {
  border-color: var(--ok);
}

.toast.err {
  border-color: var(--danger);
}

/* ==================== RESPONSIVE BREAKPOINTS ==================== */
@media (max-width: 1440px) {
  .stage-status-tag {
    display: none;
  }
  .composer-bar {
    gap: 6px;
  }
  .pill-controls {
    gap: 4px;
  }
  .pill-select,
  .pill-trigger,
  .pill-select-inner,
  .pill-toggle {
    padding-left: 6px;
    padding-right: 6px;
  }
  .composer-bar .btn-create {
    padding: 0 13px;
  }
}

@media (max-width: 1140px) {
  .workbench {
    grid-template-columns: minmax(0, 1fr);
    overflow-y: auto;
  }
  .workbench-center {
    overflow: visible;
  }
  .workbench-inspector {
    border-left: none;
    border-top: 1px solid var(--border);
    overflow: visible;
  }
  .insp-scroll {
    overflow: visible;
  }
  .videos-layout.with-inspector {
    grid-template-columns: 1fr;
  }
  .video-inspector {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 860px) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }
  .mobile-topbar {
    display: flex;
  }
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 48px);
    padding: 0;
    overflow: visible;
  }
  [data-studio-skin="atelier"] .main-stage {
    border: none;
    border-radius: 0;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 268px;
    max-width: 84vw;
    z-index: 70;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 14px 12px;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .workbench-bar {
    height: auto;
    min-height: 48px;
    padding: 8px 16px;
    flex-wrap: wrap;
    row-gap: 6px;
  }
  .workbench-bar-left {
    height: auto;
    flex-wrap: wrap;
    gap: 8px 14px;
  }
  .workbench-h1 {
    font-size: 16px;
  }
  .medium-switcher {
    height: auto;
  }
  .medium-tab {
    height: 32px;
    padding: 0 10px;
  }
  .stage-status-tag {
    display: none;
  }
  .canvas-desk {
    padding: 16px 16px 14px;
  }
  .frame-mockup.aspect-9-16 {
    width: 200px;
    height: 354px;
  }
  .page-frame {
    padding: 16px 14px 32px;
  }
  .adv-grid,
  .adv-grid-3,
  .api-key-grid {
    grid-template-columns: 1fr;
  }
  .drawer-box {
    height: min(92vh, 760px);
  }
  .jobs-split {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(140px, 34%) minmax(0, 1fr);
  }
  .jobs-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .drawer-ref-preview {
    flex-wrap: wrap;
  }
}
