/* ============================================
   NANO — JW design (jeudi.wang inspired)
   Sharp edges · monochrome · Courier Prime
   Dev preview at /preview.html (identical).
   ============================================ */

:root {
  /* Palette — monochrome, jeudi.wang */
  --bg:           #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-sunken:   #F5F5F3;
  --ink:         #0A0A0A;
  --ink-2:       #222222;
  --ink-3:       #6A6A66;
  --muted:       #B5B3AC;
  --line:        #E7E5E0;
  --line-strong: #0A0A0A;
  --accent:      #0A0A0A;          /* pure black, no warm orange */
  --accent-hover:#2A2A2A;
  --accent-soft: #F0EFEA;
  --accent-blue: #0A0A0A;
  --accent-green:#0A0A0A;
  --danger:      #9A2A1F;
  --success:     #0A0A0A;

  /* Typography — Courier Prime ONLY (matches jeudi.wang exactly).
     Same face for body, labels, buttons, stages — no sans-serif. */
  --font-heading: 'Courier Prime', 'Courier New', Courier, monospace;
  --font-sans:    'Courier Prime', 'Courier New', Courier, monospace;
  --font-mono:    'Courier Prime', 'Courier New', Courier, monospace;

  /* No radius, no shadow, ever. */
  --radius-sm: 0;
  --radius:    0;
  --radius-lg: 0;
  --shadow-sm: none;
  --shadow:    none;
  --shadow-lg: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "kern" 1;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
  border-radius: 0;
}

/* ============================================
   TOP BAR — ASCII signature + caps nav
   ============================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--ink);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
/* No pseudo-logo — just clean text marks, Courier Prime handles the graphic feel */
.logo { display: none; }

.sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  align-self: center;
}
.sidebar-toggle:hover { color: var(--ink-3); }

/* Collapsed state — library column goes to 0, content hidden */
body.library-collapsed .layout {
  grid-template-columns: 0 150px 1fr;
}
body.library-collapsed .library {
  border-right: none;
  overflow: hidden;
  visibility: hidden;
}
.title {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.title::before { content: "· "; color: var(--ink-3); font-weight: 400; }
.tagline {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  font-family: var(--font-heading);
}
.tagline::before { content: "— "; }
.status {
  color: var(--ink-3);
  font-size: 11px;
  font-family: var(--font-heading);
  letter-spacing: 0.02em;
}

/* ============================================
   LAYOUT
   ============================================ */
.layout {
  display: grid;
  grid-template-columns: 340px 150px 1fr;
  height: calc(100vh - 57px);
}

/* ============================================
   LIBRARY (LEFT)
   ============================================ */
.library {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--ink);
  background: var(--bg);
  overflow: hidden;
}

.tabs {
  display: flex;
  padding: 0;
  gap: 0;
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1;
  padding: 12px 8px;
  border: none;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: color 0.12s, background 0.12s;
}
.tab:last-child { border-right: none; }
.tab:hover { color: var(--ink); background: var(--bg-sunken); }
.tab.active {
  background: var(--ink);
  color: var(--bg);
}

.lib-controls {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
#search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 12px;
  outline: none;
  font-family: var(--font-sans);
  transition: border-color 0.12s;
}
#search::placeholder { color: var(--muted); font-style: normal; }
#search:focus { border-color: var(--ink); }

.filters summary {
  cursor: pointer;
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 0;
  user-select: none;
  list-style: none;
}
.filters summary::-webkit-details-marker { display: none; }
.filters summary::before { content: "▸ "; display: inline-block; transition: transform 0.12s; }
.filters[open] summary::before { content: "▾ "; }
.filters[open] summary { color: var(--ink); }
.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding-top: 8px;
}
.filter-grid select {
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 11px;
  font-family: var(--font-mono);
}

/* ---- Smart suggestions strip ---- */
.suggestions {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.suggestions-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.suggestions-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
}
.suggestions-title::before { content: "// "; color: var(--ink-3); }
.suggestions-jw {
  color: var(--ink-3);
  font-size: 10px;
  font-family: var(--font-mono);
}
.suggestions-autofill {
  margin-left: auto;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 4px 9px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.suggestions-autofill:hover:not(:disabled) {
  background: var(--bg);
  color: var(--ink);
}
.suggestions-autofill:disabled {
  background: var(--muted);
  color: var(--bg);
  border-color: var(--muted);
  cursor: not-allowed;
}
.suggestions-close {
  background: transparent;
  border: none;
  color: var(--ink-3);
  font-size: 15px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  font-family: var(--font-mono);
}
.suggestions-close:hover { color: var(--ink); }

.suggestions-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.suggestions-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.suggestions-group-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.suggestions-group-label::before { content: "· "; }
.suggestions-group-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.suggestions-group-strip .thumb {
  min-width: 92px;
  width: 92px;
  aspect-ratio: 4 / 3;
  flex-shrink: 0;
  min-height: unset;
}
.suggestions-group-empty {
  color: var(--ink-3);
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 4px 0;
}
.thumb-sim {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--ink);
  color: var(--bg);
  font-size: 9px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  pointer-events: none;
}
.suggestions-loading {
  color: var(--ink-3);
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 12px 4px;
}

.gallery {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  align-content: start;
}
.loading, .empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--ink-3);
  padding: 40px 20px;
  font-size: 12px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 110px;
  overflow: hidden;
  cursor: grab;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  transition: border-color 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb:hover {
  border-color: var(--ink);
}
.thumb:active { cursor: grabbing; }
.thumb img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.thumb .thumb-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 6px;
  font-size: 10px;
  color: var(--bg);
  background: var(--ink);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  font-family: var(--font-heading);
  letter-spacing: 0.02em;
}
.thumb:hover .thumb-title { opacity: 1; }

/* ============================================
   RESULTS COLUMN (MIDDLE)
   ============================================ */
.results-column {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--ink);
  background: var(--bg);
  overflow: hidden;
}
.results-col-header {
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.results-col-header::before { content: "// "; color: var(--ink-3); }
.results-col-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.results-col-empty {
  color: var(--ink-3);
  font-size: 11px;
  font-family: var(--font-mono);
  text-align: center;
  padding: 20px 10px;
  letter-spacing: 0.03em;
}
.result-thumb {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.result-thumb:hover { border-color: var(--ink); }
.result-thumb.active {
  border-color: var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: -2px;
}
.result-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.result-thumb.loading { color: var(--ink-3); font-size: 11px; font-family: var(--font-mono); }
.result-thumb.loading::before {
  content: '...';
  display: inline-block;
  animation: blink 1s steps(4) infinite;
  font-size: 16px;
}
@keyframes blink { 0%,50%,100%{opacity:1} 25%,75%{opacity:0.3} }
.result-thumb.error {
  border-color: var(--danger);
  color: var(--danger);
  font-size: 10px;
  font-family: var(--font-mono);
  text-align: center;
  padding: 4px;
}
.result-thumb-idx {
  position: absolute;
  top: 0;
  left: 0;
  background: var(--ink);
  color: var(--bg);
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  z-index: 2;
}
.result-thumb-scores {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 1px;
  z-index: 2;
  pointer-events: none;
}
.score-pill {
  flex: 1;
  background: var(--ink);
  color: var(--bg);
  padding: 1px 4px;
  font-size: 9px;
  font-family: var(--font-mono);
  text-align: center;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.score-pill.good { background: #0A0A0A; }
.score-pill.mid  { background: #444444; }
.score-pill.bad  { background: var(--danger); }
.score-pill.loading { background: #888888; }

/* ============================================
   THUMB PREVIEW (floating on hover)
   ============================================ */
.thumb-preview {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  background: var(--bg);
  border: 1px solid var(--ink);
  overflow: hidden;
  max-width: 520px;
  max-height: 520px;
  opacity: 0;
  animation: previewFadeIn 0.10s ease-out forwards;
}
@keyframes previewFadeIn { to { opacity: 1; } }
.thumb-preview img {
  display: block;
  max-width: 520px;
  max-height: 520px;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* ============================================
   WORKSPACE (RIGHT)
   ============================================ */
.workspace {
  overflow-y: auto;
  padding: 28px 36px;
  width: 100%;
}

.dropzones {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.dz-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.dz {
  background: var(--bg);
  border: 1px dashed var(--ink);
  padding: 14px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.12s, background 0.12s;
  position: relative;
}
.dz.dz-main { min-height: 420px; }
.dz.dragover {
  border-style: solid;
  border-width: 2px;
  background: var(--accent-soft);
}
.dz.filled {
  border-style: solid;
  border-color: var(--ink);
  padding: 0;
  overflow: hidden;
}
.dz-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
  pointer-events: none;
}
.dz.filled .dz-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: 6px 10px;
  background: var(--ink);
  color: var(--bg);
  margin: 0;
  z-index: 1;
}
.dz-label {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  color: var(--ink);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}
.dz.filled .dz-label { color: white; }
.dz-sub {
  font-size: 10px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.dz.filled .dz-sub { color: rgba(255,255,255,0.75); }
.required { color: var(--ink); font-weight: 700; }

.dz-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
}
.dz-content:empty::before {
  content: "drop here ·";
  letter-spacing: 0.04em;
}
.dz.filled .dz-content {
  min-height: unset;
  position: relative;
  width: 100%;
}
.dz.filled .dz-content:empty::before { content: none; }
.dz-content img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.dz.dz-main { overflow: hidden; }
.dz.dz-main.filled .dz-content {
  min-height: 420px;
  max-height: 75vh;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sunken);
  width: 100%;
}
.dz.dz-main.filled .dz-content img {
  max-width: 100%;
  max-height: 75vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  background: var(--bg-sunken);
}
.dz-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
}
.dz-remove:hover { background: var(--bg); color: var(--ink); outline: 1px solid var(--ink); outline-offset: -1px; }

.dz-multi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 3px;
  padding: 8px;
  padding-top: 36px;
  width: 100%;
}
.dz-multi-grid > div {
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
}
.dz-multi-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ============================================
   COMPARE OVERLAY
   ============================================ */
.compare-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 3;
  --split: 50%;
  background: var(--bg-sunken);
}
.compare-overlay img.compare-before,
.compare-overlay img.compare-after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg-sunken);
  display: block;
}
.compare-overlay img.compare-before { z-index: 1; }
.compare-overlay img.compare-after {
  z-index: 2;
  clip-path: inset(0 0 0 var(--split));
}
.compare-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split);
  width: 2px;
  background: var(--ink);
  cursor: ew-resize;
  user-select: none;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(-1px); /* center the 2px line on --split */
}
/* Invisible wider hit zone so the slider is easy to grab (±12px on each side) */
.compare-divider::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -12px;
  right: -12px;
  cursor: ew-resize;
}
.compare-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 12px;
  font-family: var(--font-mono);
  pointer-events: none;
  letter-spacing: 0.08em;
  min-width: 38px;
  text-align: center;
}
.compare-labels {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 5;
}
.compare-label {
  background: var(--ink);
  color: var(--bg);
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.compare-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
}
.compare-close:hover { background: var(--bg); color: var(--ink); outline: 1px solid var(--ink); outline-offset: -1px; }

/* Download PNG — same top bar area as close, to its left */
.compare-download {
  position: absolute;
  top: 10px;
  right: 44px;
  height: 26px;
  padding: 0 10px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  letter-spacing: 0.08em;
}
.compare-download:hover { background: var(--bg); color: var(--ink); outline: 1px solid var(--ink); outline-offset: -1px; }

.refine-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--ink);
  pointer-events: auto;
  border: 1px solid var(--ink);
}
.refine-bar-label {
  color: rgba(255,255,255,0.6);
  font-size: 10px;
  font-weight: 500;
  padding: 0 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.refine-btn {
  padding: 7px 12px;
  background: var(--ink);
  border: none;
  border-left: 1px solid rgba(255,255,255,0.15);
  color: white;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.12s;
}
.refine-btn:hover { background: #2A2A2A; }
.refine-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.refine-btn.loading::after {
  content: ' ...';
  display: inline-block;
  animation: blink 1s steps(4) infinite;
}

/* ============================================
   FIELDS / OPTIONS
   ============================================ */
.fields, .options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-wide { grid-column: 1 / -1; }
.field label {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink);
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.field label::before { content: "· "; color: var(--ink-3); }
.field input, .field textarea, .field select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 13px;
  outline: none;
  transition: border-color 0.12s;
  font-family: var(--font-sans);
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted); }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--ink);
}
.field textarea { resize: vertical; min-height: 60px; }

/* ============================================
   CONSTRAINTS
   ============================================ */
.constraints {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 22px;
}
.lock-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.45;
}
.lock-info-arch { border-color: var(--ink); }
.lock-info-flex { background: var(--bg-sunken); }
.lock-icon {
  font-family: var(--font-mono);
  font-size: 12px;
  flex-shrink: 0;
  margin-top: 0;
  letter-spacing: -0.05em;
  filter: none;
}
.lock-title {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.lock-sub {
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1.5;
}
.check {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color 0.12s;
  user-select: none;
}
.check:has(input:checked) {
  border-color: var(--ink);
  background: var(--accent-soft);
}
.check input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--ink);
  cursor: pointer;
}
.check-label {
  font-weight: 600;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.check-hint {
  color: var(--ink-3);
  font-size: 11px;
  flex: 1 0 100%;
  margin-left: 22px;
}

/* ============================================
   VARIATIONS SELECTOR
   ============================================ */
.variations {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.var-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--ink);
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.var-label::before { content: "· "; color: var(--ink-3); }
.var-buttons {
  display: inline-flex;
  border: 1px solid var(--ink);
  background: var(--bg);
}
.var-btn {
  padding: 7px 14px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  font-family: var(--font-mono);
  transition: background 0.12s, color 0.12s;
}
.var-btn:last-child { border-right: none; }
.var-btn:hover { background: var(--bg-sunken); }
.var-btn.active { background: var(--ink); color: var(--bg); }
.var-hint {
  color: var(--ink-3);
  font-size: 11px;
  flex: 1 0 100%;
  padding-left: 4px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* ============================================
   GENERATE BUTTON
   ============================================ */
.generate {
  width: 100%;
  padding: 18px;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 24px;
  font-family: var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.generate:hover:not(:disabled) { background: var(--bg); color: var(--ink); }
.generate:disabled {
  background: var(--muted);
  color: var(--bg);
  border-color: var(--muted);
  cursor: not-allowed;
}
.generate .label {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.20em;
}
.generate .label::before { content: "▶ "; }
.generate .cost-hint {
  font-size: 10px;
  opacity: 0.7;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: none;
  font-family: var(--font-mono);
}

/* ============================================
   RESULT
   ============================================ */
.result {
  border-top: 1px solid var(--ink);
  padding-top: 24px;
}
.result-stages {
  display: flex;
  gap: 18px;
  margin-bottom: 18px;
  font-family: var(--font-mono);
}
.stage {
  font-size: 11px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.stage-timing {
  color: var(--ink-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0.02em;
}
.stage.active { color: var(--ink); font-weight: 600; }
.stage.done { color: var(--ink); }
.stage-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: transparent;
  border: 1px solid var(--ink-3);
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.stage.active .stage-icon { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.stage.done .stage-icon { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.prompt-preview {
  margin-bottom: 18px;
  padding: 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  font-size: 12px;
}
.prompt-preview summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  list-style: none;
}
.prompt-preview summary::-webkit-details-marker { display: none; }
.prompt-preview summary::before { content: "▸ "; }
.prompt-preview[open] summary::before { content: "▾ "; }
.prompt-preview pre {
  margin: 10px 0 0 0;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  color: var(--ink);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.result-card {
  position: relative;
  overflow: hidden;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.result-card .result-img-wrap {
  aspect-ratio: 3 / 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-sunken);
  position: relative;
  overflow: hidden;
}
.result-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.result-card .result-placeholder {
  color: var(--ink-3);
  font-size: 12px;
  font-family: var(--font-mono);
  text-align: center;
  padding: 20px;
  letter-spacing: 0.04em;
}
.result-card.loading .result-placeholder::before {
  content: '... ';
  display: inline-block;
  animation: blink 1s steps(4) infinite;
  margin-right: 2px;
}
.result-card.error { border-color: var(--danger); }
.result-card.error .result-placeholder { color: var(--danger); }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

.result-card .result-actions {
  display: flex;
  gap: 0;
  padding: 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
}
.result-card .result-actions button {
  flex: 1;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  color: var(--ink);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  transition: background 0.12s;
}
.result-card .result-actions button:last-child { border-right: none; }
.result-card .result-actions button:hover { background: var(--ink); color: var(--bg); }

/* Download button overlayed on result-thumb and history-thumb.
   Hidden by default, revealed on parent hover. */
.thumb-download {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--ink);
  color: var(--bg);
  border: none;
  font-family: var(--font-heading);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 3px 5px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 3;
}
.result-thumb:hover .thumb-download,
.history-thumb:hover .thumb-download {
  opacity: 1;
}
.thumb-download:hover {
  background: var(--bg);
  color: var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: -1px;
}

/* ============================================
   HISTORY PANEL (side overlay)
   ============================================ */
#history-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
}
#history-overlay[hidden] { display: none; }
.history-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.5);
}
.history-panel {
  position: relative;
  margin-left: auto;
  width: 520px;
  max-width: 92vw;
  height: 100%;
  background: var(--bg);
  border-left: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
}
.history-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--ink);
  display: flex;
  align-items: center;
}
.history-title {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}
.history-close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  font-family: var(--font-heading);
  line-height: 1;
  padding: 0 4px;
}
.history-close:hover { color: var(--ink-3); }
.history-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  font-family: var(--font-heading);
}
.history-empty {
  color: var(--ink-3);
  font-size: 11px;
  text-align: center;
  padding: 60px 20px;
  line-height: 1.6;
}
.history-batch {
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.history-batch:last-child { border-bottom: none; }
.history-batch-header {
  font-size: 10px;
  color: var(--ink-3);
  margin-bottom: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.history-batch-time { color: var(--ink); font-weight: 700; letter-spacing: 0.08em; }
.history-batch-meta { color: var(--ink-3); }
.history-batch-instr {
  display: block;
  margin-top: 5px;
  padding: 6px 8px;
  background: var(--bg-sunken);
  color: var(--ink-2);
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  border-left: 2px solid var(--ink);
}
.history-batch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
}
.history-thumb {
  position: relative;
  aspect-ratio: 3 / 2;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s;
}
.history-thumb:hover { border-color: var(--ink); }
.history-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.history-thumb-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--ink);
  color: var(--bg);
  font-size: 9px;
  padding: 2px 6px;
  font-family: var(--font-heading);
  letter-spacing: 0.06em;
}

/* ============================================
   ASCII footer signature (optional decorative)
   ============================================ */
.workspace::after {
  content: "";
  display: block;
  height: 1px;
}
