/* ============================================================
   STUDIO — minimalist black & white AI photo/video interface
   Fonts: Lumiare (headings) · Built Titling (UI text)
   ============================================================ */

/* ---------- Fonts ---------- */
@font-face {
  font-family: 'Lumiare';
  src: url('fonts/lumiare-heading.otf') format('opentype');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Built Titling';
  src: url('fonts/built-titling-regular.otf') format('opentype');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Built Titling';
  src: url('fonts/built-titling-semibold.otf') format('opentype');
  font-weight: 600; font-display: swap;
}
@font-face {
  font-family: 'Built Titling';
  src: url('fonts/built-titling-bold.otf') format('opentype');
  font-weight: 700; font-display: swap;
}
/* Gondens Demo — bold, wide, very readable. NOTE: the free demo has LETTERS ONLY
   (no digits, no $ / punctuation), so it's paired below with a clean sans that
   supplies the numbers and symbols. */
@font-face {
  font-family: 'Gondens Demo';
  src: url('fonts/gondens-demo.otf') format('opentype');
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --ink: #fff;                       /* foreground: text, borders, active fills */
  --paper: #000;                     /* page background — black */
  --line: #fff;
  --hair: rgba(255, 255, 255, 0.18); /* structural separators */
  --hover: rgba(255, 255, 255, 0.10);
  --mute: rgba(255, 255, 255, 0.64); /* secondary text — kept bright for legibility */
  --head: 'Lumiare', 'Times New Roman', serif;
  /* Workhorse UI text: clean, complete, readable sans (letters + numbers + symbols). */
  --text: 'Helvetica Neue', Arial, system-ui, sans-serif;
  /* Labels/buttons: a wide, clean uppercase treatment (the condensed face read
     too narrow). Same family as body, set apart by weight + tracking + size. */
  --accent: 'Helvetica Neue', Arial, system-ui, sans-serif;
  --gut: 22px;
  --maxw: 1180px;
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: 17px;
  line-height: 1.6;
  letter-spacing: 0.045em;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
::selection { background: #fff; color: #000; }

/* ---------- Type ---------- */
.display {
  font-family: var(--head);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.02;
  font-size: clamp(34px, 5vw, 58px);
}
.display--sm { font-size: clamp(22px, 3vw, 30px); }
.lede {
  max-width: 58ch;
  color: var(--mute);
  text-transform: uppercase;
  font-size: 15px;
  letter-spacing: 0.08em;
  line-height: 1.95;
}

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  max-width: var(--maxw);            /* same width box as <main>, so logo aligns with the
                                        title and balance aligns with the output column */
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 var(--gut);
}
.brand { display: flex; align-items: center; min-width: 0; }

.tabs { display: flex; gap: 4px; justify-self: center; }
.tab {
  font-family: var(--accent);        /* plain uppercase text */
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 15px;
  font-weight: 700;
  padding: 9px 18px;
  border: 1px solid transparent;
  color: var(--mute);
  transition: color .15s, background .15s, border-color .15s;
}
.tab:hover { color: var(--ink); background: var(--hover); }
.tab[aria-current="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }

.balance {
  justify-self: end;
  font-family: var(--accent);        /* plain uppercase text */
  display: inline-flex; align-items: baseline; gap: 5px;
  border: 1px solid var(--line);
  padding: 9px 16px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: background .15s, color .15s;
}
.balance:hover { background: var(--ink); color: var(--paper); }
.balance__sign { font-size: 14px; opacity: .8; }
.balance__amount { font-variant-numeric: tabular-nums; }
.balance--guest .balance__amount { letter-spacing: 0.16em; }
/* Unclickable wordmark logo (top-left) */
.wordmark {
  font-family: var(--head);
  font-size: 21px;
  letter-spacing: 0.005em;
  color: var(--ink);
  white-space: nowrap;
  user-select: none;
  cursor: default;
}

/* ============================================================
   PANELS
   ============================================================ */
main { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gut); }
.panel { display: none; padding: 48px 0 24px; }
.panel.is-active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.panel__head { margin-bottom: 40px; }
.panel__head .lede { margin-top: 16px; }

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 48px;
  align-items: start;
  margin-left: 0;
  margin-right: 0;   /* batch-expand margins are animated in JS via the Web Animations API */
}
/* Batch view (2–4 tiles): keep the settings column at its normal width and grow the
   OUTPUT column. The studio is widened past the page max-width with negative left/right
   margins (auto width expands into them) so settings are never squeezed — they just
   shift. The margins are set in px by JS (setStudioWide) so the .studio `transition:
   margin` animates the expansion/collapse smoothly. Desktop only. */
@media (min-width: 901px) {
  .studio--wide { grid-template-columns: minmax(440px, 708px) minmax(0, 1fr); }
}

/* ---------- Fields ---------- */
.controls { display: flex; flex-direction: column; gap: 30px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 12px; }
.field__label {
  font-family: var(--accent);
  text-transform: uppercase;
  font-size: 16px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--ink);
}
.field__hint { float: right; color: var(--mute); font-weight: 500; letter-spacing: 0.1em; font-size: 14px; }
.row { flex-direction: row; gap: 24px; align-items: flex-start; }
.row__col { flex: 1; min-width: 0; max-width: 100%; display: flex; flex-direction: column; gap: 12px; }

.textarea, .input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  padding: 14px 15px;
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0.04em;
  resize: vertical;
  outline: none;
}
/* Placeholders match the uppercase UI rhythm so they don't read as another font */
.textarea::placeholder, .input::placeholder {
  color: var(--mute); text-transform: uppercase; letter-spacing: 0.08em; font-size: 13px;
}
.textarea:focus, .input:focus { box-shadow: inset 0 0 0 1px var(--ink); }

.linkbtn {
  align-self: flex-start;
  text-transform: uppercase;
  font-size: 12.5px;
  letter-spacing: 0.12em;
  color: var(--mute);
  border-bottom: 1px solid transparent;
}
.linkbtn:hover { color: var(--ink); border-color: var(--ink); }
.linkbtn--logout { align-self: center; margin-top: 4px; }

/* Prompt box + expand-to-fullscreen button */
.promptbox { position: relative; }
.promptbox .textarea { padding-right: 46px; }
.expandbtn {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--hair); background: var(--paper); color: var(--mute);
  font-size: 17px; line-height: 1; transition: color .15s, border-color .15s, background .15s;
}
.expandbtn:hover { color: var(--ink); border-color: var(--line); background: var(--hover); }

/* ---------- Model grid (image) ---------- */
.modelgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.model {
  text-align: left;
  border: 1px solid var(--line);
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  transition: background .15s, color .15s;
}
.model:hover { background: var(--hover); }
.model.is-on { background: var(--ink); color: var(--paper); }
.model__name {
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700; font-size: 15px;
}
.model__meta {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; letter-spacing: 0.06em; opacity: .85;
  text-transform: uppercase;
}
.model__price { font-variant-numeric: tabular-nums; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); }
.seg--wrap { flex-wrap: wrap; border: none; gap: 8px; }
.seg--center { display: inline-flex; margin: 0 0 24px; }   /* left-aligned prompt-kind toggle */
/* Full-width even segments for inline segs (e.g. video resolution) */
.seg:not(.seg--wrap):not(.seg--center) { display: flex; width: 100%; }
.seg:not(.seg--wrap):not(.seg--center) .seg__opt { flex: 1; }
.seg--center .seg__opt { min-width: 120px; }
.seg__opt {
  text-transform: uppercase; text-align: center;
  font-size: 13.5px; letter-spacing: 0.1em; font-weight: 600;
  padding: 11px 17px;
  border-right: 1px solid var(--line);
  transition: background .15s, color .15s;
}
.seg__opt:last-child { border-right: none; }
.seg__opt:hover { background: var(--hover); }
.seg__opt.is-on { background: var(--ink); color: var(--paper); }
.seg--wrap .seg__opt { border: 1px solid var(--line); }

/* ---------- Badge / stepper ---------- */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); padding: 11px 16px;
  text-transform: uppercase; letter-spacing: 0.12em; font-weight: 600; font-size: 14px;
  min-height: 46px;
}
/* Resolution is fixed per model — muted color signals it can't be changed */
.badge--locked { color: var(--mute); border-color: var(--hair); border-style: dashed; cursor: not-allowed; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); width: max-content; }
.stepper__btn { width: 46px; height: 46px; font-size: 20px; transition: background .15s; }
.stepper__btn:hover { background: var(--ink); color: var(--paper); }
.stepper__val { min-width: 48px; text-align: center; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Slider ---------- */
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 1px; background: var(--ink); }
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 50%; cursor: pointer;
}
.slider::-moz-range-thumb {
  width: 18px; height: 18px; background: var(--paper);
  border: 2px solid var(--ink); border-radius: 50%; cursor: pointer;
}

/* Duration: thick bar + seconds counter on the right */
.duration { display: flex; align-items: center; gap: 16px; }
.duration .slider { flex: 1; }
.duration__val {
  font-family: var(--accent); text-transform: uppercase;
  font-size: 20px; letter-spacing: 0.06em; font-weight: 700;
  white-space: nowrap; min-width: 86px; text-align: right;
}
/* Minimal: a flat filled bar (white = elapsed) with a thin flush handle, no borders.
   The white fill width is set in JS via a background gradient. */
.slider--thick {
  height: 12px; border: none; border-radius: 0;
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
}
.slider--thick::-webkit-slider-thumb {
  -webkit-appearance: none; width: 3px; height: 24px; margin-top: -6px;
  background: var(--ink); border: none; border-radius: 0;
  box-shadow: 0 0 0 3px var(--paper);
}
.slider--thick::-moz-range-track { height: 12px; background: transparent; }
.slider--thick::-moz-range-thumb {
  width: 3px; height: 24px; background: var(--ink);
  border: none; border-radius: 0; box-shadow: 0 0 0 3px var(--paper);
}

/* ---------- Uploads ---------- */
/* Video drop zone and the image "+" share the same height so the row reads even */
.drop {
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line); height: 58px; padding: 10px;
  text-align: center; cursor: pointer; transition: background .15s;
  overflow: hidden; min-width: 0;
}
.drop:hover { background: var(--hover); }
.drop.has-file { border-style: solid; }
.drop.is-drop, .thumbs.is-drop { outline: 2px dashed var(--ink); outline-offset: 3px; background: var(--hover); }
.thumbs.is-drop { padding: 4px; }
.drop__txt { text-transform: uppercase; font-size: 13px; letter-spacing: 0.1em; color: var(--mute); display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop.has-file .drop__txt { color: var(--ink); font-weight: 600; }
.drop.is-uploading { animation: pulse 1.1s ease-in-out infinite; }
.drop.is-uploading .drop__txt::after { content: ' · uploading…'; font-weight: 400; color: var(--mute); }

.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb {
  width: 58px; height: 58px; border: 1px solid var(--line);
  position: relative; overflow: hidden; background-size: cover; background-position: center;
}
.thumb--add {
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--mute); cursor: pointer; transition: background .15s;
}
.thumb--add:hover { background: var(--hover); color: var(--ink); }
.thumb--ref { cursor: grab; }
.thumb--ref:active { cursor: grabbing; }
.thumb--drag { opacity: 0.4; }
.thumb--over { outline: 2px solid var(--ink); outline-offset: 1px; }
.thumb__x {
  position: absolute; top: 0; right: 0; width: 18px; height: 18px;
  background: var(--ink); color: var(--paper); font-size: 12px; line-height: 18px; text-align: center;
}

/* ============================================================
   OUTPUT / ACTION
   ============================================================ */
.output {
  position: sticky; top: 88px;
  border: 1px solid var(--line);
  padding: 22px;
  display: flex; flex-direction: column; gap: 18px;
}
.costbar { display: flex; align-items: baseline; justify-content: space-between; }
.costbar__label { font-family: var(--accent); text-transform: uppercase; font-size: 16px; letter-spacing: 0.08em; font-weight: 700; }
.costbar__value { font-family: var(--head); font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.costnote { margin-top: -8px; font-size: 13px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }

.btn {
  border: 1px solid var(--line);
  font-family: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
  font-size: 16px;
  padding: 16px 18px;
  transition: background .15s, color .15s, transform .05s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--primary:hover { background: var(--paper); color: var(--ink); }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; color: var(--mute); border-color: var(--hair); }
.btn--ghost:hover { color: var(--ink); border-color: var(--line); background: var(--hover); }
.btn--google { display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: var(--paper); color: var(--ink); }
.btn--google:hover { background: var(--hover); }
.gicon { width: 18px; height: 18px; flex: none; }
.gicon path { fill: currentColor; }      /* keep the mark monochrome for the B&W UI */
.divider { display: flex; align-items: center; gap: 12px; color: var(--mute); text-transform: uppercase; font-size: 12px; letter-spacing: 0.12em; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--hair); }
.formerror { color: var(--ink); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.06em; opacity: .85; }

.canvas {
  border: 1px solid var(--hair);
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  background-image:
    linear-gradient(45deg, var(--hover) 25%, transparent 25%),
    linear-gradient(-45deg, var(--hover) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--hover) 75%),
    linear-gradient(-45deg, transparent 75%, var(--hover) 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  overflow: hidden;
}
.canvas--video { aspect-ratio: 16 / 9; }
.canvas img, .canvas video { width: 100%; height: 100%; object-fit: cover; }
.canvas__hint { text-transform: uppercase; font-size: 13px; letter-spacing: 0.1em; color: var(--mute); text-align: center; padding: 0 16px; margin: 0; }
.canvas.is-busy { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
/* Results grid — releases the fixed aspect ratio so 1–4 tiles lay out cleanly */
.canvas.canvas--results { aspect-ratio: auto; display: block; padding: 8px; background-image: none; }
.results { display: grid; gap: 8px; }
.results--1 { grid-template-columns: 1fr; }
.results--2 { grid-template-columns: 1fr 1fr; }
.results--3 { grid-template-columns: repeat(3, 1fr); }
.results--4 { grid-template-columns: 1fr 1fr; }
.tile { position: relative; margin: 0; border: 1px solid var(--hair); overflow: hidden; background: #000; }
.tile img, .tile video { display: block; width: 100%; height: auto; }
.tile img { cursor: zoom-in; }
/* Native video fullscreen: letterbox the whole frame (contain) instead of the tile's
   cover fit, so portrait 9:16 clips aren't cropped to their center on a landscape screen. */
video:fullscreen { object-fit: contain !important; width: 100%; height: 100%; background: #000; }
video:-webkit-full-screen { object-fit: contain !important; width: 100%; height: 100%; background: #000; }
video:-moz-full-screen { object-fit: contain !important; width: 100%; height: 100%; background: #000; }
.tile--ph { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; background: var(--hover); }
.tile--fail { flex-direction: column; gap: 10px; padding: 16px; }
.tile--fail .tile__x { font-size: 22px; color: var(--mute); line-height: 1; }
.tile__err { font-size: 11px; line-height: 1.4; color: var(--mute); text-align: center; max-height: 8.4em; overflow-y: auto; overflow-wrap: anywhere; width: 100%; margin: 0; }
.tile__spin { width: 22px; height: 22px; border: 2px solid var(--hair); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* image board carousel — one large item, arrow-navigated */
.carousel { position: relative; }
.carousel__item { width: 100%; margin: 0; }
.carousel__nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); color: var(--ink); border: 1px solid var(--hair);
  border-radius: 50%; font-size: 24px; line-height: 1; cursor: pointer; transition: background .15s;
}
.carousel__prev { left: 10px; }
.carousel__next { right: 10px; }
.carousel__nav:hover { background: rgba(0,0,0,0.85); }
.carousel__count {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.65); color: var(--ink); font-size: 12px; letter-spacing: 0.05em;
  padding: 2px 9px; border-radius: 10px;
}
.failbox { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; height: 100%; }
.tile__dl {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); color: var(--ink); border: 1px solid var(--line);
  font-size: 17px; line-height: 1; opacity: .9; transition: opacity .15s, background .15s, color .15s;
}
.tile__dl:hover { opacity: 1; background: var(--ink); color: var(--paper); }

/* ---------- Switch / tumbler (video mode + audio) ---------- */
.switch {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%; border: 1px solid var(--line); padding: 11px 14px;
}
.switch[hidden] { display: none; }   /* beat .switch's display:flex */
.switch__text { font-family: var(--accent); text-transform: uppercase; letter-spacing: 0.1em; font-size: 16px; font-weight: 600; }
.switch__track {
  position: relative; flex: none; width: 48px; height: 26px;
  border: 1px solid var(--line); border-radius: 999px; transition: background .15s;
}
.switch__thumb {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  background: var(--ink); border-radius: 50%; transition: transform .15s, background .15s;
}
.switch[aria-checked="true"] .switch__track { background: var(--ink); }
.switch[aria-checked="true"] .switch__thumb { transform: translateX(22px); background: var(--paper); }
.switch__hint { font-size: 12.5px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.08em; }

/* ============================================================
   PROMPTS
   ============================================================ */
.promptadd {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  max-width: 680px; margin: 0 0 28px;     /* left-aligned with the panel */
}
.promptadd .btn { justify-self: start; min-width: 160px; }
.promptlist { list-style: none; max-width: 680px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.promptitem {
  border: 1px solid var(--line); padding: 16px;
  display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: start;
}
.promptitem__title { text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; font-size: 14px; }
.promptitem__body { grid-column: 1 / 2; color: var(--mute); font-size: 15px; }
.promptitem__actions { grid-row: 1 / 3; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 230px; }
.promptitem__refs { grid-column: 1 / -1; display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.miniref { width: 40px; height: 40px; border: 1px solid var(--hair); background-size: cover; background-position: center; }
.input--inline { font-size: 14px; padding: 7px 9px; max-width: 320px; }
.minibtn {
  border: 1px solid var(--line); padding: 7px 13px;
  font-family: var(--accent);
  text-transform: uppercase; font-size: 15px; letter-spacing: 0.08em; font-weight: 600;
  transition: background .15s, color .15s;
}
.minibtn:hover { background: var(--ink); color: var(--paper); }
.minibtn--danger { background: var(--ink); color: var(--paper); }   /* armed delete */
.empty { text-align: center; color: var(--mute); text-transform: uppercase; letter-spacing: 0.1em; font-size: 14px; padding: 40px 0; }

/* ============================================================
   HISTORY
   ============================================================ */
.historylist { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; overflow: auto; }
.histitem { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); padding: 12px; }
.histitem__thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.histitem__thumb { width: 76px; height: 76px; object-fit: cover; border: 1px solid var(--hair); background: #000; cursor: zoom-in; }
.histitem__body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.histitem__meta { text-transform: uppercase; font-size: 11.5px; letter-spacing: 0.08em; color: var(--mute); }
.histitem__prompt { font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.histitem__actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.histitem__thumb--fail { display: flex; align-items: center; justify-content: center; cursor: default; color: var(--mute); font-size: 22px; }
.histitem__thumb--wait { cursor: default; animation: pulse 1.1s ease-in-out infinite; }
.histitem__chip { font-size: 11px; letter-spacing: 0.06em; padding: 1px 6px; border: 1px solid var(--hair); }
.histitem__chip--fail { color: var(--ink); border-color: var(--ink); }
.histitem__chip--wait { color: var(--mute); }
.histitem__err { font-size: 12.5px; color: var(--mute); text-transform: none; letter-spacing: 0; word-break: break-word; }

/* ============================================================
   MODALS
   ============================================================ */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.7); padding: 20px;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: fade .2s ease;
}
.modal[hidden] { display: none; }     /* beat .modal's display:flex */
.panel[hidden] { display: none; }
.modal__card {
  position: relative; background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 24px 60px rgba(0, 0, 0, 0.9);
  width: 100%; max-width: 380px; padding: 32px;
  display: flex; flex-direction: column; gap: 16px;
}
.modal__card--wide { max-width: none; width: 66vw; height: 66vh; }   /* history: prompt-window size */
/* Prompt expand: roughly two-thirds of the viewport, just a big editor + close */
.modal__card--prompt { max-width: none; width: 66vw; height: 66vh; }
.promptmodal__text { flex: 1; resize: none; font-size: 17px; line-height: 1.65; }

/* Lightbox (near-fullscreen zoom) */
.lightbox { background: rgba(0, 0, 0, 0.93); }
.lightbox__img { max-width: 94vw; max-height: 92vh; object-fit: contain; border: 1px solid var(--hair); }
.lightbox__nav {
  position: fixed; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 52px; height: 52px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08); color: var(--ink); border: 1px solid var(--hair);
  border-radius: 50%; font-size: 32px; line-height: 1; cursor: pointer; transition: background .15s;
}
.lightbox__nav:hover { background: rgba(255,255,255,0.18); }
.lightbox__prev { left: 24px; }
.lightbox__next { right: 24px; }
.lightbox__count {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 2;
  color: var(--ink); font-size: 14px; letter-spacing: 0.06em;
  background: rgba(0,0,0,0.5); padding: 4px 12px; border-radius: 12px;
}

/* Error detail box */
.errbox {
  background: #000; border: 1px solid var(--hair); padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  color: var(--mute); white-space: pre-wrap; word-break: break-word; max-height: 42vh; overflow: auto;
}
.modal__x { position: absolute; top: 12px; right: 14px; font-size: 24px; line-height: 1; color: var(--mute); }
.modal__x:hover { color: var(--ink); }
.modal__sub { color: var(--mute); font-size: 14.5px; text-transform: uppercase; letter-spacing: 0.06em; }
#authForm, #topupForm { display: flex; flex-direction: column; gap: 12px; }
.amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.amount {
  border: 1px solid var(--line); padding: 13px 0;
  text-transform: uppercase; font-weight: 700; letter-spacing: 0.06em; font-size: 16px;
  transition: background .15s, color .15s;
}
.amount:hover, .amount.is-on { background: var(--ink); color: var(--paper); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; gap: 28px; }
  .output { position: static; }
  .seo { grid-template-columns: 1fr; gap: 32px; }
}
@media (max-width: 620px) {
  .topbar__inner { grid-template-columns: auto 1fr auto; height: 56px; padding: 0 14px; }
  .brand { min-width: 0; }
  .wordmark { display: none; }   /* too cramped next to tabs + balance on phones */
  .tabs { gap: 2px; }
  .tab { padding: 8px 10px; letter-spacing: 0.08em; }
  .modelgrid { grid-template-columns: 1fr; }
  .row { flex-direction: column; }
  main { padding: 0 14px; }
  .panel { padding: 32px 0 16px; }
}
