:root {
  /* surfaces used by bars, menus, glass (themeable) */
  --bar-bg: rgba(11, 11, 12, .82);
  --hairline: rgba(255,255,255,.06);
  --border-strong: var(--border-strong);
  --menu-bg: #1b1b1e;
  --sheet-bg: #151517;
  --toast-bg: #202024;
  --code-bg: #0f0f11;
  --code-text: #d9d9de;
  --hover-tint: rgba(255,255,255,.02);
  --glass-a: rgba(40, 40, 46, .38);
  --glass-b: rgba(18, 18, 21, .52);
  --glass-border: rgba(255,255,255,.14);
  --glass-hi: rgba(255,255,255,.10);
  --glass-chip: rgba(255,255,255,.08);
  --glass-chip-hover: rgba(255,255,255,.14);
  --on-glass-muted: rgba(255,255,255,.55);
  --on-glass-soft: rgba(255,255,255,.7);
  --accent-2: #d7ff3a;           /* gradient partner for the Generate button + logo */
  --gen-bg: var(--accent);
  --bg: #0b0b0c;
  --surface: #141416;
  --surface-2: #1c1c1f;
  --surface-3: #242428;
  --border: #2a2a2f;
  --text: #f3f3f4;
  --muted: #8d8d96;
  --faint: #5d5d66;
  --accent: #d7ff3a;
  --accent-ink: #0b0b0c;
  --accent-soft: rgba(215, 255, 58, .12);
  --gold: #e8c55f;
  --danger: #ff5d5d;
  --ok: #53d98b;
  --radius: 16px;
  --radius-sm: 10px;
  --top-h: 60px;
  --tab-h: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; }
body { min-height: 100dvh; overflow-x: hidden; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; font-size: 16px; color: var(--text); } /* 16px stops iOS zoom-on-focus */
img, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }

/* ───── Top bar ───── */
.topbar {
  position: sticky; top: 0; z-index: 40; height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) 20px 0;
  display: flex; align-items: center; gap: 24px;
  background: var(--bar-bg); backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; font-size: 16px; }
.topnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; white-space: nowrap; transition: color .15s, background .15s; }
.topnav a:hover { color: var(--text); }
.topnav a.active { color: var(--accent); }
.topnav a.gold { color: var(--gold); }
.badge-new { font-size: 10px; font-weight: 700; background: var(--accent); color: var(--accent-ink); border-radius: 5px; padding: 1px 5px; margin-left: 3px; vertical-align: 2px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.balance { display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: 13px; white-space: nowrap; }
.balance .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.balance.ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.balance.err .dot { background: var(--danger); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); }
.icon-btn:hover, .icon-btn.active { color: var(--text); background: var(--surface-2); }

/* ───── Tab bar (mobile) ───── */
.tabbar { display: none; }
@media (max-width: 760px) {
  :root { --top-h: 52px; --tab-h: 58px; }
  .topbar { padding-left: 14px; padding-right: 14px; gap: 10px; }
  .topnav { display: none; }
  .brand span { font-size: 15px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: var(--bar-bg); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--hairline);
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; color: var(--muted); font-weight: 500; }
  .tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a.active { color: var(--accent); }
}

/* ───── Layout ───── */
main { outline: none; }
.page { max-width: 1400px; margin: 0 auto; padding: 24px 20px calc(40px + var(--tab-h) + var(--safe-b)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 28px; letter-spacing: -.02em; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
h2 { font-size: 17px; margin: 28px 0 12px; letter-spacing: -.01em; }
h2 small { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }
@media (max-width: 760px) { .page { padding: 16px 16px calc(24px + var(--tab-h) + var(--safe-b)); } .page-head h1 { font-size: 23px; } }

/* ───── Buttons / inputs ───── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, transform .08s; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.input, .textarea, .select { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; outline: none; transition: border-color .15s; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--border-strong); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.pill.lime { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.gold { color: var(--gold); }
.cost { font-variant-numeric: tabular-nums; }

/* ───── Create: feed + composer ───── */
.create { padding-bottom: calc(300px + var(--tab-h) + var(--safe-b)); }
.feed { display: flex; align-items: flex-start; gap: 6px; padding: 6px; }
.feed.empty { display: block; }
.feed-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.feed-col .tile { margin-bottom: 0; }
.feed-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px 2px; font-size: 13px; }
.tile { break-inside: avoid; margin-bottom: 6px; position: relative; border-radius: 6px; overflow: hidden; background: var(--surface); cursor: pointer; }
.tile img, .tile video { width: 100%; height: auto; }
.tile .tile-meta { position: absolute; inset: auto 0 0 0; padding: 30px 10px 8px; font-size: 12px; background: linear-gradient(transparent, rgba(0,0,0,.75)); opacity: 0; transition: opacity .2s; display: flex; justify-content: space-between; gap: 8px; }
.tile:hover .tile-meta { opacity: 1; }
.tile .fav-dot { position: absolute; top: 8px; right: 8px; color: var(--gold); font-size: 16px; text-shadow: 0 1px 4px #000; }
.tile.pending { aspect-ratio: var(--ar, 1); display: grid; place-items: center; background: linear-gradient(110deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%); background-size: 250% 100%; animation: shimmer 1.6s linear infinite; }
.tile.failed { aspect-ratio: var(--ar, 1); display: grid; place-items: center; background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: var(--danger); padding: 16px; text-align: center; font-size: 13px; }
.tile.audio { padding: 16px; aspect-ratio: auto; background: var(--surface-2); }
.tile.audio audio { width: 100%; margin-top: 10px; }
.pending-label { text-align: center; font-size: 12px; color: var(--muted); padding: 10px; }
.pending-label b { display: block; color: var(--text); font-size: 13px; margin-bottom: 2px; }
@keyframes shimmer { to { background-position: -150% 0; } }
.empty-feed { max-width: 560px; margin: 12vh auto 0; text-align: center; padding: 0 20px; }
.empty-feed h1 { font-size: clamp(28px, 5vw, 44px); letter-spacing: -.03em; margin: 0 0 10px; }
.empty-feed h1 em { color: var(--accent); font-style: normal; }

.composer {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + var(--tab-h) + var(--safe-b)); width: min(1290px, calc(100vw - 32px));
  /* frosted glass: generations scrolling underneath stay softly visible */
  background: var(--surface);
  transition: background .3s ease, border-color .3s ease;
  border: 1px solid var(--glass-border); border-radius: 26px; padding: 14px 16px 14px 18px;
  display: grid; grid-template-columns: 1fr auto; gap: 12px 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45), inset 0 1px 0 var(--glass-hi);
}
/* glass inner controls so they read on top of busy images */
.composer .chip, .composer .stepper, .composer .ref-add, .composer .modes button.on { background: var(--glass-chip); border-color: var(--glass-hi); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.composer .chip:hover { background: var(--glass-chip-hover); }
.composer .prompt { text-shadow: 0 1px 2px rgba(0,0,0,.45); }
.composer .prompt::placeholder { color: var(--on-glass-muted); }
.composer .ref-hint, .composer .cost-note { color: var(--on-glass-soft); }
/* browsers without backdrop-filter: fall back to a solid panel */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .composer { background: var(--surface); } }
.composer-main { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.modes { display: flex; gap: 4px; }
.modes button { padding: 5px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.modes button.on { background: var(--surface-3); color: var(--text); }
.refs { display: flex; gap: 8px; align-items: center; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.refs::-webkit-scrollbar { display: none; }
.ref { position: relative; flex: 0 0 auto; width: 60px; height: 60px; border-radius: 12px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--border); }
.ref img, .ref video { width: 100%; height: 100%; object-fit: cover; }
.ref .ref-audio { display: grid; place-items: center; height: 100%; font-size: 22px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface-2)); }
.ref .ref-dur { position: absolute; left: 3px; bottom: 3px; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 5px; background: rgba(0,0,0,.75); }
.ref.bad { opacity: .35; outline: 1.5px dashed var(--danger); }
.ref-hint b { color: var(--gold); font-weight: 600; }
h4.fam { margin: 18px 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.ref .x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.7); font-size: 13px; line-height: 20px; text-align: center; }
.ref.uploading::after { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,.55) linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 25%, transparent), transparent); background-size: 200% 100%; animation: shimmer 1s linear infinite; }
.ref-add { width: 60px; height: 60px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--border-strong); display: grid; place-items: center; color: var(--muted); flex: 0 0 auto; }
.ref-add:hover { color: var(--text); border-color: var(--border-strong); }
.ref-hint { font-size: 12px; color: var(--faint); white-space: nowrap; }
.prompt { width: 100%; background: transparent; border: 0; outline: none; resize: none; min-height: 48px; max-height: 32vh; line-height: 1.5; padding: 2px 0; }
.prompt::placeholder { color: var(--faint); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--hairline); font-weight: 600; font-size: 14px; white-space: nowrap; flex: 0 0 auto; }
.chip:hover { background: var(--surface-3); }
.chip .k { color: var(--muted); font-weight: 500; }
.chip.model { gap: 9px; }
.chip.model .logo { width: 20px; height: 20px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.chip.toggle.on { background: var(--accent-soft); color: var(--accent); }
.stepper { display: inline-flex; align-items: center; height: 40px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--hairline); flex: 0 0 auto; }
.stepper button { width: 36px; height: 40px; color: var(--muted); font-size: 18px; }
.stepper button:hover { color: var(--text); }
.stepper span { min-width: 34px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.gen-col { display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; }
.gen-btn { width: 168px; min-height: 96px; border-radius: 18px; background: var(--gen-bg); color: var(--accent-ink); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-weight: 700; font-size: 17px; transition: filter .15s, transform .08s; }
.gen-btn:hover { filter: brightness(1.06); }
.gen-btn:active { transform: scale(.98); }
.gen-btn .price { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.gen-btn .usd { font-size: 12px; font-weight: 600; opacity: .7; }
.gen-btn[disabled] { opacity: .45; }
.cost-note { font-size: 11.5px; color: var(--muted); text-align: center; max-width: 168px; line-height: 1.3; }
.cost-note.warn { color: var(--gold); }
.composer .collapse { display: none; }

@media (max-width: 760px) {
  .create { padding-bottom: calc(250px + var(--tab-h) + var(--safe-b)); }
  .feed { gap: 4px; padding: 4px; }
  .feed-col { gap: 4px; }
  .feed-bar { padding: 8px 8px 2px; }
  .tile { margin-bottom: 4px; border-radius: 4px; }
  .tile .tile-meta { opacity: 1; padding-top: 24px; font-size: 11px; }
  .composer { bottom: calc(8px + var(--tab-h) + var(--safe-b)); width: calc(100vw - 16px); border-radius: 22px; padding: 12px; grid-template-columns: 1fr; gap: 10px; }
  .ref, .ref-add { width: 48px; height: 48px; border-radius: 10px; }
  .prompt { min-height: 40px; max-height: 24vh; }
  .chip, .stepper { height: 36px; font-size: 13px; }
  .stepper button { height: 36px; width: 32px; }
  .gen-col { flex-direction: row; align-items: center; }
  .gen-btn { width: auto; flex: 1; min-height: 50px; flex-direction: row; gap: 12px; font-size: 16px; border-radius: 14px; }
  .cost-note { max-width: 44%; text-align: left; }
  /* collapsed: prompt + model/provider stay reachable */
  .composer.min .refs, .composer.min .modes { display: none; }
  .composer.min .chips > :not(.model):not(.prov) { display: none; }
  .composer.min .prompt { max-height: 44px; }
  .composer .collapse { display: block; position: absolute; top: -12px; left: 50%; transform: translateX(-50%); width: 44px; height: 22px; border-radius: 11px; background: var(--surface-3); border: 1px solid var(--border); font-size: 11px; color: var(--muted); }
}

/* ───── Menus / sheets / modals ───── */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.5); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.menu { position: fixed; z-index: 70; min-width: 220px; max-width: 360px; max-height: calc(100vh - 16px); overflow-y: auto; background: var(--menu-bg); border: 1px solid var(--border); border-radius: 16px; padding: 6px; box-shadow: 0 16px 50px rgba(0,0,0,.6); -webkit-overflow-scrolling: touch; }
.menu .mh { padding: 8px 12px 6px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.menu button.opt { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 16px; padding: 8px 12px; border-radius: 10px; text-align: left; font-weight: 500; }
.menu button.opt:hover { background: var(--surface-3); }
.menu button.opt.on { color: var(--accent); }
.menu .opt small { color: var(--muted); font-weight: 500; }
.menu.aspect-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; min-width: 300px; }
.menu.aspect-grid .mh { grid-column: 1 / -1; }
.menu.aspect-grid .opt { flex-direction: column; justify-content: center; gap: 6px; font-size: 12px; padding: 10px 4px; }
.ar-box { border: 1.5px solid currentColor; border-radius: 3px; opacity: .8; }

.sheet { position: fixed; z-index: 70; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(760px, calc(100vw - 32px)); max-height: min(86vh, 900px); display: flex; flex-direction: column; background: var(--sheet-bg); border: 1px solid var(--border); border-radius: 22px; box-shadow: 0 30px 90px rgba(0,0,0,.7); overflow: hidden; }
.sheet.wide { width: min(1100px, calc(100vw - 32px)); }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.sheet-head h3 { margin: 0; font-size: 17px; flex: 1; }
.sheet-body { padding: 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 14px 18px calc(14px + var(--safe-b)); border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.grabber { display: none; }
@media (max-width: 760px) {
  .menu { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; max-width: none; width: 100%; max-height: 70vh; border-radius: 22px 22px 0 0; padding: 8px 8px calc(12px + var(--safe-b)); }
  .menu.aspect-grid { min-width: 0; }
  .sheet, .sheet.wide { top: auto; bottom: 0; left: 0; transform: none; width: 100%; max-height: 92dvh; border-radius: 22px 22px 0 0; }
  .grabber { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 8px auto 0; }
}

/* model picker */
.msearch { margin-bottom: 14px; }
.mgroup h4 { margin: 18px 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.mgroup h4:first-child { margin-top: 0; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.mcard { position: relative; text-align: left; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid transparent; display: grid; gap: 4px; }
.mcard:hover { border-color: var(--border-strong); }
.mcard.on { border-color: var(--accent); background: var(--accent-soft); }
.mcard b { font-size: 14px; padding-right: 26px; }
.mcard .sub { font-size: 12px; color: var(--muted); }
.mcard .from { font-size: 12px; color: var(--accent); font-weight: 600; }
.star { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--faint); font-size: 16px; }
.star.on { color: var(--gold); }
.star:hover { background: var(--surface-3); }

/* confirm cost */
.cost-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cost-table td { padding: 9px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.cost-table td:last-child { text-align: right; white-space: nowrap; padding-left: 16px; }
.cost-table tr.total td { border: 0; font-weight: 700; font-size: 17px; padding-top: 14px; }
.cost-table tr.total td:last-child { color: var(--accent); }
.big-cost { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.big-cost b { font-size: 34px; letter-spacing: -.02em; color: var(--accent); }

/* lightbox */
.lightbox { display: grid; grid-template-columns: 1fr 360px; gap: 0; max-height: inherit; }
.lightbox .media { background: #000; display: grid; place-items: center; min-height: 300px; max-height: 86vh; }
.lightbox .media img, .lightbox .media video { max-height: 86vh; width: auto; object-fit: contain; }
.lightbox .info { padding: 18px; overflow-y: auto; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.lightbox .prompt-box { background: var(--surface-2); border-radius: 12px; padding: 12px; font-size: 13.5px; max-height: 220px; overflow-y: auto; white-space: pre-wrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; word-break: break-all; }
@media (max-width: 860px) {
  .lightbox { grid-template-columns: 1fr; overflow-y: auto; }
  .lightbox .media { max-height: 55dvh; }
  .lightbox .media img, .lightbox .media video { max-height: 55dvh; }
  .lightbox .info { border-left: 0; overflow: visible; padding-bottom: calc(18px + var(--safe-b)); }
}

/* ───── Library ───── */
.lib { display: grid; grid-template-columns: 230px 1fr; gap: 24px; }
.lib-side { position: sticky; top: calc(var(--top-h) + 20px); align-self: start; display: grid; gap: 2px; }
.lib-side .sec { font-size: 11.5px; color: var(--faint); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 16px 12px 6px; }
.lib-side button { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; text-align: left; width: 100%; }
.lib-side button:hover { color: var(--text); background: var(--surface); }
.lib-side button.on { background: var(--surface-2); color: var(--text); }
.lib-side .count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.lib-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.lib-tools .input { flex: 1 1 220px; }
.lib-tools .select { width: auto; flex: 0 0 auto; }
.lib-grid { display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); gap: 10px; }
.day { margin: 22px 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.day:first-child { margin-top: 0; }
.lcard { position: relative; border-radius: 12px; overflow: hidden; background: var(--surface); aspect-ratio: 1; cursor: pointer; border: 2px solid transparent; }
.lcard img, .lcard video { width: 100%; height: 100%; object-fit: cover; }
.lcard.sel { border-color: var(--accent); }
.lcard .badges { position: absolute; top: 7px; left: 7px; display: flex; gap: 4px; }
.lcard .badges span { font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: rgba(0,0,0,.65); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.lcard .badges .exp { color: var(--gold); }
.lcard .check { position: absolute; top: 7px; right: 7px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.35); display: none; }
.selecting .lcard .check { display: block; }
.lcard.sel .check { background: var(--accent); border-color: var(--accent); }
.lcard .cap { position: absolute; inset: auto 0 0; padding: 22px 9px 7px; font-size: 11.5px; background: linear-gradient(transparent, rgba(0,0,0,.8)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcard.audio-card { display: grid; place-items: center; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface)); font-size: 34px; }
.bulkbar { position: fixed; z-index: 35; left: 50%; transform: translateX(-50%); bottom: calc(20px + var(--tab-h) + var(--safe-b)); display: flex; gap: 8px; align-items: center; padding: 8px 8px 8px 16px; border-radius: 16px; background: var(--toast-bg); border: 1px solid var(--border); box-shadow: 0 16px 50px rgba(0,0,0,.6); max-width: calc(100vw - 24px); overflow-x: auto; }
.lib-mobile-filter { display: none; }
@media (max-width: 860px) {
  .lib { grid-template-columns: 1fr; }
  .lib-side { display: none; }
  .lib-mobile-filter { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; }
  .lib-mobile-filter::-webkit-scrollbar { display: none; }
  .lib-mobile-filter button { flex: 0 0 auto; padding: 7px 13px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--muted); }
  .lib-mobile-filter button.on { background: var(--text); color: var(--bg); }
  .lib-grid { gap: 3px; }
  .lcard { border-radius: 4px; }
  .lcard .cap { display: none; }
}


/* ───── Models page ───── */
.model-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.mtile { position: relative; padding: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); display: grid; gap: 8px; }
.mtile h3 { margin: 0; font-size: 16px; padding-right: 30px; }
.mtile .price-line { font-size: 13px; color: var(--accent); font-weight: 600; }
.mtile .actions { display: flex; gap: 8px; margin-top: 4px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface); position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; }
table.data tr:hover td { background: var(--hover-tint); }
table.data .best { color: var(--accent); font-weight: 700; }
table.data .worse { color: var(--muted); }
table.data input.cell { width: 90px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 5px 8px; font-size: 14px; text-align: right; }
.save-badge { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 2px 6px; margin-left: 6px; }

/* ───── Compare ───── */
.comp-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.comp-links a { display: flex; flex-direction: column; gap: 3px; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.comp-links a:hover { border-color: var(--border-strong); }
.comp-links a b::after { content: ' ↗'; color: var(--muted); font-weight: 400; }
.comp-links small { color: var(--muted); font-size: 12px; }

/* ───── LLM hub ───── */
.code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px; overflow-x: auto; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.55; white-space: pre; color: var(--code-text); max-height: 360px; }
.steps { counter-reset: s; display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.job-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.job-row:last-child { border-bottom: 0; }
.job-row .err { color: var(--danger); font-size: 13px; }

/* ───── Toasts ───── */
.toasts { position: fixed; z-index: 90; top: calc(var(--top-h) + var(--safe-t) + 10px); right: 16px; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { padding: 12px 14px; border-radius: 12px; background: var(--toast-bg); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.5); font-size: 14px; animation: tin .2s ease-out; }
.toast.err { border-color: rgba(255,93,93,.4); }
.toast.ok { border-color: rgba(83,217,139,.4); }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } }
@media (max-width: 760px) { .toasts { left: 16px; right: 16px; max-width: none; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ───── item actions (hover buttons + ⋯ menu) ───── */
.tile-actions { position: absolute; top: 8px; right: 8px; z-index: 3; display: flex; flex-direction: column; gap: 6px; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-actions, .lcard:hover .tile-actions, .tile-actions:focus-within { opacity: 1; }
.ta { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(20,20,22,.72); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: #fff; border: 1px solid rgba(255,255,255,.08); }
.ta svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ta.more svg { fill: currentColor; stroke: none; }
.ta:hover { background: rgba(40,40,44,.9); }
.ta.on { color: #ff5d7a; }
.ta.on svg { fill: currentColor; }
.tile:hover .fav-dot { opacity: 0; }
.fav-dot { color: #ff5d7a; }
.selecting .tile-actions { display: none; }
.tile.failed { position: relative; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 8px; }
.menu .opt.danger { color: var(--danger); }
.menu .mh { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: none; letter-spacing: 0; font-size: 12.5px; }
/* touch screens: no hover — keep only the ⋯ button, always visible */
@media (hover: none) {
  .tile-actions { opacity: 1; top: 6px; right: 6px; }
  .tile-actions .ta:not(.more) { display: none; }
  .ta { width: 30px; height: 30px; }
  .fav-dot { right: 42px; }
}

/* ───── grid-size slider ───── */
.grid-ctl { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); flex: 0 0 auto; }
.grid-ctl svg { fill: none; stroke: currentColor; stroke-width: 1.8; }
.grid-ctl input[type=range] { width: 110px; accent-color: var(--accent); height: 28px; margin: 0; }
@media (max-width: 760px) { .grid-ctl input[type=range] { width: 90px; } }

/* library: never wider than the screen */
.lib > div { min-width: 0; }
@media (max-width: 760px) {
  .lib-tools .input { flex: 1 1 100%; }
  .lib-tools .select { flex: 1 1 0; min-width: 0; }
  .lib-tools .grid-ctl { flex: 1 1 100%; justify-content: center; }
  .lib-tools .grid-ctl input[type=range] { flex: 1; width: auto; }
}

/* ───── model picker: All · Budget · Premium ───── */
.picker-top { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.picker-top .msearch { margin: 0; flex: 1 1 240px; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); flex: 0 0 auto; }
.seg button { padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--surface-3); color: var(--text); }
.seg button[data-tier=budget].on { color: var(--ok); }
.seg button[data-tier=premium].on { color: var(--gold); }
.tier-sum { display: flex; justify-content: space-between; align-items: center; gap: 10px 20px; flex-wrap: wrap; padding: 12px 14px; border-radius: 14px; margin-bottom: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; }
.tier-sum.budget { border-color: rgba(83,217,139,.35); }
.tier-sum.premium { border-color: rgba(232,197,95,.4); }
.tier-range { font-weight: 700; font-variant-numeric: tabular-nums; }
.mcard .typ { font-size: 12px; color: var(--text); }
.mcard .typ b { color: var(--accent); }
@media (max-width: 760px) { .seg { width: 100%; } .seg button { flex: 1; padding: 8px 6px; } }

/* ───── providers ───── */
.prov-badge { --pc: #9aa0a6; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; font-size: 12px; font-weight: 800; line-height: 1;
  color: #0b0b0c; background: var(--pc); box-shadow: 0 0 0 1px rgba(0,0,0,.25); flex: 0 0 auto; vertical-align: -5px; font-family: var(--font); }
.prov-badge.sm { width: 18px; height: 18px; font-size: 10.5px; border-radius: 6px; vertical-align: -4px; }
.prov-badge.xs { width: 15px; height: 15px; font-size: 9px; border-radius: 5px; vertical-align: -3px; }
.prov-badge.lg { width: 34px; height: 34px; font-size: 17px; border-radius: 10px; }
.prov-badge.on-tile { position: absolute; left: 8px; bottom: 8px; z-index: 2; width: 22px; height: 22px; opacity: .92; box-shadow: 0 2px 8px rgba(0,0,0,.45), 0 0 0 1.5px rgba(255,255,255,.5); }
.tile:hover .prov-badge.on-tile { opacity: 0; }
.lcard .prov-badge.on-tile { bottom: 30px; }
@media (max-width: 860px) { .lcard .prov-badge.on-tile { bottom: 6px; left: 6px; width: 18px; height: 18px; font-size: 10px; } }
.mcard .routes { display: flex; gap: 4px; align-items: center; }
.mcard .routes .off { opacity: .3; filter: grayscale(1); }
.chip.prov { gap: 8px; }
.best-tag { color: var(--ok) !important; font-weight: 700; margin-left: 4px; }
.cost-table .via { font-size: 12px; }
.balance.warn .dot { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.balance .prov-badge { margin-right: 2px; }
.icon-btn.bell { position: relative; }
.icon-btn.bell.has { color: var(--gold); }
.bell-count { position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; line-height: 16px; text-align: center; }
.bell-count:empty { display: none; }
.alert-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; font-size: 13.5px; line-height: 1.4; }
.alert-row.low, .alert-row.runway { color: var(--gold); }
.alert-row.error { color: var(--muted); }
.pv-total { margin: 4px 0 14px; font-size: 14px; }
.pv-list { display: grid; gap: 12px; }
.pv-box { border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: var(--surface-2); display: grid; gap: 10px; }
.pv-box.on { border-color: rgba(83,217,139,.28); }
.pv-head { display: flex; gap: 12px; align-items: center; }
.pv-title { display: grid; flex: 1; min-width: 0; }
.pv-title .muted { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-status { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.ok-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pv-bal { font-size: 13.5px; }
.pv-alert { color: var(--gold); margin-top: 4px; font-size: 13px; }
.pv-alert.error { color: var(--muted); }
.pv-key { flex-wrap: nowrap; }
.pv-key .input { flex: 1; min-width: 0; }
.pv-manual, .pv-custom { gap: 8px; }
.pv-add { margin-top: 14px; }
.pv-add summary { list-style: none; cursor: pointer; }
.pv-add summary::-webkit-details-marker { display: none; }
@media (max-width: 760px) { .pv-key { flex-wrap: wrap; } .pv-key .input { flex: 1 1 100%; } }

/* ───── collections ───── */
.col-group { margin-bottom: 8px; }
.col-group h2 small { display: inline; }
.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.col-card { display: grid; grid-template-rows: auto auto; border-radius: 16px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); text-align: left; transition: border-color .15s, transform .1s; }
.col-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.col-card .cover { aspect-ratio: 1; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.col-card .cover img, .col-card .cover video { width: 100%; height: 100%; object-fit: cover; }
.col-card .ph { font-size: 38px; opacity: .6; }
.col-card .meta { padding: 10px 12px; display: grid; gap: 2px; font-size: 13.5px; }
.col-card .meta .muted { font-size: 12px; }
.col-card.new { border-style: dashed; place-items: center; align-content: center; gap: 6px; aspect-ratio: auto; min-height: 170px; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.col-card.new .plus { font-size: 30px; line-height: 1; color: var(--accent); }
.col-card.new:hover { color: var(--text); }
.el-tag { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; }
.back-link { display: inline-block; margin-bottom: 14px; font-size: 14px; }
.col-head { display: grid; grid-template-columns: 180px 1fr; gap: 22px; align-items: start; margin-bottom: 22px; }
.col-hero { aspect-ratio: 1; border-radius: 18px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.col-hero img, .col-hero video { width: 100%; height: 100%; object-fit: cover; }
.col-hero .ph { font-size: 56px; opacity: .6; }
.col-info h1 { margin: 2px 0 2px; font-size: 26px; letter-spacing: -.02em; }
.el-edit { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.el-edit .input { width: 170px; padding: 7px 10px; }
.cover-btn { position: absolute; left: 8px; top: 8px; z-index: 3; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 8px; background: rgba(0,0,0,.6); color: #fff; opacity: 0; transition: opacity .15s; }
.cover-btn.on { color: var(--gold); opacity: 1; }
.lcard:hover .cover-btn { opacity: 1; }
@media (hover: none) { .cover-btn { opacity: 1; } }
.lib-side .sec { display: flex; justify-content: space-between; align-items: center; }
.sec-link { color: var(--accent); text-transform: none; letter-spacing: 0; font-weight: 600; }
.menu .mh.sub { padding-top: 10px; text-transform: none; letter-spacing: 0; }
.ref-el { flex: 0 0 auto; height: 60px; padding: 0 12px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; border: 1px dashed color-mix(in srgb, var(--accent) 35%, transparent); }
.el-thumb { width: 22px; height: 22px; border-radius: 6px; object-fit: cover; vertical-align: -6px; margin-right: 8px; }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; color: var(--muted); font-weight: 500; }
.tabbar button.active { color: var(--accent); }
@media (max-width: 760px) {
  .col-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .col-head { grid-template-columns: 96px 1fr; gap: 14px; }
  .col-info h1 { font-size: 21px; }
  .ref-el { height: 48px; }
}

/* ═════════════ THEMES (Settings → Appearance) ═════════════
   default = "Noir" (original lime). Others are original palettes — none reuse Higgsfield's lime-on-black look. */
html[data-theme="aurora"] {
  --bg: #080a12; --surface: #10131f; --surface-2: #171b2b; --surface-3: #20253a; --border: #252b42; --border-strong: #3a4263;
  --text: #eef1ff; --muted: #8b93b5; --faint: #5a6288;
  --accent: #7cc4ff; --accent-2: #a78bfa; --accent-ink: #070912; --accent-soft: rgba(124,196,255,.13);
  --gold: #f5c56b; --ok: #4ade9b; --danger: #ff6b8a;
  --bar-bg: rgba(8,10,18,.82); --menu-bg: #141829; --sheet-bg: #0f1220; --toast-bg: #181d30; --code-bg: #0a0d18;
  --glass-a: rgba(40,48,86,.34); --glass-b: rgba(10,12,24,.55); --glass-border: rgba(160,180,255,.18); --glass-hi: rgba(180,200,255,.12);
  --gen-bg: linear-gradient(135deg, #7cc4ff, #a78bfa);
}
html[data-theme="ember"] {
  --bg: #0f0b0a; --surface: #181211; --surface-2: #221917; --surface-3: #2d211e; --border: #342622; --border-strong: #4d3830;
  --text: #fbf1ec; --muted: #b09a90; --faint: #7a655c;
  --accent: #ff8a5b; --accent-2: #ffc56b; --accent-ink: #160b07; --accent-soft: rgba(255,138,91,.13);
  --gold: #ffcf6b; --ok: #6ee7a0; --danger: #ff5f6d;
  --bar-bg: rgba(15,11,10,.82); --menu-bg: #1f1715; --sheet-bg: #171110; --toast-bg: #251b18; --code-bg: #120d0c;
  --glass-a: rgba(70,40,30,.32); --glass-b: rgba(20,12,10,.55); --glass-border: rgba(255,190,160,.16); --glass-hi: rgba(255,210,190,.10);
  --gen-bg: linear-gradient(135deg, #ff8a5b, #ffc56b);
}
html[data-theme="mint"] {
  --bg: #07100e; --surface: #0e1917; --surface-2: #14221f; --surface-3: #1b2d29; --border: #1f3430; --border-strong: #2f4d47;
  --text: #ecfbf6; --muted: #86a8a0; --faint: #557a72;
  --accent: #3ef0b0; --accent-2: #7cf7e4; --accent-ink: #04120d; --accent-soft: rgba(62,240,176,.12);
  --gold: #f2d36b; --ok: #3ef0b0; --danger: #ff6b6b;
  --bar-bg: rgba(7,16,14,.82); --menu-bg: #12201d; --sheet-bg: #0d1816; --toast-bg: #162723; --code-bg: #081210;
  --glass-a: rgba(30,70,60,.30); --glass-b: rgba(6,16,14,.55); --glass-border: rgba(140,255,220,.16); --glass-hi: rgba(160,255,230,.10);
  --gen-bg: linear-gradient(135deg, #3ef0b0, #7cf7e4);
}
html[data-theme="paper"] {
  color-scheme: light;
  --bg: #f5f4f0; --surface: #ffffff; --surface-2: #efeee9; --surface-3: #e5e3dc; --border: #dedbd2; --border-strong: #c4c0b4;
  --text: #16161a; --muted: #62606a; --faint: #99968d;
  --accent: #3b5bfd; --accent-2: #8a5cff; --accent-ink: #ffffff; --accent-soft: rgba(59,91,253,.10);
  --gold: #b07a00; --ok: #11875a; --danger: #d63a4a;
  --bar-bg: rgba(245,244,240,.86); --hairline: rgba(0,0,0,.07); --menu-bg: #ffffff; --sheet-bg: #fbfaf7; --toast-bg: #ffffff; --code-bg: #f1efe9; --code-text: #2a2a30; --hover-tint: rgba(0,0,0,.025);
  --glass-a: rgba(255,255,255,.45); --glass-b: rgba(255,255,255,.62); --glass-border: rgba(0,0,0,.10); --glass-hi: rgba(255,255,255,.8);
  --glass-chip: rgba(0,0,0,.05); --glass-chip-hover: rgba(0,0,0,.09); --on-glass-muted: rgba(20,20,26,.5); --on-glass-soft: rgba(20,20,26,.7);
  --gen-bg: linear-gradient(135deg, #3b5bfd, #8a5cff);
}
html[data-theme="paper"] .composer .prompt { text-shadow: none; }
html[data-theme="paper"] .overlay { background: rgba(20,20,26,.28); }
html[data-theme="paper"] .composer { box-shadow: 0 20px 60px rgba(0,0,0,.14), inset 0 1px 0 var(--glass-hi); }
html[data-theme="paper"] .toast, html[data-theme="paper"] .menu, html[data-theme="paper"] .sheet { box-shadow: 0 16px 50px rgba(0,0,0,.14); }
/* gradient accents (buttons + logo) */
.gen-btn { color: var(--accent-ink); }
.brand-mark .bm-bg { fill: url(#bmGrad); }
/* theme picker */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.theme-card { border-radius: 14px; border: 2px solid var(--border); padding: 10px; text-align: left; display: grid; gap: 8px; background: var(--surface-2); }
.theme-card.on { border-color: var(--accent); }
.theme-card .sw { height: 56px; border-radius: 10px; position: relative; overflow: hidden; }
.theme-card .sw i { position: absolute; bottom: 8px; right: 8px; width: 44px; height: 18px; border-radius: 6px; }
.theme-card .sw b { position: absolute; top: 8px; left: 8px; width: 60%; height: 8px; border-radius: 4px; opacity: .5; }
.theme-card span { font-weight: 700; font-size: 13.5px; }
.theme-card small { color: var(--muted); font-size: 12px; }

/* prompt box: frosted glass only once the feed is scrolled, solid again while typing */
.composer.glass:not(:focus-within) { background: linear-gradient(180deg, var(--glass-a), var(--glass-b)); backdrop-filter: blur(14px) saturate(170%); -webkit-backdrop-filter: blur(14px) saturate(170%); }
.composer:not(.glass) .chip, .composer:not(.glass) .stepper, .composer:not(.glass) .ref-add, .composer:not(.glass) .modes button.on,
.composer:focus-within .chip, .composer:focus-within .stepper, .composer:focus-within .ref-add { background: var(--surface-2); border-color: var(--hairline); backdrop-filter: none; -webkit-backdrop-filter: none; }
.composer:not(.glass) .prompt, .composer:focus-within .prompt { text-shadow: none; }
.composer:not(.glass) .prompt::placeholder, .composer:focus-within .prompt::placeholder { color: var(--faint); }
.composer:not(.glass) .ref-hint, .composer:not(.glass) .cost-note { color: var(--muted); }
.composer .cost-note.warn { color: var(--gold); }

/* feed toolbar toggles */
.feed-tools { display: flex; align-items: center; gap: 8px; }
.tgl { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 13px; font-weight: 600; }
.tgl svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tgl#tglVideo svg { fill: currentColor; stroke: none; }
.tgl.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }
@media (max-width: 760px) { .feed-bar { gap: 8px; } .feed-tools { gap: 6px; } .tgl { height: 32px; padding: 0 10px; } .tgl span { display: none; } .tgl#tglVideo span { display: inline; } .feed-tools .grid-ctl input[type=range] { width: 70px; } }

/* provider logo: hidden unless "Logos" is on; sits right under the ⋯ circle, subtle */
.prov-badge.on-tile { display: none; left: auto; bottom: auto; top: 50px; right: 14px; width: 20px; height: 20px; font-size: 11px; opacity: .55; box-shadow: 0 1px 6px rgba(0,0,0,.4); }
html.show-badges .prov-badge.on-tile { display: grid; }
.lcard .prov-badge.on-tile { bottom: auto; }
.tile:hover .prov-badge.on-tile, .lcard:hover .prov-badge.on-tile { opacity: 0; }
@media (hover: none) { .prov-badge.on-tile { top: 42px; right: 12px; width: 18px; height: 18px; font-size: 10px; } .tile:hover .prov-badge.on-tile, .lcard:hover .prov-badge.on-tile { opacity: .55; } }
@media (max-width: 860px) { .lcard .prov-badge.on-tile { bottom: auto; left: auto; } }

/* no page pinch-zoom on phones; the image viewer has its own zoom */
html { touch-action: pan-x pan-y; }
.zoomable { touch-action: none; overflow: hidden; cursor: zoom-in; }
.zoomable.zoomed { cursor: grab; }
.zoomable img { transition: transform .05s linear; transform-origin: center center; will-change: transform; user-select: none; -webkit-user-drag: none; }

/* collections: detail grid follows its own slider; bigger thumbnails on phones */
.col-items-bar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
@media (max-width: 760px) {
  .col-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .col-card .cover { aspect-ratio: 4 / 5; }
  .col-card .meta { font-size: 14px; }
  .col-head { grid-template-columns: 1fr; }
  .col-hero { max-width: 240px; aspect-ratio: 4 / 5; }
  .col-items { gap: 6px; }
}

/* typing on a phone: full compose view that exactly fills the space above the keyboard */
@media (max-width: 760px) {
  html.kb-open, html.kb-open body { overflow: hidden; overscroll-behavior: none; }
  html.kb-open .tabbar { display: none; }
  html.kb-open .composer {
    position: fixed; z-index: 80; left: 0; right: 0; top: var(--vvt, 0px); bottom: auto; transform: none;
    width: 100%; height: var(--vvh, 60vh); border-radius: 0; border: 0; margin: 0;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 14px 10px;
    display: flex; flex-direction: column; gap: 10px;
    background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; transition: none;
  }
  html.kb-open .composer .composer-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
  html.kb-open .composer .modes, html.kb-open .composer .refs, html.kb-open .composer .collapse, html.kb-open .composer .cost-note { display: none; }
  html.kb-open .composer .prompt { flex: 1 1 0; min-height: 0; max-height: none; height: auto !important; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  html.kb-open .composer .chips { flex: 0 0 auto; }
  html.kb-open .composer .gen-col { flex: 0 0 auto; }
  html.kb-open .gen-btn { min-height: 46px; }
}
}

/* the prompt box never hands its swipes to the page behind */
.composer, .composer .prompt { overscroll-behavior: contain; }
.composer .chips, .composer .refs { overscroll-behavior-x: contain; }

/* ═════════════ TOFUPI (default brand theme) ═════════════
   ink black · tofu cream · chili pink → soy lilac */
html[data-theme="tofupi"] {
  --bg: #0b0b0c; --surface: #141416; --surface-2: #1c1c1f; --surface-3: #242428; --border: #2a2a2f; --border-strong: #3a3a41;   /* same neutral blacks as Classic lime */
  --text: #fbf6ef; --muted: #a1a1aa; --faint: #6b6b74;
  --accent: #ff7ab6; --accent-2: #a58bff; --accent-ink: #1a0f16; --accent-soft: rgba(255,122,182,.12);
  --gold: #ffc978; --ok: #62e3a6; --danger: #ff5d6c;
  --bar-bg: rgba(11,11,12,.82); --menu-bg: #1b1b1e; --sheet-bg: #151517; --toast-bg: #202024; --code-bg: #0f0f11;
  --glass-a: rgba(40,40,46,.38); --glass-b: rgba(18,18,21,.52); --glass-border: rgba(255,255,255,.14); --glass-hi: rgba(255,255,255,.10);
  --gen-bg: linear-gradient(135deg, #ff7ab6, #a58bff);
}
html[data-theme="tofupi-light"] {
  color-scheme: light;
  --bg: #fbf6ef; --surface: #ffffff; --surface-2: #f4eee6; --surface-3: #ebe3d8; --border: #e6ddd1; --border-strong: #cfc3b3;
  --text: #1d1622; --muted: #6b6273; --faint: #a39aa6;
  --accent: #e8488f; --accent-2: #7b61ff; --accent-ink: #ffffff; --accent-soft: rgba(232,72,143,.10);
  --gold: #b07a00; --ok: #11875a; --danger: #d63a4a;
  --bar-bg: rgba(251,246,239,.86); --hairline: rgba(0,0,0,.07); --menu-bg: #ffffff; --sheet-bg: #fffcf8; --toast-bg: #ffffff; --code-bg: #f4eee6; --code-text: #2a2230; --hover-tint: rgba(0,0,0,.025);
  --glass-a: rgba(255,255,255,.45); --glass-b: rgba(255,250,244,.62); --glass-border: rgba(0,0,0,.10); --glass-hi: rgba(255,255,255,.8);
  --glass-chip: rgba(0,0,0,.05); --glass-chip-hover: rgba(0,0,0,.09); --on-glass-muted: rgba(29,22,34,.5); --on-glass-soft: rgba(29,22,34,.7);
  --gen-bg: linear-gradient(135deg, #e8488f, #7b61ff);
}
html[data-theme="tofupi-light"] .composer .prompt { text-shadow: none; }
html[data-theme="tofupi-light"] .overlay { background: rgba(29,22,34,.28); }
/* brand wordmark */
.brand .wordmark { font-family: "Fredoka", ui-rounded, "SF Pro Rounded", system-ui, sans-serif; font-weight: 600; font-size: 20px; letter-spacing: -.01em; }
.brand .wordmark .dot { color: var(--accent); }
.brand img.brand-cube { width: 30px; height: 30px; filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--accent) 35%, transparent)); }

/* settings inbox */
.inbox-row { padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); margin-top: 10px; }
.inbox-row.new { border-color: var(--accent); }
.inbox-row p { font-size: 14px; }

/* ───── header balance: credits + $ ───── */
.bal-slide { display: inline-flex; gap: 6px; align-items: center; }
.bal-slide .usd { color: var(--muted); }
.bal-slide .usd::before { content: "· "; }
.bal-slide .dup, .balance .lbl-short { display: none; }
@media (max-width: 760px) {
  .top-right { gap: 2px; }
  .top-right .icon-btn { width: 34px; height: 34px; }
  .balance { padding: 5px 10px 5px 9px; gap: 6px; font-size: 12.5px; max-width: 118px; overflow: hidden; }
  .balance .lbl-long, .balance .bal-apis { display: none; }
  .balance .lbl-short { display: inline; }
  /* credits and dollars take turns, sliding up inside the pill */
  .bal-slide { display: block; height: 18px; overflow: hidden; min-width: 0; }
  .bal-slide > span { display: flex !important; align-items: center; gap: 4px; height: 18px; line-height: 18px; white-space: nowrap; animation: balSlide 7s cubic-bezier(.7, 0, .3, 1) infinite; }
  .bal-slide .usd::before { content: none; }
  .bal-slide.one > span { animation: none; }
}
@keyframes balSlide { 0%, 42% { transform: translateY(0); } 50%, 92% { transform: translateY(-100%); } 100% { transform: translateY(-200%); } }

/* (the old power mode styles were removed: its behavior now lives in the Premium tier) */
@media (prefers-reduced-motion: reduce) { .bal-slide > span { animation: none; } }


/* ───── Workflows ───── */
.wf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.wf-card { border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--border); cursor: pointer; transition: transform .2s, border-color .2s; }
.wf-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.wf-cover { aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.wf-cover img, .wf-cover video { width: 100%; height: 100%; object-fit: cover; }
.wf-cover .ph, .wfb-style .ph { font-size: 34px; opacity: .8; }
.wf-info { padding: 12px 14px 14px; display: grid; gap: 6px; }
.wf-steps { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.wf-steps span { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--faint); border: 1px solid transparent; }
.wf-steps span.done { color: var(--text); }
.wf-steps span.cur { border-color: var(--accent); color: var(--accent); }
.wf-empty { max-width: 620px; }

.wf-bar { padding: 12px 12px 4px; display: grid; gap: 10px; }
.wf-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wf-back { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 24px; background: var(--surface-2); color: var(--muted); }
.wf-title { display: grid; line-height: 1.25; margin-right: auto; min-width: 0; }
.wf-title b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-title span { font-size: 12.5px; }
.wf-stages { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.wf-stages::-webkit-scrollbar { display: none; }
.wf-stages button { flex: 0 0 auto; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
.wf-stages button i { font-style: normal; display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--surface-3); font-size: 10.5px; margin-right: 3px; }
.wf-stages button.cur { border-color: var(--accent); color: var(--text); }
.wf-stages button.cur i { background: var(--accent); color: var(--accent-ink); }
.wf-stages button.on { background: var(--surface-3); color: var(--text); }
.wf-hint { padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); display: grid; gap: 8px; }
.wf-hint-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.wf-hint-h > span { margin-right: auto; }
.wf-hint-h b { color: var(--text); }
.wf-hint-t { font-size: 13.5px; line-height: 1.6; }
.wf-hint .slot, .slot { background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 0 5px; font-weight: 600; }
.wf-lock-note { font-size: 12px; color: var(--faint); }
.lcard-wf { position: absolute; left: 6px; bottom: 6px; right: 6px; font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: rgba(0,0,0,.65); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-h { margin: 4px 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.pick-h:not(:first-child) { margin-top: 18px; }

/* new-workflow builder */
.wfb h4 { margin: 4px 0 10px; font-size: 14px; }
.wfb h4:not(:first-child) { margin-top: 20px; }
.wfb-gh { font-size: 12.5px; margin: 8px 0 6px; }
.wfb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.wfb-grid.formats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.wfb-style, .wfb-format { text-align: left; border-radius: 14px; background: var(--surface); border: 2px solid var(--border); overflow: hidden; display: grid; color: var(--text); }
.wfb-style .th { aspect-ratio: 4 / 3; display: grid; place-items: center; background: var(--surface-2); overflow: hidden; }
.wfb-style .th img { width: 100%; height: 100%; object-fit: cover; }
.wfb-style b { padding: 8px 10px; font-size: 13px; }
.wfb-format { padding: 12px; gap: 4px; }
.wfb-format small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.wfb-style.on, .wfb-format.on { border-color: var(--accent); }
@media (max-width: 760px) {
  .wf-bar { padding: 10px 10px 2px; }
  .wf-top .tgl { font-size: 12px; }
  .wfb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.wf-empty-art { width: 64px; height: 64px; margin: 0 auto 12px; display: block; animation: wfBob 2.6s ease-in-out infinite; }
@keyframes wfBob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
.wf-empty-feed h1 em { font-style: normal; color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .wf-empty-art { animation: none; } }
.wf-empty .wf-empty-art { margin-left: 0; }

.wfb-custom { display: grid; gap: 8px; margin-top: 10px; }
.brief-pre { white-space: pre-wrap; max-height: 46vh; overflow: auto; font-size: 12.5px; line-height: 1.55; margin: 12px 0 0; }

.wfb-custom { display: grid; gap: 8px; margin-top: 10px; }
.brief-pre { white-space: pre-wrap; max-height: 46vh; overflow: auto; font-size: 12.5px; line-height: 1.55; margin: 12px 0 0; }

.route-prov { padding: 10px 0; border-top: 1px solid var(--border); }
.route-bad { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13.5px; }
.route-bad .why { color: var(--gold); font-size: 12.5px; }
.route-bad.unclear .why { color: var(--muted); }

/* storage */
.st-bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 10px 0 8px; }
.st-bar i { display: block; height: 100%; border-radius: 99px; background: var(--gen-bg, var(--accent)); transition: width .6s; }
.st-bar.warn i { background: var(--gold); }
.st-bar.full i { background: var(--danger); }
.st-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); }
.st-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: 0; }
.k-up { background: #cfc8d8; } .k-keep { background: var(--accent); } .k-tmp { background: var(--faint); }
.st-rules { margin: 12px 0 14px; padding-left: 18px; display: grid; gap: 5px; font-size: 13px; }

/* accounts */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.auth-page { max-width: 440px; padding-top: 8vh; }
.auth-card { padding: 28px; text-align: left; }
.auth-logo { display: block; margin: 0 auto 14px; }
.auth-tabs { width: 100%; margin-bottom: 16px; display: flex; }
.auth-tabs button { flex: 1; }
.auth-card h1 { margin: 0 0 6px; font-size: 24px; }
.auth-card > p.muted { margin: 0 0 18px; font-size: 14px; }
.auth-agree { gap: 10px; align-items: flex-start; flex-wrap: nowrap; font-size: 13px; color: var(--muted); margin: 4px 0 16px; }
.auth-agree input { margin-top: 3px; }
.auth-agree a, .auth-foot a { color: var(--accent); }
.auth-foot { font-size: 13px; margin: 16px 0 0; text-align: center; }
.beta-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; font-size: 13px; background: color-mix(in srgb, var(--accent) 12%, var(--bg)); border-bottom: 1px solid var(--hairline); color: var(--text); }
.beta-bar a { color: var(--accent); text-decoration: underline; }
.beta-bar button { color: var(--muted); padding: 4px 8px; }
.acct-more { margin-top: 12px; font-size: 14px; }
.acct-more summary { cursor: pointer; color: var(--muted); }
.danger-zone { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpis.two { grid-template-columns: 1fr 1fr; margin-top: 12px; }
.kpi { display: grid; gap: 2px; }
.kpi b { font-size: 28px; letter-spacing: -.02em; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.spark i { flex: 1; min-height: 2px; background: var(--gen-bg, var(--accent)); border-radius: 3px 3px 0 0; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 10px; border-top: 1px solid var(--border); white-space: nowrap; }
.admin-table th { color: var(--muted); font-weight: 600; border-top: 0; }
@media (max-width: 760px) { .kpis { grid-template-columns: 1fr 1fr; } .kpis.two { grid-template-columns: 1fr; } .auth-page { padding-top: 3vh; } }

/* feed tiles reserve their shape before media loads (no jumping while generating) */
.tile.has-ar { aspect-ratio: var(--ar, 1); }
.tile.has-ar > img, .tile.has-ar > video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Sign in with Google */
.gsi-wrap { display: grid; justify-items: center; gap: 10px; margin: 4px 0 6px; }
.gsi-btn { width: 100%; display: flex; justify-content: center; min-height: 44px; }
.gsi-pending { font-size: 13.5px; color: var(--text); background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; text-align: center; width: 100%; }
.auth-or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--faint); font-size: 12.5px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Google renders its button in a light-mode frame; matching the frame's colour scheme keeps it transparent (no white box on dark pages) */
.gsi-btn, .gsi-btn iframe { color-scheme: light; }
.gsi-btn iframe { background: transparent !important; }

/* upscaler output targets */
.chip-group { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); flex: 0 0 auto; font-size: 13px; }
.chip.mini { padding: 4px 10px; min-height: 0; font-size: 12.5px; }
.chip.mini.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip.mini:disabled { opacity: .35; }
