/* ============================================================
   Banner Forge — Dark professional design-tool theme
   ============================================================ */

:root {
  /* Surfaces */
  --bg-0: #161616;
  --bg-1: #1c1c1e;
  --bg-2: #232326;
  --bg-3: #2a2a2e;
  --bg-4: #34343a;

  /* Borders & dividers */
  --border-1: #2d2d31;
  --border-2: #3a3a40;
  --border-3: #4a4a52;

  /* Text */
  --text-0: #f3f3f5;
  --text-1: #c9c9cf;
  --text-2: #8b8b94;
  --text-3: #5f5f68;

  /* Accent — cool teal-cyan (oklch hue ~210) */
  --accent: oklch(0.72 0.14 235);
  --accent-soft: oklch(0.72 0.14 235 / 0.16);
  --accent-line: oklch(0.72 0.14 235 / 0.45);

  /* Status */
  --success: oklch(0.74 0.14 155);
  --success-soft: oklch(0.74 0.14 155 / 0.16);
  --warning: oklch(0.78 0.14 75);
  --danger:  oklch(0.68 0.18 25);

  /* Type */
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  /* Sizes */
  --topbar-h: 48px;
  --sidebar-w: 360px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg-0); color: var(--text-0); font-family: var(--font-sans); font-size: 13px; }
body { min-height: 100vh; overflow: hidden; }
button { font-family: inherit; }

/* ----- App shell ----- */
.app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100vh;
}

/* ----- Top bar ----- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-1);
  user-select: none;
}
.topbar .logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar .crumbs { white-space: nowrap; flex-shrink: 1; overflow: hidden; }
.section-head { white-space: nowrap; }
.topbar .logo-mark {
  width: 22px; height: 22px; border-radius: 5px;
  background:
    linear-gradient(135deg, var(--accent) 0%, oklch(0.65 0.16 280) 100%);
  position: relative; box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset;
}
.topbar .logo-mark::after {
  content: ""; position: absolute; inset: 5px; border-radius: 2px;
  background: var(--bg-1);
  box-shadow: 6px 0 0 var(--bg-1), -6px 0 0 var(--bg-1);
  clip-path: inset(35% 0 35% 0);
}
.topbar .crumbs {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-2); font-size: 12px;
}
.topbar .crumbs .sep { opacity: 0.5; }
.topbar .crumbs .current { color: var(--text-1); }
.topbar .spacer { flex: 1; }
.topbar .meta {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-2); font-size: 12px;
}
.topbar .pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--border-2);
  font-size: 11px; color: var(--text-1); font-family: var(--font-mono);
}
.dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-3);
}
.dot.live { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

/* ----- Body grid: sidebar + canvas ----- */
.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
  min-height: 0;
}

/* ----- Sidebar ----- */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border-1);
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-1);
  background: var(--bg-1);
  flex-shrink: 0;
}
.sidebar-tabs .tab {
  flex: 1;
  padding: 10px 8px;
  background: transparent;
  color: var(--text-2);
  border: none;
  border-bottom: 1px solid transparent;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.sidebar-tabs .tab:hover { color: var(--text-1); }
.sidebar-tabs .tab.active {
  color: var(--text-0);
  border-bottom-color: var(--accent);
  background: var(--bg-2);
}
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}
.sidebar-body::-webkit-scrollbar { width: 8px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 4px; }
.sidebar-body::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }

/* ----- Section ----- */
.section { margin-bottom: 18px; }
.section-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-2);
}
.section-head .num {
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--bg-3); color: var(--text-1);
  font-family: var(--font-mono); font-size: 10px;
  display: inline-flex; align-items: center; justify-content: center;
}
.section-head .num.done {
  background: var(--success-soft); color: var(--success);
}
.section-head .num.active {
  background: var(--accent-soft); color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-line);
}

/* ----- Dropzone ----- */
.dropzone {
  border: 1.5px dashed var(--border-3);
  border-radius: var(--radius-lg);
  padding: 22px 14px;
  text-align: center;
  background: var(--bg-2);
  transition: 0.15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone .icon {
  width: 36px; height: 36px; margin: 0 auto 8px;
  border-radius: 8px;
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-1);
}
.dropzone .title { font-weight: 600; margin-bottom: 4px; color: var(--text-0); }
.dropzone .sub { font-size: 11px; color: var(--text-2); }

/* Source preview card */
.source-card {
  display: flex; gap: 10px; padding: 8px;
  background: var(--bg-2); border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  align-items: center;
}
.source-card .thumb {
  width: 56px; height: 56px; border-radius: 5px;
  background: var(--bg-3); flex-shrink: 0;
  background-size: cover; background-position: center;
  border: 1px solid var(--border-2);
}
.source-card .meta { flex: 1; min-width: 0; }
.source-card .name {
  font-weight: 500; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.source-card .sub {
  font-size: 11px; color: var(--text-2); font-family: var(--font-mono);
  margin-top: 2px;
}
.icon-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-2); padding: 6px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text-0); }

/* ----- Form controls ----- */
.field { margin-bottom: 10px; }
.field-label {
  font-size: 11px; color: var(--text-2);
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 6px;
  font-weight: 500;
}
.input, .textarea, .select {
  width: 100%;
  background: var(--bg-2);
  color: var(--text-0);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font-family: inherit; font-size: 12px;
  outline: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.textarea {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  resize: vertical;
  min-height: 90px;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--text-0);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: 0.12s;
}
.btn:hover:not(:disabled) { background: var(--bg-3); border-color: var(--border-3); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a1620;
  font-weight: 600;
}
.btn.primary:hover:not(:disabled) {
  background: oklch(0.78 0.14 235);
  border-color: oklch(0.78 0.14 235);
}
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-1); }
.btn.ghost:hover { background: var(--bg-3); }
.btn.danger {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
}
.btn.danger:hover { background: oklch(0.68 0.18 25 / 0.12); }
.btn.full { width: 100%; }
.btn.sm { padding: 5px 8px; font-size: 11px; }

/* ----- Banner list (sidebar) ----- */
.banner-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  cursor: pointer;
  border: 1px solid transparent;
}
.banner-row:hover { background: var(--bg-2); }
.banner-row.selected { background: var(--bg-2); border-color: var(--accent-line); }
.banner-row .swatch {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 2px;
}
.banner-row .name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.banner-row .ratio {
  font-size: 10px;
  color: var(--text-2);
  font-family: var(--font-mono);
}
.banner-row .status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  font-family: var(--font-mono);
  background: var(--bg-3); color: var(--text-2);
}
.banner-row .status.gen {
  background: var(--accent-soft); color: var(--accent);
}
.banner-row .status.done {
  background: var(--success-soft); color: var(--success);
}
.banner-row .status.err {
  background: oklch(0.68 0.18 25 / 0.15); color: var(--danger);
}

/* ----- Canvas (right side) ----- */
.canvas {
  position: relative;
  background:
    radial-gradient(ellipse at top, #1c1c1e 0%, #131315 80%);
  overflow: hidden;
  min-height: 0;
}
.canvas-toolbar {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: flex; align-items: center; gap: 8px;
  z-index: 5;
  pointer-events: none;
}
.canvas-toolbar > * { pointer-events: auto; }
.tool-group {
  display: flex;
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.tool-group .tool {
  background: transparent;
  border: none;
  padding: 5px 9px;
  font-size: 11px;
  color: var(--text-2);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.tool-group .tool:hover { background: var(--bg-3); color: var(--text-1); }
.tool-group .tool.active { background: var(--bg-3); color: var(--text-0); }

.canvas-body {
  width: 100%; height: 100%;
  overflow: auto;
  position: relative;
}
.canvas-body::-webkit-scrollbar { width: 8px; height: 8px; }
.canvas-body::-webkit-scrollbar-track { background: var(--bg-0); }
.canvas-body::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 4px; }

.canvas-stage {
  min-width: 100%; min-height: 100%;
  display: flex; flex-direction: column;
  align-items: center;
  padding: 60px 40px 40px;
  gap: 32px;
}

/* Source area in canvas */
.canvas-source {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.canvas-source .label {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-2);
  font-family: var(--font-mono);
}
.canvas-source .src-frame {
  width: 200px; height: 200px;
  background: var(--bg-2);
  border-radius: 6px;
  background-size: cover; background-position: center;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4), 0 0 0 1px var(--border-2);
  position: relative;
}
.canvas-source .src-frame.empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 12px;
  background:
    repeating-linear-gradient(45deg,
      var(--bg-2) 0 8px,
      var(--bg-1) 8px 16px);
}

/* Flow arrow */
.flow-arrow {
  display: flex; flex-direction: column; align-items: center;
  color: var(--text-3); font-size: 10px;
  font-family: var(--font-mono); letter-spacing: 0.1em;
  gap: 4px;
}
.flow-arrow .stem {
  width: 1px; height: 18px;
  background: linear-gradient(to bottom, transparent, var(--border-3));
}

/* Banner grid — TRUE ASPECT RATIOS visible */
.banner-grid {
  display: flex;
  align-items: flex-end;
  gap: 22px;
  padding: 8px 4px 28px;
  flex-wrap: wrap;
  justify-content: center;
}

.banner-card {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px;
  position: relative;
}
.banner-frame {
  background: var(--bg-2);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5), 0 0 0 1px var(--border-2);
  transition: 0.2s box-shadow;
}
.banner-frame.selected {
  box-shadow: 0 8px 28px rgba(0,0,0,0.5), 0 0 0 2px var(--accent);
}
.banner-frame img.banner-img {
  width: 100%; height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 0.5s ease-out;
}
.banner-frame img.banner-img.ready { opacity: 1; }

/* Skeleton state */
.skel {
  position: absolute; inset: 0;
  background:
    linear-gradient(110deg,
      var(--bg-2) 8%,
      var(--bg-3) 18%,
      var(--bg-2) 33%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
}
.skel-bar {
  width: 50%; height: 3px;
  background: var(--bg-3); border-radius: 2px; overflow: hidden;
}
.skel-bar > span {
  display: block; height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s ease-out;
}

/* Red-zone overlay (allowed_zone visualization) */
.zones {
  position: absolute; inset: 0; pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.zones.show { opacity: 1; }
.zones .red {
  position: absolute;
  background: oklch(0.68 0.18 25 / 0.18);
  border: 1px dashed oklch(0.68 0.18 25 / 0.5);
}
.zones .allowed {
  position: absolute;
  border: 1.5px dashed var(--accent);
}

/* Banner caption */
.banner-cap {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
  display: flex; flex-direction: column; gap: 2px;
}
.banner-cap .nm { color: var(--text-1); font-weight: 500; }
.banner-cap .sz { color: var(--text-3); }

/* Tools per-card */
.card-tools {
  display: flex; gap: 4px;
  position: absolute; top: -34px; right: 0;
  opacity: 0; transition: opacity 0.15s;
}
.banner-card:hover .card-tools { opacity: 1; }

/* ----- Anchor handle (drag for position) ----- */
.anchor-handle {
  position: absolute;
  width: 18px; height: 18px;
  margin-left: -9px; margin-top: -9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.15), 0 2px 6px rgba(0,0,0,0.4);
  cursor: grab;
  z-index: 4;
  transition: transform 0.1s;
}
.anchor-handle:hover { transform: scale(1.15); }
.anchor-handle:active { cursor: grabbing; }
.anchor-handle::after {
  content: "";
  position: absolute; inset: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
}

/* ----- Empty state ----- */
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  color: var(--text-2);
  padding: 80px 20px;
  max-width: 460px;
  margin: auto;
}
.empty-state .big-icon {
  width: 64px; height: 64px;
  margin-bottom: 16px;
  border-radius: 12px;
  background:
    linear-gradient(135deg, var(--bg-3), var(--bg-2));
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-2);
}
.empty-state h2 {
  font-size: 18px;
  margin: 0 0 6px;
  color: var(--text-0);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.empty-state p {
  font-size: 13px; line-height: 1.55; margin: 0 0 16px;
}
.kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 5px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: 3px;
  color: var(--text-1);
}

/* ----- Toast / progress strip ----- */
.progress-strip {
  position: absolute;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  font-size: 12px;
  z-index: 10;
}
.progress-strip.draggable {
  user-select: none;
  touch-action: none;
}
.progress-strip.draggable:hover .dh { opacity: 0.75; }
.progress-strip.draggable .dh { transition: opacity 0.15s; }
.progress-strip .bar {
  width: 220px; height: 4px;
  background: var(--bg-3);
  border-radius: 2px; overflow: hidden;
}
.progress-strip .bar > span {
  display: block; height: 100%;
  background: var(--accent);
  width: 0%; transition: width 0.3s;
}

/* ----- Spec JSON editor ----- */
.spec-block {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-bottom: 8px;
}
.spec-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--text-1);
  font-weight: 500;
}
.spec-head .ratio-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
}

/* ----- Tag chip ----- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  background: var(--bg-3);
  border-radius: 999px;
  font-size: 10px;
  color: var(--text-1);
  font-family: var(--font-mono);
}

/* ----- Animations ----- */
@keyframes fadein {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fadein { animation: fadein 0.3s ease-out both; }

/* SVG icons inherit currentColor */
svg { display: block; }

/* ----- API status bar (top of canvas) ----- */
.api-status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-1);
  position: sticky;
  top: 0;
  z-index: 6;
}
.api-status-bar.err {
  background: linear-gradient(180deg, oklch(0.68 0.18 25 / 0.14) 0%, var(--bg-1) 100%);
  border-bottom-color: oklch(0.68 0.18 25 / 0.4);
}
.api-status-bar.off {
  background: linear-gradient(180deg, oklch(0.78 0.14 75 / 0.10) 0%, var(--bg-1) 100%);
  border-bottom-color: oklch(0.78 0.14 75 / 0.35);
}
.api-status-left {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.api-status-text {
  display: flex; flex-direction: column;
  font-size: 12px; line-height: 1.4; min-width: 0;
}
.api-status-text strong { font-weight: 600; color: var(--text-0); }
.api-status-text .sub { font-size: 11px; color: var(--text-2); }
.api-status-right { display: flex; gap: 6px; flex-shrink: 0; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-dot.green { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.status-dot.red   {
  background: var(--danger);
  box-shadow: 0 0 0 3px oklch(0.68 0.18 25 / 0.2);
  animation: pulse-red 1.4s ease-in-out infinite;
}
.status-dot.gray  { background: var(--text-3); }
@keyframes pulse-red {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ----- Banner ERROR overlay ----- */
.banner-frame .err-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, oklch(0.68 0.18 25 / 0.18), oklch(0.68 0.18 25 / 0.30));
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 12px;
  border: 1px solid oklch(0.68 0.18 25 / 0.4);
}
.banner-frame .err-overlay .err-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--danger);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700;
  font-family: var(--font-sans); font-size: 16px;
}
.banner-frame .err-overlay .err-title {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.banner-frame .err-overlay .err-msg {
  font-size: 9px;
  line-height: 1.4;
  color: rgba(255,255,255,0.85);
  max-height: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-sans);
}


/* ============================================================
   Mode Entry — landing screen with A/B picker
   ============================================================ */
.mode-entry {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 90% 60% at 30% 0%, oklch(0.32 0.05 235 / 0.35), transparent 60%),
    radial-gradient(ellipse 70% 50% at 80% 100%, oklch(0.32 0.08 285 / 0.25), transparent 55%),
    var(--bg-0);
  color: var(--text-0);
  display: flex; align-items: center; justify-content: center;
  overflow: auto;
  padding: 40px 24px;
}
.mode-entry-inner {
  width: 100%; max-width: 1040px;
  display: flex; flex-direction: column; gap: 32px;
}
.mode-entry-hero {
  text-align: center;
}
.mode-entry-mark {
  width: 56px; height: 56px; border-radius: 14px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--accent) 0%, oklch(0.65 0.16 285) 100%);
  box-shadow:
    0 8px 32px oklch(0.6 0.16 245 / 0.35),
    0 0 0 1px rgba(255,255,255,0.1) inset;
  position: relative;
}
.mode-entry-mark::after {
  content: ""; position: absolute; inset: 14px;
  border-radius: 4px;
  background: var(--bg-0);
  box-shadow: 12px 0 0 var(--bg-0), -12px 0 0 var(--bg-0);
  clip-path: inset(35% 0 35% 0);
  opacity: 0.5;
}
.mode-entry-hero h1 {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  background: linear-gradient(180deg, #fff 0%, #c9c9cf 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.mode-entry-hero p {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
}

.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 880px) {
  .mode-cards { grid-template-columns: 1fr; }
}
.mode-card {
  text-align: left;
  background: linear-gradient(180deg,
    oklch(0.22 0.005 250) 0%,
    oklch(0.18 0.005 250) 100%);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  padding: 24px;
  cursor: pointer;
  color: var(--text-0);
  font: inherit;
  display: flex; flex-direction: column;
  gap: 14px;
  transition: 0.18s;
  position: relative;
  overflow: hidden;
}
.mode-card::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 50% at 50% 0%, var(--accent-soft), transparent 60%);
  opacity: 0; transition: 0.18s;
  pointer-events: none;
}
.mode-card:hover {
  border-color: var(--accent-line);
  transform: translateY(-2px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.45), 0 0 0 1px var(--accent-line);
}
.mode-card:hover::before { opacity: 1; }

.mode-card-head {
  display: flex; align-items: center; justify-content: space-between;
}
.mode-card-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.mode-card-tag.tag-a {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-line);
}
.mode-card-tag.tag-b {
  background: oklch(0.65 0.16 285 / 0.18);
  color: oklch(0.78 0.13 285);
  box-shadow: 0 0 0 1px oklch(0.65 0.16 285 / 0.4);
}
.mode-card-status {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mode-card-status.beta {
  color: oklch(0.78 0.13 285);
}

/* Visual block — schematic showing input → 4 outputs */
.mode-card-visual {
  height: 90px;
  border-radius: 8px;
  background: var(--bg-0);
  border: 1px solid var(--border-1);
  padding: 10px 14px;
  display: flex; align-items: center; gap: 12px;
}
.mode-card-visual .va-source {
  width: 60px; height: 60px;
  border-radius: 4px;
  background: linear-gradient(135deg, oklch(0.45 0.05 90) 0%, oklch(0.32 0.04 90) 100%);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.mode-card-visual .va-arrow,
.mode-card-visual .vb-arrow {
  color: var(--text-3);
  font-size: 14px;
  flex-shrink: 0;
}
.mode-card-visual .va-grid,
.mode-card-visual .vb-grid {
  display: flex; gap: 6px; flex: 1; align-items: center;
}
.mode-card-visual .va-grid > div,
.mode-card-visual .vb-grid > div {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 3px;
  height: 70px;
  flex-shrink: 0;
}
.mode-card-visual .va-grid > div:nth-child(1) { height: 70px; }
.mode-card-visual .va-grid > div:nth-child(2) { height: 50px; align-self: center; }
.mode-card-visual .va-grid > div:nth-child(3) { height: 65px; }
.mode-card-visual .va-grid > div:nth-child(4) { height: 75px; }

.mode-card-visual .vb-products {
  display: flex; gap: 4px; flex-shrink: 0;
}
.mode-card-visual .vb-products > div {
  width: 36px; height: 60px;
  border-radius: 3px;
  background: linear-gradient(135deg, oklch(0.55 0.08 285) 0%, oklch(0.32 0.06 285) 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.mode-card-visual .vb-products > .more {
  background: var(--bg-3);
  color: var(--text-2);
  font-family: var(--font-mono); font-size: 10px;
  display: flex; align-items: center; justify-content: center;
}
.mode-card-visual .vb-grid > div {
  background: oklch(0.65 0.16 285 / 0.18);
  border: 1px solid oklch(0.65 0.16 285 / 0.45);
  height: 60px;
}
.mode-card-visual .vb-grid > div:nth-child(2) { height: 45px; align-self: center; }
.mode-card-visual .vb-grid > div:nth-child(3) { height: 55px; }
.mode-card-visual .vb-grid > div:nth-child(4) { height: 65px; }

.mode-card-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-0);
}
.mode-card-desc {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-1);
}
.mode-card-bullets {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column;
  gap: 4px;
}
.mode-card-bullets li {
  font-size: 12px;
  color: var(--text-2);
  padding-left: 16px;
  position: relative;
  line-height: 1.5;
}
.mode-card-bullets li::before {
  content: "";
  position: absolute; left: 2px; top: 8px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.mode-card .mode-card-cta {
  margin-top: auto;
  padding-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.005em;
}
.mode-entry-foot {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
}



/* ============================================================
   Mode B — pre-compose stage (product grid + compose CTA)
   ============================================================ */
.modeb-compose-stage {
  display: flex; flex-direction: column;
  gap: 24px;
  padding: 8px 0 40px;
  max-width: 920px;
  margin: 0 auto;
  width: 100%;
}
.modeb-compose-head {
  display: flex; flex-direction: column; gap: 4px;
}
.modeb-compose-head .label {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-2); font-family: var(--font-mono);
}
.modeb-compose-head .title {
  font-size: 22px; font-weight: 600; letter-spacing: -0.015em;
}
.modeb-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.modeb-product-card {
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: 8px;
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.modeb-product-card .thumb {
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  background-color: var(--bg-2);
  background-size: cover; background-position: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 0 1px var(--border-2);
}
.modeb-product-card .meta {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.modeb-product-card .name {
  font-size: 12px; color: var(--text-0);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.modeb-product-card .sub {
  font-size: 10px; font-family: var(--font-mono);
  color: var(--text-3);
}
.modeb-compose-cta {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  background: linear-gradient(180deg,
    oklch(0.28 0.04 245 / 0.4) 0%,
    oklch(0.22 0.04 245 / 0.4) 100%);
  border: 1px solid var(--accent-line);
  border-radius: 10px;
  color: var(--text-0);
}
.modeb-compose-cta strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}
.modeb-compose-cta .sub {
  font-size: 12px; color: var(--text-2);
}
.modeb-compose-cta > svg { flex-shrink: 0; color: var(--accent); }
.modeb-compose-cta > div { flex: 1; min-width: 0; }
.modeb-compose-cta > button { flex-shrink: 0; }
.modeb-compose-error {
  padding: 10px 14px;
  background: var(--danger-soft, oklch(0.25 0.04 25 / 0.4));
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  font-size: 12px;
}

/* Disabled tab style */
.sidebar-tabs .tab:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}


/* ============================================================
   Mode B — approval stage (compose preview + approval gate)
   ============================================================ */
.modeb-approval-stage {
  display: flex; flex-direction: column;
  gap: 22px;
  max-width: 1080px;
  margin: 0 auto;
  width: 100%;
  padding: 4px 0 40px;
}
.modeb-approval-head {
  display: flex; flex-direction: column; gap: 6px;
}
.modeb-approval-head .label {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); font-family: var(--font-mono);
}
.modeb-approval-head .title {
  font-size: 24px; font-weight: 600;
  letter-spacing: -0.015em;
}
.modeb-approval-head .subtitle {
  font-size: 13px; color: var(--text-2);
  line-height: 1.6;
  max-width: 720px;
}

.modeb-approval-body {
  display: grid;
  grid-template-columns: 200px 32px 1fr;
  gap: 18px;
  align-items: center;
  padding: 24px;
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: 12px;
}
@media (max-width: 720px) {
  .modeb-approval-body {
    grid-template-columns: 1fr;
  }
}
.modeb-approval-sources {
  display: flex; flex-direction: column; gap: 10px;
}
.modeb-approval-sources-label {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-3); font-family: var(--font-mono);
}
.modeb-approval-sources-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.modeb-approval-source-thumb {
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  background-color: var(--bg-2);
  background-size: cover; background-position: center;
  box-shadow: 0 0 0 1px var(--border-2);
}
.modeb-approval-source-thumb.more {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-3); color: var(--text-2);
  font-family: var(--font-mono); font-size: 13px;
  font-weight: 600;
}
.modeb-approval-arrow {
  color: var(--accent);
  font-size: 24px;
  font-family: var(--font-mono);
  text-align: center;
}
@media (max-width: 720px) {
  .modeb-approval-arrow {
    transform: rotate(90deg);
    width: 100%;
  }
}
.modeb-approval-preview {
  display: flex; flex-direction: column; gap: 8px;
  align-items: center;
}
.modeb-approval-preview-img {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background-color: var(--bg-2);
  background-size: cover; background-position: center;
  box-shadow:
    0 16px 48px rgba(0,0,0,0.5),
    0 0 0 1px var(--accent-line),
    0 0 0 4px var(--accent-soft);
}
.modeb-approval-preview-meta {
  font-size: 11px;
  color: var(--text-2);
  font-family: var(--font-mono);
}

.modeb-approval-prompt {
  padding: 14px 18px;
  background: var(--bg-1);
  border: 1px solid var(--border-1);
  border-radius: 10px;
}
.modeb-approval-prompt.open {
  background: var(--bg-2);
}

.modeb-approval-actions {
  display: flex; justify-content: center;
  padding: 4px;
}
.btn.lg {
  padding: 14px 22px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  gap: 10px;
  min-height: 48px;
}
.btn.lg .cost-chip {
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0,0,0,0.18);
  color: rgba(10,22,32,0.7);
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.02em;
}


/* LOCAL TEST badge on approval head */
.modeb-approval-head .local-badge {
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 4px;
  background: oklch(0.68 0.16 60 / 0.22);
  color: oklch(0.78 0.13 60);
  font-size: 9px;
  letter-spacing: 0.08em;
  font-weight: 600;
  box-shadow: 0 0 0 1px oklch(0.68 0.16 60 / 0.5);
  vertical-align: middle;
}


/* ============================================================
   Bbox overlay (hybrid pipeline debug)
   ============================================================ */
.bbox-overlay {
  position: absolute;
  border: 1.5px dashed oklch(0.78 0.16 145);
  background: oklch(0.78 0.16 145 / 0.08);
  pointer-events: none;
  z-index: 5;
  border-radius: 2px;
}
.bbox-overlay.clipped {
  border-color: var(--danger);
  background: oklch(0.7 0.2 25 / 0.12);
}
.bbox-overlay .bbox-label {
  position: absolute;
  top: -16px; left: -2px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 3px;
  background: oklch(0.78 0.16 145);
  color: #0a1f12;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.bbox-overlay.clipped .bbox-label {
  background: var(--danger);
  color: #fff;
}


/* Mode B — priority badge on product cards in compose stage */
.modeb-product-card { transition: 0.15s; position: relative; }
.modeb-product-card:hover { border-color: var(--border-3); }
.modeb-product-card.priority {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 24px oklch(0.72 0.14 235 / 0.18);
}
.modeb-product-card.priority .thumb {
  box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 0 1px var(--accent);
}
.modeb-product-card .priority-badge {
  position: absolute;
  top: 6px; right: 6px;
  background: var(--accent);
  color: #0a1620;
  font-size: 9px;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  z-index: 1;
}
