:root {
  color-scheme: light;
  --ink: #171918;
  --ink-soft: #444946;
  --paper: #f5f6f2;
  --surface: #ffffff;
  --line: #d9ddd7;
  --line-dark: #3b3f3c;
  --acid: #d9ff43;
  --coral: #f06545;
  --cyan: #79d7de;
  --success: #2f8d5b;
  --danger: #d54836;
  --warning: #d99022;
  --radius: 6px;
  --header-height: 66px;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

body {
  overflow-x: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
a,
label,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.app-header {
  position: sticky;
  z-index: 40;
  top: 0;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line-dark);
  background: var(--ink);
  color: #fff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.48);
  background: var(--acid);
  color: var(--ink);
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 12px;
  line-height: 1;
}

.brand-mark b {
  display: grid;
  height: 100%;
  place-items: center;
  border-right: 1px solid var(--ink);
}

.brand-mark b:last-child {
  border-right: 0;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 13px;
  line-height: 1;
}

.brand-copy small {
  color: #aeb4af;
  font-size: 9px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.service-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #b9beb9;
  font-size: 12px;
}

.service-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(217, 144, 34, 0.15);
}

.service-state.online i {
  background: var(--acid);
  box-shadow: 0 0 0 3px rgba(217, 255, 67, 0.15);
}

.service-state.offline i {
  background: var(--coral);
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.icon-button svg,
.inline-icon svg,
button svg,
a svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}

.studio-shell {
  min-height: calc(100vh - var(--header-height));
  display: grid;
  grid-template-columns: minmax(340px, 390px) minmax(0, 1fr);
}

.control-rail {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line-dark);
  background: var(--surface);
}

.rail-heading,
.workspace-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.rail-heading {
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}

.section-index {
  display: block;
  margin-bottom: 7px;
  color: #757c77;
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: 10px;
  font-weight: 700;
}

.section-index.dark {
  color: #686e69;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2 {
  font-family: "Arial Black", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
}

#generation-form {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.form-stack {
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  gap: 20px;
  align-content: start;
  overflow-y: auto;
  padding: 20px 24px 24px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field-group {
  display: grid;
  gap: 9px;
}

.field-group > label,
.field-group > legend,
.control-label,
.field-label-row label {
  color: #303431;
  font-size: 12px;
  font-weight: 700;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-label-row > span,
.key-state {
  color: #858b86;
  font-size: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.segmented input,
.ratio-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label > span {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 4px;
  color: #616762;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.segmented input:checked + span {
  background: var(--ink);
  color: #fff;
}

.input-with-action {
  position: relative;
}

input[type="password"],
input[type="text"],
input[type="url"],
textarea,
select {
  width: 100%;
  outline: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input[type="password"],
input[type="text"],
input[type="url"],
select {
  height: 42px;
  padding: 0 40px 0 12px;
}

.endpoint-field input,
#model {
  font-family: "Courier New", monospace;
  font-size: 11px;
}

textarea {
  min-height: 132px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(23, 25, 24, 0.08);
}

.inline-icon {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: #717772;
  cursor: pointer;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  width: fit-content;
  color: #6c726d !important;
  cursor: pointer;
  font-size: 11px !important;
  font-weight: 500 !important;
}

.checkbox-row input {
  position: absolute;
  opacity: 0;
}

.check-box {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border: 1px solid #adb2ae;
  border-radius: 3px;
  background: #fff;
}

.check-box svg {
  width: 11px;
  height: 11px;
  opacity: 0;
}

.checkbox-row input:checked + .check-box {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.checkbox-row input:checked + .check-box svg {
  opacity: 1;
}

.drop-zone {
  min-height: 96px;
  display: grid !important;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 15px;
  border: 1px dashed #a9afa9;
  border-radius: var(--radius);
  background: #f8f9f6;
  cursor: pointer;
}

.drop-zone.dragging {
  border-style: solid;
  border-color: var(--ink);
  background: #eff4dc;
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-zone > svg {
  width: 19px;
  height: 19px;
}

.drop-zone > span {
  color: var(--ink);
  font-size: 12px;
}

.drop-zone > small {
  grid-column: 2 / -1;
  color: #8a908b;
  font-size: 9px;
}

.upload-previews {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.upload-preview {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #eee;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.upload-preview button {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(23, 25, 24, 0.86);
  color: #fff;
  cursor: pointer;
}

.upload-preview button svg {
  width: 13px;
  height: 13px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.model-quality-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(100px, 0.75fr);
}

.select-wrap {
  position: relative;
}

select {
  appearance: none;
  cursor: pointer;
  font-size: 12px;
}

.select-wrap > svg {
  position: absolute;
  top: 13px;
  right: 12px;
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.ratio-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.ratio-options label > span {
  min-height: 74px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: #626863;
  cursor: pointer;
}

.ratio-options input:checked + span {
  border-color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--acid);
  color: var(--ink);
}

.ratio-options b {
  font-size: 10px;
}

.ratio-options small {
  color: #8c918d;
  font-size: 8px;
}

.ratio-shape {
  display: block;
  border: 1.5px solid currentColor;
  border-radius: 1px;
}

.ratio-shape.square {
  width: 17px;
  height: 17px;
}

.ratio-shape.portrait {
  width: 14px;
  height: 19px;
}

.ratio-shape.landscape {
  width: 21px;
  height: 14px;
}

.ratio-shape.phone {
  width: 11px;
  height: 20px;
}

.ratio-shape.wide {
  width: 23px;
  height: 13px;
}

.count-field {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.stepper {
  height: 38px;
  display: grid;
  grid-template-columns: 38px 42px 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.stepper button {
  display: grid;
  place-items: center;
  border: 0;
  background: #fff;
  cursor: pointer;
}

.stepper button:hover {
  background: var(--paper);
}

.stepper output {
  display: grid;
  place-items: center;
  border-right: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.submit-dock {
  position: static;
  flex: 0 0 auto;
  padding: 14px 24px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.generate-button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 18px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition: transform 140ms ease, background 140ms ease;
}

.generate-button:hover:not(:disabled) {
  background: #2a2d2b;
  transform: translateY(-1px);
}

.generate-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.generate-button svg {
  width: 19px;
  height: 19px;
  color: var(--acid);
}

.submit-dock p {
  margin-top: 8px;
  color: #858b86;
  text-align: center;
  font-size: 9px;
}

.workspace {
  min-width: 0;
  padding: 28px 30px 50px;
  background-color: var(--paper);
  background-image: linear-gradient(#e8ebe6 1px, transparent 1px), linear-gradient(90deg, #e8ebe6 1px, transparent 1px);
  background-size: 28px 28px;
}

.workspace-head {
  min-height: 58px;
  gap: 24px;
  margin-bottom: 24px;
}

.title-line {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.title-line h2 {
  font-size: 31px;
  line-height: 1;
}

.title-line span {
  color: #8b918c;
  font-size: 12px;
}

.filter-tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.8);
}

.filter-tabs button {
  height: 32px;
  padding: 0 13px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #707671;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.filter-tabs button.active {
  background: var(--ink);
  color: #fff;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
  gap: 16px;
}

.task-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
}

.task-visual {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-bottom: 1px solid var(--ink);
  background: #e9ece7;
}

.task-visual img {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  object-fit: cover;
  transition: opacity 180ms ease, transform 240ms ease;
}

.task-visual img.is-ready {
  opacity: 1;
}

.task-image-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  color: #686e69;
  font-size: 10px;
  font-weight: 700;
}

.task-image-loader i {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(23, 25, 24, 0.16);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.task-visual.image-ready .task-image-loader {
  visibility: hidden;
}

.task-visual.image-failed .task-image-loader i {
  border: 2px solid var(--danger);
  animation: none;
}

.task-card:has(.task-visual img) .task-visual {
  cursor: zoom-in;
}

.task-card:has(.task-visual img) .task-visual:hover img {
  transform: scale(1.018);
}

.image-stack-count {
  position: absolute;
  right: 9px;
  bottom: 9px;
  min-width: 28px;
  height: 25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 7px;
  border-radius: 3px;
  background: rgba(23, 25, 24, 0.88);
  color: #fff;
  font-size: 10px;
}

.image-stack-count svg {
  width: 13px;
  height: 13px;
}

.task-progress {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #dfe4de;
}

.task-progress::before {
  position: absolute;
  inset: -40%;
  content: "";
  background: repeating-linear-gradient(115deg, transparent 0 34px, rgba(255, 255, 255, 0.58) 34px 67px);
  animation: sweep 2.8s linear infinite;
}

.progress-center {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 11px;
}

.progress-ring {
  width: 44px;
  height: 44px;
  border: 2px solid rgba(23, 25, 24, 0.18);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.progress-center strong {
  font-size: 11px;
}

.task-error-visual {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background-color: #f0ded9;
  background-image: linear-gradient(45deg, rgba(213, 72, 54, 0.1) 25%, transparent 25%, transparent 75%, rgba(213, 72, 54, 0.1) 75%);
  background-size: 24px 24px;
  color: var(--danger);
}

.task-error-visual svg {
  width: 42px;
  height: 42px;
  stroke-width: 1.3;
}

.task-body {
  display: grid;
  gap: 12px;
  padding: 13px 14px 14px;
}

.task-topline,
.task-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #656b66;
  font-size: 9px;
  font-weight: 800;
}

.status-chip i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-chip.success {
  color: var(--success);
}

.status-chip.queued,
.status-chip.running {
  color: #8a741e;
}

.status-chip.failed,
.status-chip.unknown {
  color: var(--danger);
}

.task-time {
  color: #858b86;
  font-size: 9px;
}

.task-prompt {
  min-height: 38px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: #303431;
  font-size: 12px;
  line-height: 1.55;
}

.task-error-message {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  padding: 8px 9px;
  border-left: 3px solid var(--danger);
  background: #fff2ef;
  color: #7d3026;
  font-size: 10px;
  line-height: 1.5;
}

.task-meta {
  color: #777d78;
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: 9px;
}

.task-actions {
  display: flex;
  gap: 4px;
}

.task-actions button,
.task-actions a {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}

.task-actions button:hover,
.task-actions a:hover {
  border-color: var(--ink);
}

.task-actions svg {
  width: 14px;
  height: 14px;
}

.empty-state {
  min-height: min(630px, calc(100vh - 190px));
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty-state[hidden] {
  display: none;
}

.empty-composition {
  position: relative;
  min-height: 460px;
  overflow: hidden;
  background: var(--ink);
  color: #fff;
}

.empty-composition::after {
  position: absolute;
  top: 12%;
  right: 8%;
  width: min(27vw, 360px);
  aspect-ratio: 1;
  content: "";
  border: 1px solid var(--acid);
  border-radius: 50%;
  box-shadow: inset 0 0 0 18px var(--ink), inset 0 0 0 19px rgba(217, 255, 67, 0.45);
}

.empty-composition::before {
  position: absolute;
  inset: 0;
  content: "";
  background-image: linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 44px 44px;
}

.word {
  position: absolute;
  z-index: 1;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(72px, 10vw, 168px);
  line-height: 0.78;
  white-space: nowrap;
}

.word-one {
  top: 13%;
  left: 5%;
  color: var(--acid);
}

.word-two {
  top: 42%;
  left: 17%;
  color: #fff;
}

.word-three {
  right: 7%;
  bottom: 7%;
  color: var(--coral);
}

.composition-mark {
  position: absolute;
  z-index: 2;
  right: 4%;
  bottom: 4%;
  color: #a9b0aa;
  font-family: "Courier New", monospace;
  font-size: 10px;
}

.empty-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-top: 1px solid var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.viewer {
  width: min(1180px, calc(100vw - 48px));
  height: min(780px, calc(100vh - 48px));
  max-width: none;
  max-height: none;
  grid-template-columns: minmax(0, 1fr) 320px;
  padding: 0;
  overflow: hidden;
  border: 1px solid #5d635e;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
}

.viewer[open] {
  display: grid;
}

.viewer::backdrop {
  background: rgba(10, 12, 11, 0.86);
  backdrop-filter: blur(7px);
}

.viewer-close {
  position: absolute;
  z-index: 4;
  top: 14px;
  right: 14px;
  color: #fff;
}

.viewer-stage {
  position: relative;
  min-width: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 28px;
  background-color: #0f1110;
  background-image: linear-gradient(#242725 1px, transparent 1px), linear-gradient(90deg, #242725 1px, transparent 1px);
  background-size: 32px 32px;
}

.viewer-stage .viewer-image {
  max-width: 100%;
  max-height: 100%;
  display: block;
  opacity: 1;
  object-fit: contain;
  box-shadow: 0 16px 55px rgba(0, 0, 0, 0.35);
}

.viewer-stage .viewer-image:not([src]) {
  visibility: hidden;
}

.viewer-stage .viewer-image.is-preview {
  filter: saturate(0.94);
  animation: viewer-image-in 140ms ease-out both;
}

.viewer-stage .viewer-image.is-original {
  animation: viewer-image-in 180ms ease-out both;
}

.viewer-load-state {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 22px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 12px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 4px;
  background: rgba(17, 19, 18, 0.86);
  color: #f4f6f4;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  transition: opacity 160ms ease, visibility 160ms ease;
}

.viewer-load-spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.viewer-stage[data-image-state="loading"] .viewer-load-state {
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
}

.viewer-stage[data-image-state="ready"] .viewer-load-state,
.viewer-stage[data-image-state="idle"] .viewer-load-state {
  visibility: hidden;
  opacity: 0;
}

.viewer-stage[data-image-state="fallback"] .viewer-load-state,
.viewer-stage[data-image-state="error"] .viewer-load-state {
  border-color: rgba(213, 72, 54, 0.72);
}

.viewer-stage[data-image-state="fallback"] .viewer-load-spinner,
.viewer-stage[data-image-state="error"] .viewer-load-spinner {
  border: 0;
  animation: none;
}

.viewer-stage[data-image-state="fallback"] .viewer-load-spinner::before,
.viewer-stage[data-image-state="error"] .viewer-load-spinner::before {
  content: "!";
  color: #ff9b8e;
  font-size: 14px;
  line-height: 14px;
}

.viewer-nav {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  background: rgba(20, 22, 21, 0.75);
  color: #fff;
  cursor: pointer;
}

.viewer-nav.prev {
  left: 14px;
}

.viewer-nav.next {
  right: 14px;
}

.viewer-nav[hidden] {
  display: none;
}

.viewer-info {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
  padding: 30px 24px 24px;
  border-left: 1px solid #3b3f3c;
  background: #1d201e;
}

.viewer-info h3 {
  font-size: 20px;
}

.viewer-info > p {
  max-height: 210px;
  overflow-y: auto;
  color: #d2d6d2;
  font-size: 12px;
  line-height: 1.7;
}

.viewer-info dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px 14px;
  margin: 0;
  padding-top: 18px;
  border-top: 1px solid #3b3f3c;
  font-size: 10px;
}

.viewer-info dt {
  color: #858c86;
}

.viewer-info dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #e9ece9;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-actions {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.download-button,
.delete-button {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.download-button {
  border: 1px solid var(--acid);
  background: var(--acid);
  color: var(--ink);
}

.delete-button {
  border: 1px solid #535853;
  background: transparent;
  color: #dadeda;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 35px rgba(23, 25, 24, 0.16);
  color: var(--ink);
  font-size: 11px;
  line-height: 1.45;
  animation: toast-in 180ms ease-out;
}

.toast.error {
  border-left: 5px solid var(--danger);
}

.toast.success {
  border-left: 5px solid var(--success);
}

.toast svg {
  width: 17px;
  height: 17px;
}

.mobile-only {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes sweep {
  to { transform: translateX(95px); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes viewer-image-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@media (max-width: 900px) {
  .studio-shell {
    display: block;
  }

  .control-rail {
    position: relative;
    top: 0;
    width: 100%;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

  #generation-form {
    overflow: visible;
  }

  .form-stack {
    flex: none;
    overflow: visible;
  }

  .mobile-only {
    display: inline-grid;
  }

  .rail-heading .icon-button {
    color: var(--ink);
  }

  .control-rail.collapsed .form-stack {
    display: none;
  }

  .control-rail.collapsed .submit-dock {
    display: none;
  }

  .workspace {
    min-height: 640px;
    padding: 24px 20px 42px;
  }

  .viewer {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .viewer-info {
    max-height: 230px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 20px;
    padding: 18px;
    border-top: 1px solid #3b3f3c;
    border-left: 0;
  }

  .viewer-info > p {
    max-height: 80px;
  }

  .viewer-info dl {
    padding-top: 0;
    border-top: 0;
  }

  .viewer-actions {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  :root {
    --header-height: 60px;
  }

  .app-header {
    padding: 0 14px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 10px;
  }

  .brand-copy small,
  .service-state span {
    display: none;
  }

  .service-state {
    margin-right: 3px;
  }

  .rail-heading {
    padding: 18px 16px 15px;
  }

  .form-stack {
    gap: 18px;
    padding: 18px 16px 22px;
  }

  .submit-dock {
    padding: 12px 16px 14px;
  }

  .workspace {
    padding: 22px 14px 38px;
    background-size: 24px 24px;
  }

  .workspace-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .filter-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .filter-tabs button {
    flex: 1 0 auto;
  }

  .gallery {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .empty-state {
    min-height: 430px;
  }

  .empty-composition {
    min-height: 360px;
  }

  .empty-composition::after {
    top: 11%;
    right: -10%;
    width: 52vw;
  }

  .word {
    font-size: 20vw;
  }

  .word-one {
    top: 17%;
  }

  .word-two {
    top: 43%;
    left: 8%;
  }

  .word-three {
    right: 4%;
    bottom: 13%;
  }

  .viewer {
    width: 100vw;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .viewer-stage {
    padding: 16px;
  }

  .viewer-info {
    max-height: 310px;
    display: flex;
    padding: 16px;
  }

  .viewer-info > p {
    max-height: 62px;
  }

  .viewer-info dl {
    display: none;
  }

  .viewer-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

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