:root {
  --canvas: #eef1ef;
  --surface: #ffffff;
  --surface-soft: #f6f8f7;
  --ink: #1b211f;
  --ink-muted: #68716d;
  --line: #d8dedb;
  --line-strong: #bdc7c2;
  --green: #087a5b;
  --green-dark: #075e49;
  --green-soft: #e3f2ed;
  --amber: #e5a11a;
  --danger: #bc3d3d;
  --danger-soft: #fbeaea;
  --focus: #1685c7;
  --shadow: 0 12px 28px rgba(28, 40, 35, 0.08);
  --header-height: 66px;
  font-family: "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; overflow-x: hidden; background: var(--canvas); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--canvas);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select, input[type="file"] { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 38%, transparent);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-height);
  min-height: var(--header-height);
  flex: 0 0 var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

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

.brand > span:last-child { display: grid; line-height: 1.2; }
.brand strong { font-size: 15px; font-weight: 760; }
.brand small { margin-top: 3px; color: var(--ink-muted); font-size: 11px; }

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 8px);
  grid-template-rows: repeat(2, 8px);
  gap: 3px;
  padding: 7px;
  background: var(--ink);
  border-radius: 6px;
}
.brand-mark span { background: var(--surface); border-radius: 1px; }
.brand-mark span:nth-child(2) { background: var(--amber); }
.brand-mark span:nth-child(3) { background: #54b397; }

.header-actions, .button-row, .section-actions { display: flex; align-items: center; gap: 8px; }
.section-actions { gap: 2px; }
.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 11px;
  color: var(--ink-muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
}
.connection-pill svg { width: 8px; height: 8px; fill: currentColor; }
.connection-pill.success { color: var(--green-dark); background: var(--green-soft); border-color: #b8ddcf; }
.connection-pill.error { color: var(--danger); background: var(--danger-soft); border-color: #efc4c4; }

.workspace {
  min-height: calc(100vh - var(--header-height));
  min-height: calc(100dvh - var(--header-height));
  width: 100%;
  display: grid;
  grid-template-columns: clamp(240px, 18vw, 320px) minmax(0, 1fr) clamp(260px, 20vw, 360px);
  max-width: none;
  margin: 0 auto;
}

.tool-rail, .run-panel {
  align-self: stretch;
  min-width: 0;
  background: var(--surface);
}
.tool-rail { border-right: 1px solid var(--line); }
.run-panel { border-left: 1px solid var(--line); }

.tool-section, .parameter-section, .run-section, .log-section, .advanced-section {
  padding: clamp(16px, 1.6vw, 22px);
  border-bottom: 1px solid var(--line);
}

.section-heading, .editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.section-heading h2, .editor-heading h1, .editor-heading h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 750;
}
.editor-heading h1 { font-size: 19px; }
.section-heading p, .editor-heading p, .about-section p {
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: 12px;
}

.field { display: grid; gap: 7px; margin-bottom: 14px; }
.model-picker { display: flex; align-items: center; gap: 7px; min-width: 0; }
.model-picker select { min-width: 0; flex: 1 1 auto; }
.model-picker .button { flex: 0 0 auto; white-space: nowrap; }
.field > span:first-child, .stepper-field > span:first-child {
  color: #3d4743;
  font-size: 12px;
  font-weight: 650;
}
.field small { color: var(--ink-muted); font-size: 11px; font-weight: 450; }

input, select, textarea {
  width: 100%;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}
input, select { height: 39px; padding: 0 11px; }
textarea { min-height: clamp(176px, 24vh, 280px); padding: 14px 16px; resize: vertical; line-height: 1.72; }
input:hover, select:hover, textarea:hover { border-color: #96a49d; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid color-mix(in srgb, var(--focus) 15%, transparent); }
input::placeholder, textarea::placeholder { color: #9aa39f; }

.secret-input { position: relative; display: block; }
.secret-input input { padding-right: 42px; }
.secret-input .inline-icon { position: absolute; top: 3px; right: 3px; }

.button, .icon-button, .inline-icon {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink);
  background: transparent;
  border-radius: 5px;
  font-weight: 650;
}
.button { min-height: 38px; padding: 0 13px; }
.button svg { width: 16px; height: 16px; }
.icon-button { width: 36px; height: 36px; flex: 0 0 36px; }
.icon-button svg, .inline-icon svg { width: 18px; height: 18px; }
.icon-button:hover, .inline-icon:hover, .button.quiet:hover { background: var(--surface-soft); }
.inline-icon { width: 33px; height: 33px; padding: 0; }
.button.primary { color: #fff; background: var(--green); }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { background: var(--surface); border: 1px solid var(--line-strong); }
.button.secondary:hover { background: var(--surface-soft); border-color: #98a59f; }
.button.quiet { color: #44504b; }
.button.stop { color: var(--danger); background: var(--danger-soft); border: 1px solid #edc2c2; }
.danger-ghost { color: var(--danger); }
.danger-ghost:hover { background: var(--danger-soft); }
.button.full { width: 100%; }
.button-row.compact { flex-wrap: wrap; }
.inline-status { min-height: 18px; margin: 9px 0 0; color: var(--ink-muted); font-size: 12px; }
.inline-status.error { color: var(--danger); }
.inline-status.success { color: var(--green-dark); }
.connection-note { display: flex; align-items: flex-start; gap: 7px; margin: 11px 0 0; color: var(--ink-muted); font-size: 11px; line-height: 1.45; }
.connection-note svg { width: 14px; height: 14px; flex: 0 0 14px; margin-top: 1px; }
.rail-close { display: none; }

.search-field {
  height: 39px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  margin-bottom: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
}
.search-field svg { width: 16px; color: var(--ink-muted); }
.search-field input { height: auto; min-width: 0; padding: 0; border: 0; outline: 0; }

.category-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 7px; margin-bottom: 8px; scrollbar-width: thin; }
.category-tabs button {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-muted);
  background: var(--surface);
  font-size: 12px;
}
.category-tabs button[aria-selected="true"] { color: #fff; background: var(--ink); border-color: var(--ink); }

.case-preview {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  align-items: center;
  margin: 2px 0 12px;
  padding: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.case-preview img { width: 58px; height: 58px; object-fit: cover; border-radius: 4px; background: #dde3df; cursor: zoom-in; }
.case-preview img.is-loading { opacity: 0.48; filter: saturate(0.65); }
.case-image-preview {
  position: fixed;
  z-index: 120;
  display: grid;
  place-items: center;
  width: 232px;
  height: 232px;
  padding: 8px;
  pointer-events: auto;
  background: #ffffff;
  border: 1px solid #dbe4df;
  border-radius: 10px;
  box-shadow: 0 16px 34px rgba(20, 30, 25, 0.22);
  cursor: zoom-in;
}
.case-image-preview img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 4px; background: #dde3df; cursor: zoom-in; }
.case-preview div { min-width: 0; display: grid; gap: 4px; }
.case-preview strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.case-preview span { color: var(--ink-muted); font-size: 11px; }
.about-section { color: var(--ink-muted); }

.composer-column { min-width: 0; padding: clamp(16px, 2vw, 28px) clamp(16px, 2.6vw, 36px) clamp(32px, 4vw, 52px); }
.mode-switch {
  width: min(100%, 420px);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 3px;
  margin-bottom: 20px;
  background: #dfe4e1;
  border-radius: 7px;
}
.mode-switch label { position: relative; }
.mode-switch input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.mode-switch span {
  min-width: 0;
  height: 37px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  border-radius: 5px;
  color: var(--ink-muted);
  cursor: pointer;
  font-weight: 650;
}
.mode-switch span svg { width: 16px; }
.mode-switch input:checked + span { color: var(--ink); background: var(--surface); box-shadow: 0 1px 4px rgba(26, 36, 32, 0.12); }
.mode-switch input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--focus) 38%, transparent); }

.prompt-editor, .reference-panel {
  padding: 22px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.file-action { position: relative; cursor: pointer; }
.file-action input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.editor-tools { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 8px; }
.character-count { color: var(--ink-muted); font-size: 11px; }

.translation-panel { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.translation-heading { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--ink-muted); font-size: 11px; }
#translationText { max-height: 190px; overflow-y: auto; padding: 12px; white-space: pre-wrap; background: var(--surface-soft); border-radius: 5px; line-height: 1.65; }

.drop-zone {
  min-height: 144px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: var(--ink-muted);
  border: 1px dashed #9eaaa4;
  border-radius: 6px;
  background: var(--surface-soft);
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragging { color: var(--green-dark); border-color: var(--green); background: var(--green-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone svg { width: 25px; height: 25px; }
.drop-zone strong { color: currentColor; font-size: 13px; }
.drop-zone span { font-size: 11px; }
.upload-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin-top: 12px; }
.upload-item { position: relative; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: #e1e5e3; }
.upload-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.upload-item button { position: absolute; top: 5px; right: 5px; width: 28px; height: 28px; color: #fff; background: rgba(21, 28, 25, 0.82); }
.mask-field { margin: 14px 0 0; }
.mask-field input { padding: 6px; }

.result-stage {
  min-height: clamp(280px, 46vh, 620px);
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  background-color: #e7ebe8;
  background-image: linear-gradient(45deg, #dde2df 25%, transparent 25%), linear-gradient(-45deg, #dde2df 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #dde2df 75%), linear-gradient(-45deg, transparent 75%, #dde2df 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  border-radius: 7px;
}
.result-stage.has-results { place-items: start; align-content: start; }
.empty-stage { width: min(100%, 430px); text-align: center; padding: 38px; background: rgba(246, 248, 247, 0.94); border-radius: 7px; box-shadow: var(--shadow); transition: box-shadow 180ms ease, transform 180ms ease; }
.empty-mark { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 14px; color: var(--green); background: var(--green-soft); border-radius: 50%; }
.empty-mark svg { width: 24px; }
.empty-stage h2 { margin: 0; font-size: 15px; }
.empty-stage p { margin: 5px 0 0; color: var(--ink-muted); font-size: 12px; }
.empty-stage.running .empty-mark { color: var(--amber); background: #fff1d3; }
.empty-stage.warning .empty-mark { color: #9a6a00; background: #fff1d3; }
.empty-stage.error .empty-mark { color: var(--danger); background: var(--danger-soft); }
.empty-stage.running { box-shadow: 0 14px 32px rgba(229, 161, 26, 0.16); }
.empty-stage.running .empty-mark { animation: stage-pulse 1.6s ease-in-out infinite; }
@keyframes stage-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.result-grid { width: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.result-stage.has-results { display: block; min-height: 0; padding: 14px; }
.result-item { position: relative; overflow: hidden; min-width: 0; background: var(--surface); border-radius: 6px; box-shadow: var(--shadow); transition: transform 160ms ease, box-shadow 160ms ease; }
.result-item:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(28, 40, 35, 0.13); }
.result-item img { width: 100%; max-height: 640px; display: block; object-fit: contain; background: #dfe4e1; }
.result-actions { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 12px; }
.result-actions span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-muted); font-size: 11px; }
.result-action-buttons { display: flex; align-items: center; gap: 3px; }
.result-action-buttons .icon-button { width: 30px; height: 30px; }
.result-actions a { text-decoration: none; }

.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stepper-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 2px; }
.stepper { height: 37px; display: grid; grid-template-columns: 35px 45px 35px; border: 1px solid var(--line-strong); border-radius: 5px; overflow: hidden; }
.stepper button { display: grid; place-items: center; padding: 0; border: 0; background: var(--surface-soft); }
.stepper button:hover { background: #e9eeeb; }
.stepper button svg { width: 14px; }
.stepper input { height: 35px; padding: 0; border: 0; border-radius: 0; text-align: center; appearance: textfield; }
.stepper input::-webkit-inner-spin-button { appearance: none; }

.advanced-section { padding-top: 16px; padding-bottom: 16px; }
.advanced-section summary, .log-section summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-weight: 700; list-style: none; }
.advanced-section summary::-webkit-details-marker, .log-section summary::-webkit-details-marker { display: none; }
.advanced-section summary svg { width: 16px; transition: transform 160ms ease; }
.advanced-section[open] summary svg { transform: rotate(180deg); }
.advanced-section .field-pair { margin-top: 16px; }
.advanced-section .field { margin: 0; }
.advanced-output-fields { padding-top: 15px; border-top: 1px solid var(--line); }

.run-status { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.quota-summary { display: grid; gap: 6px; margin-bottom: 14px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.quota-summary > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.quota-summary > div span { color: var(--ink-muted); font-size: 12px; }
.quota-summary strong { color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }
.quota-summary small { color: var(--ink-muted); font-size: 11px; }
.status-dot { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: #8f9994; box-shadow: 0 0 0 4px #edf0ee; }
.status-dot.running { background: var(--amber); box-shadow: 0 0 0 4px #fff1d3; }
.status-dot.success { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.run-status div { display: grid; }
.run-status strong { font-size: 13px; }
.run-status span:last-child { color: var(--ink-muted); font-size: 11px; }
.progress-track { height: 3px; overflow: hidden; margin: -4px 0 14px; background: #e3e7e5; border-radius: 3px; }
.progress-track span { display: block; width: 38%; height: 100%; background: var(--green); animation: progress 1.35s ease-in-out infinite; }
@keyframes progress { from { transform: translateX(-105%); } to { transform: translateX(270%); } }
.generate-button { min-height: 46px; font-size: 14px; }
.stop { margin-top: 8px; }

.log-section { padding-top: 17px; }
.log-section summary .inline-icon { margin: -8px; }
.log-section pre { min-height: 168px; max-height: 330px; overflow: auto; margin: 13px 0 0; padding: 12px; color: #d9e4df; background: #222a27; border-radius: 5px; font-family: Consolas, "SFMono-Regular", monospace; font-size: 11px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }

.rail-scrim { display: none; }
.mobile-action { display: none; }
.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; display: grid; gap: 9px; width: min(360px, calc(100vw - 36px)); pointer-events: none; }
.toast { padding: 12px 14px; color: #fff; background: #29322e; border-radius: 6px; box-shadow: var(--shadow); animation: toast-in 180ms ease-out; }
.toast.error { background: #862e2e; }
.toast.success { background: var(--green-dark); }
@keyframes toast-in { from { opacity: 0; transform: translateY(7px); } }

.modal-dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: min(760px, calc(100dvh - 28px));
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(20, 29, 25, 0.22);
}
.modal-dialog::backdrop { background: rgba(19, 27, 23, 0.46); backdrop-filter: blur(2px); }
.custom-prompt-form { padding: 22px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.modal-heading h2 { margin: 0; font-size: 17px; line-height: 1.35; }
.modal-heading p { margin: 4px 0 0; color: var(--ink-muted); font-size: 12px; }
.modal-heading .icon-button { margin: -7px -7px 0 0; }
.custom-prompt-form textarea { min-height: 132px; max-height: 280px; }
.custom-image-field { margin-bottom: 0; }
.custom-image-picker {
  position: relative;
  min-height: 150px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--ink-muted);
  background: var(--surface-soft);
  border: 1px dashed #9eaaa4;
  border-radius: 6px;
  cursor: pointer;
}
.custom-image-picker:hover { color: var(--green-dark); border-color: var(--green); background: var(--green-soft); }
.custom-image-picker:focus-within { border-color: var(--focus); outline: 2px solid color-mix(in srgb, var(--focus) 15%, transparent); }
.custom-image-picker > input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.custom-image-empty { display: grid; place-items: center; gap: 5px; text-align: center; }
.custom-image-empty svg { width: 25px; height: 25px; }
.custom-image-empty strong { color: currentColor; font-size: 13px; }
.custom-image-empty small { font-size: 11px; font-weight: 450; }
.custom-image-preview { position: relative; width: 100%; height: 210px; display: grid; place-items: center; padding: 8px; }
.custom-image-preview img { width: 100%; height: 100%; object-fit: contain; border-radius: 4px; }
.custom-image-change {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  color: #fff;
  background: rgba(28, 38, 34, 0.86);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 650;
}
.custom-image-change svg { width: 14px; height: 14px; }
.form-error { margin: 12px 0 0; padding: 9px 11px; color: var(--danger); background: var(--danger-soft); border-radius: 5px; font-size: 12px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.modal-actions .button { min-width: 88px; }

.auth-locked { padding-bottom: 0; }
.auth-screen { min-height: calc(100dvh - var(--header-height)); display: grid; place-items: center; padding: 36px 20px; }
.auth-form { width: min(100%, 390px); }
.auth-heading { margin-bottom: 27px; }
.auth-symbol { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; margin-bottom: 17px; color: var(--green-dark); background: var(--green-soft); border: 1px solid #bedfce; border-radius: 8px; }
.auth-symbol svg { width: 22px; height: 22px; }
.auth-heading h1 { margin: 0; font-size: 25px; font-weight: 750; line-height: 1.4; }
.auth-heading p { margin: 8px 0 0; color: var(--ink-muted); font-size: 13px; }
.auth-form .field { margin-bottom: 18px; }
.auth-submit { min-height: 44px; margin-top: 20px; }
.auth-note { margin: 18px 0 0; color: var(--ink-muted); text-align: center; font-size: 12px; }
#authRetryButton { margin-top: 10px; }
.account-button { min-width: 0; max-width: 180px; min-height: 38px; display: inline-flex; align-items: center; gap: 8px; padding: 4px 9px; color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 5px; text-align: left; cursor: pointer; }
.account-button:hover { background: var(--surface-soft); border-color: var(--line); }
.account-button > svg { flex: 0 0 17px; width: 17px; height: 17px; color: var(--ink-muted); }
.account-button > span { display: grid; min-width: 0; }
.account-button strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 650; }
.account-button small { color: var(--ink-muted); font-size: 10px; }
.account-form { padding: 22px; }
.users-dialog { width: min(660px, calc(100vw - 28px)); }
.user-list { display: grid; gap: 0; max-height: 300px; overflow-y: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.user-row { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; }
.user-row + .user-row { border-top: 1px solid var(--line); }
.user-row > div:first-child { min-width: 0; flex: 1 1 auto; display: grid; gap: 3px; }
.user-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.user-row small { color: var(--ink-muted); font-size: 11px; }
.user-row .button { min-height: 32px; flex-shrink: 0; }
.user-badges { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.user-badges span { font-size: 11px; color: var(--ink-muted); }
.user-badges .disabled-label { color: var(--danger); }
.user-badges .admin-label { color: var(--green-dark); }
.user-badges .user-balance { color: var(--green-dark); font-variant-numeric: tabular-nums; }
.user-badges .user-consumption { font-variant-numeric: tabular-nums; }
.create-user-form { padding-top: 20px; }
.create-user-form h3 { margin: 0 0 14px; font-size: 14px; }
.user-create-grid { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 14px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; margin-bottom: 18px; font-size: 13px; }
.checkbox-field input { width: 16px; height: 16px; margin: 0; accent-color: var(--green); }
#libraryButton { display: none; }
#libraryCloseButton { display: none; }
.member-workspace #libraryCloseButton { display: none; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 260px minmax(410px, 1fr) 300px; }
  .tool-section, .parameter-section, .run-section, .log-section, .advanced-section { padding-left: 17px; padding-right: 17px; }
  .composer-column { padding-left: 20px; padding-right: 20px; }
  .case-preview { grid-template-columns: 45px 1fr; }
  .case-preview img { width: 45px; height: 45px; }
}

@media (hover: none) {
  .case-preview img { cursor: pointer; }
}

@media (max-width: 960px) {
  #libraryButton { display: inline-flex; }
  .member-workspace #libraryCloseButton { display: inline-flex; }
  .workspace { grid-template-columns: minmax(0, 1fr) 300px; }
  .tool-rail { position: fixed; z-index: 60; top: 0; left: 0; bottom: 0; width: min(340px, 92vw); overflow-y: auto; box-shadow: 18px 0 50px rgba(22, 31, 27, 0.18); transform: translateX(-105%); transition: transform 180ms ease; }
  .tool-rail.open { transform: translateX(0); }
  .rail-scrim { position: fixed; z-index: 55; inset: 0; display: block; background: rgba(19, 27, 23, 0.32); backdrop-filter: blur(2px); }
  .rail-close { display: inline-flex; }
  .composer-column { grid-column: 1; }
  .run-panel { grid-column: 2; }
}

@media (max-width: 720px) {
  :root { --header-height: 58px; }
  body { padding-bottom: 70px; }
  .app-header { padding: 0 14px; }
  .header-actions { gap: 2px; }
  .header-actions .icon-button { width: 32px; height: 36px; }
  .account-button { max-width: 94px; gap: 5px; padding-inline: 5px; }
  .account-button > svg { display: none; }
  .account-button strong { max-width: 76px; }
  .brand { gap: 8px; }
  .brand strong { font-size: 13px; }
  .brand-mark { padding: 5px; grid-template-columns: repeat(2, 6px); grid-template-rows: repeat(2, 6px); gap: 2px; }
  .auth-locked .brand strong { font-size: 15px; }
  .auth-screen { align-items: start; padding-top: 48px; }
  .auth-heading h1 { font-size: 23px; }
  .brand small, .connection-pill { display: none; }
  .workspace { display: block; min-height: auto; }
  .composer-column { padding: 16px 13px 26px; }
  .run-panel { border: 0; background: transparent; }
  .run-panel .parameter-section, .run-panel .advanced-section, .run-panel .log-section { margin: 0 13px 14px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
  .run-panel .run-section { display: none; }
  .mode-switch { width: 100%; }
  .mode-switch label { min-width: 0; }
  .mode-switch span { min-width: 0; padding: 0 10px; }
  .prompt-editor, .reference-panel { padding: 17px; }
  .editor-heading { align-items: center; }
  .editor-heading h1 { font-size: 17px; }
  .editor-heading p { max-width: 220px; }
  .file-action span { display: none; }
  .file-action { width: 38px; padding: 0; }
  .editor-tools { align-items: flex-start; }
  .editor-tools .button-row { flex-wrap: wrap; justify-content: flex-end; }
  .result-stage { min-height: 280px; padding: 10px; }
  .result-stage.has-results { min-height: 0; padding: 10px; }
  .empty-stage { padding: 28px 20px; }
  .result-grid { grid-template-columns: 1fr; }
  .log-section pre { max-height: 240px; }
  .mobile-action {
    position: fixed;
    z-index: 45;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 13px max(9px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(28, 40, 35, 0.08);
    backdrop-filter: blur(10px);
  }
  .mobile-action > div { min-width: 0; max-width: 48%; display: flex; align-items: center; gap: 9px; color: var(--ink-muted); font-size: 12px; }
  .mobile-action > div span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-action > .mobile-status-group { display: grid; align-items: start; gap: 4px; }
  .mobile-status-line { min-width: 0; display: flex; align-items: center; gap: 9px; color: var(--ink-muted); font-size: 12px; }
  .mobile-status-line span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-quota { padding-left: 18px; font-size: 10px; line-height: 1.3; font-variant-numeric: tabular-nums; }
  .mobile-quota strong { color: var(--ink); font-weight: 650; }
  .mobile-action .button { min-width: 132px; min-height: 44px; }
  .toast-region { bottom: 78px; }
  .modal-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .custom-prompt-form { padding: 18px; }
  .account-form { padding: 18px; }
  .custom-image-preview { height: 180px; }
}

@media (max-width: 420px) {
  .app-header { padding-inline: 10px; }
  .header-actions { gap: 0; }
  .header-actions .icon-button { width: 28px; }
  .brand { gap: 6px; }
  .brand strong { font-size: 12px; }
  .account-button { max-width: 55px; }
  .account-button strong { max-width: 45px; }
  .user-create-grid { grid-template-columns: minmax(0, 1fr) 100px; gap: 10px; }
  .field-pair { grid-template-columns: 1fr; gap: 0; }
  .advanced-section .field-pair { gap: 12px; }
  .editor-heading p { max-width: 190px; }
  .button-row.compact .button:first-child { flex: 1; }
}

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

/* The auth view has its own product introduction while the workspace keeps its dense tool layout. */
.auth-locked {
  --auth-ink: #17223d;
  --auth-muted: #697692;
  --auth-blue: #3d6dff;
  --auth-violet: #7850ee;
  --auth-blue-soft: #edf2ff;
  background: #f7f9ff;
}
.auth-locked .app-header {
  height: 72px;
  min-height: 72px;
  padding: 0 clamp(20px, 6vw, 76px);
  color: var(--auth-ink);
  background: rgba(255, 255, 255, 0.94);
  border-bottom-color: #e4e9f6;
}
.auth-locked .brand { color: var(--auth-ink); gap: 10px; }
.auth-locked .brand-mark { width: 30px; height: 30px; padding: 6px; border-radius: 8px; background: var(--auth-blue); box-shadow: 0 6px 16px rgba(61, 109, 255, 0.2); }
.auth-locked .brand-mark span:nth-child(2) { background: #a78bfa; }
.auth-locked .brand-mark span:nth-child(3) { background: #d9e2ff; }
.auth-locked .brand strong { font-size: 16px; font-weight: 780; letter-spacing: -0.1px; }
.auth-nav { display: flex; align-items: stretch; gap: clamp(18px, 2.8vw, 40px); height: 100%; margin-left: auto; margin-right: clamp(28px, 4vw, 58px); }
.auth-nav a { position: relative; display: inline-flex; align-items: center; color: #7b879e; font-size: 12px; text-decoration: none; }
.auth-nav a:hover, .auth-nav a.active { color: var(--auth-blue); }
.auth-nav a.active::after { position: absolute; right: 0; bottom: 0; left: 0; height: 2px; background: var(--auth-blue); content: ""; }
.auth-header-actions { display: flex; align-items: center; gap: 16px; color: var(--auth-muted); font-size: 12px; }
.auth-header-cta { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 19px; color: #fff; background: var(--auth-blue); border-radius: 7px; box-shadow: 0 7px 15px rgba(61, 109, 255, 0.2); font-size: 12px; text-decoration: none; }
.auth-header-cta:hover { background: #315cdf; }
.auth-screen { min-height: calc(100dvh - 72px); display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(360px, 430px); align-items: center; gap: clamp(42px, 7vw, 116px); width: min(1240px, 100%); margin: 0 auto; padding: 44px clamp(20px, 5vw, 60px) 58px; }
.auth-hero-copy { min-width: 0; color: var(--auth-ink); }
.auth-eyebrow { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 0 12px; color: #4566ce; background: var(--auth-blue-soft); border: 1px solid #dbe4ff; border-radius: 999px; font-size: 11px; }
.auth-eyebrow svg { width: 14px; height: 14px; color: var(--auth-blue); }
.auth-hero-copy h1 { max-width: 590px; margin: 20px 0 14px; color: var(--auth-ink); font-size: clamp(37px, 4.6vw, 58px); font-weight: 760; line-height: 1.13; letter-spacing: -1.5px; }
.auth-hero-copy h1 strong { color: var(--auth-blue); font-weight: 780; }
.auth-hero-description { max-width: 500px; margin: 0; color: var(--auth-muted); font-size: 14px; line-height: 1.8; }
.auth-hero-cta { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; margin-top: 24px; padding: 0 18px; color: #fff; background: var(--auth-blue); border-radius: 8px; box-shadow: 0 10px 22px rgba(61, 109, 255, 0.25); font-size: 13px; font-weight: 700; text-decoration: none; }
.auth-hero-cta:hover { background: #315cdf; transform: translateY(-1px); }
.auth-hero-cta svg:first-child { width: 16px; height: 16px; }
.auth-hero-cta svg:last-child { width: 15px; height: 15px; margin-left: 5px; }
.auth-highlights { display: flex; flex-wrap: wrap; gap: clamp(18px, 3.4vw, 42px); margin-top: 33px; }
.auth-highlights > div { display: inline-flex; align-items: flex-start; gap: 8px; color: var(--auth-muted); font-size: 10px; line-height: 1.35; }
.auth-highlights svg { width: 17px; height: 17px; margin-top: 1px; color: #5670bd; }
.auth-highlights span { display: grid; }
.auth-highlights strong { color: #4a5876; font-size: 11px; font-weight: 700; }
.auth-artboard { position: relative; width: min(100%, 600px); height: 255px; margin-top: 25px; overflow: hidden; background: #e9efff; border: 1px solid #e0e8ff; border-radius: 23px; box-shadow: 0 18px 40px rgba(95, 115, 177, 0.1); }
.auth-artboard::before { position: absolute; right: -46px; bottom: -67px; width: 240px; height: 160px; border-radius: 50%; background: #dce5ff; content: ""; }
.auth-artboard::after { position: absolute; top: 21px; left: 41px; width: 108px; height: 68px; border-radius: 50%; background: #f6f8ff; opacity: .8; content: ""; }
.art-card { position: absolute; overflow: hidden; border: 5px solid #fff; box-shadow: 0 14px 26px rgba(63, 79, 129, 0.18); }
.art-card-main { z-index: 2; top: 35px; left: 26%; width: 51%; height: 168px; transform: rotate(-4deg); background: #9ebbe5; border-radius: 13px; }
.art-card-main::before { position: absolute; right: -16px; bottom: 0; width: 122%; height: 74%; background: #6d8cad; clip-path: polygon(0 100%, 32% 29%, 48% 54%, 65% 0, 100% 100%); content: ""; }
.art-card-main::after { position: absolute; right: -2px; bottom: -2px; width: 104%; height: 38%; background: #6589a7; clip-path: polygon(0 100%, 45% 31%, 62% 61%, 80% 12%, 100% 100%); content: ""; }
.art-mountain, .art-village { position: absolute; z-index: 3; }
.art-mountain { right: 0; bottom: 45px; left: 0; height: 110px; }
.art-mountain i { position: absolute; bottom: 0; width: 0; height: 0; border-right: 54px solid transparent; border-bottom: 91px solid #eff5ff; border-left: 54px solid transparent; }
.art-mountain i:nth-child(1) { left: 18%; transform: scale(.74); border-bottom-color: #d9e7f7; }
.art-mountain i:nth-child(2) { left: 37%; border-bottom-color: #f3f7ff; }
.art-mountain i:nth-child(3) { right: 7%; transform: scale(.82); border-bottom-color: #d2e0f4; }
.art-village { right: 12%; bottom: 25px; display: flex; align-items: end; gap: 5px; }
.art-village i { display: block; width: 15px; height: 25px; background: #f8efdf; box-shadow: 0 -7px 0 -2px #d49e70; }
.art-village i:nth-child(2) { height: 35px; background: #fff8e9; }
.art-village i:nth-child(3) { height: 19px; background: #e5f0eb; }
.art-village i:nth-child(4) { height: 29px; background: #f6d9cf; }
.art-label { position: absolute; z-index: 4; right: 14px; bottom: 11px; color: #fff; font-size: 9px; text-shadow: 0 1px 3px rgba(20, 39, 66, .5); }
.art-card-small { z-index: 3; display: flex; align-items: end; gap: 5px; width: 118px; height: 80px; padding: 8px; background: #fff; border-width: 4px; border-radius: 11px; color: #55627d; font-size: 9px; }
.art-card-small span:last-child { padding-bottom: 2px; }
.art-card-top { top: 19px; left: 12%; transform: rotate(5deg); }
.art-card-side { right: 8%; bottom: 42px; transform: rotate(7deg); }
.art-swatch { display: block; width: 48px; height: 48px; border-radius: 6px; }
.art-swatch-sun { background: #ecbd83; box-shadow: inset 0 16px #7c9bb4, inset 0 -15px #d9926d; }
.art-swatch-lake { background: #9bbdd8; box-shadow: inset 0 17px #c9d9ea, inset 0 -13px #5e8eab; }
.art-spark { position: absolute; z-index: 4; color: #6a8fff; font-size: 27px; line-height: 1; }
.art-spark-one { top: 38px; right: 25%; }
.art-spark-two { bottom: 19px; left: 13%; color: #b09af5; font-size: 18px; }
.art-prompt { position: absolute; z-index: 5; right: 11%; bottom: 8px; left: 17%; display: flex; align-items: center; gap: 8px; min-height: 39px; padding: 0 10px; color: #909bb0; background: #fff; border-radius: 10px; box-shadow: 0 12px 22px rgba(63, 79, 129, .16); font-size: 10px; }
.art-prompt > svg { width: 15px; color: var(--auth-blue); }
.art-prompt b { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; padding: 8px 11px; color: #fff; background: var(--auth-violet); border-radius: 999px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.art-prompt b svg { width: 12px; }
.auth-security-note { display: flex; align-items: flex-start; gap: 7px; max-width: 530px; margin: 20px 0 0; color: #8a95aa; font-size: 10px; line-height: 1.5; }
.auth-security-note svg { flex: 0 0 14px; width: 14px; height: 14px; color: #5f78bd; }
.auth-panel { width: 100%; padding: 30px 31px 20px; background: #fff; border: 1px solid #e4e9f5; border-radius: 13px; box-shadow: 0 20px 45px rgba(44, 63, 116, 0.11); }
.auth-panel-top { display: flex; align-items: center; gap: 9px; margin-bottom: 25px; color: #65718a; font-size: 11px; font-weight: 700; }
.auth-panel-icon { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; color: var(--auth-blue); background: var(--auth-blue-soft); border-radius: 7px; }
.auth-panel-icon svg { width: 15px; height: 15px; }
.auth-panel-rule { height: 1px; flex: 1; background: #edf0f7; }
.auth-form { width: 100%; }
.auth-heading { margin-bottom: 24px; }
.auth-heading h2 { margin: 0; color: var(--auth-ink); font-size: 24px; font-weight: 760; line-height: 1.3; }
.auth-heading p { margin: 8px 0 0; color: var(--auth-muted); font-size: 12px; line-height: 1.5; }
.auth-role-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin: 0 0 23px; padding: 4px; background: #f1f4fb; border: 1px solid #e1e7f2; border-radius: 8px; }
.auth-role-option { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 0; min-height: 42px; padding: 8px 5px; color: #697692; background: transparent; border: 1px solid transparent; border-radius: 5px; font: inherit; font-size: 12px; font-weight: 650; white-space: nowrap; cursor: pointer; }
.auth-role-option svg { flex: 0 0 16px; width: 16px; height: 16px; }
.auth-role-option:hover:not(:disabled) { color: var(--auth-blue); }
.auth-role-option[aria-checked="true"] { color: var(--auth-blue); background: #fff; border-color: #d2ddff; box-shadow: 0 2px 5px rgba(44, 63, 116, .06); }
.auth-role-option:focus-visible { outline: 2px solid var(--auth-blue); outline-offset: 2px; }
.auth-role-option:disabled { opacity: .6; cursor: wait; }
.auth-form .field { margin-bottom: 16px; }
.auth-form .field > span:first-child { color: #42506c; font-size: 12px; font-weight: 700; }
.auth-form input { border-color: #d6ddeb; border-radius: 6px; }
.auth-form input:focus { border-color: var(--auth-blue); outline-color: rgba(61, 109, 255, .17); }
.auth-form .auth-submit { min-height: 44px; margin-top: 20px; color: #fff; background: var(--auth-blue); border-radius: 6px; box-shadow: 0 8px 17px rgba(61, 109, 255, .18); }
.auth-form .auth-submit:hover { background: #315cdf; }
.auth-note { margin: 15px 0 0; color: var(--auth-muted); text-align: center; font-size: 11px; }
.auth-panel-footer { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 25px; padding-top: 16px; color: #9ba4b6; border-top: 1px solid #edf0f7; font-size: 10px; }
.auth-panel-footer svg { width: 13px; height: 13px; color: #7190d8; }

@media (max-width: 880px) {
  .auth-locked .app-header { padding-inline: 20px; }
  .auth-nav { gap: 18px; margin-right: 20px; }
  .auth-header-actions > span { display: none; }
  .auth-screen { grid-template-columns: minmax(0, 1fr) minmax(330px, 390px); gap: 28px; padding-inline: 24px; }
  .auth-hero-copy h1 { font-size: clamp(35px, 5vw, 47px); }
  .auth-artboard { height: 220px; }
  .art-card-small { transform: scale(.84) rotate(5deg); transform-origin: center; }
  .art-card-side { transform: scale(.84) rotate(7deg); }
}

@media (max-width: 700px) {
  .auth-locked .app-header { height: 62px; min-height: 62px; padding-inline: 16px; }
  .auth-nav { display: none; }
  .auth-header-actions { margin-left: auto; }
  .auth-header-cta { min-height: 32px; padding-inline: 13px; }
  .auth-screen { display: flex; flex-direction: column; align-items: stretch; gap: 25px; min-height: calc(100dvh - 62px); padding: 29px 16px 48px; }
  .auth-hero-copy { order: 1; }
  .auth-panel { order: 2; padding: 23px 20px 17px; }
  .auth-hero-copy h1 { margin-top: 15px; font-size: 36px; letter-spacing: -1px; }
  .auth-hero-description { font-size: 13px; line-height: 1.7; }
  .auth-hero-cta { margin-top: 19px; }
  .auth-highlights { gap: 17px; margin-top: 25px; }
  .auth-artboard { height: 194px; margin-top: 23px; border-radius: 18px; }
  .art-card-main { top: 25px; height: 128px; }
  .art-card-small { width: 92px; height: 61px; padding: 5px; border-width: 3px; }
  .art-swatch { width: 36px; height: 36px; }
  .art-prompt { min-height: 32px; right: 8%; left: 13%; font-size: 8px; }
  .art-prompt b { padding: 6px 8px; font-size: 8px; }
  .auth-security-note { margin-top: 15px; }
}

@media (max-width: 390px) {
  .auth-locked .brand strong { font-size: 14px; }
  .auth-header-cta { padding-inline: 10px; font-size: 11px; }
  .auth-screen { padding-inline: 13px; }
  .auth-hero-copy h1 { font-size: 32px; }
  .auth-highlights { gap: 10px; justify-content: space-between; }
  .auth-highlights > div { gap: 5px; font-size: 9px; }
  .auth-highlights svg { width: 15px; height: 15px; }
  .auth-panel { padding-inline: 17px; }
}
