:root {
  --ink: #14130f;
  --ink-2: #1f1d17;
  --ink-3: #2c2a21;
  --line: #3b382c;
  --paper: #f3eee0;
  --muted: #b4ad98;
  --signal: #ffc53d;
  --signal-ink: #1d1600;
  --bad: #ff9d7a;
  --display: 'Bricolage Grotesque', Georgia, serif;
  --body: 'Instrument Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ink); color: var(--paper); font: 400 17px/1.55 var(--body); overflow-x: hidden; }
a { color: var(--signal); }
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.04; letter-spacing: -.02em; margin: 0; text-wrap: balance; }
h2 { font-size: clamp(28px, 4.5vw, 42px); margin-bottom: 22px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

.mark { display: inline-block; width: 18px; height: 18px; margin-right: 8px; vertical-align: -2px; background: var(--signal); clip-path: polygon(0 0, 100% 50%, 0 100%); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1180px; margin: 0 auto; padding: 18px 20px; }
.brand { font: 800 22px/1 var(--display); color: var(--paper); text-decoration: none; letter-spacing: -.02em; white-space: nowrap; }
.top-nav { display: flex; align-items: center; gap: 20px; font-size: 15px; }
.top-nav a { color: var(--paper); text-decoration: none; }
.top-nav a:hover { color: var(--signal); }
.signout { margin: 0; }
.signout button { background: none; border: 0; padding: 0; color: var(--paper); font: inherit; cursor: pointer; }
.signout button:hover { color: var(--signal); }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: clamp(28px, 5vw, 72px); align-items: center; max-width: 1180px; margin: 0 auto; padding: clamp(28px, 6vw, 72px) 20px; }
.eyebrow { margin: 0 0 16px; color: var(--signal); font-weight: 600; font-size: 15px; }
h1 { font-size: clamp(46px, 7.4vw, 88px); }
.lede { margin: 22px 0 0; font-size: clamp(18px, 2vw, 21px); color: var(--muted); max-width: 30em; }

.composer { background: var(--ink-2); border: 1px solid var(--line); border-radius: 14px; padding: 18px; min-width: 0; }
.kind { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--ink); border-radius: 10px; margin-bottom: 14px; }
.kind input, .aspects input { position: absolute; opacity: 0; pointer-events: none; }
.kind span { display: block; text-align: center; padding: 10px; border-radius: 7px; font-weight: 600; cursor: pointer; color: var(--muted); transition: background .15s, color .15s; }
.kind input:checked + span { background: var(--signal); color: var(--signal-ink); }
.kind input:focus-visible + span, .aspects input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 2px; }
textarea { display: block; width: 100%; resize: vertical; min-height: 124px; background: var(--ink); color: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font: 400 17px/1.45 var(--body); }
textarea::placeholder { color: #8d8773; }
textarea:focus { outline: none; border-color: var(--signal); }
.composer-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 14px 0; }
.aspects { display: flex; flex-wrap: wrap; gap: 6px; }
.aspects span { display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.aspects span i { display: inline-block; height: 13px; border: 1.5px solid currentColor; border-radius: 2px; }
.aspects input:checked + span { color: var(--paper); border-color: var(--signal); }
.model-note { margin: 0; font-size: 13px; color: var(--muted); }
.turnstile:not(:empty) { margin-bottom: 14px; }
.go { width: 100%; padding: 15px; border: 0; border-radius: 10px; background: var(--signal); color: var(--signal-ink); font: 800 19px/1 var(--display); cursor: pointer; transition: transform .12s; }
.go:hover { transform: translateY(-1px); }
.go:active { transform: none; }
.go:disabled { opacity: .55; cursor: default; transform: none; }
.left-note { margin: 12px 0 0; font-size: 14px; color: var(--muted); min-height: 1.4em; }
.form-error { margin: 10px 0 0; color: var(--bad); font-size: 15px; }
.composer.is-busy textarea { opacity: .6; }

.stage { max-width: 860px; margin: 0 auto; padding: 0 20px 56px; scroll-margin-top: 24px; }
.stage-panel { background: var(--ink-2); border: 1px solid var(--line); border-radius: 14px; padding: clamp(20px, 4vw, 34px); }
.wait, .oops { text-align: center; }
.wait h2, .oops h2 { font-size: clamp(26px, 4vw, 36px); margin: 16px 0 8px; }
.wait p, .oops p { margin: 0 auto 10px; color: var(--muted); max-width: 36em; }
.wait .wait-prompt { color: var(--paper); font-style: italic; overflow-wrap: anywhere; }
.reel { display: inline-flex; gap: 6px; height: 34px; align-items: stretch; }
.reel i { width: 9px; background: var(--signal); border-radius: 2px; animation: reel 1.1s ease-in-out infinite; transform-origin: bottom; }
.reel i:nth-child(2) { animation-delay: .12s; }
.reel i:nth-child(3) { animation-delay: .24s; }
.reel i:nth-child(4) { animation-delay: .36s; }
.reel i:nth-child(5) { animation-delay: .48s; }
@keyframes reel { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) { .reel i { animation: none; transform: scaleY(.7); } html { scroll-behavior: auto; } }
.media { max-height: 72vh; max-width: 100%; margin: 0 auto; background: #000; border-radius: 10px; overflow: hidden; }
.media video, .media img { display: block; width: 100%; height: 100%; object-fit: contain; }
.done-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.btn-primary, .btn-quiet { display: inline-block; padding: 12px 22px; border-radius: 9px; font: 600 16px/1.2 var(--body); text-decoration: none; cursor: pointer; }
.btn-primary { background: var(--signal); color: var(--signal-ink); border: 1px solid var(--signal); }
.btn-quiet { background: none; color: var(--paper); border: 1px solid var(--line); }
.btn-quiet:hover { border-color: var(--paper); }
.fine { margin: 14px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.ad-slot { margin-top: 22px; max-width: 100%; overflow: hidden; }
.ad-slot:empty { display: none; }
.ad-home { max-width: 1180px; margin: 0 auto 40px; padding: 0 20px; }

.recent, .gallery, .how, .faq { max-width: 1180px; margin: 0 auto; padding: clamp(32px, 5vw, 56px) 20px; }
.recent-grid, .gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 12px; }
.recent-item { display: block; background: #000; border-radius: 9px; overflow: hidden; }
.recent-item video, .recent-item img { display: block; width: 100%; height: 100%; object-fit: cover; }
.gallery .gallery-grid { display: block; columns: 3 280px; column-gap: 14px; }
.gallery figure { margin: 0 0 18px; break-inside: avoid; }
.gallery video, .gallery img { display: block; width: 100%; height: auto; object-fit: cover; background: #000; border-radius: 9px; }
.gallery-note { margin: -10px 0 22px; color: var(--muted); }
.gallery figcaption { margin-top: 8px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }

.how { display: grid; grid-template-columns: repeat(12, 1fr); gap: 0 clamp(20px, 4vw, 48px); border-top: 1px solid var(--line); }
.how h2 { grid-column: 1 / -1; }
.how ol { grid-column: span 7; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.how li { counter-increment: step; padding: 16px 0 16px 52px; border-top: 1px solid var(--line); position: relative; color: var(--muted); }
.how li strong { color: var(--paper); }
.how li::before { content: counter(step); position: absolute; left: 0; top: 13px; font: 800 28px/1.2 var(--display); color: var(--signal); }
.tips { grid-column: span 5; background: var(--ink-2); border-radius: 12px; padding: 22px; align-self: start; }
.tips h3 { font-size: 22px; margin-bottom: 10px; }
.tips p { margin: 0; color: var(--muted); }

.faq { max-width: 820px; border-top: 1px solid var(--line); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { padding: 16px 0; font-weight: 600; font-size: 18px; cursor: pointer; }
.faq details p { margin: 0 0 18px; color: var(--muted); }

.foot { border-top: 1px solid var(--line); }
.foot-in { max-width: 1180px; margin: 0 auto; padding: 30px 20px 40px; color: var(--muted); font-size: 15px; }
.foot-brand { font: 800 20px/1 var(--display); color: var(--paper); margin: 0 0 10px; }
.foot p { margin: 0 0 12px; }
.foot nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.foot nav a { color: var(--paper); }

.doc { max-width: 760px; margin: 0 auto; padding: 32px 20px 64px; }
.doc h1 { font-size: clamp(38px, 6vw, 56px); margin-bottom: 8px; }
.doc h2 { font-size: 24px; margin: 32px 0 8px; }
.doc p, .doc li { color: #d6d0bd; }
.doc .updated { color: var(--muted); font-size: 15px; }

.adm { max-width: 1180px; margin: 0 auto; padding: 16px 20px 64px; }
.adm h1 { font-size: 36px; margin-bottom: 18px; }
.adm h2 { font-size: 22px; margin: 32px 0 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--ink-2); border-radius: 10px; padding: 14px; font-size: 14px; color: var(--muted); }
.tile b { display: block; font: 800 26px/1.15 var(--display); color: var(--paper); }
.adm form.set { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.adm label { display: block; font-size: 14px; color: var(--muted); }
.adm input[type=text], .adm input[type=number], .adm input[type=password], .adm textarea { display: block; width: 100%; margin-top: 4px; padding: 9px; background: var(--ink); color: var(--paper); border: 1px solid var(--line); border-radius: 7px; font: 400 15px/1.3 var(--body); min-height: 0; }
.adm .wide { grid-column: 1 / -1; }
.adm button { padding: 9px 15px; background: var(--signal); color: var(--signal-ink); border: 0; border-radius: 7px; font: 600 14px var(--body); cursor: pointer; }
.adm button.q { background: none; color: var(--paper); border: 1px solid var(--line); }
.tbl-wrap { overflow-x: auto; }
.adm table { width: 100%; border-collapse: collapse; font-size: 14px; }
.adm th, .adm td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.adm td.p { max-width: 380px; overflow-wrap: anywhere; }
.adm form.in { display: inline; margin: 0; }
.notice { padding: 10px 14px; background: var(--ink-3); border-radius: 8px; margin-bottom: 14px; }

@media (max-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .how ol, .tips { grid-column: 1 / -1; }
  .tips { margin-top: 20px; }
}
@media (max-width: 520px) {
  .top-nav a[href^="/#"] { display: none; }
  .composer { padding: 14px; }
}

/* Count picker, progress, multi-image results */
.count { display: flex; gap: 6px; }
.count input { position: absolute; opacity: 0; pointer-events: none; }
.count span { display: inline-block; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.count input:checked + span { color: var(--paper); border-color: var(--signal); }
.count input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 2px; }
.model-note { margin: -4px 0 14px; }
.model-note:empty { display: none; }
.progress { position: relative; height: 8px; max-width: 420px; margin: 14px auto 8px; background: var(--ink-3); border-radius: 99px; overflow: hidden; }
.progress i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--signal); border-radius: inherit; transition: width .9s linear; }
.progress-meta { display: flex; justify-content: space-between; gap: 12px; max-width: 420px; margin: 0 auto 14px !important; font-size: 14px; font-variant-numeric: tabular-nums; }
.media-set { display: grid; gap: 14px; }
.media-set.two { grid-template-columns: 1fr 1fr; }
.media-set figure { margin: 0; display: grid; gap: 10px; justify-items: center; }
.media-set .media { width: 100%; }
.recent-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 20px; margin-bottom: 22px; }
.recent-head h2 { margin: 0; }
.recent-grid { grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); }
.recent-item { position: relative; }
.badge { position: absolute; top: 8px; right: 8px; padding: 2px 8px; background: var(--signal); color: var(--signal-ink); border-radius: 99px; font-size: 13px; font-weight: 700; }
.nav-lib { font-weight: 600; }

/* Library */
.lib { max-width: 1180px; margin: 0 auto; padding: 20px 20px 64px; }
.lib-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; margin-bottom: 22px; }
.lib-head h1 { font-size: clamp(38px, 6vw, 56px); }
.lib-note { margin: 10px 0 0; color: var(--muted); max-width: 40em; }
.lib-filters { display: flex; gap: 6px; margin-bottom: 18px; }
.lib-filters button { padding: 8px 14px; background: none; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; font: 600 14px var(--body); cursor: pointer; }
.lib-filters button[aria-pressed="true"] { color: var(--paper); border-color: var(--signal); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 16px; align-items: start; }
.lib-card { background: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
/* The frame keeps the item's shape but never grows past 460px tall; a single item then
   fills it absolutely and is letterboxed in the middle, never pinned to one side. */
.lib-media { position: relative; background: #000; width: 100%; max-height: 460px; overflow: hidden; }
.lib-media:not(.two) > video, .lib-media:not(.two) > img, .lib-media:not(.two) > a { position: absolute; inset: 0; width: 100%; height: 100%; }
.lib-media.two { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.lib-media video, .lib-media img { display: block; width: 100%; height: 100%; object-fit: contain; }
.lib-media.two img { object-fit: cover; }
.lib-media > a { display: block; }
.lib-msg, .lib-progress { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; margin: 0; padding: 20px; text-align: center; color: var(--muted); font-size: 14px; }
.lib-progress .progress, .lib-progress .progress-meta { width: 100%; }
.lib-progress .progress { margin-top: 0; }
.lib-meta { padding: 14px; }
.lib-prompt { margin: 0 0 6px; font-size: 15px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.lib-info { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.lib-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.lib-actions .btn-primary, .lib-actions .btn-quiet { padding: 8px 14px; font-size: 14px; }
.lib-empty { color: var(--muted); }
.lib-more { text-align: center; margin-top: 24px; }
@media (max-width: 520px) { .media-set.two { grid-template-columns: 1fr; } }

/* Reference images */
.refs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 12px; }
.ref-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-list:empty { display: none; }
.ref-item { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #000; }
.ref-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-remove { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: rgba(20, 19, 15, .85); color: var(--paper); font: 700 15px/22px var(--body); cursor: pointer; }
.ref-add { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border: 1px dashed var(--line); border-radius: 8px; color: var(--paper); font-size: 14px; cursor: pointer; }
.ref-add:hover { border-color: var(--signal); }
.ref-add span { font: 700 20px/1 var(--display); color: var(--signal); }
.ref-add b { font-weight: 600; }
.ref-add input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ref-add:focus-within { outline: 2px solid var(--signal); outline-offset: 2px; }
.ref-hint { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--muted); }
.composer.is-drop { border-color: var(--signal); }

/* Maintenance popup */
.notice-dialog { width: min(440px, calc(100% - 32px)); padding: 30px 26px 24px; background: var(--ink-2); color: var(--paper); border: 1px solid var(--line); border-radius: 14px; text-align: center; }
.notice-dialog::backdrop { background: rgba(10, 9, 7, .72); }
.notice-dialog h2 { font-size: 30px; margin: 16px 0 10px; }
.notice-dialog p { margin: 0 0 20px; color: var(--muted); }
.notice-dialog .done-actions { margin-top: 0; }

/* Model picker and length slider */
.opts { margin: -2px 0 12px; }
.models { display: flex; flex-wrap: wrap; gap: 6px; }
.models input { position: absolute; opacity: 0; pointer-events: none; }
.models span { display: inline-block; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.models input:checked + span { color: var(--paper); border-color: var(--signal); }
.models input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 2px; }
.duration label { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.duration output { color: var(--paper); font-weight: 600; font-variant-numeric: tabular-nums; }
.duration input[type=range] { width: 100%; margin: 8px 0 2px; accent-color: var(--signal); }
.duration-marks { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
