:root {
  color-scheme: light;
  --bg: oklch(1 0 0);
  --surface: oklch(0.965 0.004 343);
  --surface-raised: oklch(0.985 0.002 343);
  --ink: oklch(0.19 0.018 343);
  --muted: oklch(0.47 0.025 343);
  --border: oklch(0.89 0.012 343);
  --primary: oklch(0.57 0.19 343.4);
  --primary-hover: oklch(0.51 0.19 343.4);
  --accent: oklch(0.40 0.10 205);
  --success: oklch(0.48 0.12 150);
  --danger: oklch(0.52 0.18 25);
  --shadow: 0 18px 50px oklch(0.19 0.018 343 / 0.10);
  --control-ink: oklch(0.98 0 0);
  --surface-selected: oklch(0.94 0.025 343);
  --surface-info: oklch(0.94 0.025 205);
  --border-hover: oklch(0.76 0.03 343);
  --placeholder: oklch(0.49 0.018 343);
  --error-border: oklch(0.72 0.12 25);
  --error-surface: oklch(0.96 0.025 25);
  --error-ink: oklch(0.38 0.15 25);
  --empty-accent: oklch(0.88 0.04 343);
  --empty-info: oklch(0.82 0.065 205);
  --radius: 12px;
  font-family: "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: oklch(0.16 0.018 343);
  --surface: oklch(0.21 0.018 343);
  --surface-raised: oklch(0.24 0.016 343);
  --ink: oklch(0.94 0.012 343);
  --muted: oklch(0.72 0.025 343);
  --border: oklch(0.34 0.02 343);
  --primary: oklch(0.69 0.17 343.4);
  --primary-hover: oklch(0.76 0.16 343.4);
  --accent: oklch(0.75 0.10 205);
  --success: oklch(0.72 0.12 150);
  --danger: oklch(0.72 0.16 25);
  --shadow: 0 18px 50px oklch(0 0 0 / 0.36);
  --surface-selected: oklch(0.31 0.05 343);
  --surface-info: oklch(0.29 0.035 205);
  --border-hover: oklch(0.52 0.06 343);
  --placeholder: oklch(0.67 0.022 343);
  --error-border: oklch(0.58 0.14 25);
  --error-surface: oklch(0.27 0.045 25);
  --error-ink: oklch(0.86 0.08 25);
  --empty-accent: oklch(0.38 0.05 343);
  --empty-info: oklch(0.35 0.06 205);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: oklch(0.16 0.018 343);
    --surface: oklch(0.21 0.018 343);
    --surface-raised: oklch(0.24 0.016 343);
    --ink: oklch(0.94 0.012 343);
    --muted: oklch(0.72 0.025 343);
    --border: oklch(0.34 0.02 343);
    --primary: oklch(0.69 0.17 343.4);
    --primary-hover: oklch(0.76 0.16 343.4);
    --accent: oklch(0.75 0.10 205);
    --success: oklch(0.72 0.12 150);
    --danger: oklch(0.72 0.16 25);
    --shadow: 0 18px 50px oklch(0 0 0 / 0.36);
    --surface-selected: oklch(0.31 0.05 343);
    --surface-info: oklch(0.29 0.035 205);
    --border-hover: oklch(0.52 0.06 343);
    --placeholder: oklch(0.67 0.022 343);
    --error-border: oklch(0.58 0.14 25);
    --error-surface: oklch(0.27 0.045 25);
    --error-ink: oklch(0.86 0.08 25);
    --empty-accent: oklch(0.38 0.05 343);
    --empty-info: oklch(0.35 0.06 205);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); }
body { margin: 0; min-width: 0; font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-underline-offset: 0.18em; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
h1, h2, p { text-wrap: pretty; }
h1, h2 { letter-spacing: -0.025em; line-height: 1.15; }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 50; top: 10px; left: 10px; transform: translateY(-150%); padding: 10px 14px; border-radius: 8px; background: var(--ink); color: var(--bg); }
.skip-link:focus { transform: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.app-nav { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px; padding: 22px 16px 16px; border-right: 1px solid var(--border); background: var(--surface-raised); }
.brand { display: flex; align-items: center; gap: 11px; margin: 0 8px 24px; color: var(--ink); text-decoration: none; }
.brand > span:last-child { display: flex; flex-direction: column; }
.brand strong { font-size: 15px; letter-spacing: -0.01em; }
.brand small { color: var(--muted); font-size: 12px; }
.beacon { width: 26px; height: 26px; border-radius: 8px; background: var(--primary); box-shadow: inset 0 0 0 6px oklch(1 0 0 / 0.28); }
.nav-label { display: block; padding: 14px 10px 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
.nav-link { display: flex; justify-content: space-between; align-items: center; min-height: 40px; padding: 9px 10px; border-radius: 8px; color: var(--muted); font-weight: 570; text-decoration: none; }
.nav-link:hover { background: var(--surface); color: var(--ink); }
.nav-link.active { background: var(--surface-selected); color: var(--primary-hover); }
.nav-spacer { flex: 1; }
.user-section { padding-top: 12px; border-top: 1px solid var(--border); }
.user-profile { display: flex; align-items: center; gap: 10px; padding: 8px; color: var(--ink); text-decoration: none; }
.user-profile > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.user-profile strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-profile > span > span { color: var(--muted); font-size: 11px; }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--bg); font-weight: 700; }
.user-section form button { width: 100%; padding: 7px 8px; border: 0; background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.user-section form button:hover { color: var(--danger); }

.app-main { min-width: 0; padding: 30px clamp(22px, 4vw, 64px) 20px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-header h1 { margin: 0; font-size: 25px; }
.refresh-note { color: var(--primary-hover); font-size: 13px; font-weight: 650; }
.app-footer { display: flex; justify-content: space-between; gap: 16px; margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.theme-toolbar { display: none; }
.app-nav .theme-toolbar { display: flex; width: 100%; justify-content: stretch; margin: 0 0 12px; }
.theme-toggle { min-height: 36px; display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 650; cursor: pointer; transition: background-color 170ms ease-out, border-color 170ms ease-out, color 170ms ease-out; }
.app-nav .theme-toggle { width: 100%; justify-content: flex-start; border-radius: 8px; }
.theme-toggle:hover { border-color: var(--border-hover); background: var(--surface); color: var(--ink); }
.theme-toggle-icon { display: grid; width: 17px; height: 17px; place-items: center; color: var(--primary-hover); font-size: 15px; }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 650; line-height: 1; text-decoration: none; cursor: pointer; transition: background-color 170ms ease-out, border-color 170ms ease-out, color 170ms ease-out, transform 170ms ease-out; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--primary-hover); outline-offset: 2px; box-shadow: none; }
.button.primary { background: var(--primary); color: var(--bg); }
.button.primary:hover { background: var(--primary-hover); }
.button.secondary { border-color: var(--border); background: var(--bg); color: var(--ink); }
.button.secondary:hover { border-color: var(--border-hover); background: var(--surface); }
.button.quiet { background: transparent; color: var(--muted); }
.button:disabled { opacity: 0.55; cursor: wait; transform: none; }

label { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 650; }
label small { color: var(--muted); font-weight: 430; }
input, textarea, select { width: 100%; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--ink); }
input, select { min-height: 42px; padding: 9px 11px; }
textarea { resize: vertical; padding: 12px; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--placeholder); }
input:hover, textarea:hover, select:hover { border-color: var(--border-hover); }
.form-error { margin: 0; padding: 12px 14px; border: 1px solid var(--error-border); border-radius: 9px; background: var(--error-surface); color: var(--error-ink); }

.auth-stage { min-height: calc(100vh - 190px); display: grid; grid-template-columns: minmax(260px, 1fr) minmax(300px, 420px); align-items: center; gap: clamp(40px, 8vw, 120px); max-width: 1040px; margin: 0 auto; }
.auth-copy { max-width: 540px; }
.auth-copy h2 { max-width: 10ch; margin: 22px 0 18px; font-size: clamp(38px, 6vw, 72px); letter-spacing: -0.04em; }
.auth-copy p:last-child { max-width: 52ch; color: var(--muted); font-size: 17px; }
.auth-mark { width: 48px; height: 48px; display: grid; place-items: center; margin: 0; border-radius: 14px; background: var(--primary); color: var(--bg); font-weight: 800; }
.auth-form { display: grid; gap: 18px; padding: clamp(24px, 4vw, 38px); border: 1px solid var(--border); border-radius: 16px; background: var(--surface-raised); box-shadow: var(--shadow); }

.library-tools { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.search { flex: 1; max-width: 620px; display: flex; gap: 8px; }
.prompt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: clamp(18px, 2.5vw, 32px); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 36px 0 8px; }
.page-numbers { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.page-number { min-width: 36px; height: 36px; display: grid; place-items: center; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; color: var(--muted); font-weight: 650; text-decoration: none; }
.page-number:hover { background: var(--surface); color: var(--ink); }
.page-number.current { background: var(--primary); color: var(--control-ink); }
.prompt-tile { min-width: 0; }
.prompt-image-wrap { position: relative; }
.prompt-image { aspect-ratio: 4 / 3; display: block; overflow: hidden; border-radius: var(--radius); background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.prompt-image img { width: 100%; height: 100%; object-fit: cover; transition: transform 220ms cubic-bezier(.25,.8,.25,1); }
.prompt-image:hover img { transform: scale(1.018); }
.favorite-toggle { position: absolute; top: 8px; right: 8px; margin: 0; }
.favorite-star { width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: oklch(0.19 0.018 343 / 0.55); color: oklch(0.98 0 0); font-size: 16px; line-height: 1; cursor: pointer; backdrop-filter: blur(4px); transition: background-color 170ms ease-out, transform 170ms ease-out; }
.favorite-star:hover { background: oklch(0.19 0.018 343 / 0.8); transform: scale(1.06); }
.favorite-star.on { background: var(--primary); color: oklch(0.98 0 0); }
.prompt-tile-copy { display: grid; gap: 10px; padding: 13px 3px 0; }
.prompt-tile-copy h2 { margin: 0 0 3px; font-size: 16px; }
.prompt-tile-copy h2 a { color: var(--ink); text-decoration: none; }
.prompt-tile-copy p { margin: 0; color: var(--muted); font-size: 12px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tag-list li { padding: 3px 8px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 11px; }
.empty-canvas { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 20%; }
.empty-canvas i { border-radius: 999px; background: var(--border); transform: rotate(24deg); }
.empty-canvas i:nth-child(2) { background: var(--empty-accent); transform: rotate(-12deg); }
.empty-canvas i:nth-child(3) { background: var(--empty-info); transform: rotate(42deg); }
.empty-canvas.large { width: 180px; height: 140px; padding: 35px; border-radius: var(--radius); background: var(--surface); }
.empty-library, .ungenerated { display: grid; justify-items: center; max-width: 620px; margin: 9vh auto; text-align: center; }
.empty-library h2, .ungenerated h2 { margin: 26px 0 8px; font-size: 24px; }
.empty-library p, .ungenerated p { max-width: 54ch; margin: 0 0 22px; color: var(--muted); }

.error-stage { display: grid; justify-items: center; max-width: 540px; margin: 14vh auto; padding: 0 20px; text-align: center; }
.error-mark { width: 56px; height: 56px; display: grid; place-items: center; margin: 0 0 22px; border-radius: 50%; background: var(--surface); color: var(--muted); font-size: 28px; font-weight: 800; }
.error-stage h2 { margin: 0 0 12px; font-size: 24px; letter-spacing: -0.02em; }
.error-hint { max-width: 48ch; margin: 0 0 26px; color: var(--muted); font-size: 15px; }

.revision-heading { margin: 0 0 6px; font-size: 24px; }
.revision-intro { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.revision-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.revision { padding: 20px 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); }
.revision.current { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.revision header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.revision-version { font-weight: 700; }
.revision-meta { color: var(--muted); font-size: 12px; }
.current-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--primary); color: var(--control-ink); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.revision h3 { margin: 0 0 10px; font-size: 17px; }
.revision pre { max-height: 320px; overflow: auto; margin: 0 0 10px; padding: 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font: inherit; font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.revision details summary { color: var(--muted); font-size: 13px; cursor: pointer; }

.prompt-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 330px); gap: clamp(28px, 5vw, 70px); align-items: start; }
.editor-main, .editor-settings { display: grid; gap: 20px; }
.editor-settings { position: sticky; top: 30px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); }
.editor-settings h2 { margin: 0; font-size: 16px; }
.editor-actions { display: grid; gap: 8px; margin-top: 6px; }

.detail-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.detail-actions > div:last-child { display: flex; gap: 8px; }
.detail-actions form { display: contents; }
.provenance { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 12px; }
.provenance span + span::before { content: "·"; margin-right: 16px; }
.job-status { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 22px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.job-status strong, .job-status p { display: block; margin: 0; }
.job-status p { color: var(--muted); font-size: 13px; }
.status-symbol { flex: 0 0 auto; width: 18px; height: 18px; display: grid; place-items: center; margin-top: 2px; border-radius: 50%; background: var(--primary); color: var(--bg); font-size: 11px; font-weight: 800; }
.job-status.working .status-symbol { box-shadow: 0 0 0 5px oklch(0.57 0.19 343.4 / 0.12); }
.job-status.failed { border-color: oklch(0.76 0.10 25); background: oklch(0.97 0.02 25); }
.job-status.failed .status-symbol { background: var(--danger); }
.prompt-workspace { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.7fr); gap: clamp(24px, 4vw, 54px); align-items: start; }
.result-stage { min-width: 0; }
.hero-result { margin: 0; overflow: hidden; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.hero-result > a { display: block; }
.hero-result img { width: 100%; max-height: 72vh; object-fit: contain; background: oklch(0.12 0 0); }
.hero-result figcaption { display: flex; justify-content: space-between; gap: 16px; padding: 11px 14px; color: var(--muted); font-size: 12px; }
.result-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 12px; }
.result-strip a { aspect-ratio: 1; overflow: hidden; border-radius: 8px; background: var(--surface); }
.result-strip img { width: 100%; height: 100%; object-fit: cover; }
.result-provenance { margin-top: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-height: 20px; }
.result-provenance:empty { display: none; }
.provenance-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.provenance-list li { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-raised); font-size: 12px; }
.provenance-kind { padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.provenance-kind.sheet { background: var(--surface-selected); color: var(--primary-hover); }
.provenance-kind.prop { background: var(--surface-info); color: var(--accent); }
.provenance-title { font-weight: 600; }
.provenance-empty { margin: 0; color: var(--muted); font-size: 13px; }
.prompt-inspector { position: sticky; top: 24px; min-width: 0; }
.inspector-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.inspector-heading h2 { margin: 0; font-size: 16px; }
.copy-button { border: 0; border-radius: 7px; padding: 6px 9px; background: var(--surface); color: var(--accent); font-size: 12px; font-weight: 650; cursor: pointer; }
.prompt-inspector pre { max-height: 46vh; overflow: auto; margin: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); color: var(--ink); font: inherit; font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.prompt-inspector details { padding: 13px 2px; border-bottom: 1px solid var(--border); }
.prompt-inspector summary { color: var(--ink); font-weight: 650; cursor: pointer; }
.prompt-inspector details p { max-height: 240px; overflow: auto; color: var(--muted); font-size: 13px; white-space: pre-wrap; }
.prompt-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 20px 0; }
.prompt-facts div { padding: 11px; border-radius: 8px; background: var(--surface); }
.prompt-facts dt { color: var(--muted); font-size: 11px; }
.prompt-facts dd { margin: 2px 0 0; font-weight: 650; }
.codex-health { display: flex; align-items: center; gap: 8px; margin-top: 20px; color: var(--muted); font-size: 12px; }
.codex-health span { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }

.accounts-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 390px); gap: clamp(30px, 6vw, 80px); align-items: start; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-heading h2, .account-form h2 { margin: 0; font-size: 20px; }
.section-heading p, .account-form > div p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.count-badge, .role-badge { border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 700; }
.count-badge { min-width: 28px; padding: 5px 9px; text-align: center; }
.account-list { border-top: 1px solid var(--border); }
.account-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 15px 2px; border-bottom: 1px solid var(--border); }
.account-row > .account-identity { min-width: 0; display: grid; }
.account-row strong, .account-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-row > .account-identity span { color: var(--muted); font-size: 12px; }
.role-badge { padding: 4px 8px; text-transform: capitalize; }

.account-action { position: relative; }
.account-action > summary { list-style: none; cursor: pointer; }
.account-action > summary::-webkit-details-marker { display: none; }
.account-action[open] .account-action-form { display: grid; }
.account-action-form { display: none; grid-template-columns: 1fr; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); box-shadow: var(--shadow); position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 280px; }
.account-action-form label { font-size: 12px; }
.account-action-hint { margin: 0; color: var(--muted); font-size: 11px; }
.button.danger { background: var(--danger); color: var(--control-ink); }
.button.danger:hover { background: oklch(0.46 0.18 25); }
.account-form { position: sticky; top: 30px; display: grid; gap: 18px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-nav { position: static; width: 100%; min-width: 0; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { min-width: 0; margin: 0 auto 0 0; }
  .brand small, .nav-label, .nav-spacer { display: none; }
  .nav-group { order: 3; flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 2px; }
  .nav-link { min-height: 36px; padding: 7px 9px; }
  .user-section { display: flex; align-items: center; gap: 4px; padding: 0; border: 0; }
  .user-profile { padding: 4px; }
  .user-profile > span:last-child { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .user-section form { display: block; }
  .user-section form button { width: auto; min-height: 36px; padding: 7px 9px; text-align: center; }
  .avatar { width: 30px; height: 30px; }
  .app-main { padding-top: 22px; }
  .auth-stage { grid-template-columns: 1fr; align-content: center; gap: 36px; }
  .auth-copy h2 { max-width: 14ch; font-size: 40px; }
  .prompt-editor, .prompt-workspace, .accounts-layout { grid-template-columns: 1fr; }
  .editor-settings, .prompt-inspector, .account-form { position: static; }
  .prompt-inspector pre { max-height: none; }
}

@media (max-width: 560px) {
  .app-main { padding-inline: 16px; }
  .page-header { margin-bottom: 20px; }
  .app-nav .theme-toolbar { order: 4; flex: 1 0 100%; margin: 6px 0 0; }
  .library-tools, .detail-actions { align-items: stretch; flex-direction: column; }
  .search { max-width: none; }
  .prompt-grid { grid-template-columns: 1fr; }
  .detail-actions > div:last-child { display: grid; grid-template-columns: 1fr 1fr; }
  .hero-result figcaption { flex-direction: column; gap: 2px; }
  .provenance span + span::before { content: none; margin: 0; }
  .app-footer { margin-top: 38px; }
}

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

/* Reference views */
.upload-form { display: grid; gap: 10px; margin-top: 20px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); }
.upload-form input[type=file] { padding: 8px; }
.image-manager { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.image-manager li { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.image-manager img { aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.image-manager form { display: contents; }

/* Link picker on prompt editor */
.link-picker { display: grid; gap: 14px; margin-top: 8px; }
.link-picker h2 { margin: 0; font-size: 16px; }
.link-group { border: 0; padding: 0; margin: 0; }
.link-group legend { color: var(--muted); font-size: 12px; font-weight: 650; padding: 0; margin-bottom: 6px; }
.link-chips { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.link-chips:empty { display: none; }
.link-chip { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; background: var(--surface); font-size: 12px; }
.link-chip-kind { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.link-chip-remove { min-width: 24px; min-height: 24px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; line-height: 1; font-size: 14px; }
.link-chip-remove:hover { color: var(--danger); }
.link-add { position: relative; }
.link-add > summary { list-style: none; cursor: pointer; }
.link-add > summary::-webkit-details-marker { display: none; }
.picker-options { list-style: none; margin: 8px 0 0; padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-raised); box-shadow: var(--shadow); max-height: 240px; overflow: auto; display: grid; gap: 4px; }
.picker-options li button { width: 100%; text-align: left; padding: 6px 8px; border: 0; background: transparent; color: var(--ink); cursor: pointer; border-radius: 6px; font-weight: 400; }
.picker-options li button:hover { background: var(--surface); }
.picker-empty { color: var(--muted); font-size: 12px; padding: 6px 8px; }

/* Prompt detail: references section */
.prompt-references { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.prompt-references h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.reference-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.reference-links a { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.reference-links a:hover { background: var(--surface); }
.reference-links img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; }
.reference-links span { font-size: 13px; }
