/* Imagine. Neutral grey "editing booth" surfaces so images read true; blue for actions, gold only for money. */
@font-face { font-family: "Bricolage Grotesque"; font-weight: 400 800; font-display: swap;
  src: url(fonts/bricolage-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 400 800; font-display: swap;
  src: url(fonts/bricolage-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C4, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Instrument Sans"; font-weight: 400 700; font-display: swap;
  src: url(fonts/instrument-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Instrument Sans"; font-weight: 400 700; font-display: swap;
  src: url(fonts/instrument-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C4, U+2C60-2C7F, U+A720-A7FF; }

:root {
  color-scheme: dark;
  --bg: #232427;
  --bg-2: #2b2c30;
  --bg-3: #35363b;
  --line: #3f4046;
  --line-2: #50515a;
  --text: #ececee;
  --muted: #a4a5ac;
  --faint: #76777e;
  --accent: #9fb3ff;
  --accent-ink: #11152b;
  --accent-soft: rgb(159 179 255 / .14);
  --gold: #e9c46a;
  --danger: #ff8f80;
  --scrim: rgb(10 10 12 / .62);
  --stage: #18191b;
  --shadow: 0 18px 50px rgb(0 0 0 / .45);

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --ui: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --side: 300px;
  --gutter: 16px;
  --top-h: 60px;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #e9e9ec;
    --bg-2: #f4f4f6;
    --bg-3: #ffffff;
    --line: #d3d3d9;
    --line-2: #babbc3;
    --text: #1b1c1f;
    --muted: #595a62;
    --faint: #85868e;
    --accent: #3450c8;
    --accent-ink: #ffffff;
    --accent-soft: rgb(52 80 200 / .1);
    --gold: #8a5d00;
    --danger: #b3261e;
    --scrim: rgb(30 30 35 / .45);
    --stage: #f7f7f9;
    --shadow: 0 18px 50px rgb(0 0 0 / .18);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.45 var(--ui); font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
img { display: block; max-width: 100%; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.money { font-variant-numeric: tabular-nums; color: var(--gold); }

/* ---------- buttons, chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-md);
  border: 1px solid var(--line-2); background: var(--bg-3); font-weight: 600;
}
.btn:hover { border-color: var(--faint); }
.btn { white-space: nowrap; }
a.btn { color: inherit; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { opacity: .5; cursor: default; filter: none; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--text); background: var(--bg-3); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.danger { color: var(--danger); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent; color: var(--muted);
}
.icon-btn:hover { color: var(--text); background: var(--bg-3); }
.icon-btn[aria-pressed="true"] { color: var(--danger); }
.search-toggle { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 11px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 14px;
}
.chip:hover { color: var(--text); border-color: var(--line-2); }
.chip[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.chip svg { width: 16px; height: 16px; }
.chip.toggle[aria-pressed="true"] svg { fill: var(--danger); stroke: var(--danger); }

/* ---------- layout ---------- */
.app {
  display: grid; min-height: 100dvh;
  grid-template-columns: var(--side) minmax(0, 1fr);
  grid-template-rows: var(--top-h) 1fr;
  grid-template-areas: "top top" "side main";
}
.top {
  grid-area: top; position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.wordmark {
  font: 700 26px/1 var(--display); letter-spacing: -.035em; color: var(--text); text-decoration: none;
  font-variation-settings: "opsz" 96; margin-right: 8px;
}
.views { display: flex; gap: 4px; }
.views a {
  padding: 7px 12px; border-radius: var(--r-sm); color: var(--muted); text-decoration: none; font-weight: 600;
}
.views a:hover { color: var(--text); }
.views a[aria-current="page"] { color: var(--text); background: var(--bg-3); }
.search {
  display: flex; align-items: center; gap: 8px; flex: 0 1 320px; margin-left: auto;
  height: 38px; padding: 0 12px; border-radius: var(--r-md); background: var(--bg-2); border: 1px solid var(--line);
  color: var(--faint);
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 17px; height: 17px; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--text); }
.search.grow { flex: 1 1 auto; margin-left: 0; }
.credits {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: transparent; white-space: nowrap;
}
.credits:hover { border-color: var(--line-2); }
.credits-amount { font-weight: 700; font-size: 16px; }
.credits-label { color: var(--muted); font-size: 13px; }
.credits.low .credits-amount { color: var(--danger); }

.settings {
  grid-area: side; position: sticky; top: var(--top-h); height: calc(100dvh - var(--top-h));
  border-right: 1px solid var(--line); background: var(--bg);
}
.settings-scroll { height: 100%; overflow: auto; padding: 18px 18px 40px; overscroll-behavior: contain; }
.sheet-handle { display: none; }
.main { grid-area: main; min-width: 0; padding: 20px 28px 80px; }

/* ---------- settings panel ---------- */
.field { margin-bottom: 20px; }
.field-label { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field-label .hint { font-weight: 400; color: var(--faint); }
.field-note { margin: 6px 0 0; font-size: 13px; color: var(--faint); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.model-btn {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; width: 100%;
  padding: 11px 12px; border-radius: var(--r-md); text-align: left;
  border: 1px solid var(--line-2); background: var(--bg-2);
}
.model-btn:hover { border-color: var(--accent); }
.model-btn .mb-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-btn .mb-sub { grid-column: 1; font-size: 13px; color: var(--faint); }
.model-btn .money { grid-row: 1 / span 2; grid-column: 2; font-size: 14px; }
.ar-chip { padding-left: 8px; }
.ar-shape { display: inline-block; border: 1.6px solid currentColor; border-radius: 2px; }
.seg { display: inline-flex; padding: 3px; border-radius: var(--r-md); background: var(--bg-2); border: 1px solid var(--line); }
.seg button { min-width: 44px; height: 32px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--bg-3); color: var(--text); box-shadow: 0 0 0 1px var(--line-2); }
.input {
  width: 100%; height: 38px; padding: 0 11px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
}
.input:focus { outline: none; border-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; }
.est-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.est-table td { padding: 4px 0; color: var(--muted); }
.est-table td:last-child { text-align: right; }
.est-table tr.total td { color: var(--text); font-weight: 650; border-top: 1px solid var(--line); padding-top: 7px; }

/* ---------- composer ---------- */
.composer {
  position: sticky; top: calc(var(--top-h) + 12px); z-index: 20;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  padding: 14px 14px 10px; margin-bottom: 26px; box-shadow: 0 10px 30px rgb(0 0 0 / .18);
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-2)); }
.composer.drop { border-color: var(--accent); border-style: dashed; }
.prompt-row textarea {
  display: block; width: 100%; min-height: 34px; max-height: 40vh; resize: none; border: 0; outline: none;
  background: transparent; padding: 2px 4px; color: var(--text);
  font: 500 clamp(19px, 1.7vw, 23px)/1.32 var(--display); letter-spacing: -.012em;
  font-variation-settings: "opsz" 40;
}
.prompt-row textarea::placeholder { color: var(--faint); }
.composer-bar { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.summary {
  display: none; align-items: center; gap: 6px; min-width: 0; height: 38px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: transparent; color: var(--muted); font-size: 14px;
}
.summary b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary .sum-extra { white-space: nowrap; }
.composer-warn { flex: 1; min-width: 0; font-size: 13px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.generate { margin-left: auto; min-width: 132px; }
.generate-cost { font-variant-numeric: tabular-nums; font-weight: 500; opacity: .8; }
.refs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; }
.ref {
  position: relative; flex: none; width: 64px; height: 64px; border-radius: var(--r-sm); overflow: hidden;
  background: var(--bg-3); border: 1px solid var(--line);
}
.ref img { width: 100%; height: 100%; object-fit: cover; }
.ref button {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; padding: 0; display: grid; place-items: center;
  border-radius: 50%; border: 0; background: rgb(0 0 0 / .65); color: #fff;
}
.ref button svg { width: 13px; height: 13px; stroke-width: 2.4; }
.ref.loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / .12) 50%, transparent 70%) 0 0 / 200% 100%; animation: shimmer 1.2s linear infinite; }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 18px; }
.select-wrap select {
  height: 34px; padding: 0 30px 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 14px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(-45deg, transparent 50%, currentColor 50%);
  background-position: right 15px top 15px, right 10px top 15px; background-size: 5px 5px; background-repeat: no-repeat;
  max-width: 60vw;
}
.select-wrap select.active { color: var(--text); border-color: var(--accent); background-color: var(--accent-soft); }
.filter-note { color: var(--faint); font-size: 13px; }

/* ---------- feed ---------- */
.batch { margin: 0 0 40px; }
.batch-head { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; max-width: 78ch; }
.batch-prompt {
  margin: 0; font: 500 17px/1.38 var(--display); letter-spacing: -.008em; font-variation-settings: "opsz" 24;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: text;
}
.batch-prompt.open { -webkit-line-clamp: unset; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 13px; color: var(--faint); }
.meta .model-name { color: var(--muted); font-weight: 600; }
.meta .ref-thumbs { display: inline-flex; gap: 3px; }
.meta .ref-thumbs img { width: 22px; height: 22px; border-radius: 4px; object-fit: cover; }
.group + .group { margin-top: 14px; }
.cmp { margin: 0; min-width: 0; }
.cmp figcaption { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 7px; font-size: 13px; }
.cmp .model-name { font-weight: 650; }
.cmp .note { color: var(--faint); flex-basis: 100%; }
.group-head { display: flex; gap: 12px; align-items: baseline; margin: 0 0 7px; font-size: 13px; }
.group-head .model-name { font-weight: 650; color: var(--text); }
.group-head .note { color: var(--faint); }
.tiles { display: grid; gap: 6px; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); max-width: calc(var(--cols, 2) * 360px); align-items: start; }
.tile {
  position: relative; display: block; width: 100%; padding: 0; border: 0; border-radius: var(--r-sm); overflow: hidden;
  background: var(--bg-2); aspect-ratio: var(--ar, 1);
}
.tile img { width: 100%; height: 100%; object-fit: cover; transition: opacity .25s; }
button.tile:hover img { opacity: .9; }
.tile .fav-mark { position: absolute; left: 7px; bottom: 7px; width: 18px; height: 18px; fill: var(--danger); stroke: none; filter: drop-shadow(0 1px 2px rgb(0 0 0 / .6)); }
.tile.pending { display: grid; place-items: center; border: 1px dashed var(--line-2); background: var(--bg-2); overflow: hidden; }
.tile.pending::before { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 25%, var(--accent-soft) 50%, transparent 75%) 0 0 / 220% 100%; animation: shimmer 1.6s linear infinite; }
.tile.pending .elapsed { position: relative; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.tile.failed {
  display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--line)); text-align: left;
}
.tile.failed p { margin: 0; font-size: 13px; color: var(--muted); overflow: auto; max-height: 70%; }
.tile.failed .row { flex-wrap: wrap; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -120% 0; } }
.batch-actions { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 8px; margin-left: -10px; }
.batch-actions .btn { min-height: 32px; padding: 0 10px; font-size: 14px; font-weight: 500; }
.empty { max-width: 46ch; margin: 8vh 0; color: var(--muted); }
.empty h2 { font: 650 28px/1.15 var(--display); letter-spacing: -.02em; color: var(--text); margin: 0 0 10px; }
.empty p { margin: 0 0 8px; }
.more-status { color: var(--faint); font-size: 13px; padding: 10px 0 30px; }

/* ---------- gallery ---------- */
.gallery { columns: 4 220px; column-gap: 6px; }
.gallery .tile { margin: 0 0 6px; break-inside: avoid; }

/* ---------- dialogs ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: var(--scrim); }
.models-dlg, .account-dlg {
  width: min(720px, calc(100vw - 32px)); max-height: min(86dvh, 900px); padding: 0;
  border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--bg-2); box-shadow: var(--shadow);
}
.models-dlg[open], .account-dlg[open] { display: flex; flex-direction: column; }
.account-dlg { width: min(560px, calc(100vw - 32px)); }
.account-body { overflow: auto; overscroll-behavior: contain; }
.tabs { display: flex; gap: 2px; margin-right: auto; overflow-x: auto; }
.tabs button {
  padding: 7px 11px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted);
  font-weight: 600; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); background: var(--bg-3); }
.stack { display: grid; gap: 10px; margin: 0 0 6px; }
.stack .field-label { margin: 0; }
.row.wrap { flex-wrap: wrap; }
.credit-lines p { margin: 10px 0 0; }
.credit-lines a { color: var(--accent); }
.credit-lines code, .link-box code { font-size: 13px; overflow-wrap: anywhere; }
.lede { font: 500 18px/1.4 var(--display); letter-spacing: -.008em; }
.steps { margin: 12px 0 18px; padding-left: 22px; line-height: 1.5; }
.steps li { margin: 0 0 8px; padding-left: 4px; }
.key-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.key-line code { padding: 6px 9px; border-radius: var(--r-sm); background: var(--bg-3); border: 1px solid var(--line); }
#key-form { margin-top: 10px; }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent); text-decoration: underline; font-size: inherit; }
.link-box { display: grid; gap: 10px; margin: 14px 0 4px; padding: 14px; border-radius: var(--r-md);
  border: 1px solid var(--accent); background: var(--accent-soft); }
.link-box p { margin: 0; }
.link-box code { display: block; padding: 8px 10px; border-radius: var(--r-sm); background: var(--bg-2); user-select: all; }
ul.plain { list-style: none; margin: 8px 0 0; padding: 0; }
.person { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 12px;
  padding: 12px 0; border-top: 1px solid var(--line); }
.person > div:first-child { flex: 1 1 260px; min-width: 0; }
.person .small-print { margin: 3px 0 0; }
.person.off > div:first-child { opacity: .6; }
.person-actions { justify-content: flex-end; }
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 0 0 18px; padding: 12px 14px;
  border: 1px solid var(--accent); border-radius: var(--r-md); background: var(--accent-soft); }
.notice p { margin: 0; flex: 1 1 280px; }
.avatar { display: inline-grid; place-items: center; width: 26px; height: 26px; margin: 0 -4px 0 4px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--text); font-weight: 700; font-size: 13px; }
.credits.nokey { border-color: var(--accent); }
.credits.trial .credits-label { color: var(--gold); }
.invite-row .input { flex: 1 1 180px; }
.invite-row .credit-in { flex: 0 1 150px; }
.give-row { margin-top: 8px; flex-wrap: wrap; }
.give-row .credit-in { width: 84px; height: 34px; }
.credits.nokey .credits-amount { color: var(--accent); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0 auto 0 0; font: 650 20px/1 var(--display); letter-spacing: -.015em; }
.models-dlg .dlg-head h2 { margin: 0; }
.dlg-hint { margin: 0; padding: 8px 16px; font-size: 13px; color: var(--faint); border-bottom: 1px solid var(--line); }
.dlg-hint:empty { display: none; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.model-list { overflow: auto; padding: 6px 8px 16px; overscroll-behavior: contain; }
.model-group-title { margin: 14px 10px 6px; font-size: 13px; font-weight: 650; color: var(--faint); }
.model-row {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto 36px; align-items: center; gap: 2px 10px;
  padding: 9px 6px 9px 10px; border-radius: var(--r-md); cursor: pointer;
}
.model-row:hover { background: var(--bg-3); }
.model-row.sel { background: var(--accent-soft); }
.model-row .check {
  width: 20px; height: 20px; border-radius: 50%; border: 1.6px solid var(--line-2); display: grid; place-items: center;
}
.model-row.multi .check { border-radius: 5px; }
.model-row.sel .check { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.model-row .check svg { width: 13px; height: 13px; stroke-width: 3; visibility: hidden; }
.model-row.sel .check svg { visibility: visible; }
.mr-main { min-width: 0; }
.mr-name { font-weight: 650; overflow-wrap: anywhere; }
.mr-tags { display: inline-flex; gap: 5px; margin-left: 6px; vertical-align: 1px; }
.tag { font-size: 11.5px; padding: 1px 6px; border-radius: 4px; background: var(--bg-3); color: var(--muted); border: 1px solid var(--line); }
.mr-desc { display: block; font-size: 13px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-price { font-size: 14px; text-align: right; white-space: nowrap; }
.mr-price small { display: block; color: var(--faint); font-size: 11.5px; }
.star { width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; color: var(--faint); border-radius: var(--r-sm); }
.star:hover { color: var(--text); }
.star[aria-pressed="true"] { color: var(--gold); }
.star[aria-pressed="true"] svg { fill: currentColor; }

.credit-lines { padding: 6px 18px 18px; }
.credit-big { display: flex; align-items: baseline; gap: 10px; padding: 16px 0 8px; }
.credit-big .money { font: 700 40px/1 var(--display); letter-spacing: -.03em; }
.credit-big span:last-child { color: var(--muted); }
.credit-lines dl { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 10px 0 0; font-size: 14px; }
.credit-lines dt { color: var(--muted); }
.credit-lines dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.credit-lines h3 { margin: 22px 0 0; font-size: 13px; font-weight: 650; color: var(--faint); }
.credit-lines .small-print { margin: 14px 0 0; font-size: 12.5px; color: var(--faint); }

/* ---------- lightbox ---------- */
.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: var(--stage);
}
.lightbox[open] { display: grid; grid-template-columns: minmax(0, 1fr) 360px; }
.lightbox::backdrop { background: var(--stage); }
.lb-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 24px; overflow: hidden; touch-action: pan-y pinch-zoom; }
.lb-stage img { max-width: 100%; max-height: calc(100dvh - 48px); object-fit: contain; border-radius: 4px; background: repeating-conic-gradient(var(--bg-3) 0 25%, var(--bg-2) 0 50%) 0 0 / 16px 16px; }
.lb-nav, .lb-close {
  position: absolute; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: color-mix(in srgb, var(--bg-2) 80%, transparent); color: var(--text);
}
.lb-nav:hover, .lb-close:hover { background: var(--bg-3); }
.lb-nav { top: 50%; transform: translateY(-50%); }
.lb-nav.prev { left: 16px; } .lb-nav.next { right: 16px; }
.lb-nav:disabled { opacity: 0; pointer-events: none; }
.lb-close { top: 16px; right: 16px; }
.lb-info { overflow: auto; padding: 22px 22px 40px; border-left: 1px solid var(--line); background: var(--bg-2); }
.lb-prompt { margin: 0 0 16px; font: 500 18px/1.4 var(--display); letter-spacing: -.008em; white-space: pre-wrap; overflow-wrap: anywhere; }
.lb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 20px; }
.lb-actions .btn { font-weight: 550; }
.lb-actions .btn svg { width: 18px; height: 18px; }
.lb-actions .btn[aria-pressed="true"] { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--line-2)); }
.lb-actions .btn[aria-pressed="true"] svg { fill: currentColor; }
.lb-info dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0; font-size: 14px; }
.lb-info dt { color: var(--faint); }
.lb-info dd { margin: 0; overflow-wrap: anywhere; }
.lb-delete { margin-top: 22px; }

/* ---------- toast, scrim ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; transform: translate(-50%, 20px); opacity: 0;
  max-width: min(520px, calc(100vw - 32px)); padding: 11px 16px; border-radius: var(--r-md);
  background: var(--text); color: var(--bg); font-weight: 550; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #1a0705; }
.scrim { position: fixed; inset: 0; z-index: 39; background: var(--scrim); }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.login { width: min(360px, 100%); }
.login .wordmark { display: block; font-size: 56px; margin: 0 0 28px; }
.login label { display: block; margin: 0 0 8px; font-weight: 600; color: var(--muted); }
.login input[type=password], .login input[type=text] {
  width: 100%; height: 48px; padding: 0 14px; border-radius: var(--r-md); border: 1px solid var(--line-2);
  background: var(--bg-2); font-size: 17px;
}
.login input:focus { outline: none; border-color: var(--accent); }
.login .btn { width: 100%; margin-top: 14px; min-height: 48px; font-size: 16px; }
.form-error { color: var(--danger); margin: 10px 0 0; }
.login label { margin-top: 14px; }
.login label:first-of-type { margin-top: 0; }
.form-hint { margin: 8px 0 0; font-size: 13.5px; color: var(--faint); }
.login .lede { margin: 0 0 22px; }
.login p > .btn { width: auto; }

/* ---------- phones and small tablets ---------- */
@media (max-width: 899px) {
  :root { --top-h: 56px; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .top { gap: 10px; padding: 0 var(--gutter); padding-top: env(safe-area-inset-top); height: calc(var(--top-h) + env(safe-area-inset-top)); }
  .wordmark { font-size: 23px; margin-right: 0; }
  .views a { padding: 7px 9px; }
  .search { position: absolute; left: var(--gutter); right: var(--gutter); top: calc(100% + 8px); margin: 0; display: none; background: var(--bg-2); }
  .top.searching .search { display: flex; }
  .credits { margin-left: auto; padding: 0 10px; }
  .credits-label, .avatar { display: none; }
  .search-toggle { display: inline-grid; }
  .main { padding: 14px var(--gutter) calc(150px + env(safe-area-inset-bottom)); }
  .top.searching ~ .main { padding-top: 64px; }

  .composer {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; margin: 0; z-index: 35;
    border-radius: var(--r-lg) var(--r-lg) 0 0; border-width: 1px 0 0;
    padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 30px rgb(0 0 0 / .25);
  }
  .prompt-row textarea { font-size: 18px; max-height: 30dvh; }
  .composer-bar { margin-top: 8px; }
  .summary { display: inline-flex; flex: 1 1 0; }
  .composer-warn { display: none; }
  .generate { flex: none; min-width: 0; padding: 0 14px; white-space: nowrap; }
  .refs { padding-bottom: 8px; }

  .settings {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 40; height: auto; max-height: 82dvh;
    border: 1px solid var(--line-2); border-width: 1px 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0;
    background: var(--bg-2); box-shadow: var(--shadow);
    transform: translateY(105%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); visibility: hidden;
    display: flex; flex-direction: column;
  }
  .settings.open { transform: none; visibility: visible; }
  .sheet-handle { display: flex; align-items: center; justify-content: flex-end; padding: 8px 10px 0; position: relative; }
  .sheet-handle span { position: absolute; left: 50%; top: 8px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line-2); }
  .settings-scroll { height: auto; padding: 6px var(--gutter) calc(24px + env(safe-area-inset-bottom)); }

  .tiles { --cols-m: min(var(--cols, 2), 2); grid-template-columns: repeat(var(--cols-m), minmax(0, 1fr)); max-width: none; }
  .tiles.one { grid-template-columns: minmax(0, 1fr); }
  .gallery { columns: 2 140px; }
  .toast { bottom: calc(120px + env(safe-area-inset-bottom)); }

  .lightbox[open] { display: block; overflow: auto; }
  .lb-stage { height: 72dvh; padding: 0; padding-top: env(safe-area-inset-top); }
  .lb-stage img { max-height: 72dvh; border-radius: 0; }
  .lb-nav { width: 40px; height: 40px; }
  .lb-nav.prev { left: 8px; } .lb-nav.next { right: 8px; }
  .lb-close { top: calc(10px + env(safe-area-inset-top)); right: 10px; }
  .lb-info { border-left: 0; border-top: 1px solid var(--line); padding: 18px var(--gutter) calc(30px + env(safe-area-inset-bottom)); }
  .models-dlg, .account-dlg { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; border-width: 1px 0 0; }
  .models-dlg .dlg-head { flex-wrap: wrap; }
  .models-dlg .search.grow { order: 5; flex-basis: 100%; }
}
@media (min-width: 1500px) {
  :root { --side: 330px; }
  .main { padding-left: 40px; padding-right: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
