:root {
  --ink: #10100f;
  --ink-soft: #1b1b19;
  --ink-raised: #262623;
  --paper: #f3f1e9;
  --canvas: #d8d8d0;
  --canvas-deep: #c5c5bc;
  --line-dark: #3b3b37;
  --line-light: #b8b8af;
  --muted-dark: #909088;
  --muted-light: #686861;
  --acid: #d8ff3e;
  --coral: #ff674f;
  --gold: #f2b84b;
  --cyan: #58bde8;
  --white: #fffef8;
  --danger: #c63d2b;
  --mode-accent: var(--acid);
  --shadow: 0 24px 70px rgb(0 0 0 / 0.24);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--ink);
  font-family: "Bahnschrift", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button, input, textarea, select { font: inherit; }
button, input, textarea, select, a { outline-offset: 3px; }
button, select, input[type="radio"] + span, .upload-empty { cursor: pointer; }
svg { stroke-linecap: square; stroke-linejoin: miter; }

.shell { min-height: 100vh; }
.shell[data-mode="commerce"] { --mode-accent: var(--gold); }
.shell[data-mode="science"] { --mode-accent: var(--cyan); }

.topbar {
  align-items: center;
  background: var(--ink);
  border-bottom: 1px solid var(--line-dark);
  color: var(--white);
  display: flex;
  height: 62px;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 5;
}

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

.brand-mark {
  align-items: center;
  background: var(--acid);
  color: var(--ink);
  display: inline-flex;
  flex: 0 0 34px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.brand-copy, .login-brand > span:last-child { display: flex; flex-direction: column; }
.brand-copy b, .login-brand b { font-family: Georgia, "Noto Serif SC", serif; font-size: 14px; font-weight: 700; }
.brand-copy small, .login-brand small { color: #96968f; font-family: "Courier New", monospace; font-size: 7px; margin-top: 2px; }

.topbar-context {
  align-items: center;
  display: flex;
  font-family: "Courier New", monospace;
  font-size: 11px;
  gap: 7px;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
}

.context-index { color: #777770; }
.topbar-context b { color: var(--mode-accent); font-weight: 700; }

.topbar-actions, .stage-actions, .status-line, .settings-actions {
  align-items: center;
  display: flex;
}

.topbar-actions { gap: 8px; }

.model-indicator, .key-status, .user-indicator {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line-dark);
  color: var(--white);
  display: inline-flex;
  font-family: "Courier New", monospace;
  font-size: 10px;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
}

.model-indicator i, .status-dot {
  background: var(--mode-accent);
  border-radius: 50%;
  display: inline-block;
  height: 7px;
  width: 7px;
}

.key-status:hover, .icon-button:hover { background: rgb(255 255 255 / 0.08); }
.key-status.is-ready { border-color: #788d33; color: var(--acid); }
.key-status svg, .user-indicator svg { fill: none; height: 15px; stroke: currentColor; stroke-width: 1.7; width: 15px; }
.user-indicator b { color: inherit; font-weight: 400; }

.icon-button {
  align-items: center;
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  display: inline-flex;
  flex: 0 0 34px;
  height: 34px;
  justify-content: center;
  padding: 0;
  text-decoration: none;
  width: 34px;
}

.icon-button svg { fill: none; height: 17px; stroke: currentColor; stroke-width: 1.7; width: 17px; }
.icon-button.is-disabled { opacity: 0.28; pointer-events: none; }

.workspace {
  display: grid;
  grid-template-columns: minmax(410px, 480px) minmax(0, 1fr);
  min-height: calc(100vh - 62px);
}

.control-deck {
  background: var(--ink-soft);
  border-right: 1px solid var(--line-dark);
  color: var(--white);
  max-height: calc(100vh - 62px);
  overflow-y: auto;
  padding: 25px 24px 34px;
  scrollbar-color: #50504a var(--ink-soft);
  scrollbar-width: thin;
}

.deck-header {
  align-items: flex-end;
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--muted-dark);
  display: block;
  font-family: "Courier New", monospace;
  font-size: 9px;
  font-weight: 700;
  margin-bottom: 5px;
}

h1, h2 { font-family: Georgia, "Noto Serif SC", serif; letter-spacing: 0; margin: 0; }
h1 { font-size: 27px; font-weight: 500; }
.sequence { color: var(--muted-dark); font-family: "Courier New", monospace; font-size: 11px; }

.mode-tabs {
  border: 1px solid var(--line-dark);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 24px;
}

.mode-tabs button {
  align-items: center;
  background: transparent;
  border: 0;
  color: #aaa9a2;
  display: flex;
  flex-direction: column;
  font-size: 10px;
  gap: 5px;
  height: 61px;
  justify-content: center;
  min-width: 0;
  padding: 0 4px;
}

.mode-tabs button + button { border-left: 1px solid var(--line-dark); }
.mode-tabs button svg { fill: none; height: 18px; stroke: currentColor; stroke-width: 1.6; width: 18px; }
.mode-tabs button.is-active { background: var(--mode-accent); color: var(--ink); font-weight: 800; }
.mode-tabs button:focus-visible { outline: 2px solid var(--coral); outline-offset: -4px; }

.mode-panel { min-width: 0; }
.field-label, fieldset legend, .select-row label > span, .settings-panel form > label, .settings-label-row label {
  color: #d3d2ca;
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 8px;
}

.field-gap { margin-top: 17px; }
.prompt-wrap { position: relative; }

textarea, .text-input, select {
  background: var(--ink-raised);
  border: 1px solid #4a4a45;
  border-radius: 0;
  color: var(--white);
  width: 100%;
}

textarea {
  line-height: 1.6;
  min-height: 138px;
  padding: 13px 13px 28px;
  resize: vertical;
}

.compact-prompt textarea { min-height: 100px; }
.text-input { height: 44px; padding: 0 12px; }
textarea::placeholder, .text-input::placeholder { color: #777771; }
textarea:focus, .text-input:focus, select:focus, .login-field:focus-within, .locked-field:focus-within {
  border-color: var(--mode-accent);
  box-shadow: 0 0 0 1px var(--mode-accent);
  outline: 0;
}

.counter {
  bottom: 8px;
  color: var(--muted-dark);
  font-family: "Courier New", monospace;
  font-size: 9px;
  position: absolute;
  right: 9px;
}
.counter b { color: #d2d1c9; font-weight: 400; }

fieldset { border: 0; margin: 0; padding: 0; }
.batch-fieldset { margin-top: 18px; }

.segment-control {
  border: 1px solid #4a4a45;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.segment-control label + label { border-left: 1px solid #4a4a45; }
.segment-control input, .ratio-option input { opacity: 0; pointer-events: none; position: absolute; }
.segment-control span { align-items: center; display: flex; font-size: 11px; height: 38px; justify-content: center; }
.segment-control input:checked + span { background: var(--mode-accent); color: var(--ink); font-weight: 800; }
.segment-control input:focus-visible + span { outline: 2px solid var(--coral); outline-offset: -3px; }

.select-row { display: grid; gap: 9px; grid-template-columns: 1fr 1fr; }
.mode-select-row { margin-top: 18px; }
.science-options { grid-template-columns: 1fr 1fr; margin-top: 18px; }
.science-options label:last-child { grid-column: 1 / -1; }
.select-row label > span { margin-bottom: 7px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23d8ff3e' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-repeat: no-repeat;
  height: 42px;
  padding: 0 30px 0 10px;
}

.reference-section, .output-settings {
  border-top: 1px solid var(--line-dark);
  margin-top: 23px;
  padding-top: 20px;
}

.section-label-row { align-items: center; display: flex; justify-content: space-between; }
.section-label-row .field-label { margin-bottom: 8px; }
.section-label-row > span { color: var(--muted-dark); font-family: "Courier New", monospace; font-size: 9px; }

.upload-box {
  background: #20201e;
  border: 1px dashed #565650;
  min-height: 72px;
  position: relative;
}
.upload-box.is-dragging { border-color: var(--mode-accent); background: #292925; }
.upload-box > input { height: 1px; opacity: 0; position: absolute; width: 1px; }
.upload-empty { align-items: center; color: #9b9a93; display: flex; font-size: 10px; gap: 10px; min-height: 72px; padding: 12px; }
.upload-empty svg { fill: none; height: 22px; stroke: var(--mode-accent); stroke-width: 1.6; width: 22px; }
.upload-preview { align-items: center; display: grid; gap: 10px; grid-template-columns: 50px minmax(0, 1fr) 34px; padding: 9px; }
.upload-preview img { background: #111; height: 50px; object-fit: cover; width: 50px; }
.upload-preview > div { min-width: 0; }
.upload-preview b, .upload-preview span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-preview b { font-size: 10px; }
.upload-preview span { color: var(--muted-dark); font-family: "Courier New", monospace; font-size: 9px; margin-top: 4px; }
.upload-preview .icon-button { color: #b7b6af; }

.output-settings { display: grid; gap: 14px; }
.ratio-grid { display: grid; gap: 7px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ratio-option > span {
  align-items: center;
  border: 1px solid #4a4a45;
  color: #aaa9a2;
  display: flex;
  gap: 8px;
  height: 42px;
  justify-content: center;
}
.ratio-option input:checked + span { background: var(--mode-accent); border-color: var(--mode-accent); color: var(--ink); }
.ratio-option input:focus-visible + span { outline: 2px solid var(--coral); outline-offset: 2px; }
.ratio-option b { font-family: "Courier New", monospace; font-size: 10px; }
.ratio-shape { border: 1px solid currentColor; display: block; height: 14px; width: 14px; }
.ratio-shape.landscape { height: 11px; width: 17px; }
.ratio-shape.portrait { height: 17px; width: 11px; }
.output-select-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.generate-button {
  align-items: center;
  background: var(--mode-accent);
  border: 1px solid var(--mode-accent);
  color: var(--ink);
  display: flex;
  font-weight: 900;
  height: 52px;
  justify-content: space-between;
  margin-top: 22px;
  overflow: hidden;
  padding: 0 16px;
  position: relative;
  width: 100%;
}
.generate-button:hover { box-shadow: 5px 5px 0 var(--coral); transform: translate(-2px, -2px); }
.generate-button:disabled { cursor: wait; opacity: 0.72; transform: none; }
.generate-button svg { fill: none; height: 19px; stroke: currentColor; stroke-width: 1.9; width: 19px; }
.generate-button.needs-key { background: var(--coral); border-color: var(--coral); }
.button-label, .generate-button svg { position: relative; z-index: 2; }
.button-progress { background: var(--white); bottom: 0; left: 0; opacity: 0.5; position: absolute; top: 0; transform: translateX(-102%); width: 100%; }
.generate-button.is-loading .button-progress { animation: button-progress 4s ease-in-out infinite; }

.stage {
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 16px 18px 18px;
}

.stage-toolbar {
  align-items: center;
  display: flex;
  font-family: "Courier New", monospace;
  font-size: 10px;
  justify-content: space-between;
  margin-bottom: 12px;
  min-height: 34px;
}
.status-line { gap: 8px; }
.stage .status-dot { background: #34a853; }
.stage.is-working .status-dot { animation: pulse 1s infinite; background: var(--coral); }
.stage-actions { color: #4b4b45; gap: 9px; }

.result-workspace {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr) 112px;
  min-height: 0;
}

.image-stage {
  align-items: center;
  background-color: var(--canvas-deep);
  background-image: linear-gradient(#b5b5ac 1px, transparent 1px), linear-gradient(90deg, #b5b5ac 1px, transparent 1px);
  background-size: 24px 24px;
  display: flex;
  justify-content: center;
  min-height: 450px;
  overflow: hidden;
  padding: clamp(24px, 4vw, 58px);
  position: relative;
}
.image-stage img { background: var(--white); box-shadow: var(--shadow); display: block; height: auto; max-height: calc(100vh - 185px); max-width: 100%; object-fit: contain; position: relative; width: auto; z-index: 2; }
.preview-stamp { background: var(--ink); bottom: 12px; color: var(--mode-accent); font-family: "Courier New", monospace; font-size: 8px; left: 12px; padding: 6px 8px; position: absolute; z-index: 3; }
.frame-lines { inset: 12px; pointer-events: none; position: absolute; z-index: 3; }
.frame-lines::before, .frame-lines::after { border-color: var(--ink); border-style: solid; content: ""; height: 17px; position: absolute; width: 17px; }
.frame-lines::before { border-width: 1px 0 0 1px; left: 0; top: 0; }
.frame-lines::after { border-width: 0 1px 1px 0; bottom: 0; right: 0; }

.working-layer { align-items: center; background: rgb(16 16 15 / 0.88); color: var(--white); display: flex; flex-direction: column; inset: 0; justify-content: center; position: absolute; z-index: 4; }
.working-layer > span { font-family: "Courier New", monospace; font-size: 72px; }
.working-layer p { color: var(--mode-accent); font-family: "Courier New", monospace; font-size: 10px; font-weight: 700; margin: 7px 0 0; }
.scan-line { animation: scan 2.2s linear infinite; background: var(--mode-accent); height: 1px; left: 8%; opacity: 0.75; position: absolute; right: 8%; top: 8%; }

.result-rail { background: #bdbdb4; border-left: 1px solid #a5a59c; min-width: 0; padding: 9px; }
.result-rail header { align-items: center; display: flex; font-family: "Courier New", monospace; font-size: 8px; justify-content: space-between; margin-bottom: 8px; }
.result-rail header b { color: var(--muted-light); }
.result-gallery { display: grid; gap: 8px; }
.result-thumb { aspect-ratio: 1; background: #a7a79f; border: 1px solid transparent; display: block; overflow: hidden; padding: 0; position: relative; width: 100%; }
.result-thumb img { height: 100%; object-fit: cover; width: 100%; }
.result-thumb span { background: var(--ink); bottom: 3px; color: var(--white); font-family: "Courier New", monospace; font-size: 7px; left: 3px; padding: 3px 4px; position: absolute; }
.result-thumb.is-active { border-color: var(--ink); box-shadow: 3px 3px 0 var(--mode-accent); }
.gallery-empty { align-items: center; aspect-ratio: 1; border: 1px dashed #919189; color: #7c7c75; display: flex; flex-direction: column; justify-content: center; }
.gallery-empty span { font-family: Georgia, serif; font-size: 22px; }
.gallery-empty b { font-family: "Courier New", monospace; font-size: 7px; margin-top: 3px; }

.result-meta { border: 1px solid var(--line-light); border-top: 0; display: grid; grid-template-columns: repeat(4, 1fr); }
.result-meta > div { min-width: 0; padding: 10px 12px; }
.result-meta > div + div { border-left: 1px solid var(--line-light); }
.result-meta span, .result-meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-meta span { color: var(--muted-light); font-size: 8px; margin-bottom: 3px; }
.result-meta b { font-family: "Courier New", monospace; font-size: 10px; }

.login-screen { background: var(--ink); inset: 0; overflow: hidden; position: fixed; z-index: 10; }
.login-screen.is-hidden { display: none; }
.login-background { height: 100%; inset: 0; object-fit: cover; object-position: center; position: absolute; width: 100%; }
.login-shade { background: rgb(10 10 9 / 0.58); inset: 0; position: absolute; }
.login-brand { color: var(--white); left: 28px; position: absolute; top: 24px; z-index: 2; }
.login-caption { bottom: 36px; color: var(--white); left: 34px; position: absolute; z-index: 2; }
.login-caption span { color: var(--acid); display: block; font-family: "Courier New", monospace; font-size: 9px; margin-bottom: 9px; }
.login-caption b { font-family: Georgia, "Noto Serif SC", serif; font-size: 40px; font-weight: 500; line-height: 1.04; }

.login-panel {
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 12px 12px 0 var(--acid);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 46px);
  overflow-y: auto;
  padding: 27px 29px 24px;
  position: absolute;
  right: clamp(28px, 8vw, 130px);
  top: 50%;
  transform: translateY(-50%);
  width: min(410px, calc(100vw - 40px));
  z-index: 3;
}
.login-panel > header { align-items: flex-start; display: flex; justify-content: space-between; margin-bottom: 21px; }
.login-panel h2 { color: var(--ink); font-size: 30px; font-weight: 500; }
.login-number { align-items: center; background: var(--coral); display: flex; flex: 0 0 40px; font-family: "Courier New", monospace; font-size: 11px; font-weight: 800; height: 40px; justify-content: center; order: 2; }
.auth-tabs { border: 1px solid var(--ink); display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 19px; }
.auth-tabs button { background: transparent; border: 0; color: var(--ink); font-size: 11px; font-weight: 800; height: 40px; }
.auth-tabs button + button { border-left: 1px solid var(--ink); }
.auth-tabs button.is-active { background: var(--ink); color: var(--acid); }
.auth-tabs button:focus-visible { outline: 2px solid var(--coral); outline-offset: -4px; }
.login-panel > label:not(.remember-option) { color: var(--ink); font-size: 11px; font-weight: 700; margin-bottom: 7px; }
.login-field, .locked-field { align-items: center; background: var(--white); border: 1px solid var(--line-light); display: flex; }
.login-field + label { margin-top: 12px; }
.login-field > svg, .locked-field > svg { fill: none; flex: 0 0 17px; height: 17px; margin-left: 12px; stroke: var(--muted-light); stroke-width: 1.6; width: 17px; }
.login-field input, .locked-field input { background: transparent; border: 0; color: var(--ink); height: 45px; min-width: 0; padding: 0 11px; width: 100%; }
.login-field input:focus, .locked-field input:focus { outline: 0; }
.login-field .icon-button { border: 0; color: var(--ink); flex: 0 0 45px; height: 45px; }
.remember-option { align-items: center; align-self: flex-start; color: var(--ink); cursor: pointer; display: flex; font-size: 11px; font-weight: 600; gap: 8px; margin-top: 13px; }
.remember-option input { height: 1px; opacity: 0; position: absolute; width: 1px; }
.remember-option span { background: var(--white); border: 1px solid var(--line-light); display: inline-block; height: 16px; position: relative; width: 16px; }
.remember-option input:checked + span { background: var(--acid); border-color: var(--ink); }
.remember-option input:checked + span::after { border: solid var(--ink); border-width: 0 2px 2px 0; content: ""; height: 7px; left: 5px; position: absolute; top: 2px; transform: rotate(45deg); width: 3px; }
.remember-option input:focus-visible + span { outline: 2px solid var(--coral); outline-offset: 2px; }
.login-button { background: var(--acid); border: 1px solid var(--ink); color: var(--ink); font-weight: 900; height: 48px; margin-top: 12px; }
.login-button:hover { background: var(--coral); }
.login-button:disabled { cursor: wait; opacity: 0.6; }
.login-error { color: var(--danger); font-size: 11px; margin: 10px 0 0; min-height: 16px; }

.modal-open { overflow: hidden; }
.settings-overlay { align-items: center; background: rgb(16 16 15 / 0.82); display: flex; inset: 0; justify-content: center; padding: 20px; position: fixed; z-index: 15; }
.settings-panel { background: var(--paper); box-shadow: 10px 10px 0 var(--acid); max-height: calc(100vh - 40px); overflow: auto; padding: 27px; width: min(500px, calc(100vw - 40px)); }
.settings-panel > header { align-items: flex-start; border-bottom: 1px solid var(--line-light); display: flex; justify-content: space-between; margin-bottom: 23px; padding-bottom: 17px; }
.settings-panel h2 { font-size: 27px; font-weight: 500; }
.settings-panel header .icon-button { color: var(--ink); }
.settings-panel form > label, .settings-label-row label { color: var(--ink); }
.locked-field { background: #e3e1d9; color: var(--muted-light); }
.locked-field input { color: var(--muted-light); font-family: "Courier New", monospace; font-size: 11px; }
.settings-label-row { align-items: center; display: flex; justify-content: space-between; margin-top: 19px; }
.settings-label-row label { margin-bottom: 0; }
.settings-label-row span { color: var(--muted-light); font-family: "Courier New", monospace; font-size: 9px; }
.api-key-field { margin-top: 7px; }
.settings-error { color: var(--danger); font-size: 11px; margin: 9px 0 0; min-height: 16px; }
.settings-actions { gap: 9px; justify-content: flex-end; margin-top: 16px; }
.remove-key-button, .save-key-button { align-items: center; border: 1px solid var(--ink); display: inline-flex; font-weight: 900; height: 44px; justify-content: center; padding: 0 14px; }
.remove-key-button { background: transparent; color: #a32d1e; margin-right: auto; }
.remove-key-button:hover { background: #efd5cf; }
.remove-key-button svg { fill: none; height: 15px; margin-right: 6px; stroke: currentColor; stroke-width: 1.7; width: 15px; }
.save-key-button { background: var(--acid); min-width: 128px; }
.save-key-button:hover { background: var(--coral); }
.remove-key-button:disabled, .save-key-button:disabled { cursor: wait; opacity: 0.55; }

.toast { background: var(--ink); border-left: 5px solid var(--coral); bottom: 18px; box-shadow: var(--shadow); color: var(--white); max-width: min(410px, calc(100vw - 30px)); padding: 13px 16px; position: fixed; right: 18px; z-index: 20; }

@keyframes pulse { 50% { opacity: 0.25; } }
@keyframes scan { from { top: 8%; } to { top: 92%; } }
@keyframes button-progress { 0% { transform: translateX(-102%); } 55% { transform: translateX(-25%); } 100% { transform: translateX(102%); } }

@media (max-width: 1040px) {
  .workspace { grid-template-columns: minmax(380px, 430px) minmax(0, 1fr); }
  .result-workspace { grid-template-columns: minmax(0, 1fr) 90px; }
  .control-deck { padding-left: 19px; padding-right: 19px; }
}

@media (max-width: 820px) {
  .topbar { height: 58px; padding: 0 12px; }
  .brand-copy small, .topbar-context, .model-indicator { display: none; }
  .topbar-actions { gap: 6px; }
  .key-status, .user-indicator { height: 32px; justify-content: center; padding: 0; width: 32px; }
  .key-status span, .user-indicator b { display: none; }
  .topbar .icon-button { flex-basis: 32px; height: 32px; width: 32px; }
  .workspace { display: block; min-height: calc(100vh - 58px); }
  .control-deck { border-bottom: 1px solid var(--line-dark); border-right: 0; max-height: none; padding: 21px 15px 26px; }
  .stage { min-height: 76vh; padding: 13px; }
  .result-workspace { grid-template-columns: minmax(0, 1fr) 82px; }
  .image-stage { min-height: 58vh; padding: 20px; }
  .image-stage img { max-height: 55vh; }
  .working-layer > span { font-size: 46px; }
  .result-meta { grid-template-columns: 1fr 1fr; }
  .result-meta > div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line-light); }
  .result-meta > div:nth-child(4) { border-top: 1px solid var(--line-light); }
  .login-caption { display: none; }
  .login-background { object-position: 42% center; }
  .login-panel { left: 50%; max-height: calc(100vh - 28px); right: auto; transform: translate(-50%, -50%); }
}

@media (max-width: 480px) {
  .brand { gap: 8px; }
  .brand-mark { flex-basis: 31px; height: 31px; width: 31px; }
  .brand-copy b { font-size: 12px; }
  .control-deck { padding-left: 11px; padding-right: 11px; }
  .mode-tabs button { font-size: 9px; height: 57px; }
  .output-select-row { gap: 6px; }
  .output-select-row select { font-size: 10px; padding-left: 7px; }
  .stage { padding: 10px; }
  .result-workspace { display: block; }
  .image-stage { min-height: 56vh; }
  .result-rail { border-left: 0; border-top: 1px solid #a5a59c; padding: 8px; }
  .result-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .gallery-empty { aspect-ratio: 4 / 1; grid-column: 1 / -1; }
  .login-brand { left: 16px; top: 15px; }
  .login-background { object-position: center; }
  .login-shade { background: rgb(10 10 9 / 0.7); }
  .login-panel { box-shadow: 7px 7px 0 var(--acid); padding: 22px 20px 19px; width: calc(100vw - 28px); }
  .login-panel > header { margin-bottom: 17px; }
  .login-panel h2 { font-size: 26px; }
  .settings-overlay { align-items: flex-end; padding: 0; }
  .settings-panel { box-shadow: none; max-height: 92vh; padding: 23px 19px; width: 100%; }
  .settings-actions { align-items: stretch; flex-direction: column-reverse; }
  .remove-key-button, .save-key-button { margin: 0; width: 100%; }
}

@media (max-height: 660px) and (min-width: 821px) {
  .login-panel { max-height: calc(100vh - 24px); }
  .login-panel > header { margin-bottom: 14px; }
  .auth-tabs { margin-bottom: 14px; }
}

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