/* Qwen-Image 2.1 Turbo on Tracks. One weight, gray steps instead of borders, one raised
   thing (the result), one solid block per group (selected chip, primary button). */

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--canvas); color: var(--ink); font-family: var(--font-sans); font-weight: 400; }
body { margin: 0; background: var(--canvas); font-feature-settings: "tnum" 1, "cv11" 1; -webkit-font-smoothing: antialiased; }
b, strong, th, h1, h2, h3, h4, h5, h6 { font-weight: 400; }
h1, h2, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.ink { color: var(--ink); }
.muted { color: var(--ink-muted); }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.grow { flex: 1; min-width: 0; }

a { color: var(--ink-muted); text-decoration: none; border-radius: var(--radius-row); }
a:hover { color: var(--ink); }

/* Focus: the Tracks ring (2px, ink, the only ring in the system), one at a time.
   Drawn as an outline so it follows each radius and survives forced-colors mode.
   Controls carry it one seam (space-2) outside their edge, so it stays visible on the
   inverse blocks (selected chip, primary button) whose fill is the ring's own colour.
   Full-width rows and session heads carry it inside, since their seams are only 2px. */
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: var(--space-2); box-shadow: none; }
.row:focus-visible, .group-head:focus-visible { outline-offset: calc(-1 * var(--space-2)); }

.page {
  max-width: 1024px; margin: 0 auto; padding: var(--space-32) var(--space-24);
  display: flex; flex-direction: column; gap: var(--space-14);
}

/* Header */
.top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-16); flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: var(--space-12); flex-wrap: wrap; min-width: 0; }
.links { display: flex; gap: var(--space-14); }

/* Buttons and chips */
.btn {
  font-size: 13px; line-height: 19px;
  display: inline-flex; align-items: center; gap: var(--space-8); flex-shrink: 0;
  height: var(--size-control); border: 0; border-radius: var(--radius-md);
  cursor: pointer; white-space: nowrap; background: transparent;
}
.btn-primary { background: var(--inverse); color: var(--on-inverse); padding: 0 var(--space-12); }
.btn-primary[aria-disabled="true"] { cursor: progress; }
.btn-quiet { background: var(--sunken-2); color: var(--ink); padding: 0 var(--space-12); }
.btn-quiet:hover { background: var(--sunken-3); }
.btn-link { color: var(--ink-muted); padding: 0; }
.btn-link:hover { color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.chip {
  font-size: 13px; line-height: 19px;
  display: inline-flex; align-items: center; height: var(--size-control); padding: 0 var(--space-12);
  border: 0; border-radius: var(--radius-md); background: var(--sunken-3); color: var(--ink); cursor: pointer;
}
.chip:hover { background: var(--sunken-2); }
.chip[aria-checked="true"] { background: var(--inverse); color: var(--on-inverse); }

/* Compose: the prompt is the search field */
.compose { display: flex; flex-direction: column; gap: var(--space-12); }
.field {
  display: flex; align-items: flex-end; gap: var(--space-12);
  min-height: var(--size-field); padding: 10px 10px 10px var(--space-16);
  border-radius: var(--radius-lg); background: var(--sunken-3); cursor: text;
}
.field textarea {
  flex: 1; min-width: 0; display: block; height: 30px; max-height: 222px;
  padding: 3px 0; border: 0; resize: none; overflow-y: auto;
  background: transparent; color: var(--ink);
}
.field textarea::placeholder { color: var(--ink-muted); opacity: 1; }
/* The field carries the ring while you type in it; the text box never draws its own, and
   the Generate button inside draws only its own (the field's ring goes when focus moves to it). */
.field textarea:focus, .field textarea:focus-visible { outline: none; box-shadow: none; }
.field:focus-within { outline: 2px solid var(--ink); outline-offset: var(--space-2); }
@supports selector(:has(*)) {
  .field:focus-within { outline: none; }
  .field:has(textarea:focus) { outline: 2px solid var(--ink); outline-offset: var(--space-2); }
}

.controls { display: flex; align-items: center; justify-content: space-between; gap: var(--space-12) var(--space-16); flex-wrap: wrap; }
.options { display: flex; align-items: center; gap: var(--space-16); flex-wrap: wrap; }
.seg { display: flex; gap: var(--space-12); }
.seg button { height: var(--size-control); padding: 0; border: 0; background: transparent; color: var(--ink-muted); cursor: pointer; border-radius: var(--radius-row); }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { color: var(--ink); }
.dims { min-width: 92px; }
.seed { display: flex; align-items: center; gap: var(--space-8); }
.seed input {
  width: 104px; height: var(--size-control); padding: 0 var(--space-12);
  border: 0; border-radius: var(--radius-md); background: var(--sunken-3); color: var(--ink);
}
.seed input::placeholder { color: var(--ink-muted); opacity: 1; }

/* Reference images */
.refs { display: flex; align-items: center; gap: var(--space-14); flex-wrap: wrap; }
.ref-list { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.ref {
  position: relative; width: var(--size-thumb-lg); aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm); background: var(--fill);   /* no overflow clip: the remove button's ring sits outside it */
}
.ref img { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: var(--radius-sm); }
.ref-n, .ref-x {
  position: absolute; top: var(--space-4); height: 16px; min-width: 16px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-xs); background: var(--sunken-3); color: var(--ink);
}
.ref-n { left: var(--space-4); }
.ref-x { right: var(--space-4); border: 0; cursor: pointer; font-size: 13px; line-height: 1; }
.ref-x:hover { background: var(--surface); }
.ref-note { flex: 1; min-width: 200px; }

/* Groups: an open session. sunken-3 container, 4px inset, rows on a 2px seam. */
.group { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); border-radius: var(--radius-lg); background: var(--sunken-3); }
.group-head {
  display: flex; align-items: center; gap: var(--space-16); width: 100%;
  padding: var(--space-8) var(--space-10); border: 0; border-radius: var(--radius-lg);
  background: transparent; text-align: left;
}
button.group-head { cursor: pointer; }
.label { display: flex; flex-direction: column; width: var(--size-label); flex-shrink: 0; min-width: 0; }
.label-wide { flex: 1; width: auto; }
.clock, .pm { flex-shrink: 0; text-align: right; }
.clock { min-width: 44px; }
.pm { width: var(--space-12); text-align: center; }

/* Closed session: the group drops its container, the row takes sunken-2 */
.group.is-closed { padding: 0; background: transparent; }
.group.is-closed .group-head { padding: var(--space-12) var(--space-14); background: var(--sunken-2); }
.group.is-closed .group-head:hover { background: var(--sunken-3); }
.group.is-closed .track { background: var(--sunken-3); }
.group.is-closed .rows { display: none; }

/* Track: a rail for one whole run; marks sit at their real position on it */
.track { position: relative; display: block; flex: 1; min-width: 0; height: var(--size-track); border-radius: var(--radius-sm); background: var(--surface); }
.track .m {
  position: absolute; top: var(--space-4); bottom: var(--space-4); width: var(--size-mark);
  border-radius: var(--radius-xs); background: var(--mark); transform: translateX(-50%);
  transition: opacity 160ms ease;
}
.track .m.best { width: var(--size-mark-best); background: var(--ink); }
.track .m.enter { opacity: 0; }

/* Canvas: the one raised row */
.canvas {
  display: flex; align-items: center; justify-content: center;
  min-height: 380px; padding: var(--space-12);
  border-radius: var(--radius-row); background: var(--surface);
}
.canvas img {
  display: block; max-width: 100%; max-height: min(72vh, 880px); width: auto; height: auto;
  border-radius: var(--radius-sm);
}
.canvas.alpha img {
  background-color: var(--surface);
  background-image: conic-gradient(var(--sunken-3) 25%, transparent 0 50%, var(--sunken-3) 0 75%, transparent 0);
  background-size: 16px 16px;
}
.placeholder { max-width: 100%; border-radius: var(--radius-sm); background: var(--fill); }
.empty { display: flex; flex-direction: column; gap: var(--space-8); max-width: 460px; padding: var(--space-32) var(--space-16); text-align: center; }

/* Rows */
.rows { display: flex; flex-direction: column; gap: var(--space-2); }
.row {
  display: flex; align-items: center; gap: var(--space-14); width: 100%;
  padding: var(--space-10) var(--space-12); border: 0; border-radius: var(--radius-row);
  background: var(--sunken-1); color: var(--ink); text-align: left;
  font-size: 13px; line-height: 19px;
}
.group > .row:last-child, .rows > .row:last-child { border-bottom-left-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); }
button.row { cursor: pointer; }
button.row:hover { background: var(--sunken-2); }
button.row:hover .act { color: var(--ink); }
.row .when { width: var(--size-label); flex-shrink: 0; color: var(--ink-muted); }
.row .text { flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row .sub { display: none; color: var(--ink-muted); }
.row .act { flex-shrink: 0; color: var(--ink-muted); }
.row .act.on { color: var(--ink); }
.thumb {
  flex-shrink: 0; width: var(--size-thumb); aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm); background: var(--fill); overflow: hidden;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.meta-row { gap: var(--space-14); }
.prompt-row { align-items: flex-start; }
.prompt-row .when, .prompt-row .btn { line-height: 19px; height: auto; }
.prompt-row .text { -webkit-line-clamp: 3; color: var(--ink-muted); }
.prompt-row.open .text { -webkit-line-clamp: unset; display: block; }
.meta-row .err { color: var(--ink); white-space: normal; }

.foot { display: flex; flex-direction: column; gap: var(--space-4); padding-top: var(--space-8); }
.foot a { color: var(--ink-muted); text-decoration: underline; text-underline-offset: 2px; }
.foot a:hover { color: var(--ink); }

/* Drop overlay */
.drop {
  position: fixed; inset: var(--space-16); z-index: 10;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-lg); background: var(--sunken-3); pointer-events: none;
}

@media (max-width: 720px) {
  .page { padding: var(--space-24) var(--space-16); }
  .label:not(.label-wide) { width: 112px; }
  .row .when { display: none; }
  .row .sub { display: block; }
  .row .text { display: block; }
  .row .text .p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .canvas { min-height: 280px; padding: var(--space-8); }
  .options { gap: var(--space-12); }
  .meta-row { flex-wrap: wrap; row-gap: var(--space-4); }
  .meta-row .grow { flex-basis: 100%; }
  .prompt-row { flex-wrap: wrap; }
  .prompt-row .when { display: block; width: 100%; }
}
