:root {
  color-scheme: dark;
  --ground: #050505;
  --surface: #111111;
  --raised: #191919;
  --line: #292929;
  --text: #f4f2ed;
  --muted: #b4b4b4;
  --faint: #949494;
  --gold: #f0d66f;
  --error: #e8877b;
  --control: #191919;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 64px;
  padding: 0 clamp(20px, 5vw, 76px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--ground);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
}

.brand-mark {
  width: 19px;
  height: 19px;
  display: grid;
  grid-template-columns: repeat(3, 4px);
  gap: 3px;
  align-items: end;
  transform: skew(-13deg);
}

.brand-mark i { display: block; width: 4px; background: var(--gold); }
.brand-mark i:nth-child(1) { height: 10px; }
.brand-mark i:nth-child(2) { height: 18px; }
.brand-mark i:nth-child(3) { height: 14px; }
.brand-suffix { color: var(--faint); font-size: 12px; font-weight: 400; }

.topbar-cta {
  min-height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 13px;
  border: 1px solid #626262;
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.topbar-cta img, .hero-cta img, .tool-arrow, .button-arrow { display: block; flex: none; }
.topbar-cta:hover { border-color: var(--text); background: #161616; }
.topbar-cta:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.topbar-end, .account-summary, .connection { display: flex; align-items: center; }
.topbar-end { gap: 18px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.account-summary { gap: 8px; }
.account-spend { color: var(--faint); }
.account-summary strong { color: var(--text); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.topbar-divider { width: 1px; height: 18px; background: var(--line); }
.connection { gap: 8px; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.connection.offline .connection-dot { background: var(--error); }

.hero {
  position: relative;
  min-height: 470px;
  height: clamp(470px, 65vh, 680px);
  overflow: hidden;
  isolation: isolate;
  background: #101112 url("tokyo-rain-alley-poster.jpg") center 52% / cover no-repeat;
}

.hero::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: rgba(0, 0, 0, .4);
}

.hero-media {
  position: absolute;
  z-index: -2;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 54%;
  filter: brightness(.72) saturate(.8);
}

.hero-content {
  position: absolute;
  left: clamp(24px, 8vw, 120px);
  bottom: 58px;
  max-width: 720px;
}

.hero h1 {
  margin: 0;
  color: #fff;
  font-size: 54px;
  line-height: 1.02;
  font-weight: 500;
}

.hero h1 em {
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02em;
  font-weight: 400;
}

.hero-copy { margin: 15px 0 22px; color: #e3e1dc; font-size: 14px; line-height: 1.5; }

.hero-cta {
  min-height: 43px;
  padding: 0 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border: 0;
  border-radius: 24px;
  background: var(--gold);
  color: #111;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color .16s ease, transform .16s ease;
}

.hero-cta:hover { background: #ffe98c; transform: translateY(-1px); }
.hero-cta:focus-visible { outline: 2px solid white; outline-offset: 3px; }
.hero-cta img { filter: brightness(0); }

.hero-caption {
  position: absolute;
  right: clamp(20px, 5vw, 76px);
  bottom: 20px;
  display: flex;
  gap: 17px;
  color: #e5e5e5;
  font-size: 11px;
}

.hero-caption span + span { color: #c1c1c1; }

.tools-section { padding: 40px clamp(16px, 5vw, 76px) 48px; }
.tools-section h2 { margin: 0 0 21px; font-size: 25px; line-height: 1.2; font-weight: 500; }
.tool-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.tool-link {
  min-width: 0;
  min-height: 105px;
  padding: 22px 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px;
  align-items: center;
  gap: 14px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  text-align: left;
  transition: background-color .16s ease;
}

.tool-link + .tool-link { border-left: 1px solid var(--line); }
.tool-link:hover { background: #0e0e0e; }
.tool-link:focus-visible { outline: 2px solid var(--gold); outline-offset: -3px; }
.tool-copy { display: flex; min-width: 0; flex-direction: column; gap: 7px; }
.tool-copy strong { color: var(--text); font-size: 16px; font-weight: 500; line-height: 1.2; }
.tool-copy small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.tool-arrow { align-self: start; margin-top: 2px; opacity: .65; }
.tool-link:hover .tool-arrow { opacity: 1; }

.studio-dialog {
  width: min(1360px, 96vw);
  max-width: none;
  height: min(900px, 94dvh);
  max-height: none;
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--ground);
  color: var(--text);
}
.studio-dialog::backdrop { background: rgba(0, 0, 0, .82); }
.dialog-shell { min-height: 100%; }
.dialog-header {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 60px;
  padding: 10px clamp(20px, 3vw, 44px);
  display: flex;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid var(--line);
  background: var(--ground);
}
.dialog-title-group { display: flex; align-items: baseline; gap: 13px; min-width: 0; margin-right: auto; }
.dialog-title-group h2 { margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; }
.dialog-brand { color: var(--faint); font-size: 11px; white-space: nowrap; }
.dialog-meta { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.dialog-close {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid #454545;
  border-radius: 3px;
  background: transparent;
}
.dialog-close:hover { border-color: var(--text); background: #191919; }
.dialog-close:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 18px;
}

.composer { min-width: 0; padding: 39px clamp(20px, 3vw, 44px) 42px; border-right: 1px solid var(--line); }
.library { min-width: 0; padding: 39px clamp(22px, 4.5vw, 68px) 42px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 25px; }
.section-heading h2 { margin: 0; font-size: 24px; line-height: 1.12; font-weight: 500; }

.composer-tabs { display: flex; gap: 21px; margin: 0 0 23px; border-bottom: 1px solid var(--line); }
.composer-tabs button {
  min-height: 37px;
  padding: 0 1px 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.composer-tabs button[aria-selected="true"] { border-bottom-color: var(--text); color: var(--text); }
.composer-tabs button:focus-visible, .prompt-output-actions button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.field-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; color: var(--text); font-size: 12px; font-weight: 600; }
.field-heading span:last-child { color: var(--muted); font-size: 11px; font-weight: 400; }
.row-heading { margin-top: 23px; }
textarea {
  display: block;
  width: 100%;
  min-height: 160px;
  padding: 15px;
  resize: vertical;
  border: 1px solid #3b3b3b;
  border-radius: 4px;
  outline: none;
  background: var(--control);
  color: var(--text);
  line-height: 1.55;
}
textarea::placeholder { color: #a2a2a2; }
textarea:focus, .upload:focus-within, select:focus, .segmented:focus-within, .duration-input:focus-within { border-color: var(--gold); outline: 1px solid var(--gold); outline-offset: 1px; }

.reference-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.upload {
  position: relative;
  min-width: 0;
  min-height: 91px;
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  border: 1px dashed #555;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease;
}
.upload:hover { border-color: #a0a0a0; background: #141414; }
.upload.has-file { border-style: solid; border-color: #c8ad57; }
.upload input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-icon { display: block; margin-bottom: 6px; }
.upload-main { max-width: 100%; overflow: hidden; color: var(--text); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.upload-sub { max-width: 100%; margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.image-list, .prompt-image-list, .prompt-video-list { display: grid; gap: 5px; margin: 9px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 11px; }
.image-list li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-image-list li, .prompt-video-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.prompt-image-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-image-list button, .prompt-video-list button { flex: none; padding: 4px 0; border: 0; background: none; color: var(--muted); font-size: 10px; text-decoration: underline; text-underline-offset: 2px; }
.prompt-image-list button:hover, .prompt-video-list button:hover { color: var(--text); }
.prompt-media-note { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.control-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-top: 22px; }
.control-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.control-group legend { margin-bottom: 9px; font-size: 12px; font-weight: 600; }
.duration-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.duration-label span { color: var(--muted); font-size: 11px; font-weight: 400; }
.duration-input { height: 39px; padding: 0 10px; display: flex; align-items: center; gap: 7px; border: 1px solid #3b3b3b; border-radius: 4px; background: var(--control); }
.duration-input input { width: 100%; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }
.duration-input input { appearance: textfield; -moz-appearance: textfield; }
.duration-input input::-webkit-outer-spin-button, .duration-input input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
.duration-input span { color: var(--muted); font-size: 11px; }
.segmented { height: 39px; padding: 3px; display: flex; border: 1px solid #3b3b3b; border-radius: 4px; background: var(--control); }
.segmented label { position: relative; flex: 1; min-width: 0; }
.segmented input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.segmented span { height: 100%; display: flex; align-items: center; justify-content: center; border-radius: 2px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.segmented input:checked + span { background: #2a2a2a; color: #fff; }

.model-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.model-row label { font-size: 12px; font-weight: 600; }
.model-row select, .refine-select {
  width: 70%;
  min-width: 180px;
  height: 39px;
  padding: 0 12px;
  border: 1px solid #3b3b3b;
  border-radius: 4px;
  outline: none;
  background: var(--control);
  color: var(--text);
}
.refine-select { width: 100%; }
.control-group > .field-heading { margin-bottom: 9px; }
.refine-or { margin: 12px 0; color: var(--muted); font-size: 11px; text-align: center; }
.refine-upload { min-height: 84px; }
#refine-prompt { min-height: 130px; }

.submit-area { margin-top: 26px; padding-top: 17px; border-top: 1px solid var(--line); }
.submit-area p { min-height: 15px; margin: 0 0 13px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.submit-area p.error { color: var(--error); }
.submit-area button {
  width: 100%;
  min-height: 43px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 0;
  border-radius: 4px;
  background: #f2f2f2;
  color: #111;
  font-size: 13px;
  font-weight: 700;
  transition: background-color .16s ease;
}
.submit-area button:hover { background: #fff; }
.submit-area button:disabled { opacity: .58; cursor: wait; }
.submit-area button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.button-arrow { filter: brightness(0); }
.prompt-model { margin-top: 20px; padding: 10px 0; display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.prompt-model span:first-child { color: var(--text); }
.prompt-result { margin-top: 23px; padding-top: 18px; border-top: 1px solid var(--line); }
.prompt-result textarea { min-height: 220px; }
.prompt-output-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }
.prompt-output-actions button { min-height: 36px; padding: 0 11px; border: 1px solid #484848; border-radius: 4px; background: transparent; color: var(--text); font-size: 12px; }
.prompt-output-actions button:last-child { border-color: #eee; background: #eee; color: #111; font-weight: 600; }
.prompt-output-actions button:hover { border-color: #fff; }
.prompt-output-actions button:last-child:hover { background: #fff; }

.library-body { max-width: 1120px; }
.render-count { margin-left: 6px; color: var(--muted); font-size: 13px; font-weight: 400; vertical-align: middle; }
.preview { position: relative; height: clamp(280px, 38vw, 470px); display: grid; place-items: center; overflow: hidden; border: 1px solid #292929; background: #080808; }
.preview video { width: 100%; height: 100%; object-fit: contain; background: #050505; }
.empty-preview, .preview-stage { max-width: 430px; padding: 22px; display: flex; flex-direction: column; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: center; }
.empty-preview strong, .preview-stage strong { margin-top: 4px; color: var(--text); font-size: 16px; font-weight: 500; }
.empty-preview .preview-label { color: var(--faint); font-size: 11px; }
.preview-stage { font-size: 12px; }
.spinner { width: 24px; height: 24px; margin-bottom: 3px; border: 2px solid #434343; border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.detail { min-height: 49px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.detail strong { color: var(--text); font-weight: 500; }
.detail a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.detail a:hover { color: var(--gold); }
.detail-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 15px; }
.detail-actions a { display: inline-flex; align-items: center; gap: 5px; }
.detail-actions a img { display: block; width: 14px; height: 14px; }
.detail button { padding: 0; border: 0; background: none; color: var(--text); font-size: 11px; }
.detail button:hover { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
.cost-detail { padding: 11px 0; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.cost-detail strong { color: var(--text); font-size: 12px; }
.cost-detail[hidden] { display: none; }
.queue-heading { padding: 26px 0 11px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.queue-heading h3 { margin: 0; font-size: 14px; font-weight: 500; }
.queue-heading span { color: var(--muted); font-size: 11px; }
.jobs { max-height: 380px; overflow-y: auto; }
.empty-jobs { padding: 17px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.job { width: 100%; min-height: 70px; padding: 11px 4px 11px 0; display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 12px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; }
.job:hover, .job.selected { background: #111; }
.job:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.job-dot { width: 7px; height: 7px; border-radius: 50%; background: #898989; }
.job-dot.completed { background: #eee; }
.job-dot.failed { background: var(--error); }
.job-dot.running, .job-dot.submitting { background: var(--gold); }
.job-text { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.job-text strong { overflow: hidden; font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.job-text small, .job-right small { color: var(--muted); font-size: 11px; }
.job-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.job-right span { max-width: 180px; overflow: hidden; color: var(--text); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.job-right .failed { color: var(--error); }
.job-right .job-price { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.job-pages { padding-top: 12px; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--line); }
.job-pages button { min-width: 34px; height: 34px; border: 1px solid #444; border-radius: 3px; background: transparent; color: var(--text); font-size: 12px; }
.job-pages button[aria-current="page"] { border-color: #eee; background: #eee; color: #111; }
.job-pages button:hover:not([aria-current="page"]) { border-color: #eee; }
.job-pages button:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.job-pages span { width: 16px; color: var(--muted); text-align: center; }

footer { min-height: 45px; padding: 0 clamp(20px, 5vw, 76px); display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--faint); font-size: 11px; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(320px, 42%) minmax(0, 1fr); }
  .composer { padding: 31px 23px 36px; }
  .library { padding: 31px 25px 36px; }
  .hero-content { left: 6vw; }
  .hero h1 { font-size: 48px; }
  .tool-link { padding-right: 15px; padding-left: 15px; grid-template-columns: minmax(0, 1fr) 12px; gap: 10px; }
  .dialog-brand { display: none; }
}

@media (max-width: 680px) {
  .topbar { height: 56px; padding: 0 18px; }
  .brand { gap: 8px; font-size: 16px; }
  .brand-mark { transform: scale(.9) skew(-13deg); }
  .topbar-cta { min-height: 34px; padding: 0 10px; font-size: 11px; }
  .account-summary { gap: 6px; }
  .account-summary .account-spend, .topbar-divider, .connection { display: none; }
  .account-summary strong { font-size: 12px; }
  .hero { height: clamp(390px, 58vh, 560px); min-height: 390px; }
  .hero-content { right: 22px; bottom: 64px; left: 22px; }
  .hero h1 { font-size: 39px; line-height: 1.04; }
  .hero-copy { max-width: 310px; margin: 12px 0 17px; font-size: 13px; }
  .hero-cta { min-height: 41px; }
  .hero-caption { right: 18px; bottom: 13px; left: 18px; justify-content: space-between; gap: 10px; font-size: 10px; }
  .tools-section { padding: 27px 20px 42px; }
  .tools-section h2 { margin-bottom: 14px; font-size: 21px; }
  .tool-links { grid-template-columns: 1fr; }
  .tool-link { min-height: 84px; padding: 16px 2px; }
  .tool-link + .tool-link { border-left: 0; }
  .tool-copy { gap: 5px; }
  .tool-copy strong { font-size: 16px; line-height: 1.25; }
  .tool-copy small { font-size: 11px; line-height: 1.35; }
  .tool-arrow { align-self: center; margin: 0; }
  .studio-dialog { width: 100vw; height: 100dvh; border: 0; }
  .dialog-header { min-height: 55px; padding: 8px 18px; gap: 10px; }
  .dialog-title-group h2 { font-size: 15px; }
  .dialog-meta { gap: 0; font-size: 10px; }
  .dialog-close { width: 31px; height: 31px; }
  .workspace { display: block; }
  .composer { padding: 29px 20px 31px; border-right: 0; border-bottom: 1px solid var(--line); }
  .library { padding: 29px 20px 34px; }
  .section-heading { margin-bottom: 21px; }
  .section-heading h2 { font-size: 22px; }
  .composer-tabs { gap: 17px; overflow-x: auto; scrollbar-width: none; }
  .composer-tabs::-webkit-scrollbar { display: none; }
  .composer-tabs button { font-size: 12px; }
  textarea { min-height: 148px; }
  .preview { height: 300px; }
  .jobs { max-height: none; }
  footer { min-height: 43px; padding: 0 20px; font-size: 10px; }
}

@media (max-width: 360px) {
  .topbar-cta { gap: 7px; }
  .hero h1 { font-size: 34px; }
  .dialog-title-group h2 { font-size: 13px; }
  .dialog-meta { display: none; }
  .control-grid { grid-template-columns: 1fr; }
  .reference-grid { gap: 7px; }
  .upload { padding: 10px; }
  .model-row select { min-width: 150px; }
  .detail { flex-wrap: wrap; padding: 10px 0; }
  .detail-actions { width: 100%; justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-media, .spinner { display: none; animation: none; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
