:root {
  color-scheme: dark;
  --ink: #ebe5d9;
  --muted: #aaa49a;
  --dim: #918c83;
  --ground: #13110f;
  --panel: #1a1815;
  --line: rgba(235, 229, 217, .13);
  --acid: #d7ff42;
  --orange: #ed6536;
  --blue: #4e78ff;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { background: var(--ground); }
body { margin: 0; color: var(--ink); background: var(--ground); font-family: var(--sans); min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--acid); outline-offset: 3px; }
.segmented label:has(input:focus-visible),
.resolution-toggle label:has(input:focus-visible) { z-index: 1; outline: 3px solid var(--acid); outline-offset: 3px; }

.skip-link { position: fixed; z-index: 100; top: 12px; left: 12px; padding: 12px 16px; color: #11140a; background: var(--acid); font: 600 11px var(--mono); text-transform: uppercase; text-decoration: none; transform: translateY(calc(-100% - 20px)); transition: transform .18s; }
.skip-link:focus { transform: translateY(0); }

.boot-shell { position: relative; z-index: 1; min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 32px; text-align: center; }
.boot-shell .mark { margin-bottom: 12px; }
.boot-shell h1 { margin: 0; font: 400 clamp(52px, 10vw, 96px)/.9 var(--serif); letter-spacing: -.045em; }
.boot-shell > p:not(.eyebrow), .noscript-message { max-width: 460px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.noscript-message p { margin: 0 0 8px; }
.noscript-message small { color: var(--dim); font: 300 9px/1.6 var(--mono); text-transform: uppercase; }
.retry-button { margin-top: 8px; min-width: 150px; padding: 13px 18px; border: 1px solid var(--acid); color: var(--acid); background: transparent; cursor: pointer; font: 600 10px var(--mono); text-transform: uppercase; }

.grain { position: fixed; inset: 0; pointer-events: none; opacity: .055; z-index: 20; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E"); }

.mark { display: flex; width: 80px; height: 30px; gap: 3px; }
.mark i { flex: 1; transform: skewX(-24deg); background: var(--acid); }
.mark i:nth-child(2) { background: var(--orange); }
.mark i:nth-child(3) { background: var(--blue); }

main { width: min(1500px, calc(100% - 72px)); margin: auto; }
.site-header { height: 86px; display: flex; align-items: center; gap: 28px; border-bottom: 1px solid var(--line); }
.wordmark { display: flex; align-items: center; gap: 13px; color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600; letter-spacing: -.02em; }
.mini-mark { display: flex; width: 30px; height: 13px; gap: 2px; }
.mini-mark i { flex: 1; transform: skewX(-24deg); background: var(--acid); }
.mini-mark i:nth-child(2) { background: var(--orange); }
.mini-mark i:nth-child(3) { background: var(--blue); }
.engine-pill { margin-left: auto; display: flex; align-items: center; gap: 9px; color: var(--muted); font: 400 10px var(--mono); letter-spacing: .07em; text-transform: uppercase; }
.engine-pill span { width: 7px; height: 7px; border-radius: 50%; background: #e9b24a; box-shadow: 0 0 0 4px rgba(233,178,74,.1); }
.engine-pill.ready span { background: var(--acid); box-shadow: 0 0 0 4px rgba(215,255,66,.1); }
.engine-pill.offline span { background: var(--orange); }
.quiet-button { background: none; color: var(--muted); border: 0; padding: 8px 0; font: 400 10px var(--mono); text-transform: uppercase; letter-spacing: .08em; cursor: pointer; }
.quiet-button:hover { color: var(--ink); }

.hero { display: grid; grid-template-columns: 1fr 340px; align-items: end; gap: 60px; padding: 78px 0 54px; }
.eyebrow { display: block; color: var(--acid); font: 400 10px var(--mono); text-transform: uppercase; letter-spacing: .16em; }
.hero h1 { margin: 18px 0 0; max-width: 900px; font: 400 clamp(66px, 8.5vw, 128px)/.77 var(--serif); letter-spacing: -.045em; }
.hero h1 em { color: var(--muted); font-weight: 400; }
.hero > p { margin: 0 0 9px; color: var(--muted); font-size: 13px; line-height: 1.75; }

.studio-grid { display: grid; grid-template-columns: minmax(480px, .86fr) minmax(520px, 1.14fr); min-height: 710px; border: 1px solid var(--line); }
.composer { padding: 42px; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--panel); }
.field-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.field-heading label, fieldset legend, .seed-field > span { color: var(--ink); font: 400 11px var(--mono); text-transform: uppercase; letter-spacing: .12em; }
.field-heading span { color: var(--dim); font: 300 10px var(--mono); }
textarea { resize: none; width: 100%; height: 230px; padding: 0; border: 0; background: transparent; color: var(--ink); font: 400 28px/1.38 var(--serif); }
textarea::placeholder { color: var(--dim); }
.source-tools { min-height: 66px; display: flex; align-items: center; margin-bottom: 30px; }
.source-button { width: 100%; min-height: 66px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; align-items: center; column-gap: 18px; border: 1px solid rgba(215,255,66,.55); background: rgba(215,255,66,.055); color: var(--ink); padding: 13px 18px; text-align: left; cursor: pointer; }
.source-button span { color: var(--muted); font: 300 8px var(--mono); text-transform: uppercase; letter-spacing: .09em; }
.source-button b { font-size: 13px; font-weight: 600; }
.source-button i { grid-column: 2; grid-row: 1 / 3; color: var(--acid); font: normal 24px var(--sans); transition: transform .18s; }
.source-button:hover { border-color: var(--acid); background: rgba(215,255,66,.09); }
.source-button:hover i { transform: translateX(4px); }
.source-button:disabled { opacity: .45; cursor: wait; }
.source-preview { width: 100%; min-width: 0; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 12px; padding: 7px; border: 1px solid rgba(215,255,66,.28); background: rgba(215,255,66,.035); }
.source-preview img { width: 44px; height: 44px; object-fit: cover; background: #090806; }
.source-preview div { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
.source-preview span { color: var(--acid); font: 300 8px var(--mono); text-transform: uppercase; letter-spacing: .09em; }
.source-preview b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11px; font-weight: 500; }
.source-preview button { border: 0; background: none; color: var(--muted); padding: 10px; cursor: pointer; font: 400 8px var(--mono); text-transform: uppercase; }
.source-preview button:hover { color: var(--ink); }
.controls { display: grid; grid-template-columns: 1.4fr .6fr; gap: 24px; padding: 34px 0; margin-top: 26px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:first-child { grid-column: 1 / -1; }
fieldset legend { margin-bottom: 14px; }
.segmented, .resolution-toggle { display: flex; height: 57px; border: 1px solid var(--line); }
.segmented label, .resolution-toggle label { position: relative; flex: 1; display: flex; justify-content: center; align-items: center; gap: 7px; cursor: pointer; color: var(--dim); border-right: 1px solid var(--line); }
.segmented label:last-child, .resolution-toggle label:last-child { border: 0; }
.segmented input, .resolution-toggle input { position: absolute; opacity: 0; }
.segmented label:has(input:checked), .resolution-toggle label:has(input:checked) { color: var(--ink); background: rgba(235,229,217,.055); }
.segmented label:has(input:disabled) { opacity: .28; cursor: not-allowed; }
.segmented b { font: 400 9px var(--mono); text-transform: uppercase; }
.ratio { display: block; border: 1px solid currentColor; }
.ratio.galaxy { width: 6px; height: 13px; border-radius: 1px; }
.ratio.portrait { width: 8px; height: 12px; }
.ratio.square { width: 10px; height: 10px; }
.ratio.landscape { width: 13px; height: 9px; }
.ratio.match { width: 12px; height: 12px; border-style: dashed; transform: rotate(45deg) scale(.72); }
.resolution-toggle label { flex-direction: column; gap: 2px; }
.resolution-toggle span { font: 500 11px var(--sans); }
.resolution-toggle small { color: var(--dim); font: 300 8px var(--mono); text-transform: uppercase; }
.seed-field { display: flex; flex-direction: column; }
.seed-field > span { margin-bottom: 14px; }
.seed-field small { color: var(--dim); font-size: 8px; }
.seed-field input { width: 100%; min-width: 0; height: 57px; border: 1px solid var(--line); padding: 0 12px; background: transparent; color: var(--ink); font: 400 11px var(--mono); }
.seed-field input:focus { border-color: var(--muted); }
.composer-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-top: auto; padding-top: 42px; }
.model-note { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; }
.model-note span { grid-row: span 2; color: var(--dim); font: 300 9px var(--mono); text-transform: uppercase; writing-mode: vertical-rl; transform: rotate(180deg); }
.model-note b { font: 500 12px var(--sans); }
.model-note small { color: var(--muted); font: 300 9px var(--mono); }
.create-button { min-width: 195px; height: 63px; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 0 24px; border: 0; background: var(--acid); color: #14170a; font-weight: 600; cursor: pointer; transition: transform .18s, background .18s; }
.create-button:hover { transform: translateY(-2px); background: #e3ff77; }
.create-button:disabled { opacity: .35; cursor: wait; transform: none; }
.create-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.form-error { min-height: 18px; margin: 12px 0 0; color: #ff8a65; font: 400 10px var(--mono); }

.result-panel { position: relative; min-height: 710px; overflow: hidden; background: #0e0d0b; }
.result-empty, .working { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.result-empty p { font: 400 30px/1.05 var(--serif); margin: 24px 0 12px; }
.result-empty small { color: var(--dim); font: 300 9px var(--mono); text-transform: uppercase; letter-spacing: .1em; }
.aperture { position: relative; width: 86px; height: 86px; animation: breathe 7s ease-in-out infinite; }
.aperture i { position: absolute; width: 50px; height: 25px; border: 1px solid var(--line); left: 18px; top: 30px; transform-origin: 25px 13px; }
.aperture i:nth-child(1) { transform: rotate(0deg); }
.aperture i:nth-child(2) { transform: rotate(45deg); }
.aperture i:nth-child(3) { transform: rotate(90deg); }
.aperture i:nth-child(4) { transform: rotate(135deg); }
@keyframes breathe { 50% { transform: rotate(18deg) scale(1.08); } }
.working { background: radial-gradient(circle at 50% 42%, rgba(78,120,255,.13), transparent 30%); }
.working-art { position: absolute; inset: 0; overflow: hidden; }
.working-art i { position: absolute; width: 52%; aspect-ratio: 1; border: 1px solid rgba(235,229,217,.07); transform: rotate(45deg); animation: drift 14s ease-in-out infinite alternate; }
.working-art i:nth-child(1) { left: 5%; top: 12%; }
.working-art i:nth-child(2) { right: 0; bottom: 0; animation-delay: -5s; }
.working-art i:nth-child(3) { width: 23%; left: 45%; top: 36%; animation-delay: -9s; }
@keyframes drift { to { transform: rotate(76deg) translate(30px, -20px); } }
.working > *:not(.working-art) { z-index: 1; }
.working h2 { margin: 18px 0 14px; font: 400 53px/.9 var(--serif); }
.working p { color: var(--muted); font-size: 12px; }
.working time { display: block; margin: 28px 0 12px; font: 300 12px var(--mono); }
.result { position: absolute; inset: 0; display: flex; flex-direction: column; background: #090806; }
.result img { width: 100%; min-height: 0; flex: 1; object-fit: contain; }
.result-actions { min-height: 92px; padding: 15px 21px; gap: 18px; background: var(--panel); display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); }
.result-actions .result-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.result-actions span { color: var(--dim); font: 300 8px var(--mono); text-transform: uppercase; letter-spacing: .1em; }
.result-actions b { font-size: 11px; font-weight: 500; }
.result-actions small { max-width: 280px; color: var(--muted); font: 300 8px/1.35 var(--mono); }
.auto-delete { display: flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--muted); font: 300 8px var(--mono); cursor: pointer; }
.auto-delete input { accent-color: var(--acid); }
.result-buttons { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 7px; }
.result-actions a { color: #11140a; background: var(--acid); padding: 11px 15px; text-decoration: none; font: 500 9px var(--mono); text-transform: uppercase; }
.result-actions button { border: 1px solid var(--line); background: transparent; color: var(--ink); padding: 10px 13px; cursor: pointer; font: 500 9px var(--mono); text-transform: uppercase; }
.result-actions button:hover { border-color: var(--muted); }
.result-actions button:disabled { opacity: .45; cursor: wait; }
.result-actions .delete-button { color: #ff9b7b; }

.queue-section { padding: 74px 0 10px; }
.queue-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.queue-heading h2 { margin: 8px 0 0; font: 400 48px/.9 var(--serif); }
.queue-heading strong { color: var(--acid); font: 400 9px var(--mono); text-transform: uppercase; letter-spacing: .1em; }
.queue-list { display: grid; gap: 8px; padding-top: 12px; }
.queue-card { position: relative; overflow: hidden; display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 18px; min-height: 92px; padding: 10px 14px 10px 10px; border: 1px solid var(--line); background: var(--panel); }
.queue-card::after { content: ""; position: absolute; left: 0; bottom: 0; width: 32%; height: 2px; background: linear-gradient(90deg, transparent, var(--acid), transparent); animation: queue-scan 2.2s ease-in-out infinite; }
@keyframes queue-scan { from { transform: translateX(-110%); } to { transform: translateX(420%); } }
.queue-visual { position: relative; width: 72px; height: 72px; display: grid; place-items: center; overflow: hidden; background: #0b0a08; border: 1px solid rgba(235,229,217,.08); }
.queue-visual::before, .queue-visual::after { content: ""; position: absolute; width: 42px; height: 42px; border: 1px solid rgba(78,120,255,.35); transform: rotate(45deg); animation: queue-turn 6s linear infinite; }
.queue-visual::after { width: 24px; height: 24px; border-color: rgba(215,255,66,.35); animation-direction: reverse; }
@keyframes queue-turn { to { transform: rotate(405deg); } }
.queue-number { position: relative; z-index: 1; color: var(--ink); font: 400 9px var(--mono); }
.queue-copy { min-width: 0; }
.queue-copy p { margin: 7px 0 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 400 15px/1.25 var(--serif); }
.queue-status { color: var(--acid); font: 400 8px var(--mono); text-transform: uppercase; letter-spacing: .12em; }
.queue-details { display: flex; flex-wrap: wrap; gap: 5px 13px; color: var(--muted); font: 300 8px var(--mono); text-transform: uppercase; }
.queue-cancel { border: 1px solid var(--line); background: transparent; color: var(--muted); padding: 10px 12px; cursor: pointer; font: 400 8px var(--mono); text-transform: uppercase; }
.queue-cancel:hover { color: #ff9b7b; border-color: rgba(255,155,123,.45); }
.queue-cancel:disabled { opacity: .4; cursor: wait; }

.history-section { padding: 105px 0 80px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 22px; margin-bottom: 26px; }
.section-heading h2 { margin: 8px 0 0; font: 400 48px/.9 var(--serif); }
.section-heading p { margin: 0; color: var(--dim); font: 300 9px var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.history-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.history-card { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--panel); cursor: pointer; border: 0; padding: 0; color: var(--ink); text-align: left; }
.history-card img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.history-card:hover img { transform: scale(1.025); }
.history-card div { position: absolute; inset: auto 0 0; padding: 48px 16px 15px; background: linear-gradient(transparent, rgba(8,7,6,.9)); }
.history-card p { margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 10px; }
.history-card small { color: #aaa49a; font: 300 8px var(--mono); }
footer { min-height: 90px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; color: var(--dim); font: 300 9px var(--mono); text-transform: uppercase; letter-spacing: .08em; }
#studio-content { scroll-margin-top: 24px; }

@media (max-width: 1050px) {
  .hero { grid-template-columns: 1fr; }
  .hero > p { max-width: 420px; }
  .studio-grid { grid-template-columns: 1fr; }
  .composer { border-right: 0; border-bottom: 1px solid var(--line); min-height: 650px; }
  .result-panel { min-height: 720px; }
  .history-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 680px) {
  main { width: min(100% - 28px, 1500px); }
  .site-header { height: 70px; gap: 15px; }
  .wordmark span:last-child, .engine-pill b { display: none; }
  .hero { padding: 58px 0 38px; }
  .hero h1 { font-size: clamp(58px, 20vw, 90px); }
  .studio-grid { border-left: 0; border-right: 0; }
  .composer { padding: 28px 18px; min-height: 680px; }
  textarea { height: 205px; font-size: 24px; }
  .controls { grid-template-columns: 1fr 1fr; gap: 24px 12px; }
  .controls fieldset:first-child { grid-column: 1 / -1; }
  .seed-field { grid-column: span 2; }
  .composer-footer { align-items: stretch; flex-direction: column; }
  .create-button { width: 100%; }
  .result-panel { min-height: 560px; }
  .result-actions { align-items: stretch; flex-direction: column; }
  .result-buttons { display: grid; grid-template-columns: 1fr 1fr; }
  .result-buttons > * { text-align: center; }
  .history-grid { grid-template-columns: repeat(2, 1fr); }
  .queue-card { grid-template-columns: 54px minmax(0, 1fr); gap: 12px; }
  .queue-visual { width: 54px; height: 54px; }
  .queue-visual::before { width: 32px; height: 32px; }
  .queue-visual::after { width: 18px; height: 18px; }
  .queue-cancel { grid-column: 2; justify-self: start; }
  .section-heading p { display: none; }
}

@media (max-width: 480px) {
  .controls { grid-template-columns: 1fr; }
  .seed-field { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
