/* LUMINA Adaptive Studio — final visual layer.
   Loaded after the historical stylesheet so the light/dark system is authoritative. */

:root {
  /* Primitive palette — raw material colors shared by both appearances. */
  --primitive-graphite-950: #0b1112;
  --primitive-graphite-900: #0e1516;
  --primitive-graphite-850: #121a1b;
  --primitive-graphite-800: #172122;
  --primitive-graphite-750: #1e2a2a;
  --primitive-ivory-50: #faf8f2;
  --primitive-ivory-100: #f3f0e8;
  --primitive-ivory-200: #ebe8de;
  --primitive-stone-200: #e9e7df;
  --primitive-stone-300: #dcded6;
  --primitive-jade-400: #6aa69a;
  --primitive-jade-500: #39796e;
  --primitive-jade-600: #255f56;
  --primitive-cyan-300: #8dd8e5;
  --primitive-cyan-600: #2b8395;
}

:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --studio-bg: var(--primitive-graphite-950);
  --studio-side: var(--primitive-graphite-900);
  --studio-panel: var(--primitive-graphite-850);
  --studio-panel-2: var(--primitive-graphite-800);
  --studio-panel-3: var(--primitive-graphite-750);
  --studio-line: rgba(223, 235, 228, .10);
  --studio-line-strong: rgba(223, 235, 228, .19);
  --studio-text: #eef0e9;
  --studio-muted: #a4aaa4;
  --studio-quiet: #737d78;
  --studio-accent: var(--primitive-jade-400);
  --studio-accent-strong: #91c9bb;
  --studio-accent-soft: rgba(106, 166, 154, .15);
  --studio-focus: var(--primitive-cyan-300);
  --studio-focus-soft: rgba(141, 216, 229, .13);
  --studio-ok: #85b89f;
  --studio-danger: #d98376;
  --studio-on-accent: #071110;
  --workspace-max: 1660px;
  --workspace-gutter: clamp(20px, 2.2vw, 44px);
  --studio-shadow: 0 34px 90px rgba(0, 0, 0, .42);
  --studio-shadow-soft: 0 18px 50px rgba(0, 0, 0, .24);
  --bg: var(--studio-bg);
  --bg-side: var(--studio-side);
  --surface: var(--studio-panel);
  --surface-2: var(--studio-panel-2);
  --surface-3: var(--studio-panel-3);
  --line: var(--studio-line);
  --line-strong: var(--studio-line-strong);
  --text: var(--studio-text);
  --muted: var(--studio-muted);
  --quiet: var(--studio-quiet);
  --accent: var(--studio-accent);
  --accent-hover: var(--studio-accent-strong);
  --accent-text: var(--studio-on-accent);
  --ok: var(--studio-ok);
  --danger: var(--studio-danger);
  --shadow: var(--studio-shadow);
  --shadow-soft: var(--studio-shadow-soft);
}

html[data-theme="light"] {
  color-scheme: light;
  --studio-bg: var(--primitive-ivory-100);
  --studio-side: var(--primitive-ivory-200);
  --studio-panel: var(--primitive-ivory-50);
  --studio-panel-2: var(--primitive-stone-200);
  --studio-panel-3: var(--primitive-stone-300);
  --studio-line: rgba(24, 39, 37, .11);
  --studio-line-strong: rgba(24, 39, 37, .20);
  --studio-text: #17201e;
  --studio-muted: #5f6965;
  --studio-quiet: #858e89;
  --studio-accent: var(--primitive-jade-500);
  --studio-accent-strong: var(--primitive-jade-600);
  --studio-accent-soft: rgba(57, 121, 110, .12);
  --studio-focus: var(--primitive-cyan-600);
  --studio-focus-soft: rgba(43, 131, 149, .12);
  --studio-ok: #39796e;
  --studio-danger: #a7473b;
  --studio-on-accent: #f8fbf7;
  --studio-shadow: 0 30px 80px rgba(55, 52, 40, .17);
  --studio-shadow-soft: 0 16px 44px rgba(55, 52, 40, .12);
}

html,
body { background: var(--studio-bg); }

body,
#app,
.main,
.view,
#viewCreate {
  background: var(--studio-bg);
  color: var(--studio-text);
}

#app { transition: background-color .24s ease, color .24s ease; }

.sidebar,
.sidebar:hover {
  width: 190px;
  min-width: 190px;
  padding: 18px 12px 14px;
  border-right-color: var(--studio-line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--studio-side) 95%, var(--studio-accent) 5%), var(--studio-side));
  box-shadow: none;
  transition: width .34s cubic-bezier(.22,.8,.24,1), min-width .34s cubic-bezier(.22,.8,.24,1), background-color .2s ease;
}

.sidebar .rail-toggle {
  display: grid !important;
  position: absolute;
  right: -12px;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--studio-line-strong);
  border-radius: 50%;
  background: var(--studio-panel);
  color: var(--studio-muted);
  box-shadow: var(--studio-shadow-soft);
}

.sidebar .rail-toggle svg { width: 13px; transition: transform .3s ease; }
.sidebar.rail,
.sidebar.rail:hover { width: 74px; min-width: 74px; }
.sidebar.rail .rail-toggle svg { transform: rotate(180deg); }
.sidebar.rail .brand { justify-content: center; }
.sidebar.rail .brand-text,
.sidebar.rail .nav-label,
.sidebar.rail .nav-item span,
.sidebar.rail .nav-new,
.sidebar.rail .user-info,
.sidebar.rail .logout-btn {
  display: block;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}
.sidebar.rail .nav-item,
.sidebar.rail:hover .nav-item { justify-content: center; padding: 0; gap: 0; }
.sidebar.rail .user-card { justify-content: center; padding: 7px 0; }
.sidebar .brand-text,
.sidebar .nav-item span,
.sidebar .user-info { transition: opacity .18s ease, max-width .28s ease; }
.sidebar .brand-mark { background: linear-gradient(145deg, var(--studio-panel-3), var(--studio-panel)); color: var(--studio-text); }
.sidebar .nav-item { color: var(--studio-muted); }
.sidebar .nav-item:hover { border-color: var(--studio-line); background: color-mix(in srgb, var(--studio-panel-2) 82%, transparent); color: var(--studio-text); }
.sidebar .nav-item.active { border-color: color-mix(in srgb, var(--studio-accent) 35%, transparent); background: var(--studio-accent-soft); color: var(--studio-text); }
.sidebar .nav-item.active::before { background: var(--studio-accent); box-shadow: 0 0 14px var(--studio-focus-soft); }
.sidebar .account-popover {
  left: calc(100% + 12px);
  min-width: 292px;
  padding: 18px;
  border-color: var(--studio-line-strong);
  background: color-mix(in srgb, var(--studio-panel) 94%, transparent);
  box-shadow: var(--studio-shadow);
  backdrop-filter: blur(28px) saturate(1.2);
}
.account-logout { display: flex; width: 100%; margin-top: 14px; padding: 12px 0 0; justify-content: space-between; border-top: 1px solid var(--studio-line); color: var(--studio-muted); font-size: 11px; }
.account-logout:hover { color: var(--studio-danger); }

.stage {
  padding: 0 var(--workspace-gutter) 70px;
  background:
    radial-gradient(circle at 48% -5%, var(--studio-focus-soft), transparent 28%),
    linear-gradient(180deg, color-mix(in srgb, var(--studio-bg) 94%, var(--studio-accent) 6%), var(--studio-bg) 46%);
}
.stage::after { display: none; }
.hero,
body.workspace .hero { width: min(100%, 1180px); padding: clamp(34px, 5vh, 58px) 0 16px; gap: 16px; }
.hero-copy .eyebrow { display: block; margin-bottom: 11px; color: var(--studio-accent); font-size: 8px; letter-spacing: .24em; }
.hero-title { color: var(--studio-text); font-size: clamp(38px, 4.4vw, 66px); font-weight: 620; letter-spacing: -.07em; }
.hero-lede { max-width: 640px; margin-top: 12px; color: var(--studio-muted); font-size: 12px; }
.mode-switch { background: color-mix(in srgb, var(--studio-panel) 86%, transparent); border-color: var(--studio-line-strong); }
.mode-slider { background: var(--studio-accent); }
.mode-btn { color: var(--studio-muted); }
.mode-btn.active { color: var(--studio-on-accent); }

.composer,
body.workspace .composer {
  width: min(100%, 1180px);
  min-height: 164px;
  padding: 18px 20px 15px;
  border-color: var(--studio-line-strong);
  border-radius: 18px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--studio-panel) 96%, var(--studio-focus) 4%), var(--studio-panel));
  box-shadow: var(--studio-shadow-soft), inset 0 1px color-mix(in srgb, var(--studio-text) 6%, transparent);
  transition: min-height .34s cubic-bezier(.22,.8,.24,1), padding .34s cubic-bezier(.22,.8,.24,1), border-color .2s ease, box-shadow .2s ease;
}
.composer-glow { display: block; position: absolute; inset: -1px; z-index: -1; border-radius: inherit; opacity: 0; background: linear-gradient(110deg, transparent 12%, var(--studio-focus-soft), transparent 62%); pointer-events: none; }
.composer:focus-within { border-color: color-mix(in srgb, var(--studio-focus) 58%, var(--studio-line-strong)); box-shadow: 0 20px 58px color-mix(in srgb, var(--studio-focus) 10%, transparent), 0 0 0 3px var(--studio-focus-soft); }
.composer:focus-within .composer-glow { opacity: 1; }
.prompt-input { color: var(--studio-text); }
.prompt-input::placeholder { color: var(--studio-quiet); }
.kind-mini,
.chip { border-color: var(--studio-line); background: color-mix(in srgb, var(--studio-panel-2) 74%, transparent); color: var(--studio-muted); }
.km-btn { color: var(--studio-muted); }
.km-btn.active { background: var(--studio-accent); color: var(--studio-on-accent); }
.mode-chip .mode-dot { background: var(--studio-focus); box-shadow: 0 0 0 4px var(--studio-focus-soft); }
.send-btn { background: var(--studio-accent); color: var(--studio-on-accent); box-shadow: 0 10px 28px color-mix(in srgb, var(--studio-accent) 24%, transparent); }
.send-btn:hover { background: var(--studio-accent-strong); }

.inspiration-reel,
body.workspace .inspiration-reel { width: min(100%, var(--workspace-max)); margin-top: 22px; }
.reel-head { margin-top: 30px; }
.reel-head .eyebrow { color: var(--studio-accent); }
.reel-head h2 { color: var(--studio-text); }
.reel-head p { color: var(--studio-quiet); }
.reel-grid { display: grid; grid-template-columns: 1.38fr 1fr 1fr 1.18fr; grid-auto-rows: clamp(190px, 15vw, 258px); gap: 12px; }
.inspire-chip.reel-card,
.reel-card:nth-child(1),
.reel-card:nth-child(2),
.reel-card:nth-child(3),
.reel-card:nth-child(4) { width: auto; height: 100%; min-height: 190px; grid-row: auto; grid-column: auto; border-color: var(--studio-line); border-radius: 15px; }
.reel-card img,
.reel-card video { width: 100%; height: 100%; object-fit: cover; filter: none; transform: scale(1.001); transition: transform .6s cubic-bezier(.2,.8,.2,1); }
.reel-card:hover img,
.reel-card:hover video { filter: none; transform: scale(1.035); }
.reel-card:focus-visible { outline: 2px solid var(--studio-focus); outline-offset: 3px; }
.reel-shade { background: linear-gradient(180deg, rgba(5,10,10,.02) 32%, rgba(5,10,10,.78)); }
.prompt-suggestion { border-color: var(--studio-line); background: color-mix(in srgb, var(--studio-panel) 74%, transparent); color: var(--studio-muted); }
.prompt-suggestion:hover { border-color: color-mix(in srgb, var(--studio-accent) 50%, var(--studio-line)); background: var(--studio-accent-soft); color: var(--studio-text); }

body.workspace .stage { padding-bottom: 116px; }
.results,
body.workspace .results { width: min(100%, var(--workspace-max)); margin-top: 20px; }
.generation-project { margin-bottom: 22px; }
.project-output-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.project-output-grid .card { max-width: none; }
.card-overlay { background: linear-gradient(180deg, transparent 18%, rgba(5,12,13,.9)); }
.card-config { margin-top: 5px; color: rgba(235, 241, 237, .66); font-size: 9px; }
.card-actions { display: flex; gap: 6px; }
.card-action,
.card-dl { min-height: 28px; padding: 0 10px; border: 1px solid rgba(255,255,255,.2); border-radius: 7px; background: rgba(7,14,15,.56); color: #f0f4ef; font-size: 9px; backdrop-filter: blur(12px); }
.card-action:hover,
.card-dl:hover { border-color: rgba(255,255,255,.5); background: rgba(242,247,242,.92); color: #101817; }
.asset-card-check { display: none; position: absolute; top: 12px; right: 12px; z-index: 8; width: 28px; height: 28px; place-items: center; border: 1px solid rgba(255,255,255,.32); border-radius: 8px; background: rgba(7,14,15,.58); backdrop-filter: blur(12px); cursor: pointer; }
.asset-card-check input { position: absolute; opacity: 0; }
.asset-card-check span { width: 12px; height: 12px; border: 1px solid rgba(255,255,255,.72); border-radius: 3px; }
.asset-card-check input:checked + span { border-color: var(--studio-focus); background: var(--studio-focus); box-shadow: inset 0 0 0 3px rgba(7,14,15,.72); }

body.workspace .dock {
  position: sticky;
  padding: 8px var(--workspace-gutter) max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--studio-bg) 94%, transparent) 24%, var(--studio-bg));
  backdrop-filter: blur(18px);
}
body.workspace .composer.compact { width: min(100%, 1180px); min-height: 96px; }
body.workspace .composer.compact:not(.expanded) { min-height: 64px; padding: 9px 12px; }
body.workspace .composer.compact:not(.expanded) .prompt-input { height: 23px; min-height: 23px; max-height: 23px; font-size: 12px; }
body.workspace .composer.compact:not(.expanded) .attach-tray,
body.workspace .composer.compact:not(.expanded) .chip:not(.model-chip):not(.mode-chip),
body.workspace .composer.compact:not(.expanded) .kind-mini { display: none !important; }
body.workspace .composer.compact:not(.expanded) .composer-bar { margin-top: 2px; }
body.workspace .composer.compact.expanded { min-height: 142px; padding: 16px 18px 13px; border-color: color-mix(in srgb, var(--studio-focus) 42%, var(--studio-line-strong)); box-shadow: 0 24px 70px rgba(0,0,0,.28), 0 0 0 3px var(--studio-focus-soft); }
body.workspace .composer.compact.expanded .prompt-input { min-height: 60px; max-height: 112px; font-size: 16px; }
body.workspace .composer.dock-arrived { animation: dock-arrive .48s cubic-bezier(.16,.9,.25,1) both; }
@keyframes dock-arrive { from { opacity: .3; transform: translateY(22px) scale(.985); } to { opacity: 1; transform: none; } }

.view-head,
.ai-tools-hero,
.tool-wrap,
.ai-tools-toolbar,
.ai-library-layout,
.ai-task-section,
.admin-list,
.asset-toolbar,
.asset-grid,
.asset-pagination {
  width: calc(100% - (var(--workspace-gutter) * 2));
  max-width: var(--workspace-max);
  margin-right: auto;
  margin-left: auto;
}
.view-head { padding: 40px 0 22px; border-bottom-color: var(--studio-line); }
.view-head .eyebrow { color: var(--studio-accent); }
.view-title { color: var(--studio-text); font-size: clamp(34px, 3.4vw, 52px); }
.view-subtitle { color: var(--studio-muted); }

#viewAssets,
#viewTools,
#viewAiTools,
#viewAdmin { background: var(--studio-bg); }
.asset-filters { border-color: var(--studio-line); background: var(--studio-panel); }
.af-btn { color: var(--studio-muted); }
.af-btn.active { background: var(--studio-accent); color: var(--studio-on-accent); }
.asset-toolbar { display: flex; min-height: 50px; padding: 10px 0; gap: 10px; align-items: center; border-bottom: 1px solid var(--studio-line); }
.asset-toolbar button,
.asset-pagination button,
.asset-pagination select { min-height: 32px; padding: 0 12px; border: 1px solid var(--studio-line); border-radius: 8px; background: var(--studio-panel); color: var(--studio-muted); font-size: 10px; }
.asset-toolbar button:not(:disabled):hover,
.asset-pagination button:not(:disabled):hover { border-color: var(--studio-accent); color: var(--studio-text); }
.asset-toolbar button:disabled,
.asset-pagination button:disabled { opacity: .36; }
.asset-select-page { display: flex; gap: 8px; align-items: center; color: var(--studio-text); font-size: 11px; }
.asset-selection-count { margin-right: auto; color: var(--studio-quiet); font-size: 10px; }
.asset-grid { padding: 16px 0 22px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
#viewAssets .card,
#viewAssets .card.r-square,
#viewAssets .card.r-tall,
#viewAssets .card.r-wide { min-height: 0; aspect-ratio: 4 / 3; border-color: var(--studio-line); border-radius: 13px; background: var(--studio-panel); }
#viewAssets .asset-card-check { display: grid; }
#viewAssets .card-overlay { opacity: 0; transition: opacity .2s ease; }
#viewAssets .card:hover .card-overlay,
#viewAssets .card:focus-within .card-overlay { opacity: 1; }
.asset-pagination { display: flex; padding: 12px 0 40px; gap: 10px; align-items: center; justify-content: center; color: var(--studio-muted); font-size: 10px; }
.asset-pagination label { display: flex; margin-left: 8px; gap: 7px; align-items: center; }

.tool-wrap { height: calc(100dvh - 130px); min-height: 660px; margin-top: 14px; border-color: var(--studio-line); border-radius: 14px; background: var(--studio-panel); }
.tool-frame { width: 100%; height: 100%; }
.tool-offline { color: var(--studio-text); }
.tool-start-btn { background: var(--studio-accent); color: var(--studio-on-accent); }
.tool-start-btn.ghost { border-color: var(--studio-line-strong); background: var(--studio-panel-2); color: var(--studio-text); }

.ai-tools-hero { min-height: 0; padding: 40px 0 22px; grid-template-columns: minmax(0,1fr) 360px; gap: 38px; border-bottom-color: var(--studio-line); }
.ai-tools-hero::before,
.ai-tools-hero::after { display: none; }
.ai-tools-copy .eyebrow { color: var(--studio-accent); }
.ai-tools-copy h2 { color: var(--studio-text); font-size: clamp(38px, 4.2vw, 64px); }
.ai-tools-copy h2 span { color: var(--studio-accent); }
.ai-tools-copy p { color: var(--studio-muted); }
.ai-tools-hero-meta { border-color: var(--studio-line); background: var(--studio-panel); }
.ai-tools-hero-meta div { border-color: var(--studio-line); }
.ai-tools-hero-meta b { color: var(--studio-text); }
.ai-tools-toolbar { padding: 14px 0; }
.ai-search-wrap input,
.ai-tool-filters { border-color: var(--studio-line); background: var(--studio-panel); color: var(--studio-text); }
.ai-tool-filters button { color: var(--studio-muted); }
.ai-tool-filters button.active { background: var(--studio-accent); color: var(--studio-on-accent); }
.ai-library-layout { grid-template-columns: minmax(0,1fr) minmax(360px, 430px); gap: 14px; }
.ai-tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.ai-tool-card,
.ai-tool-card:first-child { min-height: 315px; grid-column: auto; border-color: var(--studio-line); background: var(--studio-panel); }
.ai-tool-card:first-child .ai-tool-visual,
.ai-tool-visual { height: 160px; }
.ai-tool-card:first-child .ai-tool-card-copy strong,
.ai-tool-card-copy strong { color: var(--studio-text); font-size: 21px; }
.ai-tool-card-copy > span { color: var(--studio-muted); }
.ai-tool-cover,
.ai-tool-card:hover .ai-tool-cover,
.ai-tool-card.selected .ai-tool-cover { filter: none; }
.ai-tool-card:hover { border-color: color-mix(in srgb, var(--studio-focus) 48%, var(--studio-line)); transform: translateY(-2px); box-shadow: var(--studio-shadow-soft); }
.ai-tool-card.selected { border-color: var(--studio-accent); box-shadow: inset 3px 0 var(--studio-accent); }
.ai-workbench { min-height: 540px; border-color: var(--studio-line); background: var(--studio-panel); box-shadow: none; }
.ai-workbench-head,
.ai-workbench-form { border-color: var(--studio-line); }
.ai-upload-zone,
.ai-field textarea,
.ai-field select,
.ai-input-unit input,
.ai-workbench-readiness { border-color: var(--studio-line); background: var(--studio-panel-2); color: var(--studio-text); }
.ai-run-btn { background: var(--studio-accent); color: var(--studio-on-accent); }

#viewAdmin .view-head,
#viewAdmin .admin-list { max-width: var(--workspace-max); }
.admin-list { padding: 16px 0 50px; }
.admin-summary > * { border-color: var(--studio-line); background: var(--studio-panel); color: var(--studio-muted); }
.acc-card { border-color: var(--studio-line); border-radius: 13px; background: var(--studio-panel); }
.acc-head { min-height: 76px; }
.acc-detail { padding: 0 18px 18px; }
.acc-stats { grid-template-columns: repeat(4, 1fr); }
.acc-gen-row { grid-template-columns: 54px minmax(260px, 1.5fr) minmax(160px, .7fr) 80px 110px 110px; }
.g-content,
.g-model { display: flex; min-width: 0; gap: 4px; flex-direction: column; }
.g-content b { overflow: hidden; color: var(--studio-text); font-weight: 540; text-overflow: ellipsis; white-space: nowrap; }
.g-content small,
.g-model small { color: var(--studio-quiet); font-size: 8px; }

.model-panel,
.pop-panel,
.advanced-panel,
.reference-link-panel,
.modal,
.lightbox-meta { border-color: var(--studio-line-strong); background: var(--studio-panel); color: var(--studio-text); box-shadow: var(--studio-shadow); }
.model-item:hover,
.model-item.selected,
.pop-option:hover,
.pop-option.selected { background: var(--studio-panel-3); }
.toast { border-color: var(--studio-line-strong); background: var(--studio-panel-3); color: var(--studio-text); box-shadow: var(--studio-shadow-soft); }

.theme-options { grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-options .theme-opt { display: grid; min-height: 104px; padding: 12px; grid-template-columns: 44px minmax(0,1fr); gap: 11px; align-items: center; border: 1px solid var(--studio-line); border-radius: 12px; background: var(--studio-panel-2); text-align: left; }
.theme-options .theme-opt.active { border-color: var(--studio-accent); background: var(--studio-accent-soft); box-shadow: 0 0 0 3px var(--studio-focus-soft); }
.theme-opt > span:last-child { display: flex; gap: 5px; flex-direction: column; }
.theme-opt b { color: var(--studio-text); font-size: 12px; }
.theme-opt small { color: var(--studio-muted); font-size: 9px; line-height: 1.45; }
.theme-swatch { width: 44px; height: 58px; border: 1px solid var(--studio-line-strong); border-radius: 9px; }
.sw-light { background: linear-gradient(145deg, #f3f0e8 55%, #39796e 56%); }
.sw-dark { background: linear-gradient(145deg, #0b1112 55%, #6aa69a 56%); }
.sw-system { background: linear-gradient(145deg, #f3f0e8 49%, #0b1112 50% 72%, #6aa69a 73%); }

html[data-theme="light"] .mode-switch { background: rgba(250,248,242,.86); }
html[data-theme="light"] .reel-shade { background: linear-gradient(180deg, rgba(5,10,10,.02) 32%, rgba(5,10,10,.72)); }
html[data-theme="light"] body.workspace .dock { background: linear-gradient(180deg, transparent, rgba(243,240,232,.94) 28%, #f3f0e8); }
html[data-theme="light"] .card-overlay { color: #f7faf6; }

@media (max-width: 1320px) {
  .reel-grid { grid-template-columns: repeat(2, minmax(0,1fr)); grid-auto-rows: 230px; }
  .asset-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .ai-tool-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .ai-library-layout { grid-template-columns: minmax(0,1fr) 370px; }
}

@media (max-width: 920px) {
  .sidebar,
  .sidebar:hover { width: 154px; min-width: 154px; }
  .sidebar.rail,
  .sidebar.rail:hover { width: 68px; min-width: 68px; }
  .asset-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .ai-tools-hero,
  .ai-library-layout { grid-template-columns: 1fr; }
  .ai-workbench { position: relative; top: auto; }
  .acc-gen-row { grid-template-columns: 46px minmax(160px,1fr) 120px 70px 90px; }
  .g-time { display: none; }
}

@media (max-width: 760px) {
  .sidebar,
  .sidebar:hover,
  .sidebar.rail,
  .sidebar.rail:hover {
    display: flex;
    width: 100%;
    min-width: 100%;
    flex-direction: row;
    align-items: center;
  }
  .sidebar .rail-toggle { display: none !important; }
  .sidebar.rail .nav-item span { display: block; max-width: none; opacity: 1; }
  .sidebar .nav { width: auto; min-width: 0; flex: 1; }
  .sidebar .side-bottom {
    display: flex;
    position: static;
    z-index: auto;
    width: 92px;
    height: 50px;
    margin-left: 5px;
    flex-direction: row;
    flex: 0 0 92px;
    gap: 4px;
    align-items: center;
  }
  .sidebar .side-bottom #settingsBtn,
  .sidebar .side-bottom .user-card {
    display: flex;
    width: 44px;
    min-width: 44px;
    height: 50px;
    min-height: 50px;
    padding: 0;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--studio-line-strong);
    border-radius: 12px;
    background: color-mix(in srgb, var(--studio-panel) 88%, transparent);
    box-shadow: var(--studio-shadow-soft);
    backdrop-filter: blur(18px);
  }
  .sidebar .side-bottom #settingsBtn span,
  .sidebar .side-bottom .user-info,
  .sidebar .side-bottom .logout-btn { display: none; }
  .sidebar .side-bottom .user-avatar { width: 30px; height: 30px; }
  .sidebar .account-popover {
    display: block;
    top: auto;
    right: 0;
    bottom: calc(100% + 8px);
    left: auto;
    width: min(292px, calc(100vw - 24px));
    min-width: 0;
    transform-origin: 100% 100%;
  }
  .sidebar .account-popover::before { display: none; }
  .hero-title { font-size: clamp(38px, 12vw, 54px); }
  .reel-grid { display: flex; grid-auto-rows: auto; overflow-x: auto; }
  .inspire-chip.reel-card,
  .reel-card:nth-child(1),
  .reel-card:nth-child(2),
  .reel-card:nth-child(3),
  .reel-card:nth-child(4) { width: 78vw; min-width: 78vw; height: 220px; min-height: 220px; }
  .asset-grid { grid-template-columns: 1fr; }
  .asset-toolbar { flex-wrap: wrap; }
  .asset-selection-count { flex: 1; }
  .theme-options { grid-template-columns: 1fr; }
  .theme-options .theme-opt { min-height: 82px; }
  .ai-tool-grid { grid-template-columns: 1fr; }
  .acc-gen-row { grid-template-columns: 42px minmax(0,1fr) 76px; }
  .g-model,
  .g-status-stack,
  .g-time { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  body.workspace .composer.dock-arrived,
  .ai-tool-card,
  .reel-card img,
  .reel-card video { animation: none !important; transition: none !important; transform: none !important; }
}
