:root {
  --bg: #090c14;
  --bg-elev: #111624;
  --bg-card: #171e30;
  --bg-input: #0c111d;
  --border: #26314a;
  --border-soft: rgba(148, 163, 184, 0.16);
  --border-focus: #7c8cff;
  --text: #eef2ff;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #7c8cff;
  --accent-2: #c084fc;
  --free: #10b981;
  --free-bg: rgba(16, 185, 129, 0.14);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --font-sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

@media (min-width: 981px) {
  html,
  body {
    height: 100dvh;
    overflow: hidden;
  }
}

/* Custom sleek scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.24);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.42);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  transition: border-color 0.15s, background 0.15s, transform 0.08s, box-shadow 0.15s;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  background: #1f2840;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  outline: none;
}

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

textarea {
  resize: vertical;
  min-height: 76px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

kbd {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
  font-size: 12px;
}

/* ---- Topbar (50px compact) ---- */
.topbar {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px;
  background: rgba(11, 14, 23, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.32);
  color: var(--free);
  white-space: nowrap;
}

.auth-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.key-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 4px;
}

.key-input-wrap input {
  border: none;
  background: transparent;
  padding: 3px 6px;
  width: 175px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.connected-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-size: 12px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--free);
  box-shadow: 0 0 6px var(--free);
}

.quota-meters {
  display: flex;
  gap: 6px;
  align-items: center;
}

.meter-box {
  min-width: 116px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 7px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  margin-bottom: 2px;
}

.meter-tag-free {
  color: var(--free);
  font-weight: 700;
}

.meter-tag-paid {
  color: var(--accent);
  font-weight: 700;
}

.meter-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.meter-free {
  background: linear-gradient(90deg, #059669, #34d399);
}

.meter-paid {
  background: linear-gradient(90deg, #6366f1, #a855f7);
}

/* ---- Buttons & Pills ---- */
.btn-sm {
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.12);
  border-color: var(--border);
  color: var(--text);
}

.btn-primary {
  background: linear-gradient(135deg, #4f63ff, #8b5cf6);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #5d70ff, #9b6dff);
}

.btn-free {
  background: linear-gradient(135deg, #059669, #10b981);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 18px;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.28);
}

.btn-free:hover:not(:disabled) {
  background: linear-gradient(135deg, #047857, #059669);
}

.btn-free-outline {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.42);
  color: #6ee7b7;
}

.btn-paid {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  border-color: transparent;
  color: #111827;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 18px;
}

.btn-danger {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

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

.action-label-btn {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  white-space: nowrap;
}

.action-label-btn.btn-primary {
  background: linear-gradient(135deg, #4f63ff, #8b5cf6);
  border-color: transparent;
  color: #fff;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-card);
  white-space: nowrap;
}

.pill-free {
  color: var(--free);
  background: var(--free-bg);
  border-color: rgba(16, 185, 129, 0.35);
}

.pill-warn {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: rgba(245, 158, 11, 0.35);
}

.pill-danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(239, 68, 68, 0.35);
}

/* ---- Main Dual-Pane Studio Shell (Zero Page Scroll on Desktop) ---- */
.studio-shell {
  display: grid;
  grid-template-columns: minmax(470px, 50%) minmax(420px, 50%);
  height: calc(100dvh - 50px);
  max-width: 1840px;
  margin: 0 auto;
  overflow: hidden;
}

.col-left {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.col-right {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 10px 14px 12px;
  gap: 10px;
  background: #070a11;
}

/* ---- Left Col Top Quick Bar ---- */
.quick-param-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.quick-model-select {
  flex: 1.1;
  min-width: 140px;
  font-size: 12.5px;
  padding: 5px 8px;
}

.aspect-pills {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.aspect-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  white-space: nowrap;
}

.aspect-btn:hover:not(:disabled) {
  background: rgba(124, 140, 255, 0.14);
  color: var(--text);
}

.aspect-btn.active {
  background: linear-gradient(135deg, rgba(79, 99, 255, 0.36), rgba(16, 185, 129, 0.25));
  color: #fff;
  font-weight: 600;
}

.quick-res-select {
  width: 132px;
  flex-shrink: 0;
  font-size: 12px;
  padding: 5px 7px;
}

/* ---- Deck Tabs ---- */
.deck-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 7px 12px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.deck-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: nowrap;
}

.deck-tab.active {
  color: #fff;
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(79, 99, 255, 0.22), rgba(139, 92, 246, 0.16));
  box-shadow: inset 0 0 0 1px rgba(124, 140, 255, 0.25);
}

.tab-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-muted);
}

.deck-tab.active .tab-badge {
  background: rgba(124, 140, 255, 0.32);
  color: #e0e7ff;
}

.tab-badge.badge-free {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
}

.tab-badge.badge-warn {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

/* ---- Single Scroll Viewport in Left Col ---- */
.deck-viewport {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 12px 14px;
}

.deck-pane {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.deck-pane.active {
  display: flex;
}

/* ---- Starter Strip ---- */
.starter-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(99, 102, 241, 0.08));
  border: 1px solid rgba(16, 185, 129, 0.28);
  flex-wrap: wrap;
}

.starter-strip-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--free);
  white-space: nowrap;
}

.starter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
}

.starter-pill {
  padding: 3px 9px;
  font-size: 12px;
  border-radius: 999px;
  background: rgba(17, 22, 36, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.starter-pill:hover {
  border-color: var(--free);
  color: #fff;
}

.starter-strip-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---- Composer Cards & Semantic Bubble System ---- */
.composer-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.composer-card-neg {
  background: rgba(17, 22, 36, 0.8);
}

.composer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.composer-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-title {
  font-size: 13.5px;
  font-weight: 700;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.uc-select-compact {
  width: auto;
  font-size: 11.5px;
  padding: 3px 8px;
}

.weight-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.weight-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.weight-hint {
  font-size: 11px;
}

.active-artist-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.34);
}

.artist-flag {
  font-size: 11.5px;
  font-weight: 700;
  color: #d8b4fe;
  white-space: nowrap;
}

.active-artist-code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #e9d5ff;
  word-break: break-all;
}

.bubble-composer {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: border-color 0.15s;
}

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

.bubble-composer-neg {
  min-height: 54px;
}

.bubble-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.bubble-inline-input {
  border: none !important;
  background: transparent !important;
  padding: 3px 4px !important;
  font-size: 12.5px;
  color: var(--text);
  min-width: 160px;
}

.bubble-inline-input::placeholder {
  color: var(--text-dim);
}

/* ---- Semantic Tag Bubbles ---- */
.tag-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.3;
  border: 1px solid var(--border);
  background: #1a2338;
  color: #e2e8f0;
  cursor: pointer;
  user-select: none;
  max-width: 100%;
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.tag-bubble:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.55);
}

.tag-bubble.selected {
  box-shadow: 0 0 0 2px rgba(124, 140, 255, 0.65);
  border-color: #a5b4fc;
}

.tag-bubble.dragging {
  opacity: 0.45;
}

.tag-bubble.tag-artist {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(168, 85, 247, 0.24));
  border-color: rgba(168, 85, 247, 0.52);
  color: #f3e8ff;
}

.tag-bubble.tag-anchor {
  background: rgba(14, 165, 233, 0.16);
  border-color: rgba(56, 189, 248, 0.45);
  color: #bae6fd;
}

.tag-bubble.tag-meta {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(52, 211, 153, 0.42);
  color: #a7f3d0;
}

.tag-bubble.tag-boost {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(251, 191, 36, 0.52);
  color: #fef3c7;
}

.tag-bubble.tag-damp {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(96, 165, 250, 0.4);
  color: #bfdbfe;
}

.tag-bubble.tag-neg {
  background: rgba(239, 68, 68, 0.14);
  border: 1px dashed rgba(248, 113, 113, 0.58);
  color: #fecaca;
}

.tag-bubble.tag-prose {
  border-radius: 10px;
  padding: 5px 8px;
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.34);
  color: #cbd5e1;
}

.tag-icon {
  font-size: 11px;
  opacity: 0.9;
}

.tag-text {
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 12px;
}

.tag-bubble.tag-prose .tag-text {
  font-family: var(--font-sans);
  font-size: 12px;
}

.tag-weight-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  color: #fff;
}

.tag-ctrl-btn {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  width: 17px;
  height: 17px;
  padding: 0;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.78;
}

.tag-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  opacity: 1;
}

.tag-ctrl-del:hover {
  background: rgba(239, 68, 68, 0.55);
  color: #fff;
}

.tag-inline-edit {
  width: auto !important;
  min-width: 110px;
  max-width: 320px;
  padding: 2px 7px !important;
  font-family: var(--font-mono);
  font-size: 12px;
  border-radius: 999px !important;
  border-color: var(--accent) !important;
}

/* Mini non-editable bubbles in Library & Lightbox */
.tag-mini-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag-mini {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: #cbd5e1;
}

.tag-mini.tag-artist {
  background: rgba(139, 92, 246, 0.2);
  border-color: rgba(168, 85, 247, 0.45);
  color: #e9d5ff;
}

.tag-mini.tag-anchor {
  background: rgba(14, 165, 233, 0.14);
  border-color: rgba(56, 189, 248, 0.35);
  color: #bae6fd;
}

.tag-mini.tag-meta {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(52, 211, 153, 0.35);
  color: #a7f3d0;
}

.tag-mini.tag-boost {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(251, 191, 36, 0.45);
  color: #fde68a;
}

.tag-mini.tag-damp {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(96, 165, 250, 0.38);
  color: #bfdbfe;
}

.tag-mini.tag-neg {
  background: rgba(239, 68, 68, 0.14);
  border: 1px dashed rgba(248, 113, 113, 0.48);
  color: #fecaca;
}

.tag-mini-clickable {
  cursor: pointer;
}

.tag-mini-clickable:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* ---- Quick Toggle Tags ---- */
.quick-tags-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.quick-group-btn {
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.quick-group-btn.active {
  background: rgba(124, 140, 255, 0.2);
  border-color: var(--accent);
  color: #fff;
}

.quick-tags-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  padding: 3px 9px;
  font-size: 11.5px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

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

.chip.active {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.55);
  color: #a7f3d0;
  font-weight: 600;
}

/* ---- Linter & Switches ---- */
.linter-box {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
  font-size: 12px;
}

.switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
}

/* ---- Library Pane ---- */
.lib-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

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

.tab-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-input);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--accent);
}

.lib-io-btns {
  display: flex;
  gap: 5px;
}

.lib-search-row {
  display: flex;
  gap: 8px;
}

.lib-search-row input {
  flex: 1;
}

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

.preset-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 8px;
}

.preset-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.preset-card-title {
  font-weight: 700;
  font-size: 13px;
}

.preset-code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: #cbd5e1;
  background: var(--bg-input);
  padding: 6px;
  border-radius: 6px;
  word-break: break-word;
  max-height: 90px;
  overflow-y: auto;
}

.preset-meta {
  font-size: 11.5px;
  color: var(--text-muted);
}

.preset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: auto;
}

/* ---- Characters & References ---- */
.pane-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.empty-hint-box {
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-muted);
}

.char-stage-wrap {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 10px;
  align-items: start;
}

.char-stage {
  position: relative;
  width: 170px;
  height: 170px;
  background: radial-gradient(circle at center, #1b243b, #0e1320);
  border: 1px dashed var(--border-focus);
  border-radius: var(--radius-sm);
  user-select: none;
  touch-action: none;
}

.char-pin {
  position: absolute;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  margin-top: -12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: 2px solid #fff;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.char-slot,
.ref-slot {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px;
  margin-bottom: 8px;
}

.ref-slot-body {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  align-items: start;
}

.ref-thumb {
  width: 88px;
  height: 116px;
  object-fit: contain;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
}

.form-actions-right {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}

/* ---- Grids & Fields ---- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

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

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

.field label {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---- Bottom Generate Dock ---- */
.generate-dock {
  flex-shrink: 0;
  background: rgba(17, 22, 36, 0.98);
  border-top: 1px solid var(--border);
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dock-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.cost-estimate-line {
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-quick-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.dock-chip {
  padding: 2px 8px;
  font-size: 11.5px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.dock-chip.locked {
  border-color: rgba(124, 140, 255, 0.55);
  color: #c7d2fe;
}

.dock-batch-select {
  width: auto;
  padding: 2px 6px;
  font-size: 11.5px;
  border-radius: 999px;
}

.dock-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

/* ---- Right Column: Canvas & Gallery ---- */
.zip-reminder-banner {
  border-radius: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.zip-reminder-banner.has-unsaved {
  border-color: rgba(245, 158, 11, 0.55);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(239, 68, 68, 0.08));
}

.zip-reminder-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 12.5px;
  min-width: 0;
}

.canvas-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.view-switch-group {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
}

.view-switch-group .btn-sm {
  border: none;
  background: transparent;
  color: var(--text-muted);
}

.view-switch-group .btn-sm.active {
  background: var(--bg-card);
  color: var(--text);
}

.gen-progress-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(79, 99, 255, 0.14);
  border: 1px solid rgba(124, 140, 255, 0.45);
  flex-shrink: 0;
}

.gen-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(124, 140, 255, 0.25);
  border-top-color: var(--accent);
  animation: zhumi-spin 0.85s linear infinite;
  flex-shrink: 0;
}

@keyframes zhumi-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Empty State & Welcome Card */
.canvas-empty-state {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: 12px;
}

.welcome-auth-card {
  background: linear-gradient(135deg, rgba(79, 99, 255, 0.14), rgba(16, 185, 129, 0.1));
  border: 1px solid rgba(124, 140, 255, 0.4);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.welcome-title {
  font-size: 16px;
  font-weight: 700;
}

.welcome-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.welcome-input-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.welcome-input-row input {
  flex: 1;
  min-width: 200px;
  font-family: var(--font-mono);
}

.empty-guide-box {
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
}

.empty-guide-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.empty-guide-steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

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

.empty-tpl-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 10px 12px;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.empty-tpl-card strong {
  font-size: 13px;
}

.empty-tpl-card span {
  font-size: 11.5px;
  color: var(--free);
}

/* Hero Stage View */
.hero-stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hero-canvas-box {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #101625, #06080e);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  padding: 8px;
}

.hero-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  cursor: zoom-in;
}

.hero-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 52px;
  border-radius: 10px;
  background: rgba(11, 14, 23, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #fff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.hero-nav-prev {
  left: 10px;
}

.hero-nav-next {
  right: 10px;
}

.hero-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-shrink: 0;
}

.hero-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.hero-filmstrip {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 2px;
  flex-shrink: 0;
}

.film-thumb {
  width: 58px;
  height: 74px;
  flex-shrink: 0;
  border-radius: 7px;
  overflow: hidden;
  padding: 0;
  border: 2px solid var(--border);
  background: #06080d;
}

.film-thumb.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 140, 255, 0.35);
}

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

/* Grid Gallery View */
.gallery-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  align-content: start;
  padding-right: 2px;
}

.art-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.art-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: #07090f;
  cursor: zoom-in;
}

.art-card-body {
  padding: 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.art-card-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px;
}

/* ---- Modals, Lightbox & Toast ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(5, 7, 12, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 760px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 16px;
}

.lightbox-modal {
  max-width: 1060px;
}

.lightbox-body {
  display: grid;
  grid-template-columns: minmax(280px, 1.15fr) minmax(260px, 0.85fr);
  gap: 14px;
  align-items: start;
}

.lightbox-img-pane {
  background: #06080d;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img-pane img {
  max-width: 100%;
  max-height: 68vh;
  border-radius: 6px;
}

.lightbox-info-pane {
  display: flex;
  flex-direction: column;
}

.lightbox-bubble-box {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 150px;
  overflow-y: auto;
  padding: 7px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.sub-accordion {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  padding: 6px 10px;
}

.sub-accordion > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.sub-accordion > summary::-webkit-details-marker {
  display: none;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 18px;
  z-index: 80;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  max-width: 380px;
  font-size: 13px;
}

.drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(11, 14, 23, 0.84);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: none;
}

.drag-overlay-box {
  border: 2px dashed var(--accent);
  background: rgba(24, 31, 49, 0.96);
  border-radius: 16px;
  padding: 36px 42px;
  text-align: center;
  max-width: 460px;
}

.drag-overlay-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.drag-overlay-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ---- Mobile Navigation & Responsive Layout (<= 980px) ---- */
.mobile-nav-bar {
  display: none;
}

@media (max-width: 980px) {
  .topbar {
    height: auto;
    min-height: 48px;
    padding: 7px 10px;
    flex-wrap: wrap;
  }

  .brand-pill {
    display: none;
  }

  .key-input-wrap input {
    width: 135px;
  }

  .quota-meters {
    display: none;
  }

  .studio-shell {
    display: block;
    height: auto;
    min-height: calc(100dvh - 106px);
    padding-bottom: 64px;
    overflow: visible;
  }

  .col-left,
  .col-right {
    display: none;
    height: auto;
    border-right: none;
  }

  .col-left.mobile-active,
  .col-right.mobile-active {
    display: flex;
  }

  .deck-viewport {
    overflow: visible;
  }

  .quick-param-bar {
    flex-wrap: wrap;
  }

  .quick-res-select {
    width: 100%;
  }

  .deck-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .generate-dock {
    position: sticky;
    bottom: 56px;
    z-index: 25;
  }

  .hero-canvas-box {
    min-height: 54vh;
    max-height: 64vh;
  }

  .empty-template-grid,
  .grid-2,
  .grid-3,
  .char-stage-wrap,
  .lightbox-body {
    grid-template-columns: 1fr;
  }

  .mobile-nav-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    height: 54px;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
    background: rgba(11, 14, 23, 0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .mobile-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-elev);
  }

  .mobile-nav-btn.active {
    color: #fff;
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(79, 99, 255, 0.25), rgba(16, 185, 129, 0.18));
  }

  .toast {
    bottom: 66px;
  }
}
