@font-face {
  font-family: "Studio Sans";
  src: url("/studio-ui.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Studio Display";
  src: url("/studio-wordmark.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}

/* Shared tokens and controls. */
:root {
  color-scheme: light;
  --bg: #f5f6fa;
  --panel: #fff;
  --panel-soft: #f8f9fc;
  --panel-strong: #eeeff5;
  --text: #252438;
  --muted: #696a7d;
  --line: #e5e6ee;
  --line-strong: #c9cbd9;
  --accent: #6554c0;
  --accent-strong: #51409f;
  --accent-soft: #efecfa;
  --success: #247961;
  --success-soft: #eef7f3;
  --warn: #926118;
  --danger: #b94754;
  --radius: 12px;
  font-family: "Studio Sans", "PingFang SC", "Microsoft YaHei", "WenQuanYi Zen Hei", sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html { background: var(--bg); scrollbar-color: #c7c6d5 transparent; scrollbar-width: thin; }
body { margin: 0; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
::selection { background: #dfd9f7; color: #32235e; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; border: 0; color: inherit; }
button:disabled { opacity: .52; cursor: not-allowed; }
button, a { touch-action: manipulation; }
button, a, input, select, textarea { transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #a298db; outline-offset: 3px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
svg { display: block; flex-shrink: 0; }
h1, h2, h3, p { margin: 0; }
img { max-width: 100%; }
input, select, textarea {
  width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 9px; background: var(--panel); color: var(--text);
}
select { padding-right: 28px; text-overflow: ellipsis; cursor: pointer; }
textarea { line-height: 1.85; resize: vertical; }
input::placeholder, textarea::placeholder { color: #77778b; opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { accent-color: var(--accent); }
input[type="range"] { accent-color: var(--accent); padding: 0; border: 0; box-shadow: none; }
label { font-size: 13px; font-weight: 600; color: #414052; }
.primary-button, .secondary-button, .icon-button, .mini-button {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px;
  flex-shrink: 0; min-height: 42px; padding: 9px 15px; border-radius: 9px;
  font-size: 13px; line-height: 1.4; font-weight: 500; white-space: nowrap;
}
.primary-button { background: var(--accent); color: white; border: 1px solid var(--accent); }
.primary-button:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.secondary-button { background: white; border: 1px solid var(--line); color: #575469; }
.secondary-button:hover:not(:disabled) { background: var(--panel-soft); color: var(--accent); border-color: #c9c1e5; }
.icon-button { width: 38px; height: 38px; min-height: 38px; padding: 0; background: transparent; color: var(--muted); }
.icon-button:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.mini-button { min-height: 32px; padding: 5px 8px; background: transparent; color: var(--muted); font-size: 11px; }
.mini-button:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.spinner { display: none; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; }
.is-loading .spinner { display: inline-block; animation: spin 750ms linear infinite; }
.is-loading .button-icon { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Fixed desktop chrome; each workspace scrolls independently below the header. */
.app { width: 100%; height: 100vh; height: 100dvh; }
.stage { width: 100%; height: 100%; }
.result-shell { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.result-head { display: flex; flex-shrink: 0; align-items: center; justify-content: space-between; gap: 24px; height: 80px; padding: 0 36px; border-bottom: 1px solid var(--line); background: white; }
.result-title, .result-actions, .studio-home { display: flex; align-items: center; min-width: 0; }
.result-title { gap: 22px; }
.studio-home { gap: 11px; color: var(--text); }
.studio-home:hover { color: var(--accent); }
.brand-mark { display: inline-flex; width: 39px; height: 39px; flex: 0 0 39px; align-items: center; justify-content: center; border-radius: 12px; background: var(--accent); color: white; }
.studio-wordmark { font-family: "Studio Display", "Studio Sans", sans-serif; font-weight: 750; font-size: 21px; letter-spacing: -.8px; white-space: nowrap; }
.header-divider { height: 22px; width: 1px; background: var(--line); }
.studio-context { font-size: 13px; color: var(--muted); white-space: nowrap; }
.result-actions { gap: 12px; }
.admin-entry-link { min-height: 36px; padding: 6px 10px; border: 0; font-size: 12px; }
#toggleRaw { width: 36px; height: 36px; min-height: 36px; padding: 0; font-size: 0; border: 0; background: transparent; }
#toggleRaw svg { width: 17px; }
.user-summary { display: flex; align-items: center; gap: 10px; padding-left: 14px; border-left: 1px solid var(--line); }
.user-avatar { display: grid; place-items: center; flex: 0 0 33px; width: 33px; height: 33px; border: 1px solid #dfd9f0; border-radius: 50%; color: var(--accent); background: #f2eefb; font-family: "Studio Display", sans-serif; font-size: 13px; font-weight: 650; }
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-meta strong { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.user-meta small { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.logout-button { width: 32px; height: 32px; min-height: 32px; }
.conversation-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 26px; width: 100%; max-width: 1680px; margin: 0 auto; padding: 22px 32px 24px; flex: 1; min-height: 0; }
.conversation-panel { scroll-margin-top: 84px; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.workspace-tabs { display: flex; gap: 7px; min-height: 51px; flex-shrink: 0; align-items: flex-start; padding: 0 2px 12px; }
.workspace-tab { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 17px; min-height: 39px; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; }
.workspace-tab:hover { background: #ecebf3; }
.workspace-tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.workspace-tab-count { padding: 0 6px; min-width: 19px; border-radius: 6px; background: #e4e1ee; font-size: 10px; }
.generation-workspace { flex: 1; min-height: 0; overflow-y: auto; padding: 0 4px 12px 0; overscroll-behavior: contain; }
.submission-panel { display: flex; flex-direction: column; gap: 14px; padding: 23px 28px 16px; border: 1px solid #e3e3ed; border-radius: 18px; background: white; box-shadow: 0 3px 12px #29204904; }
.submission-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 0; }
.submission-heading h2 { font-size: clamp(24px, 2.1vw, 30px); font-weight: 650; letter-spacing: -.7px; line-height: 1.5; }
.submission-heading p { color: var(--muted); font-size: 13px; margin-top: 5px; }
.creation-mark { flex-shrink: 0; margin-right: 0; }
.creation-mark svg { width: 62px; height: 62px; }
.image-key-control { padding: 12px 14px; border: 1px solid #e9e7f0; background: #faf9fd; border-radius: 10px; display: grid; gap: 11px; }
.image-key-heading { display: flex; align-items: center; min-width: 0; gap: 8px; }
.image-key-icon { color: #7d719e; }
.image-key-icon svg { width: 15px; height: 15px; }
.image-key-heading > div { display: flex; flex: 1; align-items: baseline; min-width: 0; gap: 12px; }
.image-key-heading strong { font-size: 12px; font-weight: 500; white-space: nowrap; color: #5d556e; }
.image-key-heading div > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--muted); }
.image-route-controls { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; }
.image-route-field { display: grid; min-width: 0; gap: 5px; }
.image-route-field label { font-size: 11px; color: #6c657a; font-weight: 400; }
.image-route-field select { min-height: 39px; padding: 7px 28px 7px 10px; font-size: 12px; border-color: #dedbe9; border-radius: 7px; }
.image-key-control.is-empty { background: var(--panel-soft); }
.composer-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: -5px; }
.composer-heading > div { min-width: 0; }
.composer-heading label { font-size: 13px; font-weight: 600; }
.composer-parameter-summary { color: var(--muted); font-size: 11px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-trigger { min-height: 34px; padding: 7px 9px; font-size: 12px; border-color: transparent; background: #f5f4f9; color: #625477; }
.settings-trigger svg { width: 15px; height: 15px; }
#chatPrompt { min-height: 130px; max-height: 280px; padding: 15px 17px; font-size: 14px; background: #fff; border-color: #dedde8; border-radius: 10px; }
#chatPrompt:focus { border-color: var(--accent); }
.prompt-assist { display: flex; align-items: center; gap: 12px; margin-top: -6px; }
.prompt-assist > span { color: var(--muted); font-size: 11px; white-space: nowrap; }
.prompt-suggestions { display: flex; gap: 7px; }
.prompt-suggestions button { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; min-height: 28px; border-radius: 6px; background: #f5f4f9; color: #686076; font-size: 11px; }
.prompt-suggestions button:hover { color: var(--accent); background: var(--accent-soft); }
.prompt-suggestions button::before { content: "+"; color: #9384b2; font-size: 14px; }
.composer-actions { display: grid; align-items: center; grid-template-columns: auto auto auto minmax(138px, 1fr); gap: 8px; border-top: 1px solid #f0eff5; padding-top: 13px; }
.composer-actions .secondary-button { padding: 8px 11px; min-height: 40px; gap: 6px; font-size: 12px; }
.composer-actions .secondary-button svg { width: 16px; height: 16px; }
.composer-actions #clearChatPrompt { min-width: 34px; padding: 8px; border: 0; font-size: 0; }
.composer-actions .primary-button { justify-self: end; width: min(100%, 180px); min-height: 42px; font-size: 13px; font-weight: 600; box-shadow: 0 3px 8px #6554c01a; }
.composer-footnote { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: -8px; font-size: 10px; color: #727286; }
.composer-footnote > span { display: inline-flex; align-items: center; gap: 5px; }
kbd { font: inherit; background: #f7f7fa; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }
.composer-reference { display: none; padding: 10px; gap: 12px; align-items: center; border-radius: 9px; background: var(--panel-soft); border: 1px solid var(--line); }
.composer-reference.open { display: flex; }
.composer-reference img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; }
.composer-reference > div { flex: 1; min-width: 0; }
.composer-reference strong { display: block; font-size: 12px; font-weight: 500; }
.composer-reference span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.composer-reference .mini-button { flex-shrink: 0; }

@media (min-width: 1181px) {
  .image-key-control { grid-template-columns: minmax(125px, .55fr) minmax(0, 1.45fr); align-items: center; gap: 20px; }
  .image-key-heading { align-items: flex-start; }
  .image-key-icon { margin-top: 3px; }
  .image-key-heading > div { display: block; }
  .image-key-heading strong { font-size: 12px; }
  .image-key-heading div > span { display: block; margin-top: 4px; font-size: 10px; }
}

/* Works and inspiration. */
.community-panel { padding: 23px 2px 5px; }
.community-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.community-head h2 { font-size: 18px; font-weight: 600; letter-spacing: -.3px; }
.community-head p { margin-top: 4px; font-size: 12px; color: var(--muted); }
.community-head-actions { display: flex; align-items: center; gap: 8px; }
.community-head-actions strong { font-size: 11px; color: var(--muted); font-weight: 400; }
.community-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.community-card { min-width: 0; overflow: hidden; border-radius: 12px; border: 1px solid var(--line); background: white; }
.community-image-button { display: block; width: 100%; overflow: hidden; background: #eeedf5; padding: 0; position: relative; }
.community-image-button img { display: block; width: 100%; aspect-ratio: 1.18; object-fit: cover; transition: transform 220ms ease; }
.community-image-button:hover img { transform: scale(1.025); }
.community-card-body { display: grid; gap: 9px; padding: 12px; }
.community-card-body p { display: -webkit-box; min-height: 39px; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: #545263; font-size: 11px; line-height: 1.8; }
.community-card-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 10px; color: var(--muted); }
.community-card-meta span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.community-owner-mark { color: var(--accent); }
.community-use-button { min-height: 31px; width: 100%; background: #f7f6fb; border-color: transparent; color: #6b5b91; font-size: 11px; padding: 6px; }
.community-empty, .library-empty, .reverse-history-empty { display: grid; justify-items: center; align-content: center; min-height: 190px; padding: 26px 18px; text-align: center; font-size: 12px; color: var(--muted); line-height: 1.9; }
.community-empty { background: #f0eff6; border: 1px dashed #d9d5e6; border-radius: 12px; }
.community-empty::before, .library-empty::before, .reverse-history-empty::before { content: ""; display: block; width: 48px; height: 40px; margin-bottom: 17px; border: 1.5px solid #c3bad9; border-radius: 8px; background: linear-gradient(140deg, transparent 54%, #ddd7e9 55%, #ddd7e9 69%, transparent 70%), #f8f7fc; box-shadow: -6px 6px 0 -1px #eeebf6, -6px 6px 0 0 #d9d2e6; transform: rotate(-5deg); }

/* The resource rail keeps actions and image previews readable. */
.record-rail { scroll-margin-top: 84px; display: flex; flex-direction: column; gap: 0; min-width: 0; min-height: 0; }
.rail-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; align-items: center; padding: 4px; margin-bottom: 13px; border: 1px solid #e4e3ec; border-radius: 10px; background: #ececf3; }
.rail-tab { padding: 6px 3px; min-height: 30px; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; white-space: nowrap; }
.rail-tab:hover { color: var(--accent); }
.rail-tab.active { background: white; color: #403656; font-weight: 600; box-shadow: 0 1px 4px #2524380c; }
.library-panel, .job-panel { padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: white; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.library-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.library-head h3 { font-size: 15px; font-weight: 600; }
.library-head p { font-size: 11px; color: var(--muted); margin-top: 4px; }
.library-controls { display: flex; align-items: center; min-width: 0; gap: 7px; }
.library-controls select { min-height: 34px; padding: 6px 22px 6px 9px; font-size: 11px; border-color: var(--line); }
.library-controls .secondary-button { min-height: 34px; padding: 6px 9px; font-size: 11px; }
.library-controls svg { width: 14px; height: 14px; }
.library-panel[data-rail-panel="history"] .library-controls { width: 100%; }
.library-controls select { flex: 1; }
.library-stats, .reverse-history-stats { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; margin-bottom: 11px; border-top: 1px solid #f0eff5; border-bottom: 1px solid #f0eff5; color: var(--muted); font-size: 10px; }
.library-stats strong, .reverse-history-stats strong { color: #6f5d95; font-weight: 500; }
.thumb-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.thumb-card { min-width: 0; border: 1px solid #e9e7ef; border-radius: 8px; overflow: hidden; background: white; }
.thumb-button { display: block; padding: 0; width: 100%; background: var(--panel-soft); text-align: left; }
.thumb-frame { aspect-ratio: 1; overflow: hidden; }
.thumb-frame img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 180ms ease; }
.thumb-button:hover img { transform: scale(1.03); }
.thumb-meta { display: none; }
.thumb-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; padding: 3px 0; }
.thumb-actions .mini-button { min-width: 0; padding: 4px 0; font-size: 10px; min-height: 30px; border-radius: 4px; }
.share-card-button.active { color: var(--accent); background: var(--accent-soft); }
.reverse-card-button { color: #746091; }
.history-load-more { display: flex; width: 100%; margin-top: 14px; font-size: 12px; }
.reference-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.reference-card { min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 5px; overflow: hidden; }
.reference-card.active { border-color: var(--accent); background: #f8f6ff; box-shadow: 0 0 0 1px var(--accent); }
.reference-card .thumb-button { border-radius: 5px; overflow: hidden; }
.reference-card img { display: block; width: 100%; aspect-ratio: 1.2; object-fit: cover; }
.reference-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 2px; margin-top: 4px; }
.reference-actions .mini-button { font-size: 10px; padding: 5px 6px; }
.reference-time { padding: 2px 4px; font-size: 10px; color: var(--muted); text-align: center; }
.job-list { display: grid; gap: 12px; }
.job-item { display: grid; grid-template-columns: 7px minmax(0, 1fr); gap: 6px 9px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-width: 0; background: white; }
.job-item.running { border-color: #d6cdee; background: #fcfbff; }
.job-status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); margin-top: 7px; }
.job-item.done .job-status-dot { background: var(--success); }
.job-item.error .job-status-dot { background: var(--danger); }
.job-item.running .job-status-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.job-main { min-width: 0; }
.job-main strong { display: block; font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-prompt { display: block; margin-top: 4px; color: #777385; font-size: 11px; line-height: 1.65; overflow-wrap: anywhere; }
.job-side { grid-column: 2; font-size: 10px; color: var(--muted); }
.job-item.done .job-side { color: var(--success); }
.job-item.running .job-side { color: var(--accent); }
.job-image-grid { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 5px; }
.job-image-button { padding: 0; min-width: 0; overflow: hidden; border-radius: 7px; background: var(--panel-soft); }
.job-image-button img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.job-error { grid-column: 2; padding: 8px 9px; border-radius: 6px; color: var(--danger); background: #fff4f5; font-size: 10px; overflow-wrap: anywhere; }
.job-raw { grid-column: 1 / -1; font-size: 10px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 3px; padding-top: 7px; }
.job-raw summary { cursor: pointer; padding: 3px 0; }
.job-raw pre, .raw-box pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 10px; max-height: 240px; overflow: auto; }
.job-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.job-retry-button { border: 1px solid var(--line); }
.job-actions .mini-button { min-width: 60px; min-height: 44px; padding-inline: 12px; }
.job-delete-button { color: var(--danger); border: 1px solid var(--line); background: var(--panel); }
.job-delete-button:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); background: var(--panel-soft); }
.raw-box { display: none; min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: 10px; margin-top: 12px; padding: 12px; background: #f0f0f7; }
.raw-box.open { display: block; }
.request-url { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }

/* Compact notices never take over the workspace. */
.notice-box { display: none; position: relative; flex-shrink: 0; align-items: center; gap: 12px; padding: 10px 46px 10px 15px; margin: 14px 32px 0; border: 1px solid #dcd5ef; border-radius: 9px; background: #f1eef9; color: #635179; font-size: 12px; line-height: 1.7; }
.notice-box.info, .notice-box.error, .notice-box.warning, .notice-box.success { display: flex; }
.notice-box.error { background: #fff1f2; border-color: #f0d1d5; color: #9d3e4c; }
.notice-box.warning { background: #fff8e9; border-color: #e9dbc0; color: #855917; }
.notice-box.success { background: var(--success-soft); border-color: #cde3d9; color: var(--success); }
.notice-text { min-width: 0; overflow-wrap: anywhere; }
.notice-dismiss { position: absolute; top: 50%; right: 5px; transform: translateY(-50%); }
.notice-action-link, .gateway-manage-link { display: flex; flex-direction: column; align-items: flex-start; white-space: normal; padding: 8px 11px; gap: 1px; }
.action-link-label { font-size: 12px; }
.action-link-url { font-size: 10px; word-break: break-all; }

/* Settings dialog. */
.sidebar-backdrop { position: fixed; inset: 0; z-index: 80; background: #211d3e57; backdrop-filter: blur(4px); }
.settings-dialog { position: fixed; z-index: 81; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(650px, calc(100vw - 48px)); max-height: min(840px, calc(100dvh - 64px)); overflow-y: auto; padding: 0 28px; border: 1px solid #ffffffb3; border-radius: 18px; box-shadow: 0 24px 80px #1e163e40; background: white; scroll-padding: 95px 0; }
body.settings-open, body.lightbox-open { overflow: hidden; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 18px; position: sticky; top: 0; z-index: 2; padding: 21px 0 18px; border-bottom: 1px solid var(--line); background: white; }
.brand-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand h1 { font-size: 18px; font-weight: 600; }
.brand-copy p { margin-top: 2px; font-size: 11px; color: var(--muted); }
.brand-actions { display: flex; align-items: center; gap: 8px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 20px; background: var(--success-soft); color: var(--success); font-size: 11px; white-space: nowrap; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.dot.ready { background: var(--success); }
.dot.busy { background: var(--accent); }
.dot.error { background: var(--danger); }
.section { padding: 22px 0; border-bottom: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title h2 { font-size: 14px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.hint { font-size: 11px; color: var(--muted); line-height: 1.8; }
.input-row { display: flex; align-items: center; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.toolbar, .reference-toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.gateway-status { padding: 12px; background: #f4f7f6; border: 1px solid #e0ebe6; border-radius: 9px; margin-bottom: 16px; }
.gateway-status-row { display: flex; gap: 10px; align-items: center; }
.gateway-icon { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 9px; color: var(--success); background: white; }
.gateway-status-row > div { min-width: 0; }
.gateway-status-row strong { display: block; color: var(--success); font-size: 12px; font-weight: 600; }
.gateway-status-row div > span { display: block; color: #63736c; font-size: 10px; overflow-wrap: anywhere; }
.gateway-manage-link { margin-top: 11px; }
.reference-dropzone { display: flex; width: 100%; align-items: center; gap: 12px; text-align: left; padding: 18px; border: 1px dashed #d4cce5; border-radius: 10px; background: #faf9fd; color: var(--text); min-height: 82px; }
.reference-dropzone:hover, .reference-dropzone.is-dragging { background: var(--accent-soft); border-color: var(--accent); }
.reference-dropzone-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.reference-dropzone-copy { display: flex; flex-direction: column; min-width: 0; }
.reference-dropzone-copy strong { font-size: 12px; font-weight: 500; }
.reference-dropzone-copy span { color: var(--muted); font-size: 10px; margin-top: 4px; }
.reference-dropzone.is-uploading .reference-dropzone-icon { animation: spin 1.6s linear infinite; }
.reference-preview { display: none; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #f5f4f8; }
.reference-preview.open { display: block; }
.reference-preview img { display: block; width: 100%; max-height: 170px; object-fit: contain; }
.range-row { display: flex; align-items: center; gap: 12px; }
.compression-value { font-size: 12px; min-width: 40px; color: var(--muted); }
.warning { display: none; padding: 11px; border-radius: 8px; background: #fff8eb; color: #855c1c; font-size: 12px; }
.settings-footer { position: sticky; bottom: 0; z-index: 2; padding: 15px 0 20px; display: flex; justify-content: flex-end; background: white; border-top: 1px solid var(--line); }
.settings-footer .primary-button { min-width: 120px; }

/* Image-to-prompt workspace. */
.reverse-workspace { flex: 1; min-width: 0; min-height: 0; overflow: auto; background: white; border: 1px solid var(--line); border-radius: 16px; }
.reverse-prompt-head { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 23px; border-bottom: 1px solid var(--line); }
.reverse-prompt-title { display: flex; align-items: center; min-width: 0; gap: 12px; }
.reverse-prompt-mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.reverse-prompt-title h2 { font-size: 19px; font-weight: 600; }
.reverse-prompt-title p { margin-top: 4px; font-size: 11px; color: var(--muted); }
.reverse-head-actions { display: flex; align-items: center; gap: 10px; }
.reverse-model-meta { text-align: right; white-space: nowrap; }
.reverse-model-meta span { display: block; font-size: 10px; color: var(--muted); }
.reverse-model-meta strong { display: block; font-size: 11px; font-weight: 500; color: #6c5a8c; }
.reverse-workspace-content { min-width: 0; }
.reverse-editor { padding: 23px; }
.reverse-prompt-body { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 24px; }
.reverse-source-pane, .reverse-output-pane { min-width: 0; }
.reverse-section-label, .reverse-result-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 11px; }
.reverse-section-label > span { font-size: 13px; font-weight: 500; }
.reverse-section-label small { font-size: 11px; color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reverse-source-stage { display: grid; place-items: center; aspect-ratio: 1; max-height: 330px; min-height: 160px; overflow: hidden; background: #f4f2f9; border: 1px dashed #d6d0e4; border-radius: 12px; }
.reverse-source-stage img { width: 100%; height: 100%; max-height: 330px; object-fit: contain; }
.reverse-source-empty { display: flex; width: 100%; height: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 35px; background: transparent; color: #847299; font-size: 13px; }
.reverse-source-empty:hover { background: #ebe6f6; }
.reverse-source-actions { display: flex; gap: 7px; margin-top: 12px; flex-wrap: wrap; }
.reverse-source-actions .secondary-button { flex: 1; min-height: 36px; padding: 7px; font-size: 11px; gap: 6px; }
.reverse-source-actions svg { width: 15px; height: 15px; }
#reverseUseCurrent { flex-basis: 100%; }
.reverse-output-pane { display: flex; flex-direction: column; gap: 12px; }
.reverse-output-pane input { font-size: 12px; }
.reverse-result-head { margin: 2px 0 -3px; }
.reverse-status { color: var(--muted); font-size: 10px; }
.reverse-status.running { color: var(--accent); }
.reverse-status.success { color: var(--success); }
.reverse-status.error { color: var(--danger); }
#reversePromptResult { flex: 1; min-height: 215px; background: #fdfdfe; font-size: 13px; }
.reverse-prompt-footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 9px; padding-top: 20px; }
.reverse-prompt-footer .secondary-button { font-size: 12px; }
.reverse-prompt-footer .primary-button { min-width: 130px; margin-left: auto; }
.reverse-history-pane { padding: 22px; border-top: 1px solid var(--line); background: #fbfafc; }
.reverse-history-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.reverse-history-head h3 { font-size: 14px; font-weight: 600; }
.reverse-history-head p { color: var(--muted); font-size: 11px; margin-top: 3px; }
.reverse-history-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.reverse-history-card { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.reverse-history-main { display: flex; width: 100%; gap: 12px; text-align: left; padding: 0; background: transparent; }
.reverse-history-main img { width: 60px; height: 60px; object-fit: cover; flex-shrink: 0; border-radius: 6px; }
.reverse-history-content { min-width: 0; }
.reverse-history-content strong { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 11px; font-weight: 400; }
.reverse-history-content small { display: block; margin-top: 5px; font-size: 10px; color: var(--muted); }
.reverse-history-actions { display: flex; justify-content: flex-end; gap: 5px; margin-top: 7px; }
.reverse-history-empty { min-height: 130px; }

/* Full image preview. */
.lightbox { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-columns: minmax(0, 1fr) 360px; padding: 22px; gap: 0; background: #1b1924e8; backdrop-filter: blur(8px); }
.lightbox-visual { min-height: 0; display: grid; place-items: center; padding: 30px; cursor: zoom-out; }
.lightbox-visual img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.lightbox-side { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 20px; padding: 23px; background: white; border-radius: 14px; }
.lightbox-top { display: flex; align-items: center; justify-content: space-between; }
.lightbox-top h3 { font-size: 17px; font-weight: 600; }
.lightbox-meta { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px 10px; margin: 0; font-size: 12px; }
.lightbox-meta dt { color: var(--muted); }
.lightbox-meta dd { margin: 0; overflow-wrap: anywhere; }
.prompt-box { margin-top: 10px; padding: 13px; background: var(--panel-soft); border-radius: 9px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 280px; overflow: auto; }
.lightbox-side .secondary-button { width: 100%; }
#lightboxDownload { color: white; background: var(--accent); border-color: var(--accent); }

/* Authentication uses the same visual language as the canvas. */
.app-bootstrap { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; background: var(--bg); }
.bootstrap-indicator { position: relative; padding: 16px; }
.bootstrap-indicator .brand-mark { width: 48px; height: 48px; }
.bootstrap-ring { position: absolute; inset: 0; border: 1.5px solid #e2ddf1; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
.auth-gate { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 40px 24px; }
.auth-layout { display: grid; grid-template-columns: 1.1fr 1fr; width: min(1040px, 100%); min-height: 640px; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: white; box-shadow: 0 20px 70px #30205009; }
.auth-intro { position: relative; display: flex; flex-direction: column; padding: 42px 44px 30px; background: #eeebf7; overflow: hidden; }
.auth-intro-brand { font-family: "Studio Display", sans-serif; font-size: 16px; font-weight: 750; color: #625282; letter-spacing: -.4px; }
.auth-intro-copy { position: relative; z-index: 1; margin-top: 50px; }
.auth-intro-copy h2 { font-size: 32px; font-weight: 600; line-height: 1.65; letter-spacing: -1px; color: #3f345b; }
.auth-intro-copy p { font-size: 13px; line-height: 1.9; color: #736987; margin-top: 15px; }
.studio-art { width: 100%; max-width: 380px; margin: 18px auto 4px; }
.studio-art svg { width: 100%; height: auto; }
.auth-intro-foot { display: flex; align-items: center; gap: 12px; margin-top: auto; font-size: 11px; color: #80748f; }
.auth-intro-foot span { width: 3px; height: 3px; background: #b7adca; border-radius: 50%; }
.auth-dialog { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 48px; }
.auth-brand { margin-bottom: 29px; }
.auth-brand-mark { width: 44px; height: 44px; margin-bottom: 21px; }
.auth-kicker { display: none; }
.auth-brand h1 { font-size: 23px; font-weight: 600; letter-spacing: -.5px; }
.auth-brand p { font-size: 12px; margin-top: 9px; color: var(--muted); line-height: 1.9; }
.auth-form { display: grid; gap: 18px; }
.auth-form input { font-size: 14px; min-height: 46px; background: #fdfdfe; border-color: #dedce7; }
.auth-form label { font-size: 12px; }
.auth-submit { min-height: 46px; width: 100%; margin-top: 4px; }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 23px; font-size: 11px; color: var(--muted); }
.auth-links > span:last-child { display: flex; gap: 14px; }
.auth-privacy { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 36px; font-size: 10px; color: #7a7889; }
.auth-error { margin-top: 17px; padding: 11px; border: 1px solid #f1d6d9; border-radius: 8px; background: #fff3f4; color: var(--danger); font-size: 12px; }
.auth-form-actions { display: grid; gap: 9px; }
.auth-step-copy { font-size: 13px; color: var(--muted); }
.turnstile-slot { overflow: hidden; min-width: 0; }

/* Responsive layout retains readable controls instead of scaling everything down. */
@media (min-width: 1600px) {
  .submission-panel { padding: 28px 32px 18px; gap: 16px; }
  #chatPrompt { min-height: 150px; }
  .conversation-layout { grid-template-columns: minmax(0, 1fr) 370px; gap: 30px; }
}
@media (max-width: 1180px) {
  .result-head { padding: 0 24px; height: 72px; }
  .conversation-layout { grid-template-columns: minmax(0, 1fr) 304px; gap: 18px; padding: 20px; }
  .submission-panel { padding: 22px 21px 17px; gap: 15px; }
  .submission-heading h2 { font-size: 24px; }
  .creation-mark svg { width: 60px; height: 60px; }
  .image-key-heading div > span { font-size: 10px; }
  .image-key-heading > div { gap: 8px; }
  .composer-actions { grid-template-columns: auto auto 30px minmax(100px, 1fr); gap: 5px; }
  .composer-actions .secondary-button { padding: 8px 7px; font-size: 11px; }
  .composer-actions .primary-button { min-width: 100px; font-size: 12px; }
  .prompt-assist { gap: 8px; flex-wrap: wrap; }
  .prompt-suggestions button { font-size: 10px; }
  .community-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-panel, .job-panel { padding: 14px; }
  .reverse-prompt-head, .reverse-editor, .reverse-history-pane { padding: 19px; }
  .reverse-prompt-title h2 { font-size: 17px; }
  .reverse-prompt-title p { display: none; }
  .reverse-prompt-body { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .reverse-source-stage { aspect-ratio: 1.6; }
  .reverse-history-list { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { height: auto; min-height: 100dvh; }
  .stage, .result-shell { height: auto; }
  .result-head { position: sticky; top: 0; z-index: 30; height: 67px; padding: 0 22px; }
  .result-title { gap: 14px; }
  .studio-context { display: none; }
  .header-divider { display: none; }
  .conversation-layout { grid-template-columns: minmax(0, 1fr); padding: 19px 22px 28px; gap: 23px; max-width: 760px; }
  .conversation-panel, .record-rail { min-height: auto; }
  .conversation-layout:has(.reverse-mode) > .community-panel { display: none; }
  .conversation-layout > .community-panel { padding-top: 0; }
  .generation-workspace, .reverse-workspace { overflow: visible; min-height: auto; padding-right: 0; }
  .submission-panel { padding: 25px; gap: 17px; }
  .submission-heading h2 { font-size: 27px; }
  .creation-mark svg { width: 72px; height: 72px; }
  .composer-actions { grid-template-columns: auto auto 38px minmax(120px, 1fr); gap: 8px; }
  .composer-actions .secondary-button { padding: 8px 12px; font-size: 12px; }
  .community-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .library-panel, .job-panel { overflow: visible; padding: 20px; }
  .library-head { flex-wrap: nowrap; }
  .library-panel[data-rail-panel="history"] .library-controls { width: auto; }
  .thumb-grid { grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); gap: 12px; }
  .reference-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .job-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .notice-box { margin: 13px 22px 0; }
  .reverse-prompt-body { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); }
  .reverse-source-stage { aspect-ratio: 1; }
  .lightbox { grid-template-columns: minmax(0, 1fr) 310px; padding: 14px; }
  .lightbox-visual { padding: 15px; }
  .auth-layout { max-width: 720px; grid-template-columns: .95fr 1fr; min-height: 580px; }
  .auth-intro { padding: 30px 24px; }
  .auth-intro-copy h2 { font-size: 25px; }
  .auth-dialog { padding: 32px 25px; }
}
@media (max-width: 600px) {
  :root { font-size: 14px; }
  input, select, textarea { font-size: 16px; }
  .result-head { height: 64px; padding: 0 16px; gap: 12px; }
  .studio-home { gap: 8px; }
  .studio-wordmark { font-size: 18px; letter-spacing: -.6px; }
  .studio-home .brand-mark { width: 31px; height: 31px; flex-basis: 31px; border-radius: 9px; }
  .studio-home .brand-mark svg { width: 22px; height: 22px; }
  .result-actions { gap: 4px; }
  .admin-entry-link { width: 32px; height: 36px; min-height: 36px; padding: 0; font-size: 0; gap: 0; }
  .admin-entry-link svg { width: 17px; }
  .user-summary { gap: 3px; padding: 0; border: 0; }
  .user-avatar { display: none; }
  .user-meta strong { display: none; }
  .user-meta small { font-size: 10px; white-space: nowrap; background: #eeebf8; color: #65548a; padding: 5px 7px; border-radius: 6px; }
  .logout-button { width: 29px; }
  #toggleRaw { display: none; }
  .conversation-layout { padding: 16px 14px 25px; gap: 23px; }
  .workspace-tabs { min-height: 48px; gap: 4px; padding-bottom: 10px; }
  .workspace-tab { min-height: 38px; font-size: 12px; padding: 9px 13px; }
  .submission-panel { gap: 15px; padding: 19px 17px 14px; border-radius: 14px; }
  .submission-heading { gap: 5px; }
  .submission-heading h2 { font-size: 24px; letter-spacing: -.8px; }
  .submission-heading p { margin-top: 4px; font-size: 11px; }
  .creation-mark svg { width: 50px; height: 55px; }
  .image-key-control { padding: 11px; gap: 8px; }
  .image-key-heading > div { gap: 8px; align-items: center; }
  .image-key-heading strong { font-size: 11px; }
  .image-key-heading div > span { font-size: 10px; }
  .image-route-controls { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 8px; }
  .image-route-field label { font-size: 10px; }
  .image-route-field select { min-height: 42px; padding: 8px 20px 8px 8px; font-size: 12px; }
  .composer-heading label { font-size: 12px; }
  .composer-parameter-summary { font-size: 10px; max-width: 210px; }
  .settings-trigger { min-height: 38px; padding: 7px; font-size: 11px; gap: 5px; }
  #chatPrompt { min-height: 156px; padding: 13px; font-size: 16px; line-height: 1.85; }
  #chatPrompt::placeholder { font-size: 13px; }
  .prompt-assist { gap: 7px; margin-top: -5px; }
  .prompt-assist > span { display: none; }
  .prompt-suggestions { gap: 7px; }
  .prompt-suggestions button { min-height: 34px; font-size: 11px; padding: 5px 8px; }
  .composer-actions { grid-template-columns: 1fr 1fr 36px; gap: 6px; padding-top: 12px; }
  .composer-actions .secondary-button { min-height: 42px; padding: 7px 8px; font-size: 11px; }
  .composer-actions .primary-button { grid-column: 1 / -1; width: 100%; min-height: 44px; font-size: 13px; margin-top: 2px; }
  .composer-footnote { justify-content: center; margin-top: -6px; font-size: 10px; }
  .composer-footnote .keyboard-hint { display: none; }
  .composer-reference { gap: 9px; }
  .composer-reference img { width: 42px; height: 42px; }
  .community-panel { padding-top: 23px; }
  .community-head { gap: 8px; margin-bottom: 12px; }
  .community-head h2 { font-size: 17px; }
  .community-head p { font-size: 11px; }
  .community-head-actions strong { display: none; }
  .community-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .community-image-button img { aspect-ratio: 1; }
  .community-card-body { padding: 10px; gap: 8px; }
  .community-card-body p { font-size: 11px; }
  .community-card-meta { font-size: 9px; gap: 4px; }
  .community-card-meta span:last-child { display: none; }
  .community-use-button { min-height: 36px; }
  .community-empty { min-height: 180px; }
  .rail-tabs { border-radius: 10px; margin-bottom: 10px; padding: 4px; }
  .rail-tab { min-height: 36px; }
  .library-panel, .job-panel { padding: 16px; border-radius: 12px; }
  .library-head { gap: 11px; flex-wrap: wrap; }
  .library-head h3 { font-size: 15px; }
  .library-panel[data-rail-panel="history"] .library-controls { width: 100%; }
  .library-controls .secondary-button, .library-controls select { min-height: 40px; font-size: 12px; }
  .library-controls select { font-size: 16px; }
  .thumb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .thumb-actions { display: flex; flex-wrap: wrap; padding: 2px; }
  .thumb-actions .mini-button { flex: 1 1 44px; min-width: 44px; font-size: 11px; min-height: 44px; }
  .reference-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .reference-actions .mini-button { min-height: 38px; }
  .job-list { grid-template-columns: minmax(0, 1fr); }
  .job-main strong { font-size: 12px; }
  .job-prompt, .job-side, .job-error, .job-raw { font-size: 11px; }
  .job-retry-button { min-height: 38px; padding-inline: 15px; }
  .job-image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .notice-box { flex-wrap: wrap; gap: 8px; padding: 10px 38px 10px 12px; margin: 11px 14px 0; font-size: 11px; }
  .notice-action-link { min-width: 0; width: 100%; }
  .settings-dialog { top: auto; bottom: 0; left: 0; transform: none; width: 100%; max-height: calc(100dvh - 20px); border-radius: 18px 18px 0 0; padding: 0 20px; scroll-padding-top: 95px; }
  .brand { padding: 19px 0 16px; }
  .brand h1 { font-size: 17px; }
  .brand-copy p { font-size: 10px; }
  .brand-mark { width: 34px; height: 34px; flex-basis: 34px; }
  .brand-actions .status-pill { display: none; }
  .section { padding: 19px 0; }
  .form-grid { gap: 13px; }
  .settings-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .settings-footer .primary-button { width: 100%; min-height: 44px; }
  .hint { font-size: 11px; }
  .reverse-prompt-head { padding: 19px 16px; gap: 8px; }
  .reverse-prompt-title { gap: 9px; }
  .reverse-prompt-title h2 { font-size: 17px; }
  .reverse-prompt-mark { width: 33px; height: 33px; }
  .reverse-model-meta { display: none; }
  .reverse-editor, .reverse-history-pane { padding: 17px; }
  .reverse-prompt-body { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .reverse-source-stage { aspect-ratio: 1.6; }
  .reverse-source-actions .secondary-button { min-height: 42px; font-size: 12px; }
  .reverse-output-pane input, #reversePromptResult { font-size: 16px; }
  #reversePromptResult { min-height: 185px; }
  .reverse-prompt-footer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .reverse-prompt-footer .primary-button { width: 100%; margin: 0; grid-column: 1 / -1; min-height: 44px; }
  .reverse-prompt-footer .secondary-button { min-width: 0; padding: 9px; }
  .reverse-history-list { grid-template-columns: minmax(0, 1fr); }
  .reverse-history-main img { width: 68px; height: 68px; }
  .reverse-history-content strong { font-size: 12px; }
  .lightbox { padding: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .lightbox-visual { padding: 16px; }
  .lightbox-side { padding: 19px; gap: 16px; max-height: 46dvh; border-radius: 17px 17px 0 0; padding-bottom: max(19px, env(safe-area-inset-bottom)); }
  .lightbox-top { position: sticky; top: -19px; z-index: 1; margin-top: -3px; padding: 7px 0; background: white; }
  .auth-gate { padding: 25px 18px; background: #f5f4fa; }
  .auth-layout { display: block; border: 0; border-radius: 19px; min-height: auto; max-width: 420px; box-shadow: 0 10px 36px #31244e08; }
  .auth-intro { display: none; }
  .auth-dialog { padding: 35px 27px 29px; }
  .auth-brand-mark { width: 45px; height: 45px; margin-bottom: 24px; }
  .auth-brand h1 { font-size: 24px; }
  .auth-brand p { font-size: 12px; }
  .auth-form input { font-size: 16px; }
  .auth-links { font-size: 11px; }
}
@media (max-width: 360px) {
  .result-head { padding: 0 12px; gap: 5px; }
  .studio-wordmark { font-size: 16px; }
  .studio-home { gap: 6px; }
  .user-meta small { padding: 5px; font-size: 9px; }
  .conversation-layout { padding-inline: 10px; }
  .submission-panel { padding-inline: 14px; }
  .submission-heading h2 { font-size: 22px; }
  .creation-mark { display: none; }
  .composer-parameter-summary { max-width: 174px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .auth-dialog { padding-inline: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .community-image-button:hover img, .thumb-button:hover img { transform: none; }
}

/* Gallery management and recoverable image failures. */
.gallery-filters { display: grid; gap: 9px; margin-bottom: 12px; }
.gallery-search { display: grid; gap: 5px; font-size: 11px; color: var(--muted); }
.gallery-filters input, .gallery-filters select { min-height: 38px; font-size: 12px; border-color: var(--line); }
.gallery-filter-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 7px; }
.gallery-selection-tools { display: grid; gap: 9px; margin-bottom: 12px; }
.gallery-selection-tools > div:first-child { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.gallery-selection-tools label { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; }
.gallery-selection-tools input { width: 16px; min-height: 16px; height: 16px; margin: 0; }
#historySelectedCount { font-size: 11px; color: var(--muted); }
.gallery-batch-actions { display: flex; gap: 7px; }
.gallery-batch-actions .secondary-button { flex: 1; font-size: 11px; padding: 7px; min-height: 36px; }
.thumb-card { position: relative; }
.image-selection-control, .favorite-toggle { position: absolute; top: 4px; z-index: 1; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: #ffffffec; }
.image-selection-control { left: 4px; cursor: pointer; }
.image-selection-control .image-selection { width: 16px; height: 16px; min-height: 16px; margin: 0; accent-color: var(--accent); }
.favorite-toggle { right: 4px; padding: 0; color: var(--muted); }
.favorite-toggle svg { stroke: currentColor; stroke-width: 1.6; fill: none; }
.favorite-toggle.active { color: var(--accent); }
.favorite-toggle.active svg { fill: var(--accent-soft); }
.image-unavailable { position: relative; display: grid; place-items: center; min-height: 90px; background: var(--panel-soft); }
.image-unavailable::after { content: "图片暂不可用"; font-size: 11px; color: var(--muted); padding: 12px 5px; text-align: center; }
#referenceCheckStatus { color: var(--danger); white-space: normal; font-size: 11px; }
.job-item.partial { border-color: #e6d7bc; }
.job-item.partial .job-status-dot { background: var(--warn); }
.job-item.partial .job-side { color: var(--warn); }
.job-item.partial .job-error { background: #fff8eb; color: var(--warn); }
@media (max-width: 600px) {
  .gallery-filters input, .gallery-filters select { font-size: 16px; min-height: 44px; }
  .gallery-batch-actions .secondary-button { min-height: 44px; }
  .image-selection-control, .favorite-toggle { width: 38px; height: 38px; }
  .composer-reference { flex-wrap: wrap; }
  .composer-reference > div { flex-basis: calc(100% - 70px); }
}

#lightboxError { color: #eeebf6; font-size: 14px; padding: 24px; text-align: center; }
