/* ==========================================================================
   EDITORIAL PAPER & ANALOG DARKROOM DESIGN SYSTEM (HUMAN-CRAFTED, ZERO-NEON)
   ========================================================================== */

:root {
  color-scheme: light;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --bg: #f6f4ef;
  --stage-bg: #eeebe2;
  --surface: #fcfbf8;
  --subtle: #f1eee7;
  --hover: #e7e2d8;
  --ink: #191816;
  --ink-2: #5b5750;
  --ink-3: #88837a;
  --line: #e2ddd3;
  --line-strong: #c7c0b2;
  --accent: #255247;
  --accent-hover: #1a4036;
  --accent-ink: #faf9f6;
  --accent-wash: rgba(37, 82, 71, 0.10);
  --accent-border: #255247;
  --stamp: #a84322;
  --stamp-wash: rgba(168, 67, 34, 0.085);
  --stamp-border: rgba(168, 67, 34, 0.32);
  --focus: #255247;
  --positive: #236844;
  --danger: #b32b2b;
  --topbar-bg: rgba(246, 244, 239, 0.92);
  --radius-xs: 4px;
  --radius-sm: 5px;
  --radius-md: 7px;
  --radius-lg: 9px;
  --shadow-sm: 0 1px 2px rgba(25, 24, 22, 0.04);
  --shadow-md: 0 8px 24px rgba(25, 24, 22, 0.07);
  --shadow-lg: 0 20px 48px rgba(25, 24, 22, 0.14);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141311;
  --stage-bg: #100f0d;
  --surface: #1c1b18;
  --subtle: #24221f;
  --hover: #2e2b27;
  --ink: #efece5;
  --ink-2: #a29c92;
  --ink-3: #736e65;
  --line: #2c2925;
  --line-strong: #403d37;
  --accent: #b9d6c8;
  --accent-hover: #d2e5dc;
  --accent-ink: #161513;
  --accent-wash: rgba(185, 214, 200, 0.12);
  --accent-border: #b9d6c8;
  --stamp: #d46d49;
  --stamp-wash: rgba(212, 109, 73, 0.14);
  --stamp-border: rgba(212, 109, 73, 0.42);
  --focus: #ece8df;
  --positive: #68b88e;
  --danger: #e57373;
  --topbar-bg: rgba(20, 19, 17, 0.92);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.62);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: clip;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.skip-link {
  position: fixed; z-index: 180; inset-block-start: 8px; inset-inline-start: 8px;
  padding: 8px 12px; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink);
  transform: translateY(calc(-100% - 12px)); text-decoration: none;
}
.skip-link:focus { transform: none; }
:is(button, a, summary, input[type="checkbox"], input[type="range"]):focus-visible {
  outline: 1.5px solid var(--focus);
  outline-offset: 2px;
}
:is(input:not([type="checkbox"]):not([type="range"]), textarea, select):focus-visible {
  outline: none;
}

.inline-code {
  font-size: 11.5px; padding: 1px 6px; border-radius: 3px;
  background: var(--subtle); border: 1px solid var(--line); color: var(--ink);
}

.hidden, [hidden] { display: none !important; }
.auth-code-row { display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: 8px; }
.auth-hp-trap {
  position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important;
  opacity: 0 !important; pointer-events: none !important;
}
.auth-jigsaw-field { position: relative; gap: 6px; }
.auth-jigsaw-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.auth-jigsaw-title { color: var(--ink-2); font-weight: 500; }
.auth-jigsaw-refresh {
  border: 0; background: transparent; color: var(--stamp); font-size: 12px; cursor: pointer; padding: 2px 4px; border-radius: 4px;
}
.auth-jigsaw-refresh:hover { text-decoration: underline; }
.auth-jigsaw-stage {
  position: relative; width: 100%; aspect-ratio: 260 / 96; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: var(--subtle); user-select: none; -webkit-user-select: none;
}
.auth-jigsaw-scene { display: block; width: 100%; height: 100%; object-fit: fill; pointer-events: none; }
.auth-jigsaw-piece {
  position: absolute; top: 0; left: 0; height: 100%; pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35)); will-change: left;
}
.auth-jigsaw-track {
  position: relative; height: 36px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--subtle); display: flex; align-items: center; justify-content: center;
  overflow: hidden; user-select: none; -webkit-user-select: none;
}
.auth-jigsaw-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: color-mix(in srgb, var(--stamp) 16%, transparent); pointer-events: none;
}
.auth-jigsaw-track[data-state="ready"] { border-color: var(--stamp); }
.auth-jigsaw-track[data-state="ready"] .auth-jigsaw-hint { color: var(--stamp); font-weight: 600; }
.auth-jigsaw-hint {
  position: relative; z-index: 1; font-size: 12px; color: var(--ink-2); pointer-events: none;
  padding: 0 42px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.auth-jigsaw-thumb {
  position: absolute; left: 2px; top: 2px; width: 38px; height: 30px; border-radius: 6px;
  border: 1px solid var(--line-strong, var(--line)); background: var(--surface, #fff); color: var(--ink);
  font-size: 14px; font-weight: 600; cursor: grab; z-index: 2; touch-action: none;
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.auth-jigsaw-thumb:active { cursor: grabbing; background: var(--stamp); color: var(--bg); }
.full { width: 100%; }
.mono { font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--ink-2); font-size: 12.5px; line-height: 1.55; }
.text-accent { color: var(--stamp); }
.num-positive { color: var(--positive); font-weight: 600; font-size: 12px; }
.num-danger { color: var(--danger); font-weight: 600; font-size: 12px; }

/* File protocol fallback */
html[data-entry="file"] body > :not(.file-launch) { display: none; }
html[data-entry="file"] .file-launch {
  min-height: 100vh; padding: 24px; display: grid; place-items: center; background: var(--bg);
}
.file-launch-card {
  width: min(100%, 460px); padding: clamp(24px, 6vw, 38px);
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  background: var(--surface);
}
.file-launch-card h1 { font-family: var(--font-serif); font-size: 24px; font-weight: 600; }
.file-launch-card p { margin: 10px 0 20px; color: var(--ink-2); }
.file-launch-card a { text-decoration: none; }

/* ==================== EDITORIAL HEADER ==================== */
.topbar {
  position: sticky; top: 0; z-index: 80;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1680px; margin: 0 auto; height: 54px; padding: 0 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  border: 0; background: transparent; padding: 4px 0;
  flex-shrink: 0; white-space: nowrap;
}
/* Minimalist camera viewfinder / editorial mark */
.brand-mark {
  position: relative; width: 17px; height: 17px; display: inline-block; flex-shrink: 0;
  border: 1.75px solid var(--ink); border-radius: 2px;
}
.brand-mark::after {
  content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--stamp);
}
.brand-name {
  font-weight: 650; font-size: 15px; letter-spacing: 0.02em;
}

.nav {
  display: flex; align-items: stretch; gap: 4px; align-self: stretch;
}
.nav-tab {
  position: relative;
  border: 0; background: transparent; color: var(--ink-2);
  padding: 0 12px; font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: color 0.15s ease;
}
.nav-tab:hover { color: var(--ink); }
.nav-tab.active { color: var(--ink); font-weight: 620; }
.nav-tab.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px;
  height: 2px; background: var(--ink);
}

.topbar-right { display: flex; align-items: center; gap: 7px; min-width: 0; }
.topbar-right button { min-height: 30px; }
.task-icon, .more-icon { display: none; }
.topbar-menu { position: relative; }
.topbar-menu summary { min-height: 30px; list-style: none; cursor: pointer; white-space: nowrap; }
.topbar-menu summary::-webkit-details-marker { display: none; }
.topbar-menu-panel {
  position: absolute; inset: calc(100% + 8px) 0 auto auto; width: 172px;
  display: grid; gap: 2px; padding: 5px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
}
.topbar-menu-panel button {
  width: 100%; min-height: 33px; padding: 6px 10px;
  border: 0; border-radius: var(--radius-xs); background: transparent;
  color: var(--ink); font-size: 12.5px; font-weight: 530;
  justify-content: flex-start; text-align: left;
}
.topbar-menu-panel button:hover, .topbar-menu-panel button.active {
  background: var(--subtle); color: var(--ink);
}
.topbar-menu-panel .nav-tab.active::after { display: none; }
.topbar-menu-panel .cmd-trigger {
  margin-top: 3px; padding-top: 8px; border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius-xs) var(--radius-xs); color: var(--ink-2);
}
.topbar-menu-panel .cmd-trigger span { margin-right: auto; }

.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-3); display: inline-block;
}
.status-dot.busy {
  background: var(--stamp);
  animation: gentleBlink 1.2s ease-in-out infinite;
}

.vip-mini-pill {
  font-size: 10px; font-weight: 600; padding: 1px 5px; border-radius: 3px;
  background: var(--subtle); color: var(--ink-2); border: 1px solid var(--line);
}
.auth-trigger { max-width: 112px; overflow: hidden; text-overflow: ellipsis; }

.announcement-bar {
  background: var(--stamp-wash); border-bottom: 1px solid var(--stamp-border);
  padding: 6px 22px; font-size: 12px; color: var(--ink);
}
.announcement-inner {
  max-width: 1680px; margin: 0 auto; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.announcement-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--stamp); flex-shrink: 0;
}

/* ==================== PRIMITIVES ==================== */
.btn-primary, .btn-primary-sm, .btn-outline, .btn-outline-sm, .btn-subtle, .btn-icon, .btn-icon-sm {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-sm); font-weight: 550; white-space: nowrap;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, opacity 0.14s ease;
}
.btn-primary {
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  padding: 9px 16px; font-size: 13px; font-weight: 600;
}
.btn-primary-sm {
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  padding: 5px 12px; font-size: 12px; font-weight: 600;
}
.btn-primary:hover, .btn-primary-sm:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled, .btn-primary-sm:disabled { opacity: 0.38; cursor: not-allowed; }

.btn-outline {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 8px 14px; font-size: 13px;
}
.btn-outline-sm {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 5px 11px; font-size: 12px; text-decoration: none;
}
.btn-outline:hover, .btn-outline-sm:hover { background: var(--subtle); border-color: var(--ink-2); }
.btn-outline:disabled, .btn-outline-sm:disabled { opacity: 0.38; cursor: not-allowed; }

.btn-subtle {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  padding: 4px 10px; font-size: 12px;
}
.btn-subtle:hover { color: var(--ink); background: var(--subtle); border-color: var(--line-strong); }

.btn-icon {
  width: 30px; height: 30px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); border-radius: var(--radius-sm);
}
.btn-icon:hover { color: var(--ink); background: var(--subtle); border-color: var(--line-strong); }
.btn-icon-sm {
  width: 26px; height: 26px; border: none; background: transparent;
  color: var(--ink-2); font-size: 17px; border-radius: var(--radius-xs);
}
.btn-icon-sm:hover { background: var(--hover); color: var(--ink); }

.balance-btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-strong); background: var(--surface);
  padding: 4px 10px; border-radius: var(--radius-sm); font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.balance-btn:hover { border-color: var(--ink); }
.count-num { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }

kbd {
  font-family: ui-monospace, monospace; font-size: 10px;
  padding: 1px 4px; border-radius: 3px;
  background: var(--subtle); border: 1px solid var(--line); color: var(--ink-2);
}

.input-quiet, .select-quiet {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: var(--radius-sm); padding: 7px 10px; font-size: 13px; outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}
.select-quiet { width: auto; }
.input-quiet:focus, .select-quiet:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.link-quiet {
  border: none; background: transparent; color: var(--ink-2);
  font-size: 12px; padding: 2px 5px; border-radius: var(--radius-xs);
}
.link-quiet:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.seg {
  display: inline-flex; align-items: center; background: var(--subtle);
  padding: 2px; border-radius: var(--radius-sm); border: 1px solid var(--line);
}
.seg-item {
  flex: 0 0 auto; white-space: nowrap;
  border: none; background: transparent; color: var(--ink-2);
  padding: 5px 12px; border-radius: var(--radius-xs); font-size: 12px; font-weight: 500;
}
.seg.full .seg-item { flex: 1; }
.seg-item:hover { color: var(--ink); }
.seg-item.active {
  background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.seg-item:disabled { opacity: 0.35; cursor: not-allowed; }

.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  width: 28px; height: 16px; border-radius: 99px; background: var(--hover);
  border: 1px solid var(--line-strong); position: relative; transition: background 0.15s;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--ink-2); transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .switch-track { background: var(--ink); border-color: var(--ink); }
.switch input:checked + .switch-track::after { transform: translateX(12px); background: var(--surface); }
.switch input:checked ~ span { color: var(--ink); font-weight: 560; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 18px;
}

/* ==================== APP SHELL & EDITORIAL HEADERS ==================== */
.app {
  max-width: 1680px; margin: 0 auto; padding: 22px 22px 54px;
}
.panel { display: none; }
.panel.active { display: block; }

.page {
  max-width: 1380px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 20px; min-width: 0;
}
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.page-title {
  font-family: var(--font-serif);
  font-size: clamp(24px, 2.5vw, 30px); font-weight: 600;
  line-height: 1.22; letter-spacing: 0.01em;
}
.page-subtitle {
  margin-top: 5px; font-size: 13px; color: var(--ink-2); max-width: 660px;
}
.page-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.filter-surface {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}

/* ==================== 1. STUDIO WORKSPACE ==================== */
body:has(#panel-studio.active) .app { padding: 0; }
.studio-layout {
  --studio-content-width: 960px;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  height: calc(100dvh - var(--studio-top, 54px));
  min-height: 450px;
}
.studio-sidebar {
  grid-row: 1 / -1; min-height: 0; min-width: 0; display: flex;
  flex-direction: column; gap: 14px; padding: 18px 14px 14px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.studio-sidebar-actions { display: flex; gap: 7px; }
#btnNewThread { width: 100%; min-height: 38px; }
#btnToggleHistory { display: none; }
.studio-mode .seg-item { min-height: 32px; font-size: 12.5px; padding-inline: 7px; }
.studio-history-wrap { min-height: 0; flex: 1; display: flex; flex-direction: column; gap: 9px; }
.studio-history-title { font-size: 12px; font-weight: 650; color: var(--ink-2); padding: 3px 2px 0; }
.composer-wrap {
  min-width: 0; grid-column: 2; padding: 0 clamp(16px, 3vw, 42px) max(14px, env(safe-area-inset-bottom));
  display: flex; justify-content: center;
}
.composer {
  width: min(100%, var(--studio-content-width)); min-width: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer:focus-within { border-color: var(--accent); }
.composer-toolbar {
  position: relative; display: flex; flex-wrap: wrap; align-items: center;
  gap: 6px; padding: 4px 14px 9px;
}
.composer-toolbar > .anchor { flex: 0 1 244px; min-width: 145px; }
.composer-toolbar .dock-button, #btnUploadRefImg { min-height: 35px; padding: 4px 9px; }
.composer-toolbar .dock-button[aria-expanded="true"], .composer-toolbar .select-trigger[aria-expanded="true"] {
  background: var(--accent-wash); border-color: var(--accent); color: var(--ink);
}
#btnUploadRefImg { margin-left: auto; }
#mobileOutputSummary { color: var(--ink-2); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.composer-utilities-panel, .output-settings {
  position: absolute; bottom: calc(100% + 5px); left: 14px; z-index: 64;
  width: min(430px, calc(100% - 28px)); max-height: min(460px, 60dvh);
  overflow-y: auto; overscroll-behavior: contain; padding: 13px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.composer-utilities-panel { left: auto; right: 14px; }
.composer-utilities-panel .prompt-tools { padding: 0; border: 0; }
.composer-utilities-panel .prompt-tools button { min-height: 34px; }
.composer-utilities-panel .builder { margin-top: 10px; }
.composer-toolbar > .anchor .popover { top: auto; bottom: calc(100% + 5px); width: clamp(270px, 31vw, 320px); max-width: calc(100vw - 42px); }
.composer .switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Clean Paper Prompt Sheet */
.prompt-box {
  display: flex; flex-direction: column; gap: 8px;
  padding: 11px 14px 4px;
}
.prompt-box-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.field-label { font-size: 11.5px; color: var(--ink-2); font-weight: 560; }
.prompt-shortcut-hint { font-size: 10.5px; color: var(--ink-3); font-family: ui-monospace, monospace; }

.composer-input {
  width: 100%; min-height: 56px; max-height: 23dvh; resize: vertical;
  border: 0; background: transparent; padding: 0;
  font-size: 13.5px; line-height: 1.6; outline: none;
}
.composer-input:focus-visible { outline: none; }
.composer-input::placeholder { color: var(--ink-2); }
.composer-review-message { margin: 4px 0 0; font-size: .875rem; color: var(--danger); }

.prompt-tools {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding-top: 8px; border-top: 1px solid var(--line);
}
.prompt-tools .btn-subtle {
  background: var(--surface); min-height: 26px; padding: 2px 7.5px;
  font-size: 11.5px; border-radius: var(--radius-xs);
}
.tool-pill-primary {
  border-color: var(--line-strong) !important; color: var(--ink) !important; font-weight: 580;
}

.drop-hint {
  display: none; padding: 9px; border: 1px dashed var(--ink); border-radius: var(--radius-sm);
  background: var(--subtle); color: var(--ink); font-size: 12px; text-align: center;
}
.composer.drag-over { border-color: var(--ink); }
.composer.drag-over .drop-hint { display: block; }

.ref-bar {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 6px 8px; border-radius: var(--radius-sm);
}
.ref-bar-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
}
.ref-bar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.ref-strip {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  max-height: 102px; overflow-y: auto; padding: 4px 2px 2px;
}
.ref-thumb { position: relative; width: 42px; height: 42px; flex-shrink: 0; }
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-xs); display: block; border: 1px solid var(--line-strong); }
.ref-thumb-idx {
  position: absolute; bottom: 2px; left: 2px; padding: 0 3.5px;
  border-radius: 2px; background: rgba(25, 24, 22, 0.74); color: #faf9f6;
  font-size: 9.5px; line-height: 1.35; font-variant-numeric: tabular-nums; pointer-events: none;
}
.ref-thumb-del {
  position: absolute; top: -4px; right: -4px; width: 15px; height: 15px;
  border-radius: 50%; border: none; background: var(--ink); color: var(--bg);
  font-size: 10px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.ref-name { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.builder {
  background: var(--subtle); border: 1px solid var(--line);
  border-radius: var(--radius-md); padding: 9px 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.builder-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.builder-label { font-size: 11px; color: var(--ink-3); width: 30px; }

.chip {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  padding: 3px 9px; border-radius: var(--radius-xs); font-size: 11.5px;
}
.chip:hover { color: var(--ink); border-color: var(--ink); }
.chip.active { border-color: var(--ink); background: var(--ink); color: var(--bg); font-weight: 560; }

/* Series Plan */
.series-plan {
  display: flex; flex-direction: column; gap: 10px;
  padding: 13px; background: var(--subtle); border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.series-plan-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.series-plan-heading h3 { font-size: 13px; font-weight: 650; color: var(--ink); }
.series-platform-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.series-platform-field select { width: auto; min-width: 176px; max-width: 100%; background: var(--surface); }
.series-platform-field p { flex: 1 1 250px; font-size: 12px; line-height: 1.45; }
.series-strategy-block {
  display: flex; flex-direction: column; gap: 6px;
  padding-top: 6px; border-top: 1px solid var(--line);
}
.series-strategy-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap;
}
#seriesStrategyDesc { font-size: 11.5px; line-height: 1.45; flex: 1 1 260px; }
.series-strategy-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(154px, 1fr)); gap: 6px;
}
.series-strategy-card {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 7px 10px; min-height: 36px; border-radius: var(--radius-xs);
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 12px; text-align: left;
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
}
.series-strategy-card:hover { border-color: var(--line-strong); color: var(--ink); }
.series-strategy-card[aria-pressed="true"] {
  border-color: var(--accent); background: var(--accent-wash); color: var(--ink); font-weight: 600;
}
.series-strategy-tag {
  font-size: 10px; padding: 1px 5px; border-radius: 2px;
  background: var(--subtle); color: var(--ink-2); white-space: nowrap; font-weight: 500;
}
.series-strategy-card[aria-pressed="true"] .series-strategy-tag {
  background: var(--accent); color: var(--accent-ink);
}
.series-shot-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
@media (max-width: 720px) {
  .series-shot-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.series-shot {
  display: flex; align-items: center; gap: 7px; min-height: 31px; padding: 4px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-xs);
  color: var(--ink-2); text-align: left; font-size: 11.5px;
}
.series-shot:hover { border-color: var(--line-strong); color: var(--ink); }
.series-shot-label { min-width: 0; overflow-wrap: anywhere; }
.series-shot[aria-pressed="true"] {
  background: var(--surface); border-color: var(--ink); color: var(--ink); font-weight: 600;
}
.series-shot-mark {
  display: grid; place-items: center; flex: 0 0 13px; height: 13px;
  border: 1px solid var(--line-strong); border-radius: 2px; font-size: 10px; line-height: 1;
}
.series-shot[aria-pressed="true"] .series-shot-mark { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.series-shot[aria-pressed="true"] .series-shot-mark::before { content: "✓"; }
.series-board-link { justify-content: space-between; min-height: 31px; padding-inline: 10px; background: var(--surface) !important; }

/* ==================== BESPOKE FORM CONTROLS & CUSTOM SELECT ==================== */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

input[type="checkbox"]:not(.switch input) {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; flex-shrink: 0;
  border: 1.5px solid var(--line-strong); border-radius: 3px;
  background: var(--surface); cursor: pointer;
  display: inline-grid; place-content: center; vertical-align: -2px;
  transition: background 0.14s ease, border-color 0.14s ease;
}
input[type="checkbox"]:not(.switch input):hover { border-color: var(--ink-2); }
input[type="checkbox"]:not(.switch input)::before {
  content: ""; width: 8px; height: 5px;
  border-left: 1.8px solid var(--accent-ink); border-bottom: 1.8px solid var(--accent-ink);
  transform: translateY(-0.5px) rotate(-45deg) scale(0);
  transition: transform 0.12s ease;
}
input[type="checkbox"]:not(.switch input):checked {
  background: var(--accent); border-color: var(--accent);
}
input[type="checkbox"]:not(.switch input):checked::before {
  transform: translateY(-0.5px) rotate(-45deg) scale(1);
}

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer; min-height: 22px;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 99px; background: var(--line-strong);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; margin-top: -5.5px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-track {
  height: 4px; border-radius: 99px; background: var(--line-strong);
}
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
}

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

.cselect-wrap {
  position: relative; display: inline-flex; min-width: 148px; max-width: 100%; vertical-align: middle;
}
.cselect-wrap.full,
.field > .cselect-wrap,
.tool-settings-fields .cselect-wrap {
  display: flex; width: 100%;
}
.cselect-native {
  position: absolute !important; width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important; overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important;
  opacity: 0 !important; pointer-events: none !important;
}
.cselect-btn {
  width: 100%; min-height: 35px; padding: 6px 10px;
  display: inline-flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 530;
  text-align: left; transition: border-color 0.14s ease, background 0.14s ease;
}
.cselect-wrap.cselect-sm .cselect-btn { min-height: 31px; padding: 4px 9px; font-size: 12.5px; }
.cselect-btn:hover:not(:disabled) { border-color: var(--ink-2); background: var(--bg); }
.cselect-wrap.is-open .cselect-btn { border-color: var(--accent); background: var(--surface); }
.cselect-btn:disabled { opacity: 0.48; cursor: not-allowed; }
.cselect-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect-chevron { flex-shrink: 0; color: var(--ink-2); transition: transform 0.16s ease, color 0.16s ease; }
.cselect-wrap.is-open .cselect-chevron { transform: rotate(180deg); color: var(--accent); }

.cselect-menu {
  position: fixed; z-index: 10000;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  padding: 5px; border-radius: var(--radius-md);
  background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 1px;
}
.cselect-group-title {
  padding: 7px 9px 3px; font-size: 10.5px; font-weight: 650; letter-spacing: 0.04em;
  color: var(--ink-3); border-top: 1px solid var(--line); margin-top: 3px;
}
.cselect-group-title:first-child { border-top: 0; margin-top: 0; padding-top: 4px; }
.cselect-option {
  width: 100%; min-height: 33px; padding: 6px 9px; border: 0; border-radius: var(--radius-xs);
  background: transparent; color: var(--ink); font-size: 12.5px; text-align: left;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  transition: background 0.1s ease, color 0.1s ease;
}
.cselect-option:hover:not(:disabled),
.cselect-option:focus-visible { background: var(--subtle); outline: none; }
.cselect-option.is-selected {
  background: var(--accent-wash); color: var(--ink); font-weight: 620;
}
.cselect-option:disabled { opacity: 0.4; cursor: not-allowed; }
.cselect-option-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect-check { flex-shrink: 0; color: var(--accent); }

/* Output settings */
.output-settings {
  --output-button-height: 36px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
  width: min(376px, calc(100% - 28px)); padding: 12px;
}
.output-settings [hidden] { display: none !important; }
.output-settings:has(#studioFormatField[hidden]) :is(#studioSingleCountField, #studioSeriesCountField) {
  grid-column: 1 / -1;
}
.output-estimate {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 12px;
  padding: 8px 2px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 18px;
}
.output-estimate strong { color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; }
.output-model {
  grid-column: 1 / -1; display: grid; gap: 2px;
  padding: 2px 2px 9px; border-bottom: 1px solid var(--line);
}
.output-model > span, .output-model > small { font-size: 11.5px; color: var(--ink-2); }
.output-model > strong { font-size: 14.5px; line-height: 1.3; overflow-wrap: anywhere; }
.output-types, .output-pill-group {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  gap: 4px; padding: 3px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--subtle);
}
.output-types { grid-column: 1 / -1; }
.output-types > button, .output-pill {
  display: grid; place-items: center;
  min-height: var(--output-button-height); padding: 4px 2px;
  border: 0; border-radius: var(--radius-xs);
  background: transparent; color: var(--ink-2);
  font-size: 12.5px; line-height: 1.4;
}
.output-types > button { font-weight: 600; }
.output-types > button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.output-types > button:disabled { opacity: .48; cursor: not-allowed; }
.output-gif-note { grid-column: 1 / -1; margin: 0 2px; color: var(--ink-2); font-size: 11.5px; }
@media (min-width: 1050px) {
  .composer-settings { position: relative; }
  .output-settings { left: 0; width: 376px; }
}

.output-deck-section { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.output-deck-span { grid-column: 1 / -1; }
.output-deck-label { font-size: 12px; line-height: 16px; font-weight: 580; color: var(--ink-2); padding-inline: 1px; }

.ratio-tile-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px;
}
.ratio-tile {
  min-height: 48px; padding: 4px 2px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-2);
  display: grid; grid-template-rows: 18px auto; place-items: center; align-content: center; gap: 3px;
  font-size: 11.5px; line-height: 16px; font-weight: 580; font-variant-numeric: tabular-nums;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}
.ratio-tile:hover { border-color: var(--line-strong); color: var(--ink); }
.ratio-tile[aria-pressed="true"] {
  border-color: var(--accent); background: var(--accent-wash); color: var(--ink);
}
.ratio-glyph {
  display: block; border: 1.5px solid currentColor; border-radius: 2px; opacity: 0.78;
}
.ratio-tile[aria-pressed="true"] .ratio-glyph { opacity: 1; border-color: var(--accent); }
.ratio-1-1 { width: 13px; height: 13px; }
.ratio-3-4 { width: 11px; height: 15px; }
.ratio-4-3 { width: 15px; height: 11px; }
.ratio-9-16 { width: 9px; height: 16px; }
.ratio-16-9 { width: 16px; height: 9px; }

.output-pill {
  font-variant-numeric: tabular-nums;
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}
.output-option-label { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.output-pill strong { font-weight: 650; }
.output-option-label small { font-size: 11px; color: var(--ink-2); font-weight: 450; }
.output-pill:hover { color: var(--ink); }
.output-pill[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm);
}
.output-pill[aria-pressed="true"] strong { color: var(--accent); }
.output-series-readout {
  min-height: calc(var(--output-button-height) + 8px); padding: 4px 8px; border-radius: var(--radius-sm);
  background: var(--subtle); border: 1px solid var(--line);
  display: grid; place-items: center; line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.output-series-readout output { font-size: 12.5px; font-weight: 650; color: var(--ink); }

.tool-settings { margin-top: 10px; border-top: 1px solid var(--line); }
.tool-settings summary, .account-pass-box summary {
  padding: 8px 2px 3px; cursor: pointer; font-size: 12.5px; font-weight: 560; color: var(--ink-2);
  display: flex; align-items: center; justify-content: space-between; gap: 8px; user-select: none;
}
.account-pass-box summary { padding: 0; }
.tool-settings summary:hover, .account-pass-box summary:hover { color: var(--ink); }
.tool-settings summary::after, .account-pass-box summary::after {
  content: ""; width: 12px; height: 12px; flex-shrink: 0; background-color: currentColor; opacity: 0.75;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform 0.14s ease;
}
.tool-settings[open] > summary::after, .account-pass-box[open] > summary::after {
  transform: rotate(180deg);
}
.tool-settings-fields { display: grid; gap: 10px; padding: 10px 0 2px; }
.tool-settings-fields select { width: 100%; }
.tool-field-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.anchor { position: relative; min-width: 0; }
.select-trigger {
  display: grid; grid-template-columns: auto minmax(0, 1fr) 12px; align-items: center;
  width: 100%; min-height: 35px; gap: 8px; padding-inline: 10px; text-align: left;
}
.select-trigger strong {
  justify-self: end; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; max-width: 100%; color: var(--ink); font-weight: 580;
}
#currentModelCompactLabel { display: none; }
.select-trigger svg { transform: rotate(180deg); opacity: 0.6; }
.select-trigger[aria-expanded="true"] svg { transform: none; }

.popover {
  position: absolute; top: calc(100% + 5px); left: 0; width: 100%;
  max-height: min(320px, 42dvh); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-md); padding: 5px; box-shadow: var(--shadow-lg); z-index: 60;
}
.pop-item {
  width: 100%; border: 0; background: transparent; text-align: left;
  padding: 7px 9px; border-radius: var(--radius-xs); display: flex;
  justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px;
}
.pop-item:hover { background: var(--subtle); }
.pop-item.selected { background: var(--hover); font-weight: 600; }
.pop-item-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pop-item-sub { font-size: 11px; color: var(--ink-3); }
#modelPopoverMenu .pop-item { padding: 9px 10px; min-height: 49px; }
#modelPopoverMenu .pop-item-main > span:first-child { overflow-wrap: anywhere; line-height: 1.25; }
#modelPopoverMenu .pop-item-sub { color: var(--ink-2); font-weight: 400; }
#modelPopoverMenu .pop-item.selected { background: var(--accent-wash); }
.pop-item-price {
  display: grid; justify-items: end; min-width: max-content; font-variant-numeric: tabular-nums;
  line-height: 1.25; color: var(--ink);
}
.pop-item-price > small { font-size: 10px; color: var(--ink-2); font-weight: 400; }

/* Pinned Bottom Sheet Footer */
.composer-footer {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 7px 14px;
  border-top: 1px solid var(--line);
}
.composer-meta {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 12px;
  font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
#composerEstimateText { font-size: 13.5px; font-weight: 650; color: var(--ink); }
#compactOutputSummary { display: none; }
.generate-cta {
  min-height: 40px; font-size: 13.5px; font-weight: 600; flex-shrink: 0;
  justify-content: space-between; padding-inline: 14px;
  border-radius: var(--radius-sm);
}
.cta-arrow { font-size: 15px; line-height: 1; }

/* ==================== RIGHT MATBOARD STAGE ==================== */
.stage {
  min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 18px;
  width: 100%; padding: 20px clamp(16px, 3vw, 42px) 28px;
  overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: thin; scroll-padding-top: 58px;
}
.stage > * { width: 100%; max-width: var(--studio-content-width); margin-inline: auto; flex-shrink: 0; }
.stage-bar {
  position: sticky; top: -20px; z-index: 14; background: var(--bg);
  margin-top: -20px; padding-top: 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.stage-bar-left, .stage-bar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.stage-bar-left { flex: 1; }
.stage-title {
  font-family: var(--font-serif); font-size: clamp(19px, 2.5vw, 27px);
  font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#seriesStageViews { flex-shrink: 0; }
.history-content:not([hidden]) {
  display: flex; flex-direction: column; min-height: 0; gap: 9px;
}
.thread-search-box { position: relative; display: flex; align-items: center; }
.thread-search-box input { width: 100%; padding-right: 28px; cursor: text; }
.thread-search-box input::-webkit-search-cancel-button { display: none; }
.thread-search-clear {
  position: absolute; right: 5px; width: 20px; height: 20px; padding: 0;
  border: 0; border-radius: var(--radius-xs); background: transparent;
  color: var(--ink-2); font-size: 14px; line-height: 1; display: grid; place-items: center;
}
.thread-search-clear:hover { color: var(--ink); background: var(--hover); }
.history-message { padding: 8px 4px; text-align: center; text-wrap: balance; }
.thread-list { display: flex; flex-direction: column; gap: 3px; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.thread-item { display: flex; align-items: center; min-width: 0; border-radius: var(--radius-xs); border: 1px solid transparent; }
.thread-item:hover, .thread-item:focus-within, .thread-item.active { background: var(--hover); }
.thread-item.active { border-color: var(--line-strong); background: var(--surface); }
.thread-item-draft.active { border-color: var(--accent); background: var(--accent-wash); }
.thread-item-pending { border-color: var(--line); }
.thread-item-pending.active { border-color: var(--accent); background: var(--accent-wash); }
.thread-select {
  min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: stretch; gap: 2px;
  padding: 7px 9px; border: 0; background: transparent; text-align: left;
}
.thread-title { font-size: 13px; font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; min-width: 0; }
.thread-title > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.thread-mode-tag {
  font-size: 10px; padding: 0 4px; border-radius: 2px; flex-shrink: 0;
  background: var(--subtle); color: var(--ink-2); border: 1px solid var(--line); font-weight: 550;
}
.thread-meta { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.thread-meta-live { color: var(--accent); font-weight: 550; }
.thread-ops { display: flex; gap: 2px; padding-right: 4px; }
.thread-op {
  border: 0; background: transparent; color: var(--ink-2);
  min-width: 26px; min-height: 28px; border-radius: var(--radius-xs); font-size: 13px;
}
.thread-op:hover { color: var(--ink); background: var(--surface); }

/* First image */
.studio-welcome {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 16px 0 24px;
}
.studio-welcome-inner {
  width: min(100%, 540px);
  margin-inline: auto;
  text-align: center;
}
.studio-welcome-title {
  font-family: var(--font-serif);
  font-size: clamp(22px, 2.8vw, 32px);
  font-weight: 600;
  line-height: 1.25;
}
.studio-welcome-copy p {
  max-width: 34em;
  margin: 8px auto 18px;
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.6;
}
.studio-welcome-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.studio-welcome-actions > button { min-height: 36px; padding-inline: 13px; }

/* Series Storyboard */
.series-board { display: flex; flex-direction: column; gap: 12px; }
.series-board-summary { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.series-count-pill {
  font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 2px 9px; border-radius: var(--radius-xs);
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
}
.series-prompt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.series-prompt-field {
  min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 13px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
}
.series-prompt-field:focus-within { border-color: var(--ink); }
.series-prompt-heading { display: flex; align-items: center; gap: 8px; }
.series-shot-order {
  font: 600 11px ui-monospace, monospace; color: var(--stamp);
}
.series-prompt-heading label { font-size: 13.5px; color: var(--ink); font-weight: 600; }
.series-prompt-field textarea {
  display: block; flex: 1 0 auto; min-height: 84px; resize: vertical;
  border: 1px solid var(--line); background: var(--bg); line-height: 1.55;
}
.series-stage-empty {
  margin: 0; padding: 36px 16px; border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md); color: var(--ink-2); text-align: center; font-size: 13px;
  background: var(--surface);
}
#btnReturnToGenerate { display: none; }

/* Generated Turn Stream */
.studio-conversation { display: flex; flex-direction: column; gap: 24px; }
.stream { min-width: 0; display: flex; flex-direction: column; gap: 28px; }
.stream:empty { display: none; }
.turn { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.turn-message {
  margin-inline-start: auto;
  width: fit-content; max-width: min(80%, 620px);
  background: var(--accent-wash); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 10px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.turn-message-tools { justify-content: flex-end; margin-top: -6px; }
.turn-meta {
  font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 4px 10px;
  flex-wrap: wrap; font-variant-numeric: tabular-nums; margin-top: -6px;
}
.turn-refs { display: flex; gap: 6px; max-width: 100%; overflow-x: auto; padding: 2px; }
.turn-ref { width: 54px; height: 54px; padding: 0; overflow: hidden; border-radius: var(--radius-xs); border: 1px solid var(--line-strong); background: var(--subtle); flex-shrink: 0; }
.turn-ref img { display: block; width: 100%; height: 100%; object-fit: cover; }
.turn-text { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.6; color: var(--ink); }

.studio-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); align-items: start; gap: 14px; }
.studio-results:has(> :only-child) { grid-template-columns: minmax(0, 1fr); }
.studio-series-results { grid-template-columns: repeat(auto-fill, minmax(min(100%, 224px), 1fr)); }
.turn-result-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.turn-result-header h2 { font-size: 13px; font-weight: 650; }
.turn-result-header h2 span { margin-left: 6px; font-weight: 400; }
.studio-result {
  --result-height-limit: clamp(11rem, calc(100dvh - var(--studio-top, 54px) - var(--studio-dock-height, 200px) - 15rem), 22rem);
  --result-padding: 8px;
  display: flex; flex-direction: column; min-width: 0; background: var(--surface);
  width: min(100%, calc(min(35rem, var(--result-height-limit) * var(--result-ratio, 1)) + 2 * (var(--result-padding) + 1px)));
  border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden;
  padding: var(--result-padding) var(--result-padding) 0;
}
.studio-series-results .studio-result { --result-height-limit: clamp(10rem, 34dvh, 18rem); }
.result-media {
  display: block; position: relative; width: 100%; aspect-ratio: var(--result-ratio, 1);
  padding: 0; border: 0; background: var(--subtle); border-radius: var(--radius-xs); overflow: hidden;
}
.result-media img { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.result-image-status {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 8px; color: var(--ink-2); font-size: 12px;
}
.result-details { display: flex; flex-direction: column; gap: 4px; padding: 9px 4px 10px; }
.result-caption, .result-actions { display: flex; align-items: baseline; gap: 4px 8px; flex-wrap: wrap; }
.result-caption strong { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.result-caption > button { margin-inline-start: auto; }
.result-pixels { font-variant-numeric: tabular-nums; }
.result-actions { gap: 4px; }
.result-actions > button { padding-inline: 4px; }

.generation-preview {
  --frame-width: min(26rem, calc(clamp(12rem, 36dvh, 22rem) * var(--preview-ratio, 1)));
  width: min(100%, max(18rem, var(--frame-width)));
  align-self: flex-start;
}
.generation-frame {
  position: relative;
  width: min(100%, var(--frame-width));
  isolation: isolate;
  overflow: hidden;
  aspect-ratio: var(--preview-ratio, 1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background-color: var(--surface);
  background-image:
    linear-gradient(90deg, var(--accent-wash) 1px, transparent 1px),
    linear-gradient(var(--accent-wash) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: center;
}
.generation-exposure {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 28%, var(--accent-wash) 42%,
    color-mix(in srgb, var(--accent) 29%, transparent) 50%, var(--accent-wash) 58%, transparent 72%);
  opacity: .65;
}
.generation-preview[data-in-view] .generation-exposure {
  animation: generation-exposure 3.6s ease-in-out infinite;
}
.generation-delivery { display: none; }
.generation-preview.has-delivery .generation-exposure,
.generation-preview.has-delivery .generation-crop { display: none; }
.generation-preview.has-delivery .generation-delivery {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(32%, 7rem), 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 2px;
  background: var(--surface);
}
.generation-delivery img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.generation-crop {
  position: absolute;
  inset: clamp(10px, 5%, 19px);
  color: var(--accent);
  background:
    linear-gradient(currentColor, currentColor) top left / 14px 1px,
    linear-gradient(currentColor, currentColor) top left / 1px 14px,
    linear-gradient(currentColor, currentColor) top right / 14px 1px,
    linear-gradient(currentColor, currentColor) top right / 1px 14px,
    linear-gradient(currentColor, currentColor) bottom left / 14px 1px,
    linear-gradient(currentColor, currentColor) bottom left / 1px 14px,
    linear-gradient(currentColor, currentColor) bottom right / 14px 1px,
    linear-gradient(currentColor, currentColor) bottom right / 1px 14px;
  background-repeat: no-repeat;
  opacity: .72;
}
.generation-caption {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-block-start: 9px;
}
.generation-caption-copy { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.generation-status { color: var(--ink); font-size: 14px; font-weight: 600; }
.generation-caption-copy span, .generation-elapsed { color: var(--ink-2); font-size: 12px; }
.generation-elapsed { white-space: nowrap; }

@keyframes generation-exposure {
  0% { transform: translateX(-85%); opacity: 0; }
  18%, 73% { opacity: .85; }
  94%, 100% { transform: translateX(85%); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .generation-preview[data-in-view] .generation-exposure { animation: none; }
}

/* ==================== 2. PROMPT LIBRARY (ARCHIVAL INDEX CARDS) ==================== */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.prompt-library-layout {
  display: grid; grid-template-columns: 184px minmax(0, 1fr); align-items: start; gap: 22px;
}
.prompt-library-filters {
  display: grid; gap: 12px; min-width: 0; padding-right: 14px;
  border-right: 1px solid var(--line);
}
.prompt-scopes, .prompt-groups, .prompt-refinements { display: grid; gap: 4px; min-width: 0; }
.prompt-scopes button, .prompt-groups .seg-item {
  min-height: 36px; padding: 0 9px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-2); text-align: left; font-size: 13px;
}
.prompt-scopes button:hover, .prompt-groups .seg-item:hover { background: var(--subtle); color: var(--ink); }
.prompt-scopes button[aria-pressed="true"], .prompt-groups .seg-item[aria-pressed="true"] {
  border-color: var(--line); background: var(--accent-wash); color: var(--ink); font-weight: 650;
}
.prompt-refine-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#btnPromptFilters { display: none; }
.prompt-refinements { border-top: 1px solid var(--line); padding-top: 10px; }
.prompt-filter-label { padding: 5px 0 2px; font-size: 12px; font-weight: 620; color: var(--ink-2); }
#promptSourceFilter { width: 100%; min-width: 0; padding-left: 8px; font-size: 12px; }
#btnSeriesFromLibrary { justify-self: start; margin-top: 5px; }
.prompt-search-box { position: relative; min-width: 0; }
#btnClearPromptSearch { position: absolute; right: 8px; top: calc(50% - 17px); min-height: 34px; }
#promptSearchInput { width: 100%; min-height: 40px; }
#promptSearchInput::-webkit-search-cancel-button { display: none; }
.prompt-search-box:has(#btnClearPromptSearch:not([hidden])) input { padding-right: 54px; }
.prompt-subcategories { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0; }
.prompt-subcategories[hidden] { display: none; }
.prompt-subcategory {
  border: 1px solid var(--line-strong); border-radius: var(--radius-xs);
  background: var(--surface); color: var(--ink-2); font-size: 12px;
  padding: 4px 6px; min-height: 32px;
}
.prompt-subcategory:hover { border-color: var(--ink); color: var(--ink); }
.prompt-subcategory[aria-pressed="true"] {
  border-color: var(--ink); background: var(--ink); color: var(--bg); font-weight: 580;
}
.prompt-results { min-width: 0; }
.prompt-results-head, .prompt-pages { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prompt-results-head { min-height: 40px; justify-content: space-between; }
.prompt-result-count { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.prompt-catalog-note { font-size: 12px; color: var(--ink-2); }
div.prompt-catalog-note:not([hidden]):has(> :not([hidden])) {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 10px;
}
p.prompt-catalog-note { margin-top: 16px; }
.prompt-catalog-note a { color: var(--ink); text-underline-offset: 2px; }
.prompt-pages { justify-content: center; margin-top: 16px; font-variant-numeric: tabular-nums; }

.grid-prompts {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 242px), 1fr)); gap: 12px;
}
.prompt-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-md); min-width: 0; padding: 10px 12px 9px;
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color 0.16s ease;
}
.prompt-card:focus-within, .prompt-card:hover { border-color: var(--line-strong); }
.prompt-card-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.prompt-meta { min-width: 0; font-size: 11.5px; color: var(--ink-2); }
.prompt-fav-btn {
  display: grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; border-radius: var(--radius-xs);
  border: 1px solid transparent; background: transparent; color: var(--ink-2); font-size: 18px;
}
.prompt-fav-btn:hover { background: var(--subtle); color: var(--ink); }
.prompt-fav-btn[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent); }
.prompt-card-preview { display: flex; gap: 10px; min-height: 74px; margin-bottom: 6px; }
.prompt-card-text { flex: 1; min-width: 0; }
.prompt-card-text h3 { font-size: 15px; line-height: 1.4; }
.prompt-title-button {
  display: block; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: left; font: inherit; font-weight: 650; color: var(--ink); background: none; border: 0;
}
.prompt-title-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.prompt-thumbnail {
  display: grid; place-items: center; flex: 0 0 66px; width: 66px; height: 66px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--subtle); padding: 0;
}
.prompt-thumbnail img { display: block; width: 100%; height: 100%; object-fit: cover; }
.prompt-thumbnail img[hidden], .prompt-no-preview[hidden] { display: none; }
.prompt-no-preview { padding-inline: 5px; color: var(--ink-2); font-size: 11px; }
.prompt-body {
  margin-top: 5px; font-size: 13px; color: var(--ink-2); line-height: 1.65; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.prompt-foot {
  margin-top: auto; display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  padding-top: 6px; border-top: 1px solid var(--line);
}
.prompt-remove { margin-right: auto; }
.prompt-foot .link-quiet { min-height: 34px; }
.prompt-card .btn-card-use {
  min-height: 34px; border: 1px solid var(--line); background: var(--accent-wash); color: var(--ink);
  padding: 4px 10px; font-size: 12px; font-weight: 620; border-radius: var(--radius-xs);
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.prompt-card .btn-card-use:hover, .prompt-card .btn-card-use:focus-visible {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}

.var-token {
  background: var(--subtle); color: var(--ink); font-weight: 600;
  padding: 0 4px; border-radius: 3px; border: 1px solid var(--line-strong);
}

/* ==================== 3. SHOWCASE (EDITORIAL SAMPLE BOOK) ==================== */
.hero-split {
  display: grid; grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  gap: 28px; align-items: stretch;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 24px;
}
.hero-copy { display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.hero-headline {
  font-family: var(--font-serif);
  font-size: clamp(23px, 2.4vw, 29px); font-weight: 600; line-height: 1.28;
}
.hero-desc { font-size: 13.5px; color: var(--ink-2); line-height: 1.65; }

.hero-scene-tabs { display: flex; flex-direction: column; gap: 6px; margin: 4px 0; }
.scene-tab {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.scene-tab strong { font-size: 13px; font-weight: 600; color: var(--ink); }
.scene-tab span { font-size: 11.5px; color: var(--ink-2); }
.scene-tab:hover { border-color: var(--line-strong); }
.scene-tab.active {
  border-color: var(--ink); background: var(--surface);
  box-shadow: inset 3px 0 0 var(--stamp);
}
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

.ba-frame {
  border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--line); background: var(--stage-bg);
}
.ba-viewport { position: relative; width: 100%; height: 100%; min-height: 410px; overflow: hidden; user-select: none; }
.ba-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.ba-clip { position: absolute; inset: 0; }
.ba-line { position: absolute; top: 0; bottom: 0; width: 1.5px; background: #faf9f6; transform: translateX(-50%); pointer-events: none; }
.ba-knob {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 32px; height: 32px; border-radius: 50%; background: #faf9f6; color: #191816;
  border: 1px solid rgba(25,24,22,0.2);
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  box-shadow: var(--shadow-md);
}
.ba-badge {
  position: absolute; bottom: 12px; z-index: 3; pointer-events: none;
  padding: 3px 9px; border-radius: var(--radius-xs); font-size: 11px;
  background: rgba(25, 24, 22, 0.74); color: #faf9f6;
}
.ba-badge-left { left: 12px; }
.ba-badge-right { right: 12px; }
.ba-range { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; z-index: 4; }

.section-heading {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-top: 8px; border-top: 1px solid var(--line);
}
.section-heading h2 { font-family: var(--font-serif); font-size: 20px; font-weight: 600; }

.grid-showcase {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px;
}
.showcase-card {
  border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface);
  padding: 8px 8px 0; display: flex; flex-direction: column; cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.showcase-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.showcase-card img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block;
  border-radius: var(--radius-xs);
}
.showcase-foot {
  padding: 10px 4px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.showcase-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.showcase-meta span { font-size: 11px; font-family: ui-monospace, monospace; color: var(--ink-3); }
.showcase-meta strong { font-size: 14px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.showcase-btn {
  border: 1px solid var(--line-strong); background: var(--subtle);
  color: var(--ink); padding: 4px 11px;
  border-radius: var(--radius-xs); font-size: 12px; font-weight: 550; flex-shrink: 0;
}
.showcase-card:hover .showcase-btn { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ==================== 4. MASONRY ARCHIVE GALLERY ==================== */
.masonry-gallery {
  columns: 4 260px;
  column-gap: 18px;
}
.art-card {
  position: relative; break-inside: avoid; margin-bottom: 18px;
  border-radius: var(--radius-md); overflow: hidden;
  border: 1px solid var(--line); background: var(--surface);
  padding: 8px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.art-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.art-preview { display: block; width: 100%; border: 0; padding: 0; background: transparent; }
.art-preview:focus-visible { outline-offset: -3px; }
.art-media { position: relative; width: 100%; overflow: hidden; border-radius: var(--radius-xs); }
.art-media img { width: 100%; height: auto; display: block; }
.art-preview-fallback {
  display: grid; place-items: center; min-height: 126px; padding: 24px 8px;
  background: var(--subtle); color: var(--ink-2); font-size: 12px;
}

.art-spec-pill {
  position: absolute; top: 8px; left: 8px;
  background: rgba(25, 24, 22, 0.72); color: #faf9f6;
  font-size: 10px; font-family: ui-monospace, monospace;
  padding: 2px 7px; border-radius: 3px; pointer-events: none;
}
.art-corner {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; border-radius: var(--radius-xs);
  background: rgba(25, 24, 22, 0.65); color: #faf9f6;
  border: none; font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.art-overlay {
  position: absolute; inset: auto 0 0 0;
  padding: 24px 8px 8px;
  background: linear-gradient(to top, rgba(20, 19, 17, 0.88) 0%, rgba(20, 19, 17, 0.45) 65%, transparent 100%);
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none; opacity: 0; transition: opacity 0.16s ease;
}
.art-card:hover .art-overlay, .art-card:focus-within .art-overlay { opacity: 1; }
.art-caption {
  color: #faf9f6; font-size: 12px; padding: 0 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.art-dock {
  display: flex; gap: 4px; background: rgba(250, 249, 246, 0.94);
  border-radius: var(--radius-xs); padding: 3px;
}
.art-act {
  pointer-events: auto; flex: 1; border: none; background: transparent; color: #191816;
  font-size: 11.5px; font-weight: 560; padding: 4px 6px; border-radius: 3px;
}
.art-act:hover { background: rgba(25, 24, 22, 0.08); }

.gallery-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 48px 16px; text-align: center;
}

.gallery-search { max-width: 260px; }

#btnToggleGallerySelect[aria-pressed="true"] {
  background: var(--accent-wash); border-color: var(--accent); color: var(--ink);
}
.gallery-batch-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: var(--radius-md);
  background: var(--accent-wash); border: 1px solid var(--accent);
}
.gallery-batch-meta { font-size: 12.5px; font-weight: 560; color: var(--ink); font-variant-numeric: tabular-nums; }
.gallery-batch-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.art-card.is-selectable { cursor: pointer; }
.art-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-wash); }
.art-select-badge {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 26px; height: 26px; border-radius: var(--radius-xs);
  border: 1.5px solid rgba(250, 249, 246, 0.92); background: rgba(25, 24, 22, 0.62);
  color: transparent; font-size: 13px; font-weight: 700;
  display: grid; place-items: center; pointer-events: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.art-card.is-selected .art-select-badge {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}

/* ==================== 5. PRICING SHEET ==================== */
.pricing-summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; flex: 1; }
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat span { font-size: 11.5px; color: var(--ink-2); }
.stat strong { font-size: 20px; font-weight: 650; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.stat-profit strong { color: var(--positive); }

.grid-pricing { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.price-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 11px;
}
.price-card:hover { border-color: var(--line-strong); }
.price-card-featured { border-color: var(--line-strong); }
.price-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.price-title-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.price-head h4 { font-size: 15px; font-weight: 650; }
.price-role-badge {
  font-size: 11px; padding: 1px 7px; border-radius: var(--radius-xs);
  background: var(--subtle); border: 1px solid var(--line); color: var(--ink-2);
}
.price-card-featured .price-role-badge {
  background: var(--stamp-wash); border-color: var(--stamp-border); color: var(--stamp);
}
.price-desc { font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }
.price-id { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-size: 12px; color: var(--ink-2); }
.price-id code { overflow-wrap: anywhere; }
.price-tiers {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 0;
}
.tier { display: flex; flex-direction: column; gap: 2px; }
.tier span { font-size: 12px; color: var(--ink-2); }
.tier strong { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.price-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; }

/* ==================== 6. BILLING & API ==================== */
.table-wrap {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); overflow-x: auto;
}
.table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
.table th {
  padding: 10px 16px; color: var(--ink-2); font-size: 12px; font-weight: 560;
  border-bottom: 1px solid var(--line); background: var(--subtle); white-space: nowrap;
}
.table td { padding: 11px 16px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: none; }
.table-empty-cell { text-align: center; color: var(--ink-3); padding: 28px 16px !important; font-size: 12.5px; }

.subnav { width: fit-content; }
.subpanel { display: none; flex-direction: column; gap: 16px; }
.subpanel.active { display: flex; }

.billing-bento {
  display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 16px; align-items: stretch;
}
.member-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
}
.member-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.wallet-label { font-size: 12px; color: var(--ink-2); }
.wallet-hero-row { display: flex; align-items: baseline; gap: 10px; margin-top: 3px; flex-wrap: wrap; }
.wallet-hero-num { font-family: var(--font-serif); font-size: 32px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.member-badge {
  background: var(--subtle); color: var(--ink-2); border: 1px solid var(--line-strong);
  font-size: 11px; font-weight: 560; padding: 1px 8px; border-radius: var(--radius-xs);
}

/* 3-Step Loyalty Ladder */
.tier-steps {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
}
.tier-step {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--bg); border: 1px solid var(--line);
}
.tier-step-lv { font-size: 11px; color: var(--ink-3); font-weight: 560; }
.tier-step strong { font-size: 13px; font-weight: 620; color: var(--ink); font-variant-numeric: tabular-nums; }
.tier-step small { font-size: 10.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tier-step.active {
  background: var(--surface); border-color: var(--ink);
  box-shadow: inset 0 2px 0 var(--stamp);
}
.tier-step.active .tier-step-lv { color: var(--stamp); font-weight: 600; }

.member-tier-box { display: flex; flex-direction: column; gap: 6px; }
.member-status-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.member-status-line strong { font-size: 13px; font-weight: 620; }
.member-progress-track {
  width: 100%; height: 5px; border-radius: 99px; background: var(--subtle); overflow: hidden;
}
.member-progress-fill { height: 100%; background: var(--ink); border-radius: 99px; transition: width 0.3s ease; }

/* Direct Balance Top-Up Card (Minimum ¥10.00) */
.direct-topup-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
  border-color: var(--line-strong);
}
.direct-topup-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.direct-topup-head h3 { font-family: var(--font-serif); font-size: 17px; font-weight: 600; }
.direct-amount-chips {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px;
}
.amount-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  padding: 6px 4px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.amount-chip small { font-size: 10px; font-weight: 500; color: var(--ink-3); }
.amount-chip:hover { border-color: var(--line-strong); background: var(--surface); }
.amount-chip.active {
  border-color: var(--ink); background: var(--surface);
  box-shadow: inset 0 2px 0 var(--stamp);
}
.amount-chip.active small { color: var(--stamp); font-weight: 580; }

.direct-input-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.direct-money-input {
  display: flex; align-items: center; gap: 4px; flex: 1 1 110px; min-width: 96px;
  border: 1px solid var(--line-strong); background: var(--bg);
  border-radius: var(--radius-sm); padding: 0 10px; height: 36px;
}
.direct-money-input:focus-within { border-color: var(--ink); background: var(--surface); }
.direct-money-input span { font-weight: 650; color: var(--ink-2); font-size: 14px; }
.direct-money-input input {
  width: 100%; border: 0; outline: none; background: transparent; color: var(--ink);
  font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; min-width: 0;
}
.direct-topup-foot {
  font-size: 12px; color: var(--ink-2); padding-top: 9px; border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums; line-height: 1.5;
}
.direct-topup-foot strong { color: var(--ink); font-weight: 620; }
.recent-pay-orders { display: grid; gap: 8px; }
.direct-order-row {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 6px 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 12px;
}
.direct-order-row strong { font-variant-numeric: tabular-nums; }
.direct-order-status { justify-content: space-between; }

.cdk-vault-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 16px;
  border-color: var(--line-strong);
}
.cdk-vault-card.cdk-horizontal {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.95fr); gap: 18px; align-items: center;
  padding: 15px 18px;
}
.cdk-vault-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.cdk-vault-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.cdk-vault-head h3 { font-family: var(--font-serif); font-size: 17px; font-weight: 600; }
.cdk-row { display: flex; gap: 8px; align-items: center; }
.cdk-code-input {
  flex: 1; min-width: 0; height: 38px; padding: 0 12px; font-size: 13px; letter-spacing: 0.02em;
  background: var(--bg); border-color: var(--line-strong);
}
.cdk-code-input:focus { background: var(--surface); border-color: var(--ink); }
.cdk-row .btn-primary { height: 38px; padding: 0 18px; white-space: nowrap; flex-shrink: 0; }
.cdk-guarantees {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
  padding-top: 12px; border-top: 1px solid var(--line);
}
.cdk-horizontal .cdk-guarantees {
  padding-top: 0; padding-left: 18px; border-top: none; border-left: 1px solid var(--line);
}
.cdk-g-item { display: flex; flex-direction: column; gap: 1px; }
.cdk-g-item strong { font-size: 12px; font-weight: 600; color: var(--ink); }
.cdk-g-item span { font-size: 11px; color: var(--ink-3); }

.ledger-section-bar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-top: 6px;
}
.ledger-section-bar h2 { font-family: var(--font-serif); font-size: 18px; font-weight: 600; }

.grid-packs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.pack {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 20px;
}
.pack-accent {
  border-color: var(--ink);
  box-shadow: var(--shadow-md);
}
.pack-ribbon {
  position: absolute; top: 14px; right: 14px;
  font-size: 11px; font-weight: 580; padding: 2px 8px; border-radius: var(--radius-xs);
  background: var(--stamp-wash); color: var(--stamp); border: 1px solid var(--stamp-border);
}
.pack-top { display: flex; flex-direction: column; gap: 4px; }
.pack-top-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pack-tag { font-size: 11.5px; color: var(--ink-3); }
.pack-tag-hot { color: var(--stamp); font-weight: 560; }
.pack-unit-pill {
  font-size: 10.5px; font-family: ui-monospace, monospace; color: var(--ink-2);
  background: var(--bg); border: 1px solid var(--line); padding: 1px 6px; border-radius: var(--radius-xs);
}
.pack-top h4 { font-family: var(--font-serif); font-size: 19px; font-weight: 600; }
.pack-price {
  font-size: 27px; font-weight: 680; font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.pack-price small { font-size: 12px; font-weight: 500; color: var(--ink-2); }

.pack-perks {
  list-style: none; display: flex; flex-direction: column; gap: 6px;
  margin: 2px 0 6px; flex: 1; font-size: 12.5px; color: var(--ink-2);
}
.pack-perks li { position: relative; padding-left: 14px; line-height: 1.55; }
.pack-perks li::before { content: "—"; position: absolute; left: 0; color: var(--ink-3); }
.pack-perks strong { color: var(--ink); font-weight: 600; }

/* Purchase & Redeem Modal */
.purchase-summary-box {
  background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: var(--radius-md); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.purchase-price-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.purchase-big-price { font-family: var(--font-serif); font-size: 28px; font-weight: 600; line-height: 1.1; margin-top: 2px; font-variant-numeric: tabular-nums; }
.purchase-face-col { text-align: right; display: flex; flex-direction: column; gap: 2px; }
.purchase-face-col strong { font-size: 17px; color: var(--stamp); font-variant-numeric: tabular-nums; }
.purchase-tier-note { font-size: 12px; color: var(--ink-2); padding-top: 8px; border-top: 1px solid var(--line); }

.purchase-channel-box, .purchase-redeem-box {
  display: flex; flex-direction: column; gap: 8px;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface);
}
.purchase-step-title { font-size: 12.5px; font-weight: 620; color: var(--ink); }
.purchase-wechat-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 12.5px;
}
.purchase-qr-wrap { text-align: center; padding: 8px; background: var(--bg); border-radius: var(--radius-sm); }
.purchase-qr-wrap img { max-width: 180px; max-height: 180px; border-radius: var(--radius-xs); display: inline-block; }

.api-inventory, .api-connect, .api-examples {
  min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.api-inventory-head, .api-examples-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px 16px;
  flex-wrap: wrap; padding: 14px 16px;
}
.api-inventory-head h2 { font-size: 19px; }
.api-inventory-head p, .api-connect > p { margin-top: 3px; }
.api-key-actions { display: flex; align-items: center; gap: 8px; }
.api-key-actions button { min-height: 34px; }
.api-key-list { list-style: none; }
.api-key-row {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto; align-items: center; gap: 16px;
  border-top: 1px solid var(--line); padding: 12px 16px;
}
.api-key-identity { display: grid; min-width: 0; gap: 3px; overflow-wrap: anywhere; }
.api-key-identity code { font-size: 12px; }
.api-key-usage { display: flex; flex-wrap: wrap; gap: 6px 24px; font-variant-numeric: tabular-nums; }
.api-key-usage dt { font-size: 12px; color: var(--ink-2); }
.api-key-usage dd { margin-top: 2px; font-weight: 620; }
.api-revoke { color: var(--danger); }
.api-key-row .api-key-actions { justify-content: flex-end; }
.api-key-empty { border-top: 1px solid var(--line); padding: 18px 16px; }
.api-integration { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.4fr); gap: 16px; }
.api-connect { display: flex; flex-direction: column; align-items: flex-start; padding: 14px 16px 16px; }
.api-connect h3, .api-examples h3 { font-size: 16px; }
.api-connect-address {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; align-self: stretch; gap: 4px 10px;
  margin: 14px 0 10px; background: var(--subtle); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 9px 10px;
}
.api-connect-address > span { grid-column: 1; font-size: 12px; }
.api-connect-address code { grid-column: 1; grid-row: 2; overflow-wrap: anywhere; }
.api-connect-address button { grid-column: 2; grid-row: 1 / 3; }
.api-auth-note { color: var(--ink-2); overflow-wrap: anywhere; margin-bottom: 13px; }
#btnDownloadApiDocs { margin-top: auto; }
.api-examples-head code { font-size: 12px; }
.api-example-tools {
  display: flex; justify-content: space-between; gap: 10px; padding: 5px 16px;
  border-top: 1px solid var(--line); background: var(--subtle);
}
.api-example-code {
  min-width: 0; max-height: 320px; overflow: auto; padding: 13px 16px; font-size: 12.5px;
  line-height: 1.7; background: #202521; color: #e5ece6;
}
.api-example-code:focus-visible { outline-offset: -3px; outline-color: #b9d6c8; }
.api-example-note { padding: 10px 16px; font-size: 12.5px; }
.api-example-note code { white-space: nowrap; }
.api-key-dialog {
  position: fixed; inset: 0; margin: auto; padding: 0; width: min(460px, calc(100% - 24px));
  max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain;
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface);
  color: var(--ink); box-shadow: var(--shadow-lg);
}
.api-key-dialog::backdrop { background: rgba(20, 19, 17, .58); }
.api-dialog-head {
  display: flex; justify-content: space-between; align-items: start; gap: 10px; padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}
.api-dialog-head h2 { font-family: var(--font-serif); font-size: 24px; line-height: 1.2; }
.api-dialog-head p { margin-top: 6px; }
.api-dialog-head .btn-icon-sm { flex: 0 0 34px; height: 34px; font-size: 20px; }
.api-dialog-body { display: grid; gap: 16px; padding: 16px 18px; }
.api-dialog-body .field label { font-size: 13px; font-weight: 620; color: var(--ink); }
.api-dialog-body input, .api-dialog-body select { width: 100%; min-height: 42px; }
.api-dialog-body p.muted { font-size: 12.5px; }
.api-name-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; }
.api-name-presets button { min-height: 32px; }
.api-dialog-error { padding: 8px 10px; background: var(--stamp-wash); border-radius: var(--radius-sm); }
.api-dialog-foot {
  display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px;
  border-top: 1px solid var(--line); background: var(--subtle);
}
.api-dialog-foot button { min-height: 40px; }
#apiKeyCreatedSummary { overflow-wrap: anywhere; }

/* ==================== OVERLAYS, DRAWER, LIGHTBOX & DIALOGS ==================== */
body:has(.prompt-sheet) { overflow: hidden; }
#panel-prompts.prompt-sheet {
  position: fixed; inset: 0; z-index: 170; display: grid; place-items: center;
  padding: 22px; background: rgba(20, 19, 17, 0.49);
}
.prompt-sheet > .page {
  width: min(1140px, 100%); height: min(820px, 100%); padding: 0 22px 22px;
  display: block; overflow: auto; overscroll-behavior: contain; background: var(--surface);
  border-radius: var(--radius-lg); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg);
}
#panel-prompts .page-header { align-items: center; }
.prompt-sheet .page-header {
  position: sticky; top: 0; z-index: 3; background: var(--surface); padding: 12px 0 10px;
}
.prompt-sheet .prompt-library-layout { padding-top: 14px; }
#btnClosePromptSheet { font-size: 21px; }
.overlay {
  position: fixed; inset: 0; background: rgba(20, 19, 17, 0.52);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
#taskDrawerBackdrop { justify-content: flex-end; padding: 0; }
.overlay[data-active-overlay] { z-index: 201; }

.drawer {
  width: 360px; max-width: 92vw; height: 100%; background: var(--surface);
  border-left: 1px solid var(--line-strong); display: flex; flex-direction: column;
}
.drawer-head, .dialog-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.drawer-head h3, .dialog-head h3 { font-family: var(--font-serif); font-size: 16px; font-weight: 600; }
.drawer-body { padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.task-drawer-state { padding: 8px; }
.task-item {
  display: flex; gap: 10px; align-items: center; padding: 8px; text-align: left;
  border-radius: var(--radius-sm); border: 1px solid var(--line); cursor: pointer;
  background: var(--bg);
}
.task-item:hover { border-color: var(--line-strong); background: var(--subtle); }
.task-item-live { border-color: var(--accent); background: var(--accent-wash); }
.task-item-live:hover { border-color: var(--accent); background: var(--accent-wash); }
.task-item-live-badge {
  width: 44px; height: 44px; border-radius: var(--radius-xs); flex-shrink: 0;
  display: grid; place-items: center; background: var(--surface); border: 1px solid var(--accent-border);
  color: var(--accent); font-size: 11.5px; font-weight: 600;
}
.task-item img { width: 44px; height: 44px; border-radius: var(--radius-xs); object-fit: cover; flex-shrink: 0; }
.task-info { min-width: 0; flex: 1; }
.task-title { display: block; font-size: 12.5px; font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-meta { display: block; font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-top: 2px; }

/* Darkroom image viewer */
body:has(.lightbox[open]) { overflow: hidden; }
.lightbox {
  --ink: #efece5;
  --ink-2: #c2bbb0;
  --surface: #1c1b18;
  --subtle: #252320;
  --line: #34312b;
  --focus: #b9d6c8;
  position: fixed; inset: 0; width: 100%; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; overflow: hidden;
  background: #11100e; color: var(--ink); color-scheme: dark;
}
.lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.lightbox::backdrop { background: #11100e; }
.lb-toolbar, .lb-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border-color: var(--line);
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
}
.lb-toolbar { min-height: 56px; padding-block: max(8px, env(safe-area-inset-top)) 8px; border-bottom: 1px solid var(--line); }
.lb-title { font-size: 14px; font-weight: 600; }
.lb-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-inline-start: auto; }
.lb-bar { justify-content: center; min-height: 48px; border-top: 1px solid var(--line); padding-block: 6px max(6px, env(safe-area-inset-bottom)); }
.lb-btn, .lb-close, .lb-nav {
  min-height: 36px; padding: 5px 11px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: transparent; color: var(--ink); font-size: 13px;
}
.lb-btn:hover, .lb-close:hover, .lb-nav:hover { background: var(--subtle); }
.lb-btn[aria-pressed="true"], .lb-btn[aria-expanded="true"] { border-color: var(--focus); }
.lb-btn:disabled { opacity: .5; cursor: not-allowed; }
.lb-close, .lb-nav { display: grid; place-items: center; width: 36px; padding: 0; font-size: 22px; line-height: 1; }
.lb-navigation { display: flex; align-items: center; gap: 6px; }
.lb-counter { color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.lb-workspace { min-width: 0; min-height: 0; position: relative; display: flex; overflow: hidden; }
.lb-stage {
  position: relative; flex: 1; min-width: 0; min-height: 0;
  padding: clamp(8px, 2.5vw, 32px);
}
.lb-img-box, .lb-ba-box { width: 100%; height: 100%; }
.lb-img-box { overflow: hidden; }
.lb-img-box img { display: block; width: 100%; height: 100%; object-fit: contain; }
.lb-img-box.is-zoomed { overflow: auto; overscroll-behavior: contain; }
.lb-img-box.is-zoomed img { width: 200%; height: 200%; max-width: none; }
.lb-img-box:focus-visible { outline-offset: -2px; }
.lb-image-error { position: absolute; inset-inline: 0; bottom: 10px; margin: 0 auto; width: fit-content; max-width: 90%; padding: 4px 10px; border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-2); text-align: center; }
.lb-ba-box .lb-vp { min-height: 0; }
.lb-ba-box .ba-img { object-fit: contain; }
.lb-ba-box:focus-within .ba-knob { outline: 2px solid var(--focus); outline-offset: 3px; }
.lb-side {
  flex: 0 0 min(340px, 36%); min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-inline-start: 1px solid var(--line);
  padding: 18px; display: flex; flex-direction: column; gap: 16px;
}
.lb-head { display: grid; gap: 2px; font-size: 12px; color: var(--ink-2); }
.lb-head strong { color: var(--ink); font-size: 15px; overflow-wrap: anywhere; }
.lb-prompt p { font-size: 14px; color: var(--ink); line-height: 1.6; margin-bottom: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.lb-specs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.lb-specs div { background: var(--subtle); padding: 8px 10px; border-radius: var(--radius-xs); border: 1px solid var(--line); overflow-wrap: anywhere; }
.lb-specs div:last-child:nth-child(odd) {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.lb-specs div:last-child:nth-child(odd) dd { margin-top: 0; }
.lb-specs dt { font-size: 12px; color: var(--ink-2); }
.lb-specs dd { font-size: 13px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.lb-actions { display: grid; gap: 8px; }
.lb-actions .btn-outline, .lb-actions .btn-primary { min-width: 0; white-space: normal; text-align: center; }
.lb-actions .btn-outline { background: transparent; color: var(--ink); border-color: var(--line); }
.lb-actions .btn-outline:hover { background: var(--subtle); }
.lb-actions .btn-primary { background: #b9d6c8; color: #161513; border-color: #b9d6c8; }
@media (max-width: 680px) {
  .lb-toolbar, .lb-bar { padding-inline: 8px; }
  .lb-side {
    position: absolute; inset: 0 0 0 auto; z-index: 2; width: min(100%, 380px);
    padding: 14px;
  }
  .lb-actions .row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.cmd-box {
  width: 100%; max-width: 520px; align-self: flex-start; margin-top: 10vh;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); overflow: hidden;
}
.cmd-head { display: flex; align-items: center; gap: 10px; padding: 12px 15px; border-bottom: 1px solid var(--line); }
.cmd-head input { flex: 1; border: none; background: transparent; outline: none; font-size: 14px; }
.cmd-list { max-height: 330px; overflow-y: auto; padding: 6px; }
.cmd-item {
  width: 100%; border: none; background: transparent; text-align: left;
  padding: 8px 10px; border-radius: var(--radius-xs);
  display: flex; justify-content: space-between; align-items: center; font-size: 13px;
}
.cmd-item:hover { background: var(--subtle); }
.cmd-tag { font-size: 11px; color: var(--ink-3); font-family: ui-monospace, monospace; }

.dialog {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden;
}
.dialog-sm { max-width: 420px; }
.dialog-md { max-width: 580px; }
.dialog-lg { max-width: 790px; }
.dialog-body { padding: 18px; max-height: 76vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.dialog-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.dialog-body.pd-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px; }
.dialog-body.pd-grid-text { grid-template-columns: minmax(0, 1fr); }
.pd-visual { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.pd-visual[hidden] { display: none; }
.pd-cover { height: auto; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--stage-bg); }
.pd-cover img { object-fit: contain; }
#pdSource { overflow-wrap: anywhere; min-width: 0; }
.empty-prompts { padding: 24px 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); text-align: center; }
.empty-prompts p { margin: 5px 0 12px; }
.pd-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pd-code {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px; font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word;
  max-height: 250px; overflow-y: auto; font-family: inherit;
}
.pd-code.mono { font-family: ui-monospace, monospace; font-size: 11.5px; }

.var-fields { display: flex; flex-direction: column; gap: 10px; }
.var-preview {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px; font-size: 12.5px; color: var(--ink-2); line-height: 1.6;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--ink-2); font-weight: 550; }
.auth-account, .auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-policies:not([hidden]) { display: flex; align-items: baseline; gap: 8px; font-size: 0.875rem; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); }

/* Brand Kits Modal */
.kit-save-box { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px; display: flex; flex-direction: column; gap: 7px; }
.kit-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.kit-empty { padding: 22px 14px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius-md); }
.kit-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--bg);
}
.kit-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.kit-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.kit-head strong { font-size: 13.5px; }
.kit-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kit-thumbs { display: flex; gap: 5px; margin-top: 2px; }
.kit-thumbs img { width: 36px; height: 36px; object-fit: cover; border-radius: var(--radius-xs); border: 1px solid var(--line-strong); }
.kit-ops { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Admin & Inpaint */
.admin-corner-btn {
  position: fixed; bottom: 14px; left: 14px; z-index: 75;
  width: 28px; height: 28px; border-radius: var(--radius-xs);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-3);
  display: flex; align-items: center; justify-content: center; opacity: 0.45;
}
.admin-corner-btn:hover { opacity: 1; color: var(--ink); }
.admin-block { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 13px; display: flex; flex-direction: column; gap: 9px; }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.test-line { font-size: 12px; padding: 7px 10px; background: var(--surface); border-radius: var(--radius-sm); border: 1px solid var(--line); }
.channel-list { display: flex; flex-direction: column; gap: 6px; }
.channel-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 12px;
}
.channel-info { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
.channel-url { color: var(--ink-3); font-family: ui-monospace, monospace; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cdk-grid { display: flex; flex-wrap: wrap; gap: 6px; max-height: 96px; overflow-y: auto; }
.cdk-item {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-xs);
  padding: 4px 8px; font-family: ui-monospace, monospace; font-size: 11.5px;
}
.cdk-item.used { opacity: 0.4; text-decoration: line-through; }

/* Admin Direct Recharge Orders & User Account Password Box */
.admin-orders-list {
  display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow-y: auto;
}
.admin-order-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 12px;
}
.admin-order-row.is-pending { border-color: var(--stamp-border); background: var(--stamp-wash); }
.admin-order-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-order-ops { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.account-pass-box {
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); padding: 8px 10px;
}
.account-pass-box summary {
  cursor: pointer; font-size: 12.5px; font-weight: 560; color: var(--ink-2); user-select: none;
}
.account-pass-fields { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }

/* Keep required site information reachable from the fullscreen Studio tab. */
#panel-studio.active ~ .site-footer:not(.site-footer-public-info) { display: none; }
.site-footer {
  max-width: 1280px; margin: 28px auto 0; padding: 16px 4px 6px;
  border-top: 1px solid var(--line);
}
.site-footer-inner {
  display: flex; align-items: center; justify-content: center; gap: 8px 12px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--ink-3); text-align: center;
}
.footer-sep { opacity: 0.5; }
.site-policy-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.site-service-details { width: fit-content; max-width: 100%; margin: 8px auto 0; overflow-wrap: anywhere; }
.site-service-details summary { cursor: pointer; width: fit-content; margin-inline: auto; }
.site-service-details ul { margin-block: 6px 0; padding-inline-start: 1.25rem; text-align: start; }
.auth-policy-links { padding: 8px 14px 12px; margin: 0; border-top: 1px solid var(--line); }
.billing-policy-links { justify-content: flex-start; margin-top: 0; }

.canvas-stage {
  background: var(--stage-bg); border: 1px solid var(--line-strong);
  border-radius: var(--radius-md); padding: 14px; display: grid; place-items: center;
}
.canvas-stage canvas { max-width: 100%; border-radius: var(--radius-xs); cursor: crosshair; box-shadow: var(--shadow-md); display: block; }
#inpaintCanvas { touch-action: none; }
#inpaintImageStatus { color: #f6f3ef; padding: 18px 8px; }

.toast-stack { position: fixed; bottom: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
body:has(#panel-studio.active) .toast-stack { bottom: calc(var(--studio-dock-height, 190px) + 10px); }
.toast {
  background: var(--ink); color: var(--bg); padding: 8px 14px;
  border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 550; box-shadow: var(--shadow-md);
}

/* ==================== RESPONSIVE BREAKPOINTS ==================== */
@media (max-width: 1140px) {
  .grid-showcase { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
  .topbar-inner { height: auto; min-height: 50px; flex-wrap: wrap; gap: 4px 8px; padding: 8px 14px 0; }
  .topbar-right { margin-left: auto; }
  .nav {
    order: 1; flex: 1 0 100%; width: 0; overflow-x: auto;
    border-top: 1px solid var(--line); padding-top: 2px; scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-tab { padding: 7px 10px; }
  .nav-tab.active::after { bottom: 0; left: 10px; right: 10px; }
  .app { padding: 14px 14px 44px; }
  .hero-split, .grid-pricing, .grid-packs, .billing-bento, .cdk-vault-card.cdk-horizontal, .row-2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .cdk-horizontal .cdk-guarantees {
    padding-left: 0; padding-top: 10px; border-left: none; border-top: 1px solid var(--line);
  }
  .ba-viewport { min-height: 300px; }
  .series-prompt-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .studio-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .studio-sidebar {
    grid-row: auto; position: relative; z-index: 69; flex-direction: row; align-items: center;
    justify-content: space-between; gap: 6px; padding: 8px 12px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  #btnToggleHistory { display: inline-flex; }
  #btnNewThread { width: auto; min-height: 34px; padding-inline: 8px; font-size: 12px; }
  .studio-mode { width: auto; flex-shrink: 0; }
  .studio-history-title { display: none; }
  .studio-history-wrap {
    position: absolute; top: calc(100% + 3px); left: 12px; width: min(320px, calc(100vw - 24px));
  }
  .history-content:not([hidden]) {
    padding: 10px; background: var(--surface); border: 1px solid var(--line-strong);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg); max-height: 48dvh;
  }
  .stage { padding: 14px 12px; gap: 12px; }
  .stage-bar { padding-bottom: 8px; }
  .composer-wrap { grid-column: 1; padding: 0 10px max(8px, env(safe-area-inset-bottom)); }
}

@media (max-width: 680px) {
  .vip-mini-pill { display: none !important; }
  #btnReturnToGenerate { display: inline-flex; align-self: flex-end; min-height: 34px; }
  .grid-showcase { grid-template-columns: minmax(0, 1fr); }
  .prompt-library-layout { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .prompt-library-filters { padding: 0; border: 0; gap: 6px; }
  .prompt-scopes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .prompt-scopes button { text-align: center; white-space: nowrap; padding-inline: 2px; }
  #btnPromptFilters { display: inline-flex; }
  #btnPromptFilters[aria-expanded="true"] { background: var(--accent-wash); }
  .prompt-refine-row:not(:has(#btnPromptFilters[aria-expanded="true"])) + .prompt-refinements { display: none; }
  .prompt-refinements { padding: 7px 0 2px; }
  .prompt-groups { display: flex; flex-wrap: wrap; }
  .prompt-groups .seg-item { min-height: 32px; }
  #promptSourceFilter { justify-self: start; width: min(240px, 100%); }
  #promptSearchInput { min-height: 42px; font-size: 16px; }
  .api-integration { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .api-key-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .api-key-identity { grid-column: 1 / -1; }
  .api-key-actions { gap: 5px; }
  .api-key-usage { gap: 3px 14px; }
  .api-key-usage dt, .api-key-usage dd { font-size: 12px; }
  .api-example-code { white-space: pre-wrap; overflow-wrap: anywhere; }
  .api-dialog-body input, .api-dialog-body select { font-size: 16px; }
}

@media (max-width: 560px) {
  .studio-welcome { padding: 8px 0 12px; }
  .studio-welcome-copy p { margin: 6px auto 12px; font-size: 12.5px; }
  .studio-welcome-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-width: 304px;
    margin-inline: auto;
  }
  .studio-welcome-actions > button { min-height: 40px; padding-inline: 8px; font-size: 12px; }
  .output-settings { --output-button-height: 40px; }
  .price-tiers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-surface > .gallery-search { width: 100%; max-width: none; }

  .topbar-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 6px 8px 0; gap: 4px 6px; }
  .topbar-right { gap: 4px; }
  .brand { gap: 6px; min-width: 0; flex: 0 1 auto; }
  .brand-mark { width: 14px; height: 14px; }
  .brand-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
  .nav { grid-column: 1 / -1; width: 100%; justify-content: space-between; gap: 0; }
  .nav .nav-tab { min-height: 34px; flex: 1 0 auto; padding-inline: 6px; }
  #btnOpenCmdPalette, #btnOpenTaskDrawer, #userBalancePill { padding-inline: 7px; }
  #btnOpenCmdPalette kbd { display: none; }
  .auth-trigger { max-width: 64px; padding-inline: 6px; }
  .topbar-right .topbar-menu summary { padding-inline: 8px; }
  #btnOpenTaskDrawer .status-dot:not(.busy), .task-label, .more-label { display: none; }
  .task-icon { display: block; flex: none; }
  .more-icon { display: block; font-size: 17px; line-height: 1; }
  .app { padding-inline: 10px; }
  .composer-input, .series-prompt-field textarea { font-size: 16px; }
  .studio-layout { min-height: 0; }
  .studio-sidebar { padding: 4px 8px; }
  .studio-sidebar-actions { gap: 4px; }
  .studio-mode .seg-item, #btnNewThread, #btnToggleHistory { min-height: 34px; }
  .composer-wrap { padding-inline: 8px; }
  .prompt-box { padding: 8px 10px 2px; gap: 4px; }
  .prompt-box-head { display: none; }
  .composer-input {
    min-height: 44px; max-height: min(108px, 18dvh); line-height: 1.4;
    field-sizing: content; resize: none;
  }
  .ref-strip { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
  .composer-toolbar {
    display: grid; grid-template-columns: minmax(0, 1fr) repeat(4, auto);
    gap: 4px; padding: 4px 8px;
  }
  .composer-toolbar > .anchor { min-width: 0; }
  .composer-toolbar .select-trigger {
    min-height: 36px; grid-template-columns: minmax(0, 1fr) 10px;
    gap: 3px; padding-inline: 6px; font-size: 12px;
  }
  .composer-toolbar .select-trigger > span:first-child,
  .prompt-library-prefix, #btnUploadRefImg > span[aria-hidden], #currentModelLabel { display: none; }
  #currentModelCompactLabel { display: block; }
  .composer-toolbar .select-trigger strong { justify-self: start; }
  .composer-toolbar .dock-button, #btnUploadRefImg { min-height: 36px; padding-inline: 6px; font-size: 12px; }
  #btnUploadRefImg { margin-left: 0; }
  #mobileOutputSummary { display: none; }
  .composer-utilities-panel { max-height: min(365px, 51dvh); }
  .output-control select, .tool-settings-fields input, .tool-settings-fields select { font-size: 16px; }
  .composer-footer { padding: 4px 8px; }
  .composer-meta { gap: 1px 8px; font-size: 11px; line-height: 1.35; }
  #composerEstimateText { font-size: 13px; }
  #compactOutputSummary { display: inline; }
  .composer-meta > span:last-child { flex-basis: 100%; }
  .studio-example-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .studio-example img { height: clamp(66px, 12dvh, 111px); }
  .studio-example-caption { padding: 5px 6px; }
  .studio-example-title { font-size: 11px; }
  .studio-example-action { display: none; }
  #panel-prompts.prompt-sheet { padding: 0; }
  .prompt-sheet > .page { height: 100%; border-radius: 0; border: 0; padding: 0 12px 15px; }
  #panel-prompts .page-header { gap: 8px; }
  #promptLibraryTitle { font-size: 22px; }
  #panel-prompts .page-header-actions { gap: 4px; }
  #panel-prompts .page-header-actions button { padding-inline: 6px; font-size: 12px; min-height: 34px; }
  #panel-prompts #btnClosePromptSheet { font-size: 20px; width: 34px; }
  .stage { padding: 8px 10px 12px; gap: 8px; scroll-padding-top: 42px; }
  .stage-bar { top: -8px; margin-top: -8px; padding-block: 12px 6px; min-height: 44px; flex-wrap: nowrap; }
  .stage-title { font-size: 17px; }
  .stage:has(> .studio-conversation:not([hidden])) .stage-bar-right,
  .stage-bar-right:has(> .hidden) { display: none; }
  .stream { gap: 20px; }
  .turn { gap: 8px; }
  .turn-message { max-width: 90%; padding: 8px 10px; }
  .turn-message-tools, .turn-meta { margin-top: 0; }
  .toolbar-right { width: 100%; }
  #pricingSearchInput, #gallerySearchInput { flex: 1 1 100%; max-width: 100% !important; min-width: 0; }
  .grid-prompts, .tier-steps, .cdk-guarantees { grid-template-columns: minmax(0, 1fr); }
  .direct-amount-chips { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .direct-input-row #btnSubmitDirectTopup { width: 100%; }
  .subnav { max-width: 100%; overflow-x: auto; }
  .dialog-body.pd-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 360px) {
  .topbar-right { gap: 3px; }
  #btnOpenTaskDrawer, #userBalancePill, .auth-trigger { padding-inline: 5px; }
  .topbar-right .topbar-menu summary { padding-inline: 5px; }
  .composer-toolbar { gap: 3px; }
  .composer-toolbar .select-trigger, .composer-toolbar .dock-button, #btnUploadRefImg { padding-inline: 4px; }
}

@media (hover: none) {
  .art-overlay { opacity: 1; }
}

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