/* Keep layout measurable while bootstrap restores controls, drafts and widths.
   Startup failures reveal the workspace through the existing recovery marker. */
html:not([data-workspace-ready="true"]):not([data-workspace-boot-error="true"]) .app-shell {
  opacity: 0;
  pointer-events: none;
}
/* App chrome is draggable UI, not a selectable document. Keep text editing native. */
body {
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, [contenteditable=""], [contenteditable="true"], [contenteditable="plaintext-only"] {
  -webkit-user-select: text;
  user-select: text;
}

:root {
  --app-font-increase: 1pt;
  font-size: calc(16px + var(--app-font-increase));
  color-scheme: dark;
  --bg: #0b0d12;
  --rail: rgba(18, 20, 27, 0.7);
  --panel: rgba(23, 25, 32, 0.72);
  --panel-soft: rgba(39, 42, 52, 0.58);
  --stage: #0e1016;
  --rail-solid: #111319;
  --composer-solid: #191b22;
  --density-selected-bg: #303a47;
  --composer-card-solid: #242730;
  --option-bg: #2b303a;
  --option-border: #7e8b9d;
  --option-selected-bg: #0064d8;
  --option-selected-hover: #0056ba;
  --choice-bg: #2b2d34;
  --choice-border: #484b54;
  --choice-selected-bg: #3b3e47;
  --choice-selected-hover: #3e4149;
  --choice-selected-border: #8c8f98;
  --surface: rgba(13, 15, 21, 0.72);
  --surface-focus: rgba(24, 27, 35, 0.88);
  --surface-raised: rgba(70, 74, 88, 0.46);
  --surface-subtle: rgba(255, 255, 255, 0.055);
  --surface-hover: rgba(255, 255, 255, 0.095);
  --material: rgba(43, 46, 57, 0.56);
  --material-strong: rgba(22, 24, 31, 0.72);
  --material-floating: rgba(39, 42, 52, 0.74);
  --line: rgba(255, 255, 255, 0.105);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #f5f5f7;
  --muted: #aeaeb2;
  --dim: #77777c;
  --placeholder: #68686d;
  --accent: #0a84ff;
  --accent-hover: #409cff;
  --accent-gradient: linear-gradient(180deg, #168fff 0%, #0074e8 100%);
  --accent-soft: rgba(10, 132, 255, 0.16);
  --accent-faint: rgba(10, 132, 255, 0.075);
  --accent-line: rgba(10, 132, 255, 0.42);
  --accent-shadow: rgba(10, 132, 255, 0.24);
  --accent-ink: #ffffff;
  --good: #30d158;
  --good-soft: rgba(48, 209, 88, 0.13);
  --good-line: rgba(48, 209, 88, 0.28);
  --good-text: #9bf2ad;
  --warning: #ffd60a;
  --warning-soft: rgba(255, 214, 10, 0.12);
  --danger: #ff453a;
  --danger-soft: rgba(255, 69, 58, 0.12);
  --danger-line: rgba(255, 69, 58, 0.38);
  --danger-text: #ffb4ae;
  --scroll-thumb: rgba(255, 255, 255, 0.18);
  --canvas-dot: rgba(255, 255, 255, 0.08);
  --canvas-inset: rgba(0, 0, 0, 0.3);
  --image-well: rgba(6, 8, 12, 0.76);
  --image-control: rgba(255, 255, 255, 0.76);
  --image-control-hover: #ffffff;
  --image-control-border: rgba(255, 255, 255, 0.16);
  --image-control-bg: rgba(28, 28, 30, 0.76);
  --image-control-solid: #1c1c1e;
  --image-icon-shadow: 0 2px 5px rgba(0, 0, 0, 0.72);
  --overlay: rgba(0, 0, 0, 0.5);
  --shadow-control: 0 1px 2px rgba(0, 0, 0, 0.24), 0 8px 24px rgba(0, 0, 0, 0.14);
  --shadow-panel: 0 22px 68px rgba(0, 0, 0, 0.28);
  --shadow-floating: 0 24px 70px rgba(0, 0, 0, 0.38);
  --shadow-image: 0 24px 54px rgba(0, 0, 0, 0.42);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.09);
  --glass-sidebar: rgba(17, 19, 25, 0.66);
  --glass-panel: rgba(25, 27, 35, 0.64);
  --glass-toolbar: rgba(28, 30, 38, 0.58);
  --glass-card: rgba(50, 53, 65, 0.42);
  --glass-control: rgba(255, 255, 255, 0.065);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-bright: rgba(255, 255, 255, 0.22);
  --glass-rim: rgba(255, 255, 255, 0.16);
  --glass-rim-soft: rgba(255, 255, 255, 0.055);
  --glass-reflection: rgba(255, 255, 255, 0.07);
  --glass-shadow-card: 0 1px 0 rgba(255, 255, 255, 0.035) inset, 0 14px 40px rgba(0, 0, 0, 0.18);
  --glass-shadow-panel: 0 1px 0 rgba(255, 255, 255, 0.045) inset, 0 28px 90px rgba(0, 0, 0, 0.3);
  --glass-noise-opacity: 0.035;
  --gallery-base: rgba(20, 22, 29, 0.78);
  --gallery-sheen: rgba(255, 255, 255, 0.065);
  --gallery-glow: rgba(10, 132, 255, 0.07);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Pretendard, "Noto Sans KR", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

:root[data-theme="light"] {
  --photo-selection-wash: rgb(72 78 88 / 13%);
  --photo-selection-edge: rgb(68 74 84 / 75%);
  color-scheme: light;
  --bg: #e9eef5;
  --rail: rgba(248, 250, 253, 0.72);
  --panel: rgba(248, 250, 253, 0.7);
  --panel-soft: rgba(255, 255, 255, 0.62);
  --stage: #edf2f9;
  --rail-solid: #f3f6fb;
  --composer-solid: #edf1f7;
  --density-selected-bg: #e6eef7;
  --composer-card-solid: #ffffff;
  --option-bg: #f1f4f8;
  --choice-bg: #ffffff;
  --choice-border: #e2e4e8;
  --choice-selected-bg: #eef0f3;
  --choice-selected-hover: #e7eaee;
  --choice-selected-border: #92969f;
  --surface: rgba(235, 240, 247, 0.7);
  --surface-focus: #ffffff;
  --surface-raised: rgba(255, 255, 255, 0.86);
  --surface-subtle: rgba(255, 255, 255, 0.6);
  --surface-hover: rgba(0, 0, 0, 0.055);
  --material: rgba(255, 255, 255, 0.58);
  --material-strong: rgba(250, 252, 255, 0.72);
  --material-floating: rgba(255, 255, 255, 0.82);
  --line: rgba(60, 60, 67, 0.14);
  --line-strong: rgba(60, 60, 67, 0.23);
  --text: #1d1d1f;
  --muted: #5f5f65;
  --dim: #85858b;
  --placeholder: #8e8e93;
  --accent: #007aff;
  --accent-hover: #006ee6;
  --accent-gradient: linear-gradient(180deg, #1689ff 0%, #0071e3 100%);
  --accent-soft: rgba(0, 122, 255, 0.11);
  --accent-faint: rgba(0, 122, 255, 0.06);
  --accent-line: rgba(0, 122, 255, 0.34);
  --accent-shadow: rgba(0, 122, 255, 0.2);
  --accent-ink: #ffffff;
  --good: #248a3d;
  --good-soft: rgba(40, 180, 70, 0.1);
  --good-line: rgba(36, 138, 61, 0.22);
  --good-text: #1f7735;
  --warning: #b65a00;
  --warning-soft: rgba(182, 90, 0, 0.1);
  --danger: #d70015;
  --danger-soft: rgba(215, 0, 21, 0.08);
  --danger-line: rgba(215, 0, 21, 0.24);
  --danger-text: #b00012;
  --scroll-thumb: rgba(60, 60, 67, 0.25);
  --canvas-dot: rgba(60, 60, 67, 0.13);
  --canvas-inset: rgba(0, 0, 0, 0.075);
  --image-well: #dcdce2;
  --overlay: rgba(31, 31, 35, 0.28);
  --shadow-control: 0 1px 2px rgba(0, 0, 0, 0.08), 0 5px 16px rgba(0, 0, 0, 0.07);
  --shadow-panel: 0 18px 50px rgba(42, 42, 48, 0.12);
  --shadow-floating: 0 12px 34px rgba(42, 42, 48, 0.16);
  --shadow-image: 0 24px 54px rgba(32, 32, 36, 0.22);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  --glass-sidebar: rgba(246, 249, 253, 0.7);
  --glass-panel: rgba(250, 252, 255, 0.66);
  --glass-toolbar: rgba(255, 255, 255, 0.58);
  --glass-card: rgba(255, 255, 255, 0.52);
  --glass-control: rgba(255, 255, 255, 0.5);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-border-bright: rgba(255, 255, 255, 0.92);
  --glass-rim: rgba(255, 255, 255, 0.9);
  --glass-rim-soft: rgba(255, 255, 255, 0.46);
  --glass-reflection: rgba(255, 255, 255, 0.55);
  --glass-shadow-card: 0 1px 0 rgba(255, 255, 255, 0.82) inset, 0 14px 36px rgba(28, 38, 54, 0.1);
  --glass-shadow-panel: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 26px 78px rgba(36, 48, 68, 0.14);
  --glass-noise-opacity: 0.022;
  --gallery-base: rgba(239, 243, 249, 0.82);
  --gallery-sheen: rgba(255, 255, 255, 0.82);
  --gallery-glow: rgba(0, 122, 255, 0.055);
}

* { box-sizing: border-box; }

html,
body { height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: color 220ms ease, background-color 220ms ease;
}

button,
textarea,
select,
input { font: inherit; }

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

button,
select { cursor: pointer; }

button,
a { touch-action: manipulation; }

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] { display: none !important; }
.reference-library-section header .library-sort-trigger { display: grid; place-items: center; flex: 0 0 26px; width: 26px; height: 26px; padding: 5px; border: 1px solid transparent; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; }
.library-sort-trigger svg, .library-like svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.reference-library-section header .library-sort-trigger:hover { color: var(--accent); background-color: var(--accent-faint); border-color: var(--accent-line); }
.library-sort-menu { position: fixed; inset: auto; margin: 0; padding: 5px; width: 150px; box-sizing: border-box; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); color: var(--text); box-shadow: 0 8px 24px rgb(20 35 60 / 14%); }
.library-sort-menu button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: transparent; color: inherit; text-align: left; font: inherit; font-size: calc(11px + var(--app-font-increase, 1pt)); cursor: pointer; }
.library-sort-menu button[aria-pressed="true"], .library-sort-menu button:hover { background: var(--accent-faint); color: var(--accent); }
.moodboard-card .library-like { position: absolute; z-index: 5; right: 6px; bottom: 6px; display: grid; place-items: center; width: 27px; height: 27px; padding: 5px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised); color: var(--muted); opacity: 0; cursor: pointer; transition: opacity 120ms ease; }
.moodboard-card:hover .library-like, .moodboard-card:focus-within .library-like, .moodboard-card .library-like[aria-pressed="true"] { opacity: 1; }
.moodboard-card .library-like[aria-pressed="true"] { color: #d99a00; }
.library-like[aria-pressed="true"] svg { fill: currentColor; }
.library-like:focus-visible, .library-sort-trigger:focus-visible, .library-sort-menu button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: none) { .moodboard-card .library-like { opacity: 1; } }

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Keep the scrollable area fixed; reveal only the thumb, never a new gutter. */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track,
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border: 2px solid transparent; background-clip: padding-box; border-radius: 99px; }

@media (hover: hover) and (pointer: fine) {
  ::-webkit-scrollbar-thumb { background-color: transparent; }
  :hover::-webkit-scrollbar-thumb,
  :focus-within::-webkit-scrollbar-thumb { background-color: var(--scroll-thumb); }
}

/* Use standard colors only where they cannot override the inset WebKit thumb. */
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }

  @media (hover: hover) and (pointer: fine) {
    * { scrollbar-color: transparent transparent; }
    *:hover,
    *:focus-within { scrollbar-color: var(--scroll-thumb) transparent; }
  }
}

@media (forced-colors: active) {
  * { scrollbar-color: auto !important; }
  ::-webkit-scrollbar-thumb { background-color: CanvasText !important; }
}

@media (min-width: 901px) {
  .composer-panel::-webkit-scrollbar-track:vertical { margin-block: 18px; }
}

.app-shell {
  --composer-width: 400px;
  --app-edge: 24px;
  --app-gap: 16px;
  width: 100%;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--composer-width) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--app-gap);
  padding: var(--app-edge);
  overflow: hidden;
}

.app-topbar {
  display: flex;
  grid-column: 1 / -1;
  min-width: 0;
  min-height: 64px;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: 7px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--composer-card-solid);
  box-shadow: none;
  z-index: 10;
}

.app-topbar-actions {
  display: flex;
  flex: 0 1 auto;
  min-width: 0;
  min-height: 32px;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.topbar-engine {
  flex: 0 1 190px;
  width: 190px;
  min-width: 0;
}

.app-topbar-actions .model-select {
  min-width: 0;
  min-height: 34px;
  height: 34px;
  padding: 0 9px;
  border-color: var(--line);
  border-radius: 9px;
  background: var(--surface-raised);
  box-shadow: none;
  font-size: calc(12px + var(--app-font-increase, 1pt));
  text-overflow: ellipsis;
}

.app-topbar-actions .model-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app-brand {
  display: flex;
  flex: 0 0 auto;
  min-width: 0;
  align-items: center;
  gap: 10px;
}
.app-brand-logo {
  display: block;
  flex: 0 0 auto;
  width: 38px;
  height: 44px;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
}
.app-brand-name { display: grid; min-width: 0; gap: 2px; white-space: nowrap; }
.app-brand-name strong { color: var(--text); font-size: calc(17px + var(--app-font-increase, 1pt)); font-weight: 750; line-height: 1.15; letter-spacing: -0.025em; }
.app-brand-name small { color: var(--muted); font-size: calc(9px + var(--app-font-increase, 1pt)); line-height: 1.3; letter-spacing: 0.06em; }

.rail {
  position: relative;
  z-index: 12;
  display: flex;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px 16px;
  border-right: 1px solid var(--line);
  background: var(--rail);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  transition: color 220ms ease, background-color 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.brand-mark,
.provider-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: var(--accent-ink);
  background: var(--accent-gradient);
  text-decoration: none;
  box-shadow: var(--glass-highlight), 0 8px 24px var(--accent-shadow);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
}

.rail-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  margin-top: auto;
}

.rail-button,
.icon-button {
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, transform 120ms var(--ease-out);
}

.rail-button {
  display: flex;
  width: 68px;
  height: 56px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0 auto;
  border-radius: 12px;
  /* Navigation controls must not re-sample neighboring surfaces on hover. */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.rail-button svg { width: 18px; height: 18px; }

.rail-label {
  font-size: calc(10px + var(--app-font-increase, 1pt));
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.rail-button.is-active {
  color: var(--accent);
  border-color: var(--accent-line);
  background: var(--accent-soft);
  box-shadow: var(--glass-highlight);
}

.rail-status {
  display: flex;
  width: 68px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-inline: 0;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-subtle);
  box-shadow: var(--glass-highlight);
  font-size: calc(10px + var(--app-font-increase, 1pt));
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1;
  white-space: nowrap;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, filter 150ms ease, transform 120ms var(--ease-out);
}

.gpt-account-button {
  position: absolute;
  z-index: 3;
  top: 9px;
  right: 12px;
  flex: 0 0 auto;
  width: auto;
  min-width: 126px;
  min-height: 38px;
  justify-content: flex-start;
  gap: 8px;
  margin: 0;
  padding: 4px 10px 4px 6px;
  border-color: var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: 0 1px 2px rgb(15 23 42 / 5%);
}

.gpt-account-avatar {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-subtle);
}

.gpt-account-avatar svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gpt-account-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
  text-align: left;
}

.gpt-account-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 600; line-height: 1.2; }
.gpt-account-button.has-profile .gpt-account-label,
.gpt-account-button.has-profile .gpt-account-avatar svg { display: none; }
.gpt-account-button.ready.has-profile .gpt-account-avatar { border-radius: 50%; border-color: transparent; background: #dc5947; color: #fff; }
.gpt-account-initials { font-size: 10px; font-weight: 600; line-height: 1; }
.gpt-account-button.has-profile .gpt-account-copy strong { font-size: 10px; font-weight: 500; color: var(--muted); }

.gpt-account-label {
  color: var(--muted);
  font-size: calc(8px + var(--app-font-increase, 1pt));
  font-weight: 600;
  line-height: 1;
}

.gpt-account-copy strong {
  font-size: calc(10px + var(--app-font-increase, 1pt));
  font-weight: 750;
  line-height: 1;
}

.gpt-account-button .rail-status-dot { margin-left: auto; }
.gpt-account-button.ready { border-color: var(--good-line); color: var(--text); background: var(--surface-raised); }
.gpt-account-button.ready .gpt-account-avatar { border-color: var(--good-line); color: var(--good-text); background: var(--good-soft); }
.gpt-account-button.login-required { border-color: var(--accent-line); color: var(--accent); background: var(--accent-faint); }
.gpt-account-button.login-required .gpt-account-avatar { border-color: var(--accent-line); color: var(--accent); background: var(--surface-raised); }
.gpt-account-button.login-required .rail-status-dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gpt-account-button.offline { border-color: var(--danger-line); color: var(--danger-text); background: var(--danger-soft); }
.gpt-account-button.offline .rail-status-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.gpt-account-button.usage-limit .rail-status-dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

@media (hover: hover) and (pointer: fine) {
  .gpt-account-button:hover { border-color: var(--line-strong); background: var(--surface-hover); }
  .gpt-account-button.login-required:hover { border-color: var(--accent); background: var(--accent-soft); }
}

.gpt-account-button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

@media (max-width: 720px) {
  .gpt-account-button {
    width: 38px;
    min-width: 38px;
    justify-content: center;
    gap: 0;
    padding: 4px;
  }
  .gpt-account-copy,
  .gpt-account-button .rail-status-dot { display: none; }
  .stage .workspace-nav { padding-right: 54px; }
}

.rail-status-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-soft);
}

.rail-status.ready {
  border-color: var(--good-line);
  color: var(--good-text);
  background: var(--good-soft);
}

.rail-status.ready .rail-status-dot {
  background: var(--good);
  box-shadow: 0 0 0 3px var(--good-soft);
}

.rail-status.error {
  border-color: var(--danger-line);
  color: var(--danger-text);
  background: var(--danger-soft);
}

.rail-status.error .rail-status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.composer-panel {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  background: var(--panel);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(32px) saturate(175%);
  -webkit-backdrop-filter: blur(32px) saturate(175%);
  visibility: visible;
  opacity: 1;
  transition: color 220ms ease, background-color 220ms ease, border-color 220ms ease, box-shadow 220ms ease, opacity 160ms ease, visibility 0s linear;
}

.composer-panel {
  z-index: 9;
  border-right: 1px solid var(--line);
}

.panel-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 80px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--material-strong);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
}

.overline {
  display: block;
  margin-bottom: 5px;
  color: var(--dim);
  font-size: calc(9px + var(--app-font-increase, 1pt));
  font-weight: 800;
  letter-spacing: 0.18em;
}

.panel-header h1,
.stage-header h2,
.history-header h2 {
  margin: 0;
  letter-spacing: -0.035em;
}

.panel-header h1 { font-size: calc(20px + var(--app-font-increase, 1pt)); }

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border-color: var(--line);
  background: var(--surface-subtle);
  box-shadow: var(--glass-highlight);
  font-size: calc(21px + var(--app-font-increase, 1pt));
}

.composer-form {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  padding: 20px;
}

.provider-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
  box-shadow: var(--glass-highlight);
}

.login-button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  color: var(--accent-ink);
  background: var(--accent-gradient);
  box-shadow: var(--glass-highlight), 0 5px 16px var(--accent-shadow);
  font-size: calc(9px + var(--app-font-increase, 1pt));
  font-weight: 800;
  white-space: nowrap;
}

.login-button[hidden] { display: none; }
.login-button:disabled { cursor: wait; filter: saturate(0.35) brightness(0.8); }

.provider-icon {
  width: 29px;
  height: 29px;
  border-radius: 9px;
  color: var(--accent-ink);
  background: var(--accent-gradient);
  box-shadow: var(--glass-highlight), 0 5px 16px var(--accent-shadow);
  font-size: calc(12px + var(--app-font-increase, 1pt));
}

.provider-row > div:nth-child(2),
.provider-card > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.provider-row strong,
.provider-card strong { font-size: calc(12px + var(--app-font-increase, 1pt)); }

.provider-row > div:nth-child(2) > span,
.provider-card div > span {
  overflow: hidden;
  color: var(--dim);
  font-size: calc(10px + var(--app-font-increase, 1pt));
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 99px;
  color: var(--muted);
  background: var(--surface-subtle);
  font-size: calc(9px + var(--app-font-increase, 1pt));
  white-space: nowrap;
}

.status-pill[hidden] { display: none; }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
}

.status-pill.ready { color: var(--good-text); background: var(--good-soft); }
.status-pill.ready .status-dot { background: var(--good); }
.status-pill.error { color: var(--danger-text); background: var(--danger-soft); }
.status-pill.error .status-dot { background: var(--danger); }

.prompt-field {
  position: relative;
  display: flex;
  min-height: 0;
  flex-direction: column;
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 160ms ease, background-color 160ms ease;
}

.prompt-field:focus-within {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-control);
}

.prompt-field-header {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--composer-solid);
}

.prompt-field-header > .field-label {
  margin: 0;
  color: var(--muted);
  font-size: calc(11px + var(--app-font-increase, 1pt));
  font-weight: 650;
  line-height: 1.5;
  letter-spacing: .02em;
}

.prompt-field-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.prompt-quality-select {
  width: 100px;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-raised);
  font-family: inherit;
  font-size: calc(11px + var(--app-font-increase, 1pt));
  font-weight: 500;
}

.prompt-quality-select option { background: var(--panel); }
.prompt-quality-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.prompt-preset-list {
  position: relative; display: grid; flex: 0 0 auto; min-width: 0;
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 0.9fr) minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 3px; margin: 0; padding: 8px 8px 0;
  border-bottom: 1px solid var(--line); border-radius: 16px 16px 0 0;
  background: var(--composer-solid);
}

.prompt-preset-button {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  margin-bottom: -1px;
  border: 1px solid transparent;
  border-radius: 10px 10px 0 0;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  transition: none;
  font-size: calc(10px + var(--app-font-increase, 1pt));
  line-height: 1.4;
  text-align: center;
}
.prompt-preset-visual { display: flex; flex: 0 0 14px; align-items: center; justify-content: center; color: inherit; }
.prompt-preset-visual svg { width: 14px; height: 14px; stroke-width: 1.7; }
.prompt-preset-label { min-width: 0; font-size: calc(10px + var(--app-font-increase, 1pt)); font-weight: 600; white-space: nowrap; }
.prompt-preset-button[aria-selected="true"] {
  z-index: 1; border-color: var(--line); border-bottom-color: var(--composer-card-solid);
  color: var(--accent); background: var(--composer-card-solid);
}
.prompt-preset-button[aria-selected="true"]::after {
  position: absolute; right: 0; bottom: -1px; left: 0; height: 1px;
  content: ""; background: var(--composer-card-solid); pointer-events: none;
}
.prompt-preset-button:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.prompt-preset-button:disabled { opacity: 0.5; cursor: not-allowed; }

@media (hover: hover) and (pointer: fine) {
  .prompt-preset-button:not(:disabled):not([aria-selected="true"]):hover { color: var(--text); background: var(--surface-hover); }
  .prompt-preset-button[aria-selected="true"]:not(:disabled):hover { color: var(--accent-hover); }
}

#prompt:focus,
#prompt:focus-visible {
  border-color: transparent !important;
  outline: none !important;
  box-shadow: none !important;
}

.field-label {
  position: relative;
  z-index: 1;
  padding: 0;
  color: var(--muted);
  font-size: calc(10px + var(--app-font-increase, 1pt));
  font-weight: 700;
  letter-spacing: 0.08em;
}

.generation-instructions-trigger {
  position: relative;
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease, transform 120ms var(--ease-out);
}

.generation-instructions-trigger svg { width: 16px; height: 16px; }

.generation-instructions-trigger.is-custom::after {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 5px;
  height: 5px;
  border: 1px solid var(--surface-focus);
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

textarea {
  width: 100%;
  min-height: 190px;
  flex: 1;
  resize: vertical;
  padding: 14px 15px 54px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: calc(13px + var(--app-font-increase, 1pt));
  line-height: 1.7;
}

textarea::placeholder { color: var(--placeholder); }

#prompt {
  min-height: 72px;
  height: 84px;
  flex: 0 0 auto;
  padding-top: 10px;
  padding-bottom: 10px;
}

.prompt-preset-detail {
  margin: 10px 15px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.prompt-preset-detail label { display: flex; align-items: baseline; gap: 8px; color: var(--text); font-size: calc(11px + var(--app-font-increase, 1pt)); font-weight: 600; }
.prompt-preset-detail small { color: var(--dim); font-size: calc(10px + var(--app-font-increase, 1pt)); font-weight: 400; }
.prompt-preset-detail textarea {
  display: block;
  min-height: 84px;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: calc(12px + var(--app-font-increase, 1pt));
}
.prompt-preset-detail textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.prompt-preset-detail textarea:disabled { opacity: 0.6; cursor: not-allowed; }
.prompt-preset-detail.is-poster-copy > textarea,
.typography-text-field > textarea,
.poster-copy-secondary > textarea { min-height: 64px; }
.typography-text-field > textarea + label { margin-top: 14px; }
.poster-copy-secondary { margin-top: 14px; }
.preset-direction-field { margin-top: 14px; }
.poster-details-toggle {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  margin-top: 6px;
  padding: 4px 0;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: calc(11px + var(--app-font-increase, 1pt));
  font-weight: 500;
  text-align: left;
}
.poster-details-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.poster-details-toggle:disabled { opacity: 0.6; cursor: not-allowed; }
.poster-details-toggle:active:not(:disabled) { color: var(--accent); }
.poster-details-field { margin-top: 6px; }
@media (hover: hover) and (pointer: fine) {
  .poster-details-toggle:hover:not(:disabled) { color: var(--accent); }
}
.prompt-base-label { margin: 13px 15px 0; color: var(--dim); font-size: calc(10px + var(--app-font-increase, 1pt)); font-weight: 600; }
.prompt-base-label:not([hidden]) ~ #prompt { min-height: 64px; height: 72px; flex: 0 0 auto; padding-top: 8px; }

#prompt.is-template-guide {
  color: var(--dim);
  cursor: default;
}

.prompt-edit-trigger:disabled { opacity: 0.5; cursor: not-allowed; }
.prompt-edit-trigger .prompt-edit-close-icon { display: none; }
.prompt-edit-trigger[aria-expanded="true"] .prompt-edit-open-icon { display: none; }
.prompt-edit-trigger[aria-expanded="true"] .prompt-edit-close-icon { display: block; }

.prompt-field.is-preset-collapsed { min-height: 0; }
.prompt-field.is-preset-collapsed .prompt-preset-detail { padding-bottom: 0; border-bottom: 0; }
.prompt-field.is-preset-collapsed .prompt-footer { margin-top: 14px; }

/* Frequently used controls sit with the prompt, without another card layer. */
.generation-options-bar {
  display: grid; flex: 0 0 auto; gap: 16px; min-width: 0;
  margin: 4px 15px 18px; padding-top: 16px;
  border-top: 1px solid var(--line); container-type: inline-size;
}
.generation-options-top { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; }
.generation-option-inline { display: grid; align-content: start; gap: 8px; min-width: 0; }
.generation-option-heading { display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 28px; }
.generation-option-heading > span:first-child,
.generation-option-inline > label { color: var(--text); font-size: calc(11px + var(--app-font-increase, 1pt)); font-weight: 600; line-height: 16px; white-space: nowrap; }
.generation-option-inline > label { display: flex; align-items: center; min-height: 28px; }
.generation-options-bar .count-grid {
  display: grid; min-width: 0; gap: 3px; padding: 3px;
  border: 1px solid var(--line); border-radius: 12px;
  background: color-mix(in srgb, var(--choice-selected-bg) 65%, var(--composer-card-solid) 35%);
}
.generation-options-bar .count-button {
  min-width: 0; min-height: 32px; height: 32px; padding: 0 4px;
  border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--muted); box-shadow: none;
  font-size: calc(11px + var(--app-font-increase, 1pt)); font-weight: 600; white-space: nowrap; transition: none;
}
.generation-options-bar .count-button.is-selected {
  border-color: var(--line); background: var(--composer-card-solid); color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.compact-ratio-control { position: relative; min-width: 0; color: var(--muted); }
.compact-ratio-control.is-enhanced > select { display: none; }
.ratio-picker-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 40px; min-width: 0;
  padding: 0 11px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--composer-card-solid); color: var(--text); box-shadow: none;
  font: inherit; font-size: calc(11px + var(--app-font-increase, 1pt)); font-weight: 600; text-align: left; cursor: pointer; transition: none;
}
.ratio-picker-trigger > span:not(.ratio-picker-chevron) { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ratio-picker-trigger[aria-expanded="true"] { border-color: var(--choice-selected-border); background: var(--choice-selected-bg); }
.ratio-picker-trigger:focus-visible { outline: 2px solid var(--choice-selected-border); outline-offset: 2px; }
.ratio-picker-trigger:active:not(:disabled) { background: var(--surface-hover); }
.ratio-picker-trigger:disabled { opacity: 0.5; cursor: not-allowed; }
.ratio-picker-shape { flex: 0 0 22px; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.4; color: var(--muted); }
.ratio-picker-trigger .ratio-picker-shape { flex-basis: 17px; width: 17px; height: 17px; }
.ratio-picker-chevron { flex: 0 0 6px; width: 6px; height: 6px; margin: -3px 2px 0 auto; border-right: 1.3px solid currentColor; border-bottom: 1.3px solid currentColor; transform: rotate(45deg); color: var(--muted); }
.ratio-picker-trigger[aria-expanded="true"] .ratio-picker-chevron { transform: rotate(225deg); margin-top: 3px; }
.ratio-picker-menu {
  position: fixed; z-index: 90; box-sizing: border-box; padding: 6px;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--composer-card-solid); color: var(--text);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.05);
}
.ratio-picker-menu[hidden] { display: none; }
.ratio-picker-option {
  display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 0 9px;
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  font-size: calc(12px + var(--app-font-increase, 1pt)); line-height: 1.4; user-select: none;
}
.ratio-picker-option + .ratio-picker-option { margin-top: 2px; }
.ratio-picker-name { flex: 1; font-weight: 500; }
.ratio-picker-number { color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); font-variant-numeric: tabular-nums; }
.ratio-picker-check { width: 14px; visibility: hidden; text-align: center; font-size: calc(13px + var(--app-font-increase, 1pt)); }
.ratio-picker-option[aria-selected="true"] { background: var(--choice-selected-bg); }
.ratio-picker-option[aria-selected="true"] .ratio-picker-name { font-weight: 650; }
.ratio-picker-option[aria-selected="true"] .ratio-picker-check { visibility: visible; }
.ratio-picker-option.ratio-picker-group-start { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto 14px; grid-template-rows: auto minmax(32px, auto); column-gap: 9px; row-gap: 0; }
.ratio-picker-option.ratio-picker-group-start::before { content: attr(data-group-label); grid-column: 1 / -1; display: block; padding: 4px 0 6px; color: var(--muted); font-size: 11px; font-weight: 500; }
.ratio-picker-option.ratio-picker-group-divider { margin-top: 8px; border-top: 1px solid var(--line-strong); border-top-left-radius: 0; border-top-right-radius: 0; padding-top: 8px; }
.ratio-picker-option.is-active { border-color: var(--choice-selected-border); }
@media (hover: hover) and (pointer: fine) {
  .ratio-picker-trigger:not(:disabled):hover { border-color: var(--line-strong); }
  .ratio-picker-option:hover { background: var(--surface-hover); }
}
.generation-options-bar .compact-ratio-select {
  display: block; appearance: none; -webkit-appearance: none;
  width: 100%; min-width: 0; height: 40px; padding: 0 28px 0 32px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--composer-card-solid); color: var(--text); font: inherit; font-size: calc(11px + var(--app-font-increase, 1pt)); font-weight: 600;
  cursor: pointer; box-shadow: none; text-overflow: ellipsis;
}
.compact-ratio-control > svg { position: absolute; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; pointer-events: none; }
.compact-ratio-icon { left: 10px; }
.compact-ratio-chevron { right: 9px; }
.generation-options-bar .compact-ratio-select:focus-visible { outline: 2px solid var(--choice-selected-border); outline-offset: 2px; }
.candidate-variation-inline { display: inline-flex; flex: 0 0 auto; }
.candidate-variation-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 56px; height: 28px; padding: 0 8px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--composer-card-solid); color: var(--muted); box-shadow: none;
  font: inherit; font-size: calc(10px + var(--app-font-increase, 1pt)); font-weight: 600; line-height: 1; white-space: nowrap;
  cursor: pointer; touch-action: manipulation; transition: none;
}
.candidate-variation-toggle[data-mode="diverse"] { background: var(--choice-selected-bg); color: var(--accent); }
.candidate-variation-toggle:focus-visible { outline: 2px solid var(--choice-selected-border); outline-offset: 2px; }
.candidate-variation-toggle:active:not(:disabled) { background: var(--surface-hover); }
.candidate-variation-toggle:disabled { opacity: 0.5; cursor: not-allowed; }
@media (hover: hover) and (pointer: fine) {
  .candidate-variation-toggle:not(:disabled):hover { background: var(--surface-hover); border-color: var(--line-strong); }
  .generation-options-bar .count-button:not(:disabled):not(.is-selected):hover { border-color: transparent; background: var(--surface-hover); color: var(--text); }
  .generation-options-bar .count-button.is-selected:not(:disabled):hover { border-color: var(--line); background: var(--composer-card-solid); }
  .generation-options-bar .compact-ratio-select:hover { border-color: var(--line-strong); }
}
@container (max-width: 300px) {
  .generation-options-top { gap: 10px; }
  .compact-ratio-icon { display: none; }
  .generation-options-bar .compact-ratio-select { padding-left: 10px; }
}

.prompt-footer {
  position: static;
  display: grid;
  flex: 0 0 auto;
  min-width: 0;
  margin: 0 13px 12px;
  gap: 8px;
  color: var(--dim);
  font-size: calc(9px + var(--app-font-increase, 1pt));
}

.prompt-validation {
  display: block; flex: 0 0 auto; min-width: 0;
  margin: 8px 0 0; padding: 0 14px; border: 0;
  border-radius: 0; background: transparent; box-shadow: none; color: var(--muted);
  font-size: 12px; font-weight: 400; line-height: 1.5; text-align: start; overflow-wrap: anywhere;
}
.prompt-validation[hidden] { display: none; }

.prompt-character-count { justify-self: end; white-space: nowrap; }

.workspace-nav {
  position: relative;
  display: flex;
  grid-row: 1;
  min-width: 0;
  width: 100%;
  align-items: flex-end;
  gap: 4px;
  padding: 8px 150px 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--rail-solid);
}
.workspace-tab {
  position: relative;
  display: inline-flex;
  flex: 0 1 144px;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-bottom: -1px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px 10px 0 0;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-size: calc(12px + var(--app-font-increase, 1pt));
  font-weight: 600;
  white-space: nowrap;
  transition: none;
}
.workspace-tab svg { width: 16px; height: 16px; flex: 0 0 auto; }
.workspace-tab > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace-tab.is-active {
  z-index: 1;
  color: var(--accent);
  border-color: var(--line);
  border-bottom-color: var(--stage);
  background: var(--stage);
  font-weight: 700;
}
.workspace-tab.is-active::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 1px;
  content: "";
  background: var(--stage);
  pointer-events: none;
}
.workspace-tab:active { color: var(--accent); }
.workspace-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.workspace-account-actions { position: absolute; z-index: 3; top: 9px; right: 12px; display: flex; align-items: center; gap: 8px; }
.workspace-account-actions .gpt-account-button { position: static; }
.workspace-account-actions .header-settings { display: inline-flex; width: auto; min-height: 38px; height: 38px; padding: 0 12px; gap: 7px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-raised); color: var(--text); font-size: 12px; white-space: nowrap; }
.header-settings:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stage .workspace-nav { padding-right: 270px; }
@media (max-width: 720px) {
  .workspace-account-actions .header-settings { width: 38px; min-width: 38px; padding: 0; justify-content: center; }
  .header-settings span { display: none; }
  .stage .workspace-nav { padding-right: 102px; }
}
.workspace-options.is-active { color: var(--accent); background: var(--accent-soft); }
.app-topbar-actions .workspace-options { flex: 0 0 32px; width: 32px; height: 32px; }
@media (hover: hover) and (pointer: fine) {
  .workspace-tab:not(.is-active):hover { color: var(--text); background: var(--surface-hover); }
}

kbd {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 4px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: calc(8px + var(--app-font-increase, 1pt));
}

.reference-section { margin-top: 24px; }

.easy-photo-pending { display: grid; gap: 7px; }
.easy-photo-pending:empty { display: none; }
.easy-photo-card { display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 8px; padding: 7px; border: 1px solid var(--line); border-radius: 10px; background: var(--composer-card-solid); }
.easy-photo-card img { inline-size: 42px; block-size: 42px; border-radius: 7px; object-fit: cover; }
.easy-photo-card strong, .easy-photo-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.easy-photo-card small { white-space: normal; overflow-wrap: anywhere; margin-top: 2px; color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); }
.easy-photo-actions { grid-column: 2; display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 4px; }
.easy-photo-actions button, .reference-meta-control select { min-height: 28px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; font-size: calc(11px + var(--app-font-increase, 1pt)); cursor: pointer; }
.easy-photo-actions button.is-suggested { border-color: var(--accent-line); color: var(--accent); }
.easy-photo-remove { color: var(--muted); }
.reference-details { margin-top: 6px; }
.reference-details > summary { cursor: pointer; color: var(--muted); font-size: calc(12px + var(--app-font-increase, 1pt)); }
.reference-details > summary span { margin-left: 5px; color: var(--dim); font-size: calc(11px + var(--app-font-increase, 1pt)); }
.reference-details[open] > summary { margin-bottom: 12px; color: var(--text); }
.reference-meta-control { display: grid; gap: 4px; margin-top: 5px; }
.reference-meta-control label { color: var(--muted); font-size: calc(10px + var(--app-font-increase, 1pt)); }
.skillbook-migration-panel { margin: 14px 0; padding: 12px; border: 1px solid var(--accent-line); border-radius: 10px; background: var(--accent-faint); }
.skillbook-migration-panel h3, .skillbook-migration-panel p { margin: 0; }
.skillbook-migration-panel > p { margin-top: 5px; color: var(--muted); font-size: calc(12px + var(--app-font-increase, 1pt)); line-height: 1.5; }
.skillbook-migration-panel details { margin-top: 9px; font-size: calc(12px + var(--app-font-increase, 1pt)); }
.skillbook-migration-panel pre { max-height: 150px; overflow: auto; white-space: pre-wrap; color: var(--muted); font: 11px/1.5 ui-monospace, monospace; }
.skillbook-migration-conflict { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--accent-line); }
.skillbook-migration-conflict p { font-size: calc(12px + var(--app-font-increase, 1pt)); }
.skillbook-migration-conflict div { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.skillbook-migration-conflict button { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; font-size: calc(11px + var(--app-font-increase, 1pt)); }

.section-minihead,
.inspector-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-minihead { margin-bottom: 9px; }

.section-minihead > div { display: flex; align-items: baseline; gap: 8px; }
.section-minihead strong { font-size: calc(11px + var(--app-font-increase, 1pt)); }
.section-minihead span { color: var(--dim); font-size: calc(9px + var(--app-font-increase, 1pt)); }

.text-button {
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: calc(9px + var(--app-font-increase, 1pt));
}

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


.reference-role-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-subtle);
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease, transform 120ms var(--ease-out);
}

.reference-role-card.is-dragging,
.reference-role-card:focus-within {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.reference-role-card.has-reference {
  border-style: solid;
  border-color: var(--accent-line);
  background: var(--surface);
}

.reference-role-picker {
  display: grid;
  min-width: 0;
  min-height: 108px;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px 9px;
  padding: 10px;
  cursor: pointer;
}

.reference-role-input { display: none; }

.reference-role-grid { align-items: start; }
.custom-reference-fields { display: grid; gap: 6px; padding: 0 10px 10px; }
.custom-reference-fields[hidden],
.custom-reference-fields [hidden] { display: none; }
.custom-reference-fields label { display: block; margin: 0 0 4px; color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); }
.custom-reference-fields textarea,
.custom-reference-fields select {
  width: 100%; min-width: 0; box-sizing: border-box; margin: 0;
  padding: 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: calc(12px + var(--app-font-increase, 1pt));
}

.reference-reset-button {
  display: inline-grid; place-items: center; flex: 0 0 32px;
  width: 32px; height: 32px; padding: 6px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.reference-reset-button svg {
  width: 19px; height: 19px; fill: none; stroke: currentColor;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
}
.reference-reset-button:disabled { opacity: .35; cursor: default; }
.reference-reset-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.reference-reset-button:active:not(:disabled) { background: var(--surface-hover); color: var(--text); }
@media (hover: hover) and (pointer: fine) {
  .reference-reset-button:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
}
.custom-reference-fields textarea { min-height: 62px; resize: vertical; }
.custom-reference-fields textarea::placeholder { color: var(--muted); }

.reference-role-visual {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  grid-row: 1 / -1;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--accent);
  background: var(--panel-soft);
}

.reference-role-icon,
.reference-role-icon svg {
  display: block;
  width: 23px;
  height: 23px;
}

.reference-role-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reference-role-icon[hidden] { display: none; }
.reference-role-thumbnail { position: relative; display: block; width: 100%; height: 100%; }
.reference-role-thumbnail-remove {
  position: absolute; z-index: 2; top: 1px; right: 1px;
  display: grid; place-items: center; width: 22px; height: 22px; padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.65); border-radius: 50%;
  background: rgba(35, 38, 44, 0.86); color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); font: inherit; font-size: calc(18px + var(--app-font-increase, 1pt)); line-height: 1;
  opacity: 0; pointer-events: none; cursor: pointer; transition: none;
}
.reference-role-thumbnail:focus-within .reference-role-thumbnail-remove { opacity: 1; pointer-events: auto; }
.reference-role-thumbnail-remove:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
.reference-role-thumbnail-remove:active { background: #8e2635; }
@media (hover: hover) and (pointer: fine) {
  .reference-role-thumbnail:hover .reference-role-thumbnail-remove { opacity: 1; pointer-events: auto; }
  .reference-role-thumbnail-remove:hover { background: #8e2635; }
}
@media (hover: none), (pointer: coarse) {
  .reference-role-thumbnail-remove { opacity: 1; pointer-events: auto; width: 26px; height: 26px; }
}
.has-multiple-references .reference-role-picker {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 8px;
}
.has-multiple-references .reference-role-visual {
  display: flex; flex-wrap: wrap; gap: 5px; width: 100%; height: auto; min-height: 42px;
  grid-column: 1 / -1; grid-row: 1;
  padding-right: 20px; box-sizing: border-box;
  overflow: visible; border: 0; border-radius: 0; background: transparent;
}
.has-multiple-references .reference-role-image {
  position: static; flex: 0 0 42px; width: 42px; height: 42px;
  border: 1px solid var(--line); border-radius: 10px; box-sizing: border-box;
}
.has-multiple-references .reference-role-thumbnail { flex: 0 0 42px; width: 42px; height: 42px; }
.has-multiple-references .reference-role-copy { grid-column: 1; grid-row: 2; }
.has-multiple-references .reference-role-action { grid-column: 2; grid-row: 2; white-space: nowrap; }

.reference-role-badge {
  position: absolute;
  right: 3px;
  bottom: 3px;
  display: grid;
  min-width: 25px;
  height: 18px;
  place-items: center;
  padding: 0 5px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  color: white;
  background: rgba(10, 10, 12, 0.7);
  font-size: calc(10px + var(--app-font-increase, 1pt));
  font-weight: 750;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.reference-preview-section {
  margin-top: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-subtle);
}

.reference-preview-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.reference-preview-heading strong { color: var(--text); font-size: calc(11px + var(--app-font-increase, 1pt)); }
.reference-preview-heading span { color: var(--dim); font-size: calc(10px + var(--app-font-increase, 1pt)); }

.reference-preview-list {
  display: grid;
  min-width: 0;
  grid-auto-columns: 68px;
  grid-auto-flow: column;
  gap: 7px;
  overflow-x: auto;
  padding: 1px 1px 4px;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
}

.reference-preview-card {
  position: relative;
  display: grid;
  min-width: 0;
  gap: 4px;
  scroll-snap-align: start;
}

.reference-preview-open {
  position: relative;
  display: block;
  width: 68px;
  height: 68px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--image-well);
}

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

.reference-preview-open span {
  position: absolute;
  bottom: 4px;
  left: 4px;
  display: grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  padding: 0 4px;
  border-radius: 999px;
  color: white;
  background: rgba(10, 10, 12, 0.68);
  font-size: calc(10px + var(--app-font-increase, 1pt));
}

.reference-preview-card > strong {
  overflow: hidden;
  color: var(--muted);
  font-size: calc(10px + var(--app-font-increase, 1pt));
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-preview-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  color: white;
  background: rgba(10, 10, 12, 0.72);
  font-size: calc(13px + var(--app-font-increase, 1pt));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.reference-preview-dialog {
  width: min(860px, calc(100vw - 36px));
  height: min(760px, calc(100vh - 36px));
  height: min(760px, calc(100dvh - 36px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow-floating);
}

.reference-preview-dialog::backdrop { background: rgba(0, 0, 0, 0.68); backdrop-filter: blur(8px); }

.reference-preview-dialog[open] { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }

.reference-preview-dialog > header {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px 10px 17px;
  border-bottom: 1px solid var(--line);
  background: var(--material-strong);
}

.reference-preview-dialog > header > div { display: grid; flex: 1 1 auto; min-width: 0; gap: 3px; }
.reference-preview-dialog > header strong { font-size: calc(13px + var(--app-font-increase, 1pt)); }
.reference-preview-dialog > header span { overflow: hidden; color: var(--dim); font-size: calc(10px + var(--app-font-increase, 1pt)); text-overflow: ellipsis; white-space: nowrap; }
.reference-preview-dialog > header button {
  display: grid;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-raised);
  font-size: calc(18px + var(--app-font-increase, 1pt));
}

.reference-preview-dialog-image {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  background: var(--surface);
}

.reference-preview-dialog-image img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.gallery-viewer-dialog {
  --viewer-edge: 18px;
  --viewer-gutter: 56px;
  --viewer-max-width: min(1500px, calc(100vw - var(--viewer-edge) * 2));
  --viewer-max-height: min(980px, calc(100dvh - var(--viewer-edge) * 2));
  width: fit-content;
  height: fit-content;
  max-width: var(--viewer-max-width);
  max-height: var(--viewer-max-height);
  margin: auto;
  inset: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 22px;
  color: white;
  background: rgba(8, 9, 12, 0.94);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 34px 110px rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(42px) saturate(145%);
  -webkit-backdrop-filter: blur(42px) saturate(145%);
}

.gallery-viewer-dialog::backdrop {
  background: rgba(4, 6, 10, 0.7);
  backdrop-filter: blur(16px) saturate(110%);
  -webkit-backdrop-filter: blur(16px) saturate(110%);
}

.gallery-viewer-dialog[open] {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  animation: glass-materialize 190ms var(--ease-out);
  transform-origin: center;
}

.gallery-viewer-canvas {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  padding: var(--viewer-gutter);
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 46%, rgba(255, 255, 255, 0.055), transparent 58%),
    linear-gradient(160deg, rgba(24, 27, 34, 0.82), rgba(5, 6, 9, 0.9));
}

.gallery-viewer-canvas img {
  display: block;
  width: auto;
  height: auto;
  /* Bound the photo by the viewport, not the intrinsic height of its grid row. */
  max-width: calc(var(--viewer-max-width) - var(--viewer-gutter) * 2 - 2px);
  max-height: calc(var(--viewer-max-height) - var(--viewer-gutter) * 2 - 2px);
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.gallery-viewer-chrome {
  position: absolute;
  top: 14px;
  right: 14px;
  left: 14px;
  z-index: 3;
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  pointer-events: none;
}

.gallery-viewer-close {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(24, 26, 32, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 7px 24px rgba(0, 0, 0, 0.24);
  font-size: calc(21px + var(--app-font-increase, 1pt));
  line-height: 1;
  pointer-events: auto;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  transition: color 140ms ease, background-color 140ms ease, transform 100ms ease-out;
}

.gallery-viewer-meta {
  justify-self: center;
  min-height: 30px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(24, 26, 32, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 7px 24px rgba(0, 0, 0, 0.2);
  font-size: calc(11px + var(--app-font-increase, 1pt));
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.gallery-viewer-arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  width: 44px;
  height: 88px;
  place-items: center;
  padding: 0;
  border: 0;
  color: rgba(255, 255, 255, 0.62);
  background: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.7));
  transform: translateY(-50%);
  transition: color 140ms ease, transform 100ms ease-out;
}

.gallery-viewer-arrow svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gallery-viewer-previous { left: 5px; }
.gallery-viewer-next { right: 5px; }
.gallery-viewer-arrow:disabled { visibility: hidden; }
.gallery-viewer-close:active { transform: scale(0.94); }
.gallery-viewer-arrow:active { transform: translateY(-50%) scale(0.92); }
.gallery-select:active img { transform: scale(0.985); }

@media (hover: hover) {
  .gallery-viewer-close:hover { color: white; background: rgba(52, 55, 64, 0.82); }
  .gallery-viewer-arrow:not(:disabled):hover { color: rgba(255, 255, 255, 0.96); }
}

@media (max-width: 620px) {
  .gallery-viewer-dialog {
    --viewer-edge: 8px;
    --viewer-gutter: 44px;
    border-radius: 18px;
  }

  .gallery-viewer-chrome { top: 8px; right: 8px; left: 8px; }
  .gallery-viewer-arrow { width: 42px; }
  .gallery-viewer-arrow svg { width: 30px; height: 30px; }
  .gallery-viewer-previous { left: 0; }
  .gallery-viewer-next { right: 0; }
}

.moodboard-collage-button:disabled { cursor: default; opacity: 0.4; }
.moodboard-collage-button.is-busy { cursor: wait; opacity: 0.65; }

.toolbar-button.moodboard-collage-button.has-selection:not(:disabled) {
  color: #fff;
  border-color: #007aff;
  background: #007aff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 4px 14px rgba(0, 122, 255, 0.22);
}

.has-contained-viewer { position: relative; }
.gallery-viewer-dialog.is-board-contained[open] {
  position: absolute; inset: 12px; z-index: 20; margin: 0;
  width: calc(100% - 24px); height: calc(100% - 24px);
  max-width: none; max-height: none; box-sizing: border-box;
  animation: none; transform: none; border-radius: 18px;
}
.gallery-viewer-dialog.is-board-contained .gallery-viewer-canvas {
  width: 100%; height: 100%; box-sizing: border-box; padding: 56px 42px 24px;
}
.gallery-viewer-dialog.is-board-contained .gallery-viewer-canvas img {
  max-width: 100%; max-height: 100%; min-height: 0; object-fit: contain;
}

.moodboard-collage-dialog {
  width: min(980px, calc(100vw - 36px));
  height: min(900px, calc(100dvh - 36px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow-floating);
}

.moodboard-collage-dialog::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); }
.moodboard-collage-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }

.moodboard-collage-dialog > header {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px 10px 17px;
  border-bottom: 1px solid var(--line);
  background: var(--material-strong);
}

.moodboard-collage-dialog > header > div { display: grid; min-width: 0; gap: 3px; }
.moodboard-collage-dialog > header strong { font-size: calc(14px + var(--app-font-increase, 1pt)); }
.moodboard-collage-dialog > header span { color: var(--dim); font-size: calc(10px + var(--app-font-increase, 1pt)); }
.moodboard-collage-dialog > header button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-raised);
  font-size: calc(18px + var(--app-font-increase, 1pt));
}

.moodboard-collage-preview {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  padding: 18px;
  overflow: auto;
  background: var(--surface);
}

.moodboard-collage-preview img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: var(--shadow-image);
}

.moodboard-collage-dialog > footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 66px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  background: var(--material-strong);
}

.moodboard-collage-dialog > footer > * {
  display: inline-flex;
  width: auto;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 14px;
  border-radius: 10px;
  font-size: calc(11px + var(--app-font-increase, 1pt));
  text-decoration: none;
}

#useMoodboardCollageAsStyleButton { min-width: 132px; }

.app-options-dialog {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow-floating);
}

.app-options-dialog::backdrop {
  background: rgba(5, 7, 12, 0.46);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-options-dialog[open] { display: grid; }

.app-options-dialog > header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px 10px 17px;
  border-bottom: 1px solid var(--line);
  background: var(--material-strong);
}

.app-options-dialog > header > div { display: grid; gap: 2px; }
.app-options-dialog > header span { color: var(--dim); font-size: calc(10px + var(--app-font-increase, 1pt)); }
.app-options-dialog > header strong { font-size: calc(15px + var(--app-font-increase, 1pt)); letter-spacing: -0.02em; }

.app-options-dialog > header button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-raised);
  font-size: calc(18px + var(--app-font-increase, 1pt));
}

.app-options-dialog .appearance-card {
  margin: 0;
  padding: 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.app-options-dialog .important-updates { border-top: 1px solid var(--line); }
.app-options-dialog .shortcut-help { border-top: 1px solid var(--line); }
.shortcut-help h2 { margin: 0; font-size: calc(13px + var(--app-font-increase, 1pt)); font-weight: 600; }
.shortcut-help-note, .shortcut-help-safety { margin: 10px 0; color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); line-height: 1.65; word-break: keep-all; overflow-wrap: anywhere; }
.shortcut-list { margin: 0; }
.shortcut-list > div { display: grid; grid-template-columns: minmax(100px, .85fr) minmax(0, 1.4fr); align-items: start; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.shortcut-list dt { color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); line-height: 1.9; }
.shortcut-list dd { margin: 0; color: var(--text); font-size: calc(12px + var(--app-font-increase, 1pt)); line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere; }
.shortcut-list small { display: block; margin-top: 3px; color: var(--muted); font-size: calc(10px + var(--app-font-increase, 1pt)); line-height: 1.65; }
.shortcut-list kbd { display: inline-block; min-width: 22px; padding: 1px 5px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface-raised); color: var(--text); font: inherit; text-align: center; }
.shortcut-help-safety { padding: 10px; border-radius: 9px; background: var(--surface-raised); }
.shortcut-details summary { padding: 8px 0; color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); cursor: pointer; }
.shortcut-details summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.updates-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.updates-heading h2 { margin: 0; font-size: calc(13px + var(--app-font-increase, 1pt)); font-weight: 600; }
.updates-heading > span { color: var(--muted); font-size: calc(10px + var(--app-font-increase, 1pt)); }
.updates-days { display: grid; gap: 10px; margin: 14px 0; }
.updates-day { border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); }
.updates-day > summary { display: flex; min-height: 44px; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; list-style: none; cursor: pointer; }
.updates-day > summary::-webkit-details-marker { display: none; }
.updates-day > summary::marker { content: ""; }
.updates-day > summary time { font-size: calc(12px + var(--app-font-increase, 1pt)); font-weight: 600; font-variant-numeric: tabular-nums; }
.updates-day > summary svg { width: 16px; height: 16px; margin-left: auto; color: var(--muted); stroke-width: 1.4; }
.updates-day[open] > summary svg { transform: rotate(180deg); }
.updates-day > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.updates-day > summary:active { background: var(--surface-hover); }
.updates-latest { padding: 2px 6px; border-radius: 5px; color: var(--accent); background: var(--accent-soft); font-size: calc(9px + var(--app-font-increase, 1pt)); font-weight: 500; }
.updates-day > .updates-list { margin: 0; padding: 4px 12px 14px; }
.updates-list { display: grid; gap: 14px; list-style: none; padding: 0; margin: 16px 0; }
.updates-list strong { display: block; font-size: calc(12px + var(--app-font-increase, 1pt)); font-weight: 600; }
.updates-list p { margin: 4px 0 0; color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); line-height: 1.65; word-break: keep-all; overflow-wrap: anywhere; }
.updates-notice { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); line-height: 1.65; word-break: keep-all; }
.updates-notice strong { display: block; margin-bottom: 4px; color: var(--text); font-weight: 600; }

.generation-instructions-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(820px, calc(100dvh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  color: var(--text);
  background: var(--panel);
  box-shadow: var(--shadow-floating);
}

.generation-instructions-dialog::backdrop {
  background: rgba(5, 7, 12, 0.46);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.generation-instructions-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.generation-instructions-dialog > header {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--material-strong);
}

.generation-instructions-dialog > header > div { display: grid; gap: 2px; }
.generation-instructions-dialog > header span { color: var(--dim); font-size: calc(10px + var(--app-font-increase, 1pt)); }
.generation-instructions-dialog > header strong { font-size: calc(15px + var(--app-font-increase, 1pt)); letter-spacing: -0.02em; }

.generation-instructions-dialog > header button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-raised);
  font-size: calc(18px + var(--app-font-increase, 1pt));
}

.generation-instructions-body {
  display: grid;
  min-height: 0;
  gap: 10px;
  padding: 18px;
  overflow: auto;
}

.generation-instructions-body > p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: calc(11px + var(--app-font-increase, 1pt));
  line-height: 1.55;
}

.generation-instructions-body > label {
  color: var(--text);
  font-size: calc(11px + var(--app-font-increase, 1pt));
  font-weight: 720;
}

.generation-instructions-editor {
  min-height: 390px;
  resize: vertical;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 0 1px 3px var(--canvas-inset);
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  font-size: calc(12px + var(--app-font-increase, 1pt));
  line-height: 1.65;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.generation-instructions-editor:focus {
  border-color: var(--accent-line);
  background: var(--surface-focus);
  box-shadow: 0 0 0 3px var(--accent-faint), inset 0 1px 3px var(--canvas-inset);
}

.generation-instructions-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--dim);
  font-size: calc(10px + var(--app-font-increase, 1pt));
}

.generation-instructions-meta > span:last-child {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.generation-instructions-dialog > footer {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  background: var(--material-strong);
}

.generation-instructions-dialog > footer > div { display: flex; gap: 8px; }

.generation-instructions-dialog > footer button {
  width: auto;
  min-width: 82px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: calc(11px + var(--app-font-increase, 1pt));
}

.generation-instructions-dialog > footer .generate-button { justify-content: center; }

.instructions-reset-button {
  border: 0;
  color: var(--muted);
  background: transparent;
}

.reference-role-copy {
  display: grid;
  min-width: 0;
  align-self: end;
  gap: 3px;
}

.reference-role-copy strong { color: var(--text); font-size: calc(11px + var(--app-font-increase, 1pt)); }
.reference-role-copy small {
  overflow: hidden;
  color: var(--dim);
  font-size: calc(10px + var(--app-font-increase, 1pt));
  line-height: 1.35;
  text-overflow: ellipsis;
}

.reference-role-action {
  align-self: end;
  color: var(--accent);
  font-size: calc(10px + var(--app-font-increase, 1pt));
  font-weight: 750;
}

.reference-role-card:not(.has-reference) .reference-role-action {
  position: absolute;
  top: 8px;
  right: 11px;
  z-index: 1;
  color: var(--accent);
  font-size: calc(22px + var(--app-font-increase, 1pt));
  font-weight: 420;
  line-height: 1;
}

.reference-role-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--image-control-border);
  border-radius: 50%;
  color: var(--image-control-hover);
  background: var(--image-control-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: calc(14px + var(--app-font-increase, 1pt));
}

.settings-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-top: 18px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: var(--surface-subtle);
  box-shadow: var(--glass-highlight);
  text-align: left;
  transition: border-color 150ms ease, background-color 150ms ease, transform 120ms var(--ease-out);
}

.settings-summary > span:first-child { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.settings-summary small { color: var(--dim); font-size: calc(9px + var(--app-font-increase, 1pt)); }
.settings-summary strong { overflow: hidden; color: var(--text); font-size: calc(11px + var(--app-font-increase, 1pt)); text-overflow: ellipsis; white-space: nowrap; }
.settings-summary > span:last-child { font-size: calc(9px + var(--app-font-increase, 1pt)); white-space: nowrap; }

.settings-summary[aria-expanded="true"] {
  border-color: var(--accent-line);
  border-radius: 11px 11px 0 0;
  background: var(--accent-faint);
}

.inline-settings {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--material);
  box-shadow: var(--shadow-control);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  transition: color 220ms ease, background-color 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.inline-settings.is-highlighted { animation: reveal-options 180ms var(--ease-out); }

@keyframes reveal-options {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.composer-actions {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 9px;
  margin-top: 10px;
  padding-top: 0;
}

.secondary-button,
.generate-button,
.empty-action {
  min-height: 48px;
  border-radius: 12px;
  font-weight: 750;
  transition: filter 150ms ease, background-color 150ms ease, border-color 150ms ease, transform 120ms var(--ease-out);
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-subtle);
  box-shadow: var(--glass-highlight);
  font-size: calc(11px + var(--app-font-increase, 1pt));
}

.generate-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border: 0;
  color: var(--accent-ink);
  background: var(--accent-gradient);
  box-shadow: var(--glass-highlight), 0 8px 22px var(--accent-shadow);
  font-size: calc(12px + var(--app-font-increase, 1pt));
}

.generate-button:disabled { cursor: wait; filter: saturate(0.35) brightness(0.72); }
.generation-icon {
  display: block; flex: 0 0 18px; width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.65;
  stroke-linecap: round; stroke-linejoin: round; pointer-events: none;
}

.form-message {
  min-height: 30px;
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: calc(10px + var(--app-font-increase, 1pt));
  line-height: 1.5;
}

.form-message[hidden] { display: none; }
.form-message.error { color: var(--danger); }

.form-message.is-detailed {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--danger-line);
  border-radius: 11px;
  color: var(--muted);
  background: var(--danger-soft);
}

.form-message.is-detailed strong {
  color: var(--danger-text);
  font-size: calc(11px + var(--app-font-increase, 1pt));
}

.form-message .message-hint { color: var(--text); }

.message-details { min-width: 0; }

.message-details summary {
  width: fit-content;
  padding: 4px 0;
  color: var(--muted);
  cursor: pointer;
}

.message-details-content {
  display: grid;
  gap: 8px;
  padding-top: 6px;
  overflow-wrap: anywhere;
}

.form-message code {
  overflow-wrap: anywhere;
  color: var(--dim);
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: calc(9px + var(--app-font-increase, 1pt));
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 2px;
}

.message-actions button,
.message-actions a {
  min-height: 29px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-subtle);
  font: inherit;
  line-height: 27px;
  text-decoration: none;
}

.message-actions button:first-child {
  border-color: var(--accent-line);
  color: var(--accent);
}

.stage {
  position: relative;
  display: grid;
  isolation: isolate;
  contain: paint;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--stage);
  transition: color 220ms ease, background-color 220ms ease;
}

.stage > .canvas-panel,
.stage > .history-panel,
.stage > .moodboard-panel { grid-row: 2; }

.stage > [role="tabpanel"]:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: -4px;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--material-strong);
  box-shadow: var(--glass-highlight);
  backdrop-filter: blur(26px) saturate(175%);
  -webkit-backdrop-filter: blur(26px) saturate(175%);
  transition: color 220ms ease, background-color 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.stage-title-group { display: flex; align-items: center; gap: 11px; min-width: 0; }
.stage-header h2 { font-size: calc(21px + var(--app-font-increase, 1pt)); }
.stage-actions { display: flex; gap: 7px; }

.toolbar-button,
.compact-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-subtle);
  box-shadow: var(--glass-highlight);
  text-decoration: none;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease, transform 120ms var(--ease-out);
}

.toolbar-button {
  min-height: 36px;
  padding: 0 11px;
  border-radius: 10px;
  font-size: calc(10px + var(--app-font-increase, 1pt));
}

.toolbar-button svg { width: 16px; height: 16px; }

.canvas-panel {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 20px;
  overflow: hidden;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  min-height: 48px;
  padding: 9px 2px 11px;
}

.active-copy {
  display: none;
  min-width: 0;
  grid-template-columns: auto minmax(0, auto);
  align-items: baseline;
  column-gap: 9px;
}

.canvas-kicker {
  color: var(--accent);
  font-size: calc(8px + var(--app-font-increase, 1pt));
  font-weight: 800;
  letter-spacing: 0.14em;
}

.active-copy strong {
  overflow: hidden;
  font-size: calc(12px + var(--app-font-increase, 1pt));
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-copy > span:last-child {
  grid-column: 1 / -1;
  overflow: hidden;
  margin-top: 3px;
  color: var(--dim);
  font-size: calc(9px + var(--app-font-increase, 1pt));
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-actions { display: flex; justify-content: flex-end; gap: 6px; }

.compact-button {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: calc(9px + var(--app-font-increase, 1pt));
}

button.compact-button:disabled { cursor: default; opacity: 0.35; }
.compact-button.icon-only { width: 30px; padding: 0; }

.canvas-panel .canvas-surface {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  z-index: 4;
  display: grid;
  width: 58px;
  height: 72px;
  place-items: center;
  padding: 0;
  border: 0;
  color: var(--image-control);
  background: transparent;
  transform: translateY(-50%);
  transition: color 150ms ease, opacity 150ms ease, transform 120ms var(--ease-out);
}

.carousel-arrow svg {
  width: 32px;
  height: 32px;
  stroke-width: 2.6;
  filter: drop-shadow(var(--image-icon-shadow));
}
.carousel-previous { left: 16px; }
.carousel-next { right: 16px; }

.carousel-arrow:disabled {
  cursor: default;
  opacity: 0.28;
}

.carousel-counter {
  display: flex;
  flex: 0 0 auto;
  min-height: 34px;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  background: var(--composer-card-solid);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-size: calc(13px + var(--app-font-increase, 1pt));
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.carousel-counter > #carouselScope {
  margin-right: 2px;
  padding-right: 8px;
  border-right: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: calc(12px + var(--app-font-increase, 1pt));
  font-weight: 500;
}
.carousel-counter strong { color: var(--accent-hover); font-size: calc(14px + var(--app-font-increase, 1pt)); font-weight: 700; }

.canvas-empty {
  display: flex;
  max-width: 390px;
  flex-direction: column;
  align-items: center;
  padding: 28px;
  text-align: center;
}

.empty-visual {
  display: grid;
  width: 64px;
  height: 64px;
  margin-bottom: 17px;
  place-items: center;
  color: var(--accent);
}

.empty-visual svg { width: 64px; height: 64px; overflow: visible; }
.empty-visual-frame { fill: var(--surface-raised); stroke: var(--accent-line); stroke-width: 1.5; }
.empty-visual-sun { fill: var(--accent-soft); stroke: currentColor; stroke-width: 1.5; }
.empty-visual-landscape { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.empty-visual-sparkle { fill: var(--accent-soft); stroke: currentColor; stroke-width: 1.4; stroke-linejoin: round; }
.empty-visual-sparkle-large { fill: var(--stage); }

.canvas-empty strong, .history-empty strong { color: var(--text); font-size: calc(15px + var(--app-font-increase, 1pt)); letter-spacing: -0.025em; }
.canvas-empty p, .history-empty p { margin: 8px 0 18px; color: var(--dim); font-size: calc(10px + var(--app-font-increase, 1pt)); line-height: 1.55; }

.empty-action {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: var(--surface-raised);
  font-size: calc(10px + var(--app-font-increase, 1pt));
}

.canvas-image-link {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  padding: 18px;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: default;
  text-decoration: none;
  transition: background-color 220ms ease;
}

.canvas-image-link.returns-to-moodboard { cursor: zoom-out; }
/* Disabled archive-photo actions must not swallow clicks in the surrounding
   letterbox. The photo still receives drag input and never toggles privacy. */
.canvas-image-link:disabled { cursor: default; pointer-events: none; }
.canvas-image-link:disabled > img { pointer-events: auto; }
.canvas-image-link:focus-visible { outline: none; }
.canvas-image-link:focus-visible img { outline: 1px solid var(--line-strong); outline-offset: 3px; }
.canvas-image-link.toggles-privacy { cursor: zoom-in; }
.canvas-image-link.is-privacy-obscured { cursor: default; }
.canvas-surface:has(> .preview-mode-header > .preview-action-button:not([hidden])) { padding-inline: 48px; }
.preview-action-button { position: absolute; left: 8px; top: 16px; z-index: 5; display: grid; place-items: center; width: 32px; height: 32px; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-raised); color: var(--muted); cursor: pointer; }
.preview-action-button[hidden] { display: none; }
.preview-action-button svg { width: 20px; height: 20px; }
.preview-action-button .preview-eye-closed { display: none; }
.preview-action-button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-line); }
.preview-action-button[aria-pressed="true"] .preview-eye-open { display: none; }
.preview-action-button[aria-pressed="true"] .preview-eye-closed { display: block; }
.preview-action-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.preview-action-button:active { background: var(--accent-faint); }

.canvas-delete-button {
  position: absolute;
  top: 30px;
  right: 30px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--image-control-border);
  border-radius: 50%;
  color: var(--image-control-hover);
  background: var(--image-control-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}
.canvas-delete-button svg { width: 18px; height: 18px; stroke-width: 1.6; }
.canvas-image-link[hidden] ~ .canvas-delete-button { display: none; }
.canvas-delete-button:focus-visible { opacity: 1; pointer-events: auto; transition: none; outline: 2px solid var(--image-control-hover); outline-offset: 3px; }
.canvas-delete-button:active:not(:disabled) { background: var(--image-control-solid); }
.canvas-delete-button:disabled { cursor: wait; }
@media (hover: hover) and (pointer: fine) {
  .canvas-surface:hover .canvas-delete-button { opacity: 1; pointer-events: auto; }
  .canvas-delete-button:not(:disabled):hover { background: var(--image-control-solid); }
}
@media (hover: none), (pointer: coarse) {
  .canvas-delete-button { width: 44px; height: 44px; opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .canvas-delete-button { transition: none; }
}

.canvas-image-link img {
  display: block;
  /* Fit the element itself to the photo so rounded corners don't sit on letterboxing. */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 16px;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(var(--shadow-image)) blur(0) brightness(1) saturate(1);
  transform: scale(1);
  transition:
    filter 480ms var(--ease-out),
    opacity 480ms var(--ease-out),
    transform 480ms var(--ease-out);
  will-change: filter, opacity, transform;
}

.canvas-image-link.is-privacy-obscured { background: rgba(4, 6, 11, 0.78); }

.canvas-image-link.is-privacy-obscured img {
  opacity: 0.62;
  filter: drop-shadow(var(--shadow-image)) blur(11px) brightness(0.42) saturate(0.68);
  transform: scale(1.025);
}

.canvas-privacy-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.94);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.86);
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.82));
  transition:
    opacity 420ms ease 80ms,
    transform 480ms var(--ease-out) 80ms;
}

.privacy-eye {
  width: 52px;
  height: 52px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.privacy-eye-open,
.privacy-status-revealed { display: none; }

.privacy-status {
  color: white;
  font-size: calc(13px + var(--app-font-increase, 1pt));
  font-weight: 750;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.canvas-image-link.is-privacy-obscured .canvas-privacy-indicator {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.canvas-image-link.is-privacy-revealing .canvas-privacy-indicator {
  animation: privacy-reveal-feedback 720ms var(--ease-out) forwards;
}

.canvas-image-link.is-privacy-revealing .privacy-eye-closed,
.canvas-image-link.is-privacy-revealing .privacy-status-protected { display: none; }

.canvas-image-link.is-privacy-revealing .privacy-eye-open,
.canvas-image-link.is-privacy-revealing .privacy-status-revealed { display: block; }

@keyframes privacy-reveal-feedback {
  0%, 34% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.08);
  }
}

.preview-navigation {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 10px 2px 1px;
}

.preview-thumbnail-strip {
  display: grid;
  width: auto;
  min-width: 0;
  flex: 1 1 0;
  grid-auto-columns: 72px;
  grid-auto-flow: column;
  justify-content: start;
  gap: 8px;
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
}

.preview-thumbnail {
  /* Keep every focusable/original-image node while Chromium skips rendering
     offscreen descendants. Grid columns and the fixed height reserve geometry. */
  content-visibility: auto;
  position: relative;
  height: 68px;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  scroll-snap-align: nearest;
  border: 2px solid transparent;
  border-radius: 9px;
  color: white;
  background: var(--image-well);
  box-shadow: var(--shadow-control);
  opacity: 0.64;
  /* Selection changes are immediate, including keyboard navigation. */
  transition: none;
}

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

.preview-thumbnail span {
  position: absolute;
  right: 5px;
  bottom: 5px;
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  padding: 0 5px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: white;
  background: rgba(10, 10, 12, 0.62);
  font-size: calc(10px + var(--app-font-increase, 1pt));
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.preview-thumbnail.is-active {
  border-color: var(--accent);
  opacity: 1;
}

/* Keep keyboard focus visible without adding a second blue selection ring. */
.preview-thumbnail:focus-visible {
  outline: none;
}

.preview-thumbnail:focus-visible span {
  outline: 2px solid #fff;
  outline-offset: 2px;
  background: #16181d;
}

@media (forced-colors: active) {
  .preview-thumbnail.is-active { border-color: Highlight; }
  .preview-thumbnail:focus-visible span { outline-color: CanvasText; background: Canvas; color: CanvasText; }
}

.camera-options-row { display: flex; align-items: stretch; gap: 4px; min-width: 0; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--composer-card-solid); }
.composer-fields .camera-options-row > .shot-size-options { flex: 1; min-width: 0; padding: 0; border: 0; background: transparent; grid-template-columns: minmax(0, .85fr) minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, .85fr) minmax(0, 1fr); }
.composer-fields .camera-options-row > .camera-angle-options { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.composer-fields .camera-options-row .shot-size-option { white-space: normal; overflow-wrap: anywhere; font-size: 11px; }
@media (max-width: 600px) { .composer-fields .camera-options-row .shot-size-option { font-size: 10px; } }
.camera-series-button { display: flex; flex: 0 0 64px; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-width: 0; padding: 5px 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised, var(--panel)); color: var(--text); font: inherit; font-size: 11px; font-weight: 600; line-height: 1.3; cursor: pointer; overflow-wrap: anywhere; }
.camera-series-label { font-size: 12px; font-weight: 600; letter-spacing: -.02em; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .camera-series-button:not(:disabled):hover { background: color-mix(in srgb, var(--text) 7%, var(--panel)); } }
.camera-series-button:not(:disabled):active { transform: scale(.97); }
.camera-series-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.camera-series-count { color: var(--muted); font-size: 11px; font-weight: 400; white-space: nowrap; font-variant-numeric: tabular-nums; }
.camera-series-button[aria-pressed="true"] .camera-series-count { color: inherit; opacity: .8; }
.camera-series-button:disabled { opacity: .55; cursor: wait; }
.camera-series-status { grid-column: 1 / -1; margin: 0; color: var(--accent); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.is-camera-series .shot-size-option:not([data-shot-size="auto"]):not([data-camera-angle="auto"]) { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.is-camera-series .shot-size-option:is([data-shot-size="auto"], [data-camera-angle="auto"]) { color: var(--muted); background: transparent; border-color: transparent; box-shadow: none; }
.shot-size-picker {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  grid-column: 1 / -1;
  gap: 10px;
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.shot-size-label {
  color: var(--text);
  font-size: calc(11px + var(--app-font-increase, 1pt));
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
}
.shot-size-options {
  display: grid;
  grid-template-columns: minmax(30px, .85fr) minmax(34px, 1fr) minmax(44px, 1.3fr) minmax(34px, 1fr) minmax(30px, .85fr) minmax(34px, 1fr);
  gap: 2px;
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--choice-selected-bg) 65%, var(--composer-card-solid) 35%);
}
.shot-size-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 50px;
  padding: 5px 1px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: calc(10px + var(--app-font-increase, 1pt));
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  transition: none;
  -webkit-user-select: none;
  user-select: none;
}
.camera-angle-picker { border-top: 0; padding-top: 0; }
.camera-angle-options { grid-template-columns: repeat(7, minmax(30px, 1fr)); }
.camera-angle-option { position: relative; }
.camera-angle-option[data-camera-angle-group="direction"] + .camera-angle-option[data-camera-angle-group="elevation"]::before {
  content: "";
  position: absolute;
  inset: 8px auto 8px -2px;
  width: 1px;
  background: var(--line);
  pointer-events: none;
}
.camera-angle-guidance {
  display: grid;
  grid-column: 1 / -1;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: calc(11px + var(--app-font-increase, 1pt));
  line-height: 1.55;
}
.camera-angle-guidance p { margin: 0; }
.camera-angle-selection strong { color: var(--text); font-weight: 600; margin-right: 6px; }
.shot-size-option > .shot-icon {
  flex: 0 0 auto; width: 24px; height: 24px;
  /* Override the global svg rule, which otherwise outweighs SVG attributes. */
  fill: none; stroke-width: 1.2;
}
.shot-size-option[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-faint);
  box-shadow: none;
  font-weight: 600;
}
.shot-size-option[aria-pressed="true"] > .shot-icon { color: var(--accent); }
.shot-size-option:active:not(:focus-visible) { transform: scale(.97); }
.shot-size-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (hover: hover) and (pointer: fine) {
  .shot-size-option:not([aria-pressed="true"]):hover { color: var(--text); background: var(--surface-hover); }
}
@container (max-width: 300px) {
  .shot-size-picker { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .shot-size-option:active:not(:focus-visible) { transform: none; }
}
@media (forced-colors: active) {
  .shot-size-option[aria-pressed="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
}

.generation-queue {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  box-sizing: border-box;
}

.generation-progress-surface {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 0;
  border-radius: inherit;
  background: transparent;
  box-shadow: none;
  z-index: 0;
}

.generation-progress-dots {
  position: absolute;
  inset: 58px 12px 12px;
  display: block;
  width: calc(100% - 24px);
  height: calc(100% - 70px);
  min-height: 0;
  color: var(--accent);
  pointer-events: none;
}

.generation-progress-percent {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--accent);
  background: var(--composer-card-solid);
  font-size: calc(12px + var(--app-font-increase, 1pt));
  font-variant-numeric: tabular-nums;
}

.generation-progress-percent small { color: var(--muted); font-size: calc(10px + var(--app-font-increase, 1pt)); }

.generation-progress-label {
  position: absolute;
  right: 18px;
  top: 22px;
  z-index: 1;
  color: var(--muted);
  font-size: calc(11px + var(--app-font-increase, 1pt));
}

/* Keep generation status over an in-frame photo without intercepting image input. */
.generation-queue.is-previewing { pointer-events: none; }
.generation-queue.is-previewing .generation-progress-dots { display: none; }
.generation-queue.is-previewing .generation-progress-label {
  top: 16px;
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--composer-card-solid);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

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

.history-panel {
  display: none;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 20px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: var(--stage);
  transition: color 220ms ease, background-color 220ms ease, border-color 220ms ease;
}

body[data-active-view="history"] .canvas-panel,
body[data-active-view="moodboard"] .canvas-panel { display: none; }
body[data-active-view="history"] .history-panel { display: grid; }
body[data-active-view="moodboard"] .moodboard-panel { display: grid; }

.moodboard-panel {
  --board-card-radius: 16px;
  position: relative;
  display: none;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
  row-gap: 16px;
  padding: 20px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: var(--stage);
  transition: color 220ms ease, background-color 220ms ease, border-color 220ms ease;
}

.workboard-panel {
  --workboard-thumbnail-size: 112px;
  position: relative;
  display: flex;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 18px;
  overflow: hidden;
  color: var(--text);
  background: var(--stage);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.workboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  flex-shrink: 0;
  gap: 8px 16px;
}

.workboard-copy { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.workboard-copy h2 { margin: 0; font-size: calc(14px + var(--app-font-increase, 1pt)); font-weight: 720; letter-spacing: -0.035em; }
.workboard-copy span { color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); }
.workboard-copy strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.workboard-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.board-selection-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }

.workboard-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--composer-card-solid);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-size: calc(11px + var(--app-font-increase, 1pt));
  white-space: nowrap;
}
.workboard-button svg { width: 15px; height: 15px; }
.workboard-button:active { border-color: var(--accent); color: var(--accent-hover); }
.workboard-button:disabled { opacity: 0.5; cursor: default; }
.board-delete-selection:not(:disabled) { color: var(--danger-text); border-color: var(--danger-line); background: var(--danger-soft); }
.workboard-help { margin: 0; color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); line-height: 1.5; }
.workboard-help, .workboard-status { flex-shrink: 0; }
.workboard-status { max-height: 4.5em; margin: 0; overflow-y: auto; color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); line-height: 1.5; overflow-wrap: anywhere; }
.workboard-status.is-error { color: var(--danger-text); }

.workboard-grid {
  position: relative;
  isolation: isolate;
  contain: paint;
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  grid-auto-flow: column;
  grid-auto-columns: var(--workboard-thumbnail-size);
  grid-template-rows: var(--workboard-thumbnail-size);
  align-content: start;
  justify-content: start;
  gap: 12px;
  padding: 3px 3px 9px;
  overflow-x: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scroll-behavior: auto;
  user-select: none;
  -webkit-user-select: none;
}

.workboard-panel.is-expanded .workboard-grid {
  grid-auto-flow: row;
  grid-template-columns: repeat(auto-fill, var(--workboard-thumbnail-size));
  grid-auto-rows: var(--workboard-thumbnail-size);
  max-height: min(30dvh, 300px);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.moodboard-panel.has-board-split { grid-template-rows: var(--workboard-height) auto minmax(0, 1fr); }
.moodboard-panel.has-board-split .workboard-panel .workboard-grid { max-height: none; }
.moodboard-panel.has-board-split .workboard-empty { flex: 1 1 auto; min-height: 0; overflow: auto; }
.board-splitter {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  height: 16px;
  align-items: center;
  justify-content: center;
  cursor: row-resize;
  touch-action: none;
  user-select: none;
  outline: none;
}
.board-splitter::before {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--line-strong);
  content: "";
}
.board-splitter span {
  z-index: 1;
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--muted);
}
.board-splitter:focus-visible::before,
.board-splitter:focus-visible span,
.is-resizing-boards .board-splitter::before,
.is-resizing-boards .board-splitter span { background: var(--accent); }
.is-resizing-boards, .is-resizing-boards * { cursor: row-resize !important; user-select: none; }
@media (hover: hover) and (pointer: fine) {
  .board-splitter:hover::before, .board-splitter:hover span { background: var(--accent); }
}

.workboard-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: var(--workboard-thumbnail-size);
  height: var(--workboard-thumbnail-size);
  border: 1px solid var(--line);
  border-radius: var(--board-card-radius);
  overflow: hidden;
  background: var(--composer-card-solid);
}

.workboard-image {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: inherit;
  background: var(--composer-card-solid);
  touch-action: manipulation;
}
.workboard-image[draggable="true"] { cursor: default; }
.workboard-image[draggable="true"]:active { cursor: default; }
.workboard-image img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.workboard-image:focus-visible { outline-offset: -3px; }

.workboard-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 4;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: var(--composer-card-solid);
  font-size: calc(16px + var(--app-font-increase, 1pt));
  line-height: 1;
}
.workboard-remove:active { color: var(--danger-text); border-color: var(--danger-line); }
.workboard-remove svg { width: 14px; height: 14px; }

.board-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  background: var(--composer-card-solid);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  line-height: 1.5;
  text-align: center;
}
.board-empty-icon {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--accent);
  border: 0;
  background: none;
}
.board-empty-icon svg { width: 24px; height: 24px; }
.board-empty-copy { min-width: 0; }
.board-empty-copy strong { display: block; color: var(--text); font-size: calc(13px + var(--app-font-increase, 1pt)); font-weight: 600; }
.board-empty-copy p { margin: 4px 0 0; color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); }
.board-empty-button {
  min-height: 34px;
  margin-top: 4px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  background: var(--composer-card-solid);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  font-size: calc(11px + var(--app-font-increase, 1pt));
}
.board-empty-button:active { color: var(--accent); border-color: var(--accent); }
.board-empty-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.workboard-empty { min-height: 104px; }
.workboard-panel.is-dragging .workboard-grid { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 10px; }

@media (hover: hover) and (pointer: fine) {
  .workboard-remove { opacity: 0; pointer-events: none; }
  .workboard-card:hover .workboard-remove,
  .workboard-card:focus-within .workboard-remove { opacity: 1; pointer-events: auto; }
  .workboard-button:not(:disabled):hover { color: var(--text); border-color: var(--line-strong); }
}

.moodboard-header {
  position: relative;
  z-index: 2;
  grid-row: 2;
  isolation: isolate;
  background: var(--stage);
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* Keep toolbar glass from sampling the scrolling image layer below it. */
.moodboard-header .toolbar-button {
  position: relative;
  overflow: hidden;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.moodboard-copy { display: flex; align-items: baseline; flex-wrap: wrap; gap: 9px; }
.moodboard-copy h2 { margin: 0; font-size: calc(14px + var(--app-font-increase, 1pt)); letter-spacing: -0.035em; }
.moodboard-copy span { color: var(--dim); font-size: calc(10px + var(--app-font-increase, 1pt)); }
.moodboard-copy span strong { color: var(--muted); font-weight: 700; }

.moodboard-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.moodboard-selection-count { color: var(--accent); font-size: calc(10px + var(--app-font-increase, 1pt)); font-weight: 700; }
.moodboard-clear-selection {
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  color: var(--accent);
  background: transparent;
  font-size: calc(10px + var(--app-font-increase, 1pt));
}
.moodboard-add-button { cursor: pointer; }
.moodboard-add-button input { display: none; }

.moodboard-grid {
  position: relative;
  z-index: 0;
  grid-row: 3;
  isolation: isolate;
  contain: paint;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: auto;
  align-content: start;
  gap: 12px;
  padding: 1px 3px 14px 1px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  overflow-x: hidden;
  overflow-anchor: none;
  scroll-behavior: auto;
  user-select: none;
  -webkit-user-select: none;
}

.workboard-grid:focus-visible,
.moodboard-grid:focus-visible { outline: 2px solid var(--accent-line); outline-offset: -2px; border-radius: 8px; }
.workboard-grid.is-selecting,
.workboard-grid.is-selecting *,
.moodboard-grid.is-selecting,
.moodboard-grid.is-selecting * { cursor: default; }
.workboard-grid.is-selecting .workboard-card,
.moodboard-grid.is-selecting .moodboard-card { transition: none; }

.moodboard-marquee {
  position: absolute;
  z-index: 5;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--accent-soft);
  pointer-events: none;
}

.moodboard-card {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--board-card-radius);
  background: var(--panel-soft);
  box-shadow: var(--glass-highlight), var(--shadow-control);
  transition: border-color 150ms ease, background-color 150ms ease;
}

.moodboard-import-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  aspect-ratio: 1;
  padding: 20px 14px;
  overflow: auto;
  border: 1px dashed var(--line-strong);
  border-radius: var(--board-card-radius);
  background: var(--panel-soft);
  color: var(--text);
  text-align: center;
}

.moodboard-import-ring {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
}
.moodboard-import-card[data-status="loading"] .moodboard-import-ring {
  border-top-color: var(--accent);
  animation: moodboard-import-spin 850ms linear infinite;
}
.moodboard-import-card[data-status="failed"] .moodboard-import-ring { display: none; }
.moodboard-import-label { font-size: calc(13px + var(--app-font-increase, 1pt)); font-weight: 600; }
.moodboard-import-detail { font-size: calc(11px + var(--app-font-increase, 1pt)); line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.moodboard-import-retry { padding: 6px 10px; font-size: calc(11px + var(--app-font-increase, 1pt)); }
.moodboard-import-cancel { position: absolute; top: 5px; right: 5px; width: 28px; height: 28px; padding: 0; }
.moodboard-card.is-import-revealing .moodboard-image-wrap img {
  animation: moodboard-import-reveal 280ms cubic-bezier(0.23, 1, 0.32, 1) both;
}
@keyframes moodboard-import-spin { to { transform: rotate(360deg); } }
@keyframes moodboard-import-reveal {
  from { opacity: 0.25; filter: blur(2px); }
  to { opacity: 1; filter: blur(0); }
}
@media (prefers-reduced-motion: reduce) {
  .moodboard-import-card[data-status="loading"] .moodboard-import-ring,
  .moodboard-card.is-import-revealing .moodboard-image-wrap img { animation: none; }
}

.moodboard-select {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
  touch-action: manipulation;
}

.moodboard-select:focus-visible { outline-offset: -4px; }
.moodboard-select[draggable="true"] { cursor: default; }
.moodboard-select[draggable="true"]:active { cursor: default; }

.moodboard-selection-check {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  display: none;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  color: white;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
}

.moodboard-selection-check svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.workboard-card.is-selected .moodboard-selection-check,
.moodboard-card.is-selected .moodboard-selection-check,
.gallery-card.is-selected .moodboard-selection-check { opacity: 1; }

.moodboard-image-wrap {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  background: var(--composer-card-solid);
}

.moodboard-image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transition: filter 180ms ease, transform 220ms var(--ease-out);
}

.moodboard-card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 5px;
}

.moodboard-card-actions button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(20, 20, 22, 0.62);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: calc(10px + var(--app-font-increase, 1pt));
  transition: color 150ms ease, background-color 150ms ease;
}

.moodboard-card-actions .moodboard-remove {
  width: 28px;
  padding: 0;
  color: white;
  font-size: calc(16px + var(--app-font-increase, 1pt));
}

.moodboard-panel.is-dragging .moodboard-grid,
.moodboard-panel.is-dragging .moodboard-empty,
.workboard-panel.is-dragging .workboard-empty {
  border-color: var(--accent);
  background-color: var(--accent-faint);
  box-shadow: inset 0 0 0 2px var(--accent-line);
}

.moodboard-empty {
  grid-row: 3;
  min-height: 0;
  height: 100%;
  overflow: auto;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  margin-bottom: 11px;
}

.history-copy { display: flex; align-items: baseline; gap: 9px; }
.history-header h2 { font-size: calc(14px + var(--app-font-increase, 1pt)); }
.history-header span { color: var(--dim); font-size: calc(9px + var(--app-font-increase, 1pt)); }
.history-header span strong { color: var(--muted); font-weight: 600; }

.history-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.gallery-density-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.density-title {
  color: var(--muted);
  font-size: calc(9px + var(--app-font-increase, 1pt));
  white-space: nowrap;
}

.gallery-density-buttons {
  display: flex;
  flex: 0 0 auto;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--composer-card-solid);
}

.gallery-density-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--text);
  background: transparent;
}

.gallery-density-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.gallery-density-button[aria-pressed="true"] {
  border-color: transparent;
  color: var(--text);
  background: var(--density-selected-bg);
}
.gallery-density-button:active { border-color: var(--accent); }

@media (hover: hover) and (pointer: fine) {
  .gallery-density-button[aria-pressed="false"]:hover { background: var(--option-bg); border-color: var(--option-border); }
  .gallery-density-button[aria-pressed="true"]:hover { background: var(--density-selected-bg); }
}

@media (pointer: coarse) {
  .gallery-density-button { width: 44px; height: 44px; }
}

.local-badge { display: inline-flex; align-items: center; gap: 6px; }
.local-badge i,
.privacy-card i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
}

.gallery {
  --gallery-columns: 6;
  --gallery-gap: 18px;
  display: block;
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  scroll-snap-type: none;
  /* Keep a continuous empty gutter for starting marquee selection. */
  padding: 12px 24px 64px;
}

.gallery[data-columns="3"] { --gallery-columns: 3; --gallery-gap: 20px; }
.gallery[data-columns="6"] { --gallery-columns: 6; --gallery-gap: 18px; }
.gallery[data-columns="9"] { --gallery-columns: 9; --gallery-gap: 16px; }

.gallery-date-group {
  width: 100%;
  min-width: 0;
  max-width: none;
  scroll-margin-top: 44px;
}

.gallery-date-group + .gallery-date-group { margin-top: 22px; }

.gallery-date-heading {
  position: relative;
  z-index: 3;
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--material-strong);
  box-shadow: var(--glass-highlight), var(--shadow-control);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

.gallery-date-heading strong {
  overflow: hidden;
  color: var(--text);
  font-size: calc(11px + var(--app-font-increase, 1pt));
  font-weight: 750;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-date-heading span {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: calc(9px + var(--app-font-increase, 1pt));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.gallery-date-grid {
  display: grid;
  width: 100%;
  min-width: 0;
  max-width: none;
  grid-template-columns: repeat(var(--gallery-columns), minmax(0, 1fr));
  grid-auto-flow: row;
  grid-auto-rows: auto;
  align-content: start;
  align-items: start;
  justify-content: stretch;
  gap: var(--gallery-gap);
}

.gallery[data-columns="3"] .gallery-date-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gallery[data-columns="6"] .gallery-date-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.gallery[data-columns="9"] .gallery-date-grid { grid-template-columns: repeat(9, minmax(0, 1fr)); }

.gallery-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: auto;
  aspect-ratio: 1 / 1;
  align-self: start;
  overflow: hidden;
  scroll-snap-align: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--image-well);
  box-shadow: var(--glass-highlight), 0 10px 30px rgba(0, 0, 0, 0.16);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms var(--ease-out);
}

.gallery-card.is-selected {
  border-color: var(--line);
  box-shadow: var(--glass-highlight), 0 10px 30px rgba(0, 0, 0, 0.16);
}

.gallery-select {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: zoom-in;
}

.gallery-select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.gallery-image-wrap {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--image-well);
}

.gallery-image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 220ms var(--ease-out), filter 180ms ease;
}

.gallery-resolution {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  text-align: center;
  overflow-wrap: anywhere;
}

.history-empty {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px dashed var(--line);
  border-radius: 11px;
  color: var(--dim);
  font-size: calc(10px + var(--app-font-increase, 1pt));
}

.history-empty button {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-raised);
  font-size: calc(9px + var(--app-font-increase, 1pt));
}

.settings-content { padding: 0 13px 13px; }

.inspector-section {
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.inspector-heading {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: calc(10px + var(--app-font-increase, 1pt));
}

.inspector-heading > span:last-child { color: var(--dim); font-size: calc(8px + var(--app-font-increase, 1pt)); }
.provider-state { color: var(--good-text) !important; }
.provider-state.error { color: var(--danger) !important; }

.provider-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-soft);
}

.provider-check {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  color: var(--accent-ink);
  background: var(--good);
  font-size: calc(11px + var(--app-font-increase, 1pt));
  font-weight: 800;
}

.provider-card.is-error .provider-check { color: white; background: var(--danger); }

.model-select {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  color: var(--text);
  background: var(--panel-soft);
  font-size: calc(10px + var(--app-font-increase, 1pt));
}

.model-select option { background: var(--panel); }

.option-grid,
.count-grid { display: grid; gap: 6px; }
.option-grid-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.option-grid-size { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.count-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.option-button,
.count-button {
  border: 1px solid var(--choice-border);
  color: var(--text);
  background: var(--choice-bg);
  box-shadow: none;
  font-weight: 600;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease, transform 120ms var(--ease-out);
}

.option-button {
  display: flex;
  min-width: 0;
  min-height: 54px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 9px;
  border-radius: 9px;
  text-align: left;
}

.option-button span { color: inherit; font-size: calc(9px + var(--app-font-increase, 1pt)); font-weight: 700; }
.option-button small { color: var(--muted); font-size: calc(8px + var(--app-font-increase, 1pt)); font-weight: 400; }

.option-button.is-selected,
.count-button.is-selected {
  border-color: var(--choice-selected-border);
  color: var(--text);
  background: var(--choice-selected-bg);
  box-shadow: none;
}

.option-button.is-selected small { color: var(--muted); }
.option-button:focus-visible,
.count-button:focus-visible { outline: 2px solid var(--choice-selected-border); outline-offset: 2px; }
.option-button:disabled,
.count-button:disabled { opacity: 0.45; cursor: not-allowed; }

.size-option {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 48px;
}

.size-option i {
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 3px;
  color: var(--dim);
  font-style: normal;
  font-size: calc(7px + var(--app-font-increase, 1pt));
}

.size-option.is-selected i { color: inherit; }
.ratio-square { width: 18px; height: 18px; }
.ratio-landscape { width: 23px; height: 16px; }
.ratio-portrait { width: 14px; height: 21px; }
.ratio-auto { width: 21px; height: 18px; }
.ratio-wide { width: 25px; height: 14px; }
.ratio-tall { width: 13px; height: 23px; }
.size-option small { justify-self: end; }

.ratio-disclosure {
  display: grid;
  width: 100%;
  min-height: 34px;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease, transform 120ms var(--ease-out);
}

.ratio-disclosure-icon {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  color: var(--accent);
  font-size: calc(17px + var(--app-font-increase, 1pt));
  font-weight: 400;
  line-height: 1;
  transition: transform 180ms var(--ease-out);
}

.ratio-disclosure[aria-expanded="true"] .ratio-disclosure-icon { transform: rotate(45deg); }
.ratio-disclosure-label { font-size: calc(9px + var(--app-font-increase, 1pt)); font-weight: 700; }
.ratio-disclosure small { color: var(--dim); font-size: calc(8px + var(--app-font-increase, 1pt)); }
.ratio-disclosure.has-selection { color: var(--text); }
.ratio-disclosure.has-selection small { color: var(--accent); }

.additional-ratios {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 220ms var(--ease-out), opacity 160ms ease;
}

.additional-ratios.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
}

.additional-ratios-inner {
  min-height: 0;
  overflow: hidden;
}

.option-grid-extra { padding-top: 6px; }

.count-button {
  min-height: 37px;
  border-radius: 8px;
  font-size: calc(10px + var(--app-font-increase, 1pt));
}

.candidate-variation {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  transition: opacity 150ms ease;
}

.candidate-variation.is-disabled { opacity: 0.5; }

.candidate-variation-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: calc(10px + var(--app-font-increase, 1pt));
}

.candidate-variation-heading label { font-weight: 700; }
.candidate-variation-heading output { color: var(--accent); font-size: calc(9px + var(--app-font-increase, 1pt)); font-weight: 700; }

.candidate-variation input[type="range"] {
  --range-progress: 50%;
  width: 100%;
  height: 14px;
  margin: 0;
  appearance: none;
  border-radius: 999px;
  outline: 0;
  background: linear-gradient(90deg, var(--accent) 0 var(--range-progress), var(--line-strong) var(--range-progress) 100%);
  background-size: 100% 3px;
  background-position: center;
  background-repeat: no-repeat;
  cursor: pointer;
}

.candidate-variation input[type="range"]:disabled { cursor: not-allowed; }
.candidate-variation input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: transparent; }
.candidate-variation input[type="range"]::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  margin-top: -6px;
  appearance: none;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-line), var(--shadow-control);
}

.candidate-variation input[type="range"]::-moz-range-track { height: 3px; background: transparent; }
.candidate-variation input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-line), var(--shadow-control);
}

.candidate-variation input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-control);
}

.candidate-variation-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  color: var(--dim);
  font-size: calc(8px + var(--app-font-increase, 1pt));
}

.candidate-variation > small {
  display: block;
  margin-top: 7px;
  color: var(--dim);
  font-size: calc(8px + var(--app-font-increase, 1pt));
  line-height: 1.4;
}

.privacy-card {
  margin-top: 18px;
  padding: 13px;
  border: 1px solid var(--good-line);
  border-radius: 11px;
  background: var(--good-soft);
  box-shadow: var(--glass-highlight);
}

.privacy-card > div { display: flex; align-items: center; gap: 8px; }
.privacy-card strong { font-size: calc(10px + var(--app-font-increase, 1pt)); }
.privacy-card p { margin: 7px 0 0 14px; color: var(--good-text); font-size: calc(8px + var(--app-font-increase, 1pt)); line-height: 1.55; }

.appearance-card {
  margin-top: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-subtle);
  box-shadow: var(--glass-highlight);
}

.appearance-card .inspector-heading { margin-bottom: 10px; }

.theme-segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: inset 0 1px 2px var(--canvas-inset);
}

.theme-option {
  display: flex;
  min-width: 0;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: calc(9px + var(--app-font-increase, 1pt));
  font-weight: 700;
  transition: color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, transform 120ms var(--ease-out);
}

.theme-option svg { width: 15px; height: 15px; }

.theme-option.is-selected {
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: var(--glass-highlight), var(--shadow-control);
}

.theme-option.is-selected svg { color: var(--accent); }

/* 읽기 어려운 보조 글자도 10px 아래로 내려가지 않게 맞춥니다. */
.overline,
.login-button,
.status-pill,
.prompt-footer,
kbd,
.section-minihead span,
.text-button,
.reference-role-copy small,
.settings-summary small,
.settings-summary > span:last-child,
.form-message code,
.canvas-kicker,
.active-copy > span:last-child,
.compact-button,
.history-header span,
.density-title,
.gallery-date-heading span,
.card-prompt,
.card-meta,
.card-actions button,
.card-actions a,
.history-empty button,
.inspector-heading > span:last-child,
.option-button span,
.option-button small,
.size-option i,
.privacy-card p,
.theme-option {
  font-size: calc(10px + var(--app-font-increase, 1pt));
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* macOS glass material system */
body {
  isolation: isolate;
  font-optical-sizing: auto;
}

.app-shell {
  position: relative;
  z-index: 1;
  isolation: isolate;
  background: rgba(0, 0, 0, 0.025);
}

.app-shell::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  content: "";
  pointer-events: none;
  opacity: var(--glass-noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.88' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  mix-blend-mode: soft-light;
}

:where(.app-shell > *) {
  position: relative;
  z-index: 1;
}

.rail {
  border-color: var(--glass-border);
  background:
    linear-gradient(135deg, var(--glass-reflection), transparent 36%),
    var(--glass-sidebar);
  box-shadow: inset -1px 0 0 var(--glass-rim-soft), var(--glass-shadow-panel);
  backdrop-filter: blur(42px) saturate(185%);
  -webkit-backdrop-filter: blur(42px) saturate(185%);
}

.composer-panel {
  border-right: 1px solid var(--glass-border);
  background:
    linear-gradient(145deg, var(--glass-reflection), transparent 31%),
    var(--glass-panel);
  box-shadow: inset -1px 0 0 var(--glass-rim-soft), var(--glass-shadow-panel);
  backdrop-filter: blur(46px) saturate(180%);
  -webkit-backdrop-filter: blur(46px) saturate(180%);
}

.stage { background: var(--stage); }

.history-panel,
.moodboard-panel { background: transparent; }

.history-panel,
.moodboard-panel { border-top-color: transparent; }

.panel-header,
.stage-header {
  border-color: var(--glass-border);
  background:
    linear-gradient(180deg, var(--glass-reflection), transparent 62%),
    var(--glass-toolbar);
  box-shadow: inset 0 1px 0 var(--glass-rim), 0 10px 32px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(34px) saturate(180%);
  -webkit-backdrop-filter: blur(34px) saturate(180%);
}

.panel-header h1,
.stage-header h2,
.history-header h2,
.moodboard-copy h2 {
  font-weight: 720;
  letter-spacing: -0.035em;
}

.overline,
.canvas-kicker {
  font-weight: 760;
  letter-spacing: 0.11em;
}

.brand-mark,
.provider-icon {
  background: linear-gradient(180deg, #3aa4ff 0%, #087df2 54%, #0068d8 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.34), 0 10px 28px var(--accent-shadow);
}

.icon-button,
.toolbar-button,
.compact-button,
.secondary-button,
.text-button,
.theme-option,
.history-empty button {
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  backdrop-filter: blur(18px) saturate(170%);
}

.rail-button.is-active {
  border-color: var(--accent-line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 78%, white 4%), var(--accent-soft));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 8px 26px rgba(0, 122, 255, 0.12);
}

.icon-button,
.toolbar-button,
.compact-button,
.secondary-button,
.history-empty button {
  border-color: var(--glass-border);
  background:
    linear-gradient(180deg, var(--glass-reflection), transparent 72%),
    var(--glass-control);
  box-shadow: inset 0 1px 0 var(--glass-rim), var(--shadow-control);
}

.provider-row,
.prompt-field,
.reference-role-card,
.reference-preview-section,
.settings-summary,
.inline-settings,
.privacy-card,
.appearance-card,
.provider-card,
.model-select,
.theme-segmented-control {
  border-color: var(--glass-border);
  background:
    linear-gradient(145deg, var(--glass-reflection), transparent 38%),
    var(--glass-card);
  box-shadow: var(--glass-shadow-card);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
}

/* Large empty states should not sample or re-blur neighboring navigation layers. */
.history-empty {
  box-sizing: border-box;
  flex-direction: column;
  gap: 0;
  padding: 28px;
  text-align: center;
  border: 0;
  background: var(--stage);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.history-empty .empty-action { min-height: 36px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-raised); color: var(--text); font-size: calc(10px + var(--app-font-increase, 1pt)); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.history-empty .empty-action:hover { background: var(--surface-hover); }
.history-empty .empty-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.prompt-field {
  border-radius: 17px;
  background:
    linear-gradient(145deg, var(--glass-reflection), transparent 38%),
    color-mix(in srgb, var(--glass-card) 78%, var(--surface) 22%);
}

.prompt-field:focus-within {
  border-color: var(--line-strong);
  box-shadow: var(--glass-highlight), 0 16px 42px rgba(0, 0, 0, 0.12);
}

.reference-role-card { border-style: solid; border-radius: 14px; }
.reference-role-card:not(.has-reference) { border-style: dashed; }
.privacy-card {
  border-color: var(--good-line);
  background:
    linear-gradient(145deg, var(--glass-reflection), transparent 38%),
    var(--good-soft);
}

.settings-summary,
.inline-settings { border-radius: 14px; }

.settings-summary[aria-expanded="true"] {
  border-color: var(--accent-line);
  background: color-mix(in srgb, var(--glass-card) 80%, var(--accent-soft));
}

.moodboard-card-actions button,
.reference-preview-remove,
.reference-role-remove {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(25, 27, 34, 0.62);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 8px 24px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(18px) saturate(170%);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
}

.preview-thumbnail {
  border-radius: 11px;
  background:
    linear-gradient(145deg, var(--glass-reflection), transparent 48%),
    var(--glass-card);
  box-shadow: inset 0 1px 0 var(--glass-rim), var(--shadow-control);
}

.gallery { background: transparent; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }

.gallery-date-heading {
  border-color: var(--glass-border);
  background:
    linear-gradient(180deg, var(--glass-reflection), transparent 65%),
    var(--glass-toolbar);
  box-shadow: inset 0 1px 0 var(--glass-rim), 0 8px 26px rgba(0, 0, 0, 0.09);
  backdrop-filter: blur(30px) saturate(175%);
  -webkit-backdrop-filter: blur(30px) saturate(175%);
}

.gallery-card {
  border-color: var(--glass-border);
  border-radius: 16px;
  background: var(--image-well);
  box-shadow: inset 0 1px 0 var(--glass-rim), 0 14px 38px rgba(0, 0, 0, 0.16);
}

.moodboard-card {
  border-color: var(--glass-border);
  border-radius: var(--board-card-radius);
  background:
    linear-gradient(145deg, var(--glass-reflection), transparent 38%),
    var(--glass-card);
  box-shadow: var(--glass-shadow-card);
  backdrop-filter: blur(22px) saturate(165%);
  -webkit-backdrop-filter: blur(22px) saturate(165%);
}

.generate-button,
.login-button {
  border-color: rgba(255, 255, 255, 0.18);
  background: linear-gradient(180deg, #369cff 0%, #0a84ff 50%, #0071e3 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36), 0 10px 30px var(--accent-shadow);
}

.reference-preview-dialog,
.moodboard-collage-dialog,
.app-options-dialog,
.generation-instructions-dialog {
  border-color: var(--glass-border-bright);
  background:
    linear-gradient(145deg, var(--glass-reflection), transparent 35%),
    color-mix(in srgb, var(--glass-panel) 92%, transparent);
  box-shadow: inset 0 1px 0 var(--glass-rim), 0 34px 110px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(46px) saturate(185%);
  -webkit-backdrop-filter: blur(46px) saturate(185%);
}

.reference-preview-dialog::backdrop,
.moodboard-collage-dialog::backdrop,
.app-options-dialog::backdrop,
.generation-instructions-dialog::backdrop {
  background: rgba(5, 7, 12, 0.48);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
}

.reference-preview-dialog[open],
.moodboard-collage-dialog[open],
.app-options-dialog[open],
.generation-instructions-dialog[open] {
  animation: glass-materialize 190ms var(--ease-out);
  transform-origin: center;
}

.app-options-dialog .appearance-card {
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

@keyframes glass-materialize {
  from { opacity: 0; transform: scale(0.975) translateY(6px); filter: blur(3px); }
  to { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .rail,
  .composer-panel,
  .panel-header,
  .stage-header,
  .provider-row,
  .prompt-field,
  .reference-role-card,
  .reference-preview-section,
  .settings-summary,
  .inline-settings,
  .appearance-card,
  .provider-card,
  .canvas-surface,
  .gallery-date-heading,
  .gallery-card,
  .moodboard-card,
  .reference-preview-dialog,
  .moodboard-collage-dialog,
  .app-options-dialog,
  .generation-instructions-dialog {
    background-color: var(--surface-focus);
  }
}

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

@media (hover: hover) and (pointer: fine) {
  .rail-button:hover,
  .icon-button:hover,
  .toolbar-button:hover,
  .compact-button:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface-raised); }
  .generation-instructions-trigger:hover { color: var(--text); border-color: var(--line); background: var(--surface-hover); }
  .carousel-arrow:not(:disabled):hover { color: var(--image-control-hover); }
  .reference-role-card:hover { border-color: var(--accent-line); background: var(--accent-faint); }
  .reference-preview-open:hover { border-color: var(--accent); }
  .reference-preview-remove:hover { background: rgba(10, 10, 12, 0.9); }
  .settings-summary:hover { border-color: var(--line-strong); background: var(--surface-hover); }
  .secondary-button:hover { color: var(--text); border-color: var(--line-strong); }
  .generate-button:hover { filter: brightness(1.05); }
  .gallery-card:hover { border-color: var(--line-strong); box-shadow: inset 0 1px 0 var(--glass-rim), 0 18px 44px rgba(0, 0, 0, 0.24); transform: translateY(-2px); }
  .gallery-card:hover .gallery-image-wrap img { filter: brightness(1.05); transform: scale(1.015); }
  .moodboard-card:hover { border-color: var(--line-strong); }
  .moodboard-card:hover .moodboard-image-wrap img { filter: brightness(1.05); }
  .preview-thumbnail:not(.is-active):hover { border-color: var(--line-strong); opacity: 1; }
  .moodboard-card-actions button:hover { color: white; background: rgba(10, 10, 12, 0.82); }
  .option-button:not(:disabled):not(.is-selected):hover,
  .count-button:not(:disabled):not(.is-selected):hover {
    border-color: var(--choice-selected-border);
    background: color-mix(in srgb, var(--choice-bg) 60%, var(--choice-selected-bg) 40%);
  }
  .option-button.is-selected:not(:disabled):hover,
  .count-button.is-selected:not(:disabled):hover {
    border-color: var(--choice-selected-border);
    background: var(--choice-selected-hover);
  }
  .ratio-disclosure:hover { color: var(--text); border-color: var(--line); background: var(--surface-hover); }
  .theme-option:hover { color: var(--text); background: var(--surface-hover); }
  .rail-status:hover { filter: brightness(1.08); }
  .text-button:hover { color: var(--text); }
  .instructions-reset-button:hover { color: var(--text); background: var(--surface-hover); }
}

/* Pointer press feedback stays small and never delays keyboard/repeated browsing.
   Reference cards contain editable controls, so the whole card must not shrink. */
:is(.rail-button, .icon-button, .toolbar-button, .compact-button,
  .generation-instructions-trigger, .settings-summary, .secondary-button,
  .generate-button, .empty-action, .option-button, .count-button,
  .ratio-disclosure, .ratio-picker-trigger, .theme-option, .rail-status) {
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease,
    filter 150ms ease, transform 120ms var(--ease-out);
}
@media (prefers-reduced-motion: no-preference) {
  :root[data-input-modality="pointer"] :is(.rail-button, .icon-button,
    .toolbar-button, .compact-button, .generation-instructions-trigger,
    .settings-summary, .secondary-button, .generate-button, .empty-action,
    .option-button, .count-button, .ratio-disclosure, .ratio-picker-trigger,
    .theme-option, .rail-status):active:not(:disabled):not([aria-disabled="true"]) {
    transform: scale(0.97);
  }
}

@media (max-width: 1280px) {
  .app-shell {
    --composer-width: 376px;
    --app-edge: 16px;
    grid-template-columns: var(--composer-width) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  body { overflow: hidden; }

  .app-shell {
    --app-edge: 12px;
    --app-gap: 12px;
    --topbar-space: 76px;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow-y: auto;
    scroll-padding-top: var(--topbar-space);
  }

  .app-topbar { position: sticky; top: 0; flex: 0 0 auto; }

  .rail {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 14;
    display: grid;
    height: 68px;
    grid-template-columns: 52px 1fr 52px;
    padding: 6px 12px;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .brand-mark { width: 38px; height: 38px; }
  .rail-nav { flex-direction: row; justify-content: center; gap: 4px; margin: 0; }
  .rail-button { width: 44px; height: 54px; }
  .rail-footer { flex-direction: row; justify-content: flex-end; gap: 0; margin: 0; }

  .composer-panel {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage {
    flex: 0 0 auto;
    height: calc(100dvh - var(--app-edge) * 2 - var(--topbar-space));
    grid-template-rows: auto minmax(0, 1fr);
  }

  .stage-header { padding: 12px 14px; }
  .stage-header h2 { font-size: calc(19px + var(--app-font-increase, 1pt)); }
  .canvas-panel { padding: 16px; }
  .canvas-toolbar { min-height: 52px; }
  .history-panel,
  .moodboard-panel { padding: 16px; }
}

@media (max-width: 620px) {
  .stage { grid-template-rows: auto minmax(0, 1fr); }
  .app-shell { --app-edge: 8px; --topbar-space: 76px; }
  .app-topbar { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 44px; gap: 8px; padding: 8px 12px; }
  .app-brand { grid-column: 1; grid-row: 1; }
  .workspace-nav { padding: 7px 8px 0; }
  .workspace-tab { gap: 5px; padding: 8px 6px; font-size: calc(11px + var(--app-font-increase, 1pt)); }
  .app-topbar-actions { grid-column: 2; grid-row: 1; justify-self: end; justify-content: flex-end; width: 100%; gap: 6px; }
  .topbar-engine { max-width: 170px; }
  .stage-header { gap: 10px; }
  .stage-title-group .overline { display: none; }
  .stage-header h2 { font-size: calc(17px + var(--app-font-increase, 1pt)); }
  .toolbar-button { width: 36px; padding: 0; }
  .toolbar-button span { display: none; }

  .canvas-toolbar { align-items: flex-start; }
  .active-copy { padding-top: 2px; }
  .active-copy > span:last-child { max-width: 47vw; }
  .canvas-actions { gap: 4px; }
  .canvas-actions .compact-button:nth-child(-n+2) { width: 30px; overflow: hidden; color: transparent; }
  .canvas-actions .compact-button:nth-child(1)::before { content: "C"; color: var(--muted); }
  .canvas-actions .compact-button:nth-child(2)::before { content: "↩"; color: var(--muted); font-size: calc(13px + var(--app-font-increase, 1pt)); }
  .canvas-actions #moodboardToggleButton { width: 30px; overflow: hidden; color: transparent; }
  .canvas-actions #moodboardToggleButton::before { content: "▦"; color: var(--muted); font-size: calc(13px + var(--app-font-increase, 1pt)); }
  .canvas-actions #moodboardToggleButton.is-added::before { color: var(--accent); }
  .canvas-image-link { padding: 10px; }
  .carousel-arrow { width: 50px; height: 64px; }
  .carousel-arrow svg { width: 28px; height: 28px; }
  .carousel-previous { left: 8px; }
  .carousel-next { right: 8px; }
  .preview-navigation { gap: 6px; padding-top: 7px; }
  .preview-thumbnail-strip { grid-auto-columns: 58px; gap: 6px; }
  .preview-thumbnail { height: 54px; border-radius: 8px; }

  .history-header .local-badge { display: none; }
  .history-header { align-items: stretch; flex-direction: column; gap: 8px; }
  .moodboard-header { align-items: stretch; flex-direction: column; gap: 8px; }
  .workboard-panel { --workboard-thumbnail-size: 104px; }
  .workboard-header { align-items: flex-start; flex-direction: column; }
  .workboard-tools { width: 100%; }
  .workboard-empty { min-height: 84px; }
  .history-tools { width: 100%; }
  .gallery-density-control { width: 100%; justify-content: space-between; }
  .gallery-copy { padding: 7px; }

  .composer-form { padding: 16px; }
  .prompt-field { min-height: 0; }

  .generation-instructions-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 18px;
  }

  .generation-instructions-body { padding: 14px; }
  .generation-instructions-editor { min-height: 300px; }
  .generation-instructions-meta { align-items: flex-start; flex-direction: column; gap: 4px; }
  .generation-instructions-dialog > footer { align-items: stretch; flex-direction: column; }
  .generation-instructions-dialog > footer > div { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .generation-instructions-dialog > footer button { width: 100%; }
}

@media (max-height: 560px) {
  .workboard-panel { gap: 6px; }
  .workboard-help { display: none; }
  .workboard-empty { min-height: 60px; padding: 10px 14px; flex-direction: row; }
  .workboard-panel.is-expanded .workboard-grid { max-height: 124px; }
}

@media (prefers-reduced-transparency: reduce) {
  .rail,
  .composer-panel,
  .panel-header,
  .stage-header,
  .gallery-date-heading,
  .inline-settings,
  .provider-row,
  .prompt-field,
  .reference-role-card,
  .reference-preview-section,
  .settings-summary,
  .canvas-surface,
  .gallery-card,
  .moodboard-card,
  .reference-preview-dialog,
  .moodboard-collage-dialog,
  .app-options-dialog,
  .generation-instructions-dialog {
    background: var(--surface-focus);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .gallery-viewer-meta,
  .gallery-viewer-close,
  .reference-role-remove,
  .moodboard-card-actions button,
  .preview-thumbnail-remove {
    background: var(--image-control-solid);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .reference-preview-dialog::backdrop,
  .gallery-viewer-dialog::backdrop,
  .moodboard-collage-dialog::backdrop,
  .app-options-dialog::backdrop,
  .generation-instructions-dialog::backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .gallery-viewer-dialog {
    background: #0b0d12;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  :root,
  :root[data-theme="light"] {
    --glass-border: var(--line-strong);
    --glass-border-bright: var(--text-primary);
  }

  button,
  input,
  select,
  textarea,
  .rail,
  .composer-panel,
  .provider-row,
  .prompt-field,
  .reference-role-card,
  .reference-preview-section,
  .settings-summary,
  .canvas-surface,
  .gallery-card,
  .moodboard-card {
    border-color: var(--line-strong);
  }
}

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

  .spinner { animation-duration: 1.4s; }
}

/* Light-mode dialogs use the same opaque surfaces as the rest of the app.
   Keep these after material/accessibility overrides, including viewer chrome. */
:root[data-theme="light"] .gallery-viewer-dialog,
:root[data-theme="light"] .reference-preview-dialog,
:root[data-theme="light"] .moodboard-collage-dialog,
:root[data-theme="light"] .app-options-dialog,
:root[data-theme="light"] .generation-instructions-dialog {
  border-color: var(--line-strong);
  color: var(--text);
  background: var(--composer-card-solid);
  box-shadow: var(--shadow-floating);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

:root[data-theme="light"] .gallery-viewer-dialog::backdrop,
:root[data-theme="light"] .reference-preview-dialog::backdrop,
:root[data-theme="light"] .moodboard-collage-dialog::backdrop,
:root[data-theme="light"] .app-options-dialog::backdrop,
:root[data-theme="light"] .generation-instructions-dialog::backdrop {
  background: rgba(225, 232, 242, 0.68);
}

:root[data-theme="light"] .gallery-viewer-canvas,
:root[data-theme="light"] .reference-preview-dialog-image,
:root[data-theme="light"] .moodboard-collage-preview {
  background: var(--stage);
}

:root[data-theme="light"] .gallery-viewer-canvas img { box-shadow: var(--shadow-image); }

:root[data-theme="light"] .gallery-viewer-close,
:root[data-theme="light"] .gallery-viewer-meta {
  border-color: var(--line-strong);
  color: var(--text);
  background: var(--composer-card-solid);
  box-shadow: var(--shadow-control);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

:root[data-theme="light"] .gallery-viewer-arrow {
  color: var(--muted);
  filter: none;
}

@media (hover: hover) and (pointer: fine) {
  :root[data-theme="light"] .gallery-viewer-close:hover {
    color: var(--text);
    background: var(--option-bg);
  }
  :root[data-theme="light"] .gallery-viewer-arrow:not(:disabled):hover { color: var(--accent); }
}

/* Stable navigation/composer surfaces. Keep this after the material and media
   rules so nested controls cannot restore backdrop sampling on pointer hover. */
.rail,
.app-topbar,
.composer-panel,
.rail *,
.app-topbar *,
.composer-panel * {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.rail {
  isolation: isolate;
  background: var(--rail-solid);
  box-shadow: inset -1px 0 0 var(--line);
}

.composer-panel {
  isolation: isolate;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--composer-solid);
  box-shadow: none;
}

.composer-panel .prompt-field,
.composer-panel .reference-role-card,
.composer-panel .reference-preview-section,
.composer-panel .inline-settings,
.composer-panel .settings-summary {
  background: var(--composer-card-solid);
}

@media (hover: hover) and (pointer: fine) {
  .composer-panel .reference-role-card:hover {
    border-color: var(--accent-line);
    background: color-mix(in srgb, var(--composer-card-solid) 94%, var(--accent) 6%);
  }

  .composer-panel .settings-summary:hover {
    border-color: var(--line-strong);
    background: color-mix(in srgb, var(--composer-card-solid) 96%, var(--text) 4%);
  }
}

.composer-panel .reference-role-card.is-dragging,
.composer-panel .reference-role-card:focus-within,
.composer-panel .settings-summary[aria-expanded="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--composer-card-solid) 88%, var(--accent) 12%);
}

/* Workspace shell: clear input order, one scrolling surface, persistent submit. */
.composer-panel.has-workspace-shell { overflow: hidden; }
.has-workspace-shell .composer-form { height: 100%; min-height: 0; padding: 0; }
.composer-fields {
  --composer-content-padding: 18px;
  --composer-scroll-inset: 12px;
  display: flex; flex: 1 1 auto; min-height: 0; min-width: 0; flex-direction: column;
  gap: 10px; margin: var(--composer-scroll-inset) var(--composer-scroll-inset) var(--composer-scroll-inset) 0;
  padding: calc(var(--composer-content-padding) - var(--composer-scroll-inset)) calc(var(--composer-content-padding) - var(--composer-scroll-inset)) calc(var(--composer-content-padding) - var(--composer-scroll-inset)) var(--composer-content-padding);
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-gutter: stable; scroll-padding-block: 16px;
}
.composer-fields::-webkit-scrollbar { width: 8px; height: 8px; }
.composer-fields::-webkit-scrollbar-track:vertical { margin-block: 4px; }
.composer-fields::-webkit-scrollbar-thumb {
  background-color: transparent; border: 2px solid transparent;
  background-clip: padding-box; border-radius: 99px;
}
.composer-fields.is-scrolling::-webkit-scrollbar-thumb,
.composer-fields:focus-visible::-webkit-scrollbar-thumb { background-color: var(--scroll-thumb); }
@media (hover: hover) and (pointer: fine) {
  .composer-fields:hover::-webkit-scrollbar-thumb { background-color: var(--scroll-thumb); }
}
@supports not selector(::-webkit-scrollbar) {
  .composer-fields { scrollbar-width: thin; scrollbar-color: transparent transparent; }
  .composer-fields.is-scrolling,
  .composer-fields:focus-visible { scrollbar-color: var(--scroll-thumb) transparent; }
  @media (hover: hover) and (pointer: fine) {
    .composer-fields:hover { scrollbar-color: var(--scroll-thumb) transparent; }
  }
}
.composer-fields > * { flex-shrink: 0; }
.composer-fields .reference-section { margin: 0; }
.reference-section-help { margin: -2px 0 12px; color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); line-height: 1.55; word-break: keep-all; }
.composer-submit-bar {
  flex: 0 0 auto; position: relative; z-index: 3; min-width: 0;
  padding: 12px 18px; border-top: 1px solid var(--line); background: var(--composer-solid);
}
.composer-submit-bar .composer-actions { margin: 0; grid-template-columns: 72px minmax(0, 1fr); }
.composer-submit-bar .form-message { max-height: 120px; overflow: auto; margin-bottom: 0; }
.composer-submit-bar .generate-button { min-height: 44px; box-shadow: none; font-size: calc(13px + var(--app-font-increase, 1pt)); font-weight: 650; }
.composer-submit-bar .secondary-button { min-height: 44px; box-shadow: none; font-size: calc(12px + var(--app-font-increase, 1pt)); font-weight: 550; }

/* Content owns the hierarchy; repeated cards do not need their own elevation. */
.composer-panel .prompt-field,
.composer-panel .reference-role-card,
.composer-panel .reference-preview-section,
.composer-panel .inline-settings { box-shadow: none; border-color: var(--line); border-radius: 12px; }
.composer-panel .prompt-field:focus-within { border-color: var(--line-strong); box-shadow: none; }
.composer-panel .reference-role-card { border-style: solid; }
.composer-panel .reference-role-card.has-reference { border-color: var(--accent-line); }
.composer-fields .reference-role-picker {
  min-height: 72px; grid-template-columns: 36px minmax(0, 1fr); grid-template-rows: auto;
  gap: 8px; padding: 10px;
}
.composer-fields .reference-role-visual { width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; }
.composer-fields .reference-role-icon,
.composer-fields .reference-role-icon svg { width: 22px; height: 22px; stroke-width: 1.4; }
.composer-fields .reference-role-copy { align-self: center; gap: 3px; padding-right: 5px; }
.composer-fields .reference-role-copy strong { font-size: calc(12px + var(--app-font-increase, 1pt)); font-weight: 600; line-height: 1.3; }
.composer-fields .reference-role-copy small { color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); line-height: 1.4; }
.composer-fields .reference-role-action { grid-column: 2; font-size: calc(11px + var(--app-font-increase, 1pt)); }
.composer-fields .reference-role-card:not(.has-reference) .reference-role-action { top: 5px; right: 7px; font-size: calc(16px + var(--app-font-increase, 1pt)); }
.composer-fields .reference-role-card.has-reference .reference-role-picker { padding-top: 22px; }
.composer-fields .has-multiple-references .reference-role-picker { grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.composer-fields .has-multiple-references .reference-role-visual { grid-column: 1 / -1; grid-row: 1; width: 100%; height: 38px; display: flex; gap: 5px; }
.composer-fields .has-multiple-references .reference-role-thumbnail { width: 38px; height: 38px; flex-basis: 38px; }
.composer-fields .has-multiple-references .reference-role-copy { grid-row: 2; grid-column: 1; }
.composer-fields .has-multiple-references .reference-role-action { grid-row: 2; grid-column: 2; }
.composer-fields .reference-role-custom.has-reference .reference-role-picker { grid-template-columns: 36px minmax(0, 1fr); padding-right: 10px; }
.composer-fields .custom-reference-refine { font-size: calc(12px + var(--app-font-increase, 1pt)); }
.composer-fields .custom-reference-fields { font-size: calc(12px + var(--app-font-increase, 1pt)); }
.composer-fields .reference-role-remove { box-shadow: none; width: 11px; height: 11px; min-width: 0; min-height: 0; font-size: calc(10px + var(--app-font-increase, 1pt)); line-height: 1; }
.composer-fields .reference-role-picker:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; border-radius: 10px; }
.composer-fields .reference-preview-section { padding: 0; border: 0; background: transparent; }
.reference-preview-heading { align-items: center; list-style: none; cursor: pointer; margin: 0; padding: 9px 1px; }
.reference-preview-heading::-webkit-details-marker { display: none; }
.reference-preview-heading strong { color: var(--muted); font-size: calc(12px + var(--app-font-increase, 1pt)); font-weight: 500; }
.reference-preview-heading svg { width: 16px; height: 16px; }
.reference-preview-section[open] > summary svg { transform: rotate(180deg); }
.reference-preview-list { padding-top: 4px; }
.reference-preview-heading:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 5px; }

/* Shared controls remain visible, with candidate variation read before quantity. */
.composer-fields .generation-options-bar { margin: 0; padding: 6px 0 0; gap: 8px; }
.shot-size-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.shot-size-heading .reference-reset-button { flex: 0 0 24px; width: 24px; height: 24px; min-width: 24px; min-height: 24px; }
.shot-size-heading .reference-reset-button svg { width: 16px; height: 16px; }
@media (pointer: coarse) { .shot-size-heading .reference-reset-button { flex-basis: 40px; width: 40px; height: 40px; } }
.shared-settings-heading { display: flex; align-items: center; justify-content: space-between; min-height: 28px; gap: 10px; }
.shared-settings-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.shared-settings-heading strong { font-size: calc(13px + var(--app-font-increase, 1pt)); font-weight: 650; }
.shared-settings-heading span { color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); }
.generation-options-top { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 12px; }
.generation-option-heading { min-height: 20px; }
.generation-option-heading > span:first-child,
.generation-option-inline > label { min-height: 20px; font-size: calc(12px + var(--app-font-increase, 1pt)); }
.count-variation-strip {
  display: flex; align-items: center; gap: 3px; min-width: 0; padding: 3px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--choice-selected-bg);
}
.count-variation-strip .candidate-variation-inline { padding-right: 3px; border-right: 1px solid var(--line); }
.count-variation-strip .candidate-variation-toggle { min-width: 61px; height: 32px; padding: 0 5px; font-size: calc(12px + var(--app-font-increase, 1pt)); background: transparent; border-color: transparent; border-radius: 7px; }
.count-variation-strip .candidate-variation-toggle[data-mode="diverse"] { background: transparent; color: var(--accent); }
.generation-options-bar .count-variation-strip .count-grid { flex: 1 1 auto; gap: 1px; padding: 0; border: 0; border-radius: 0; background: transparent; }
.generation-options-bar .count-button { font-size: calc(12px + var(--app-font-increase, 1pt)); padding: 0 2px; }
.ratio-picker-trigger { font-size: calc(12px + var(--app-font-increase, 1pt)); border-radius: 11px; padding-inline: 9px; gap: 5px; }
.composer-fields .shot-size-picker { grid-template-columns: minmax(0, 1fr); gap: 4px; border-top: 0; padding-top: 0; }
.composer-fields .shot-size-label { font-size: calc(12px + var(--app-font-increase, 1pt)); }
.composer-fields .shot-size-options { padding: 3px; gap: 2px; border-radius: 11px; }
.composer-fields .shot-size-option { min-height: 48px; padding-inline: 2px; font-size: calc(11px + var(--app-font-increase, 1pt)); font-weight: 550; }
.composer-fields .shot-size-option[aria-pressed="true"] { box-shadow: none; }
.composer-fields .inline-settings { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; }
.composer-fields .settings-content { padding: 0; }
.composer-fields .inspector-section:last-child { padding-bottom: 0; border: 0; }
.composer-fields .inspector-heading { font-size: calc(12px + var(--app-font-increase, 1pt)); color: var(--text); align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.composer-fields .inspector-heading > span:last-child { font-size: calc(11px + var(--app-font-increase, 1pt)); color: var(--muted); }
.composer-fields .option-button { min-height: 48px; padding: 8px; }
.composer-fields .option-button span { font-size: calc(12px + var(--app-font-increase, 1pt)); }
.composer-fields .option-button small { font-size: calc(11px + var(--app-font-increase, 1pt)); }
.composer-fields .model-select { font-size: calc(12px + var(--app-font-increase, 1pt)); box-shadow: none; background: var(--composer-card-solid); }
.composer-fields .field-label,
.composer-fields .section-minihead strong,
.composer-fields .prompt-preset-detail label { font-size: calc(13px + var(--app-font-increase, 1pt)); font-weight: 600; }
.composer-fields .section-minihead span,
.composer-fields .text-button,
.composer-fields .prompt-footer { font-size: calc(11px + var(--app-font-increase, 1pt)); color: var(--muted); }
.composer-fields .prompt-preset-detail small { color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); }
.composer-fields .prompt-preset-button,
.composer-fields .prompt-preset-label { font-size: calc(12px + var(--app-font-increase, 1pt)); }

/* Wayfinding and accessible, non-animated options tabs. */
.board-purpose { flex-basis: 100%; margin: 4px 0 0; color: var(--muted); font-size: calc(12px + var(--app-font-increase, 1pt)); line-height: 1.5; }
.workboard-help { font-size: calc(12px + var(--app-font-increase, 1pt)); }
.moodboard-copy > span,
.history-copy > span { color: var(--muted); font-size: calc(12px + var(--app-font-increase, 1pt)); }
.canvas-actions .compact-button,
.workboard-button,
.moodboard-tools .toolbar-button { box-shadow: none; font-size: calc(12px + var(--app-font-increase, 1pt)); border-color: var(--line); }
.app-options-dialog { width: min(500px, calc(100vw - 32px)); }
.options-tabs {
  position: sticky; top: 64px; z-index: 2; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--composer-card-solid);
}
.options-tabs button { min-height: 36px; padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: calc(12px + var(--app-font-increase, 1pt)); font-weight: 550; transition: none; }
.options-tabs button[aria-selected="true"] { color: var(--accent); background: var(--accent-faint); }
.options-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.options-tab-panel[hidden] { display: none !important; }
.options-tab-panel { min-width: 0; }
.app-options-dialog .shortcut-help,
.app-options-dialog .important-updates { border-top: 0; }
.app-options-dialog .inspector-heading,
.app-options-dialog .shortcut-help-note,
.app-options-dialog .shortcut-help-safety,
.app-options-dialog .shortcut-list dt,
.app-options-dialog .shortcut-list small { font-size: calc(12px + var(--app-font-increase, 1pt)); }
.app-options-dialog .inspector-heading > span:last-child { font-size: calc(11px + var(--app-font-increase, 1pt)); color: var(--muted); }

@container (max-width: 360px) {
  .generation-options-top { grid-template-columns: minmax(0, 1fr); }
  .composer-fields .shot-size-picker { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .composer-panel.has-workspace-shell { height: min(760px, calc(100dvh - 110px)); min-height: 350px; }
}
@media (max-width: 620px) {
  .composer-fields { --composer-content-padding: 14px; gap: 16px; }
  .composer-submit-bar { padding: 10px 14px; }
  .canvas-actions { flex-wrap: wrap; }
  .canvas-actions .compact-button:nth-child(-n+2),
  .canvas-actions #moodboardToggleButton { width: auto; color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); padding: 0 8px; }
  .canvas-actions .compact-button:nth-child(-n+2)::before,
  .canvas-actions #moodboardToggleButton::before { content: none; }
}

/* A single prompt surface: tabs, input, then shared tools. */
.composer-panel .prompt-field { background: var(--composer-card-solid); }
.prompt-field .prompt-preset-list { padding: 4px 10px 0; border: 0; background: transparent; }
.prompt-field .prompt-preset-button { min-height: 38px; margin: 0; border: 0; border-radius: 0; background: transparent; }
.prompt-field .prompt-preset-button[aria-selected="true"] { border: 0; background: transparent; box-shadow: none; color: var(--accent); }
.prompt-field .prompt-preset-button[aria-selected="true"]::after { content: ""; position: absolute; bottom: 0; left: 28%; right: 28%; height: 2px; border-radius: 2px; background: currentColor; }
.prompt-field .prompt-preset-visual { display: none; }
.prompt-field .prompt-field-header { min-height: 36px; padding: 4px 12px 10px; border: 0; background: transparent; gap: 8px; }
.prompt-field .prompt-field-actions { margin-left: 0; gap: 3px; }
.prompt-field .prompt-quality-select { width: 96px; border-color: transparent; background: transparent; }
.prompt-field .prompt-quality-select:hover { background: var(--surface-hover); }
.prompt-field .prompt-character-count { margin-left: auto; color: var(--muted); font-size: calc(10px + var(--app-font-increase, 1pt)); white-space: nowrap; }
.prompt-field .prompt-footer { display: none; }
.prompt-field .prompt-preset-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.basic-copy-options { margin: 0 14px 10px; font-size: calc(12px + var(--app-font-increase, 1pt)); color: var(--muted); }
.basic-copy-options > summary { padding: 8px 0; cursor: pointer; }
.basic-copy-options[open] { border-top: 1px solid var(--line); }
.basic-copy-options .prompt-preset-detail { margin: 0; padding: 4px 0 8px; border: 0; }
.is-image-edit .prompt-field-header > .prompt-character-count { display: none; }
body[data-active-view="moodboard"] .stage > #generationJobsPanel,
body[data-active-view="history"] .stage > #generationJobsPanel { display: none; }

.canvas-actions { gap: 6px; align-items: center; }
.canvas-actions > .compact-button { min-height: 30px; padding: 5px 10px; border-radius: 8px; font-size: calc(11px + var(--app-font-increase, 1pt)); font-weight: 500; }
.canvas-actions > #copyPromptButton { border-color: transparent; background: transparent; color: var(--muted); }
.canvas-actions > #downloadLink { background: var(--surface-raised); color: var(--text); border-color: var(--line); }

/* Preview expansion fills the right workspace below its tabs. */
/* The redundant ID exclusions preserve the former relational specificity. */
body[data-active-view="create"] .stage.has-contained-preview:not(#canvasPanel) { grid-template-columns: minmax(0, 1fr); }
body[data-active-view="create"] .stage.has-contained-preview:not(#canvasPanel) > #canvasPanel { grid-column: 1 / -1; grid-row: 2 / 5; }
body[data-active-view="create"] .stage.has-contained-preview:not(#canvasPanel) > #generationJobsPanel,
body[data-active-view="create"] .stage.has-contained-preview:not(#canvasPanel) > #completedResultsButton { display: none; }

#prompt { resize: none; }
#prompt.is-expanded { overflow-y: hidden; max-height: none; }
.prompt-expand-button { flex: 0 0 auto; margin-left: auto; }
.prompt-expand-button[aria-expanded="true"] { color: var(--accent); background: var(--accent-faint); }
.prompt-expand-button[aria-expanded="true"] svg { transform: rotate(180deg) scale(.8); }
.prompt-field .prompt-expand-button + .prompt-character-count { margin-left: 0; }

#customReferenceRefineButton:disabled { opacity: .45; color: var(--muted); border-color: var(--line); background: var(--surface-subtle); cursor: not-allowed; }
.reference-role-card[data-reference-role="person"] { padding-bottom: 32px; }

.custom-reference-choices { display: flex; flex-wrap: wrap; gap: 5px; margin: 7px 0; }
.custom-reference-choices button { padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--composer-card-solid); color: var(--muted); font: inherit; font-size: calc(11px + var(--app-font-increase, 1pt)); cursor: pointer; }
.custom-reference-choices button[aria-pressed="true"] { border-color: var(--accent-line); color: var(--accent); background: var(--accent-faint); }

/* Uniform reference tiles; detailed custom controls occupy their own full row. */
.composer-fields .reference-role-grid { align-items: stretch; }
.composer-fields .reference-role-card:not(.reference-role-custom) { min-height: 132px; padding-bottom: 34px; }
.composer-fields .reference-role-card:not(.reference-role-custom) .reference-role-picker { min-height: 96px; padding-bottom: 8px; }
.composer-fields .reference-role-card[data-reference-role="background"] .background-color-picker { position: absolute; right: 7px; bottom: 7px; padding: 0; }
.composer-fields .reference-role-custom { grid-column: 1 / -1; }
.composer-fields .reference-role-custom .custom-reference-heading { display: flex; align-items: center; gap: 10px; padding-right: 40px; }
.composer-fields .reference-role-custom .reference-role-picker { flex: 1; min-height: 82px; padding-top: 12px; }
.composer-fields .reference-role-custom .custom-reference-refine { flex: 0 0 auto; margin: 0; }
.composer-fields .reference-role-custom .custom-reference-fields { padding: 0 12px 12px; }
.composer-fields .reference-role-custom .custom-reference-choices { gap: 6px; }
.composer-fields .reference-role-custom .custom-reference-fields textarea { min-height: 62px; resize: vertical; }
.composer-fields .reference-role-card:not(.reference-role-custom) { min-height: 140px; }
.composer-fields .reference-role-card[data-reference-role="background"] { grid-column: 1 / -1; min-height: 82px; padding-bottom: 0; }
.composer-fields .reference-role-card[data-reference-role="background"] .reference-role-picker { min-height: 80px; padding-right: 108px; }
.composer-fields .reference-role-card[data-reference-role="background"] .background-color-picker { bottom: 12px; right: 12px; }

.gallery-viewer-help { position:absolute; z-index:3; bottom:12px; right:12px; margin:0; padding:9px 11px; max-width:calc(100% - 24px); box-sizing:border-box; display:grid; gap:6px; border:1px solid color-mix(in srgb,var(--line) 70%,transparent); border-radius:12px; background:color-mix(in srgb,var(--surface-raised) 88%,transparent); color:var(--muted); box-shadow:0 4px 16px rgb(0 0 0 / 8%),inset 0 1px 0 rgb(255 255 255 / 8%); backdrop-filter:blur(20px) saturate(140%); -webkit-backdrop-filter:blur(20px) saturate(140%); font-family:-apple-system,BlinkMacSystemFont,sans-serif; font-size:10px; line-height:1.4; pointer-events:none; }
.gallery-viewer-help span { display:flex; align-items:center; gap:10px; }
.gallery-viewer-help kbd { flex:0 0 76px; min-width:0; padding:0; border:0; border-radius:0; background:none; box-shadow:none; font:inherit; color:var(--text); font-weight:500; text-align:start; white-space:normal; }
.gallery-viewer-help strong { margin-left:auto; padding:1px 5px; border-radius:5px; background:color-mix(in srgb,var(--muted) 10%,transparent); color:var(--text); font-size:10px; font-weight:600; font-variant-numeric:tabular-nums; }
@media(prefers-reduced-transparency:reduce) { .gallery-viewer-help { background:var(--surface-raised); backdrop-filter:none; -webkit-backdrop-filter:none; } }
.gallery-viewer-canvas img { cursor: zoom-out; }
.gallery-viewer-canvas.is-panning, .gallery-viewer-canvas.is-panning img { cursor: grabbing; user-select: none; }
.gallery-viewer-dialog.is-board-contained .gallery-viewer-canvas { padding-bottom: 44px; }

/* Create: the live moodboard sits above job history in one scrolling rail. */
#createSideRail { min-width: 0; min-height: 0; overflow: auto; margin: 8px 0 8px 12px; display: flex; flex-direction: column; gap: 12px; }
#createSideRail[hidden] { display: none; }
#createSideRail #generationJobsPanel { margin: 0; flex: 0 0 auto; }
#createMoodboardDock { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-raised); }
#createMoodboardDock .moodboard-header { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 0; }
#createMoodboardDock .moodboard-copy { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
#createMoodboardDock .moodboard-copy h2 { font-size: calc(13px + var(--app-font-increase, 1pt)); }
#createMoodboardDock .moodboard-copy > span { display: none; }
#createMoodboardDock .moodboard-tools { display: flex; flex-wrap: wrap; gap: 5px; }
#createMoodboardDock .moodboard-tools button, #createMoodboardDock .moodboard-tools label { padding: 5px 6px; font-size: calc(10px + var(--app-font-increase, 1pt)); }
#createMoodboardDock .moodboard-grid { margin-top: 10px; max-height: 300px; grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 6px; }
#createMoodboardDock .moodboard-empty { min-height: 120px; padding: 12px 0; }
#createMoodboardDock .board-empty-copy p { font-size: calc(11px + var(--app-font-increase, 1pt)); }
body[data-active-view="create"] .stage:where(.has-asset-rail):not(#createSideRail) { grid-template-columns: 260px minmax(0, 1fr); }
body[data-active-view="create"] .stage > #createSideRail { grid-column: 1; grid-row: 2 / 5; }
body[data-active-view="create"] .stage.has-contained-preview:not(#canvasPanel) > #createSideRail { display: none; }
body[data-active-view="create"] .stage.has-contained-preview:not(#canvasPanel) { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1099px) {
  body[data-active-view="create"] .stage:where(.has-asset-rail):not(#createSideRail) { grid-template-columns: minmax(0, 1fr); }
  body[data-active-view="create"] .stage > #createSideRail { grid-column: 1; grid-row: 2; max-height: 380px; margin: 8px 12px; }
}

/* A tall, uncluttered moodboard; history continues beneath it. */
#createMoodboardDock { display: flex; flex-direction: column; flex: 0 0 auto; height: max(380px, calc(100dvh - 230px)); }
#createMoodboardDock .moodboard-header { flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; flex: 0 0 auto; }
#createMoodboardDock .moodboard-copy { flex: 1; min-width: 0; }
#createMoodboardDock #clearMoodboardButton { flex: 0 0 auto; }
#createMoodboardDock .moodboard-grid { flex: 1 1 auto; min-height: 0; max-height: none; }
#createMoodboardDock .moodboard-empty { flex: 1 1 auto; }
.moodboard-header > #clearMoodboardButton { margin-left: auto; }

/* One stable options shell for every tab; only the active panel scrolls. */
#appOptionsDialog { box-sizing: border-box; width: min(1040px, calc(100vw - 32px)); height: min(880px, calc(100dvh - 48px)); max-height: calc(100dvh - 32px); overflow: hidden; grid-template-rows: auto auto minmax(0, 1fr); }
#appOptionsDialog > header { position: static; }
#appOptionsDialog > .options-tabs { position: static; grid-template-columns: repeat(5, minmax(0, 1fr)); }
#appOptionsDialog > .options-tab-panel { min-height: 0; height: 100%; box-sizing: border-box; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-gutter: stable; }
@media (max-width: 560px) {
  #appOptionsDialog { width: calc(100vw - 16px); height: calc(100dvh - 24px); max-height: calc(100dvh - 16px); }
  #appOptionsDialog > .options-tabs { padding: 6px; gap: 2px; }
  #appOptionsDialog > .options-tabs button { padding: 6px 3px; font-size: calc(11px + var(--app-font-increase, 1pt)); }
}

/* Reserve history space instead of pushing it below the viewport. */
body[data-active-view="create"] .stage > #createSideRail { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, min(360px, 40%)); height: calc(100dvh - 180px); max-height: 100%; overflow: hidden; box-sizing: border-box; }
#createSideRail #createMoodboardDock { height: auto; min-height: 0; overflow: hidden; background: transparent; border-color: transparent; box-shadow: none; }
#createSideRail #createMoodboardDock .moodboard-header, #createMoodboardDock .moodboard-empty { background: transparent; }
#createSideRail #generationJobsPanel { min-height: 0; overflow: auto; overscroll-behavior: contain; }
#createSideRail .generation-jobs-list { max-height: none; overflow: visible; }
body[data-active-view="create"] .stage.has-contained-preview:not(#canvasPanel) > #createSideRail { display: none; }
@media (max-width: 1099px) {
  body[data-active-view="create"] .stage > #createSideRail { max-height: 600px; height: calc(100dvh - 180px); }
}

/* Square, edge-to-edge moodboard thumbnails; the viewer keeps the original. */
.moodboard-card { aspect-ratio: 1 / 1 !important; }
.moodboard-image-wrap img { object-fit: cover; object-position: center; }
#createMoodboardDock .moodboard-grid { grid-auto-rows: auto !important; }
#createMoodboardDock .moodboard-card { width: 100%; height: auto; align-self: start; }

/* The main work board uses the same panel and thumbnail treatment as history. */
#createSideRail #createMoodboardDock { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-raised); color: var(--text); }
#createMoodboardDock .moodboard-header { min-height: 28px; margin-bottom: 6px; }
#createMoodboardDock .moodboard-copy h2 { margin: 0; font-size: calc(13px + var(--app-font-increase, 1pt)); font-weight: 650; line-height: 1.5; }
#createMoodboardDock .moodboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; grid-auto-rows: 124px !important; gap: 8px; margin-top: 12px; padding: 2px; scrollbar-gutter: auto; }
#createMoodboardDock .moodboard-card { height: 124px; aspect-ratio: auto !important; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-raised); box-shadow: none; }
#createMoodboardDock .moodboard-image-wrap { inset: 5px; border-radius: 5px; background: transparent; }
#createMoodboardDock .moodboard-image-wrap img { object-fit: contain; }
#createMoodboardDock .moodboard-card:hover { border-color: var(--accent-line); }

/* Share desktop width between assets and the photo preview as the window resizes. */
@media (min-width: 1100px) {
  body[data-active-view="create"] .stage:where(.has-asset-rail):not(#createSideRail) { grid-template-columns: minmax(240px, 0.38fr) minmax(0, 0.62fr); }
  body[data-active-view="create"] .stage.has-contained-preview:not(#canvasPanel) { grid-template-columns: minmax(0, 1fr); }
}
#createMoodboardDock .moodboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
#createSideRail .job-result-thumbnails { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Reveal image removal after a deliberate hover, never in the main work board. */
@media (hover: hover) {
  .moodboard-card .moodboard-remove,
  .workboard-card .workboard-remove { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 120ms ease, visibility 0s linear; }
  .moodboard-card:hover .moodboard-remove,
  .workboard-card:hover .workboard-remove { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 500ms; }
  .moodboard-card:has(:focus-visible) .moodboard-remove,
  .workboard-card:has(:focus-visible) .workboard-remove { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
}
#createMoodboardDock .moodboard-remove { display: none !important; }

.main-board-clear-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
#undoBoardClearButton { display: none; }
#createMoodboardDock #undoBoardClearButton { display: grid; }

#createMoodboardDock .moodboard-selection-check { display: none; }
#createMoodboardDock .moodboard-card.is-selected { border-color: var(--line); }

#createMoodboardDock .main-board-clear-actions { display: none; }
.moodboard-panel #undoBoardClearButton { display: grid; }

/* Typography details expand only while this role has an attached photo. */
.composer-fields .reference-role-card[data-reference-role="typography"] { padding-bottom: 12px; }
.composer-fields .reference-role-card[data-reference-role="typography"].has-reference { grid-column: 1 / -1; }
.reference-role-card[data-reference-role="typography"]:not(.has-reference) .basic-copy-options { display: none; }
#resetTypographyTextButton { position: absolute; top: 6px; right: 34px; z-index: 2; }
.reference-role-card[data-reference-role="typography"]:not(.has-reference) #resetTypographyTextButton { display: none; }
.composer-fields .reference-role-card[data-reference-role="typography"] .reference-role-picker { min-height: 76px; }
.composer-fields .reference-role-card[data-reference-role="typography"] .basic-copy-options { margin: 0 12px; padding: 0; border: 0; }
.reference-role-card[data-reference-role="typography"] .basic-copy-options > summary { display: none; }
.reference-role-card[data-reference-role="typography"] .prompt-preset-detail { margin: 0; padding: 0; border: 0; }
.reference-role-card[data-reference-role="typography"] textarea { width: 100%; min-height: 58px; resize: none; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--composer-card-solid); color: var(--text); font: inherit; }
.typography-layout-options { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; font-size: calc(11px + var(--app-font-increase, 1pt)); color: var(--muted); }
.typography-layout-options label { display: flex; align-items: center; gap: 5px; }
.typography-layout-options input { accent-color: var(--accent); }

/* Compact generation controls in the prompt footer. */
.prompt-field .prompt-field-header { display: flex; flex-wrap: wrap; gap: 4px; }
.prompt-field .prompt-field-actions { gap: 3px; flex: 0 1 auto; min-width: 0; }
.prompt-field .prompt-quality-select { width: 83px; padding-left: 4px; padding-right: 18px; font-size: calc(11px + var(--app-font-increase, 1pt)); }
.prompt-field #promptCountControl { display: flex; align-items: center; padding: 2px; border: 1px solid var(--line); border-radius: 8px; }
.prompt-field #promptCountControl[hidden] { display: none; }
.prompt-field .prompt-count-grid { display: flex; gap: 1px; padding: 0; border: 0; background: transparent; }
.prompt-field .prompt-count-grid .count-button { width: 23px; min-width: 23px; min-height: 27px; padding: 0; border: 0; border-radius: 5px; font-size: calc(11px + var(--app-font-increase, 1pt)); }
.prompt-field .candidate-variation-inline { margin-left: 3px; padding-left: 3px; border-left: 1px solid var(--line); }
.prompt-field .candidate-variation-toggle { min-width: 57px; height: 27px; padding: 0 5px; border: 0; border-radius: 5px; font-size: calc(11px + var(--app-font-increase, 1pt)); }
.prompt-field .prompt-character-count { flex-basis: 100%; text-align: right; margin-top: 2px; }

/* Server job state is shown as plain text on a still background. */
.generation-activity { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; padding: 32px 16px; border-radius: inherit; background: var(--composer-card-solid); pointer-events: auto; overflow: hidden; }
.generation-activity[hidden] { display: none; }
.generation-activity strong { position: relative; z-index: 1; padding: 7px 14px; border-radius: 20px; background: var(--composer-card-solid); font-size: calc(14px + var(--app-font-increase, 1pt)); color: var(--text); }
.generation-activity small { position: relative; z-index: 1; padding: 4px 10px; border-radius: 12px; background: var(--composer-card-solid); font-size: calc(11px + var(--app-font-increase, 1pt)); color: var(--muted); }
.has-generation-activity #generationQueue { display: none; }

/* Stack main and supporting copy in full-width rows. */
.reference-role-card[data-reference-role="typography"] #promptPresetDetailField { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px 10px; }
.reference-role-card[data-reference-role="typography"] #posterCopySecondary { display: contents; }
.reference-role-card[data-reference-role="typography"] label[for="promptPresetDetail"] { grid-column: 1; grid-row: 1; }
.reference-role-card[data-reference-role="typography"] label[for="posterSubCopy"] { grid-column: 1; grid-row: 3; }
.reference-role-card[data-reference-role="typography"] #promptPresetDetail { grid-column: 1; grid-row: 2; }
.reference-role-card[data-reference-role="typography"] #posterSubCopy { grid-column: 1; grid-row: 4; }
.reference-role-card[data-reference-role="typography"] #posterDetailsToggle { grid-column: 1 / -1; grid-row: 6; justify-self: start; margin-top: 2px; }
.reference-role-card[data-reference-role="typography"] #posterDetailsField { grid-column: 1 / -1; grid-row: 7; }
.reference-role-card[data-reference-role="typography"] .typography-copy-help { grid-column: 1 / -1; grid-row: 5; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.reference-role-card[data-reference-role="typography"] #promptPresetDetailField > label,
.reference-role-card[data-reference-role="typography"] #posterCopySecondary > label { display: block; margin: 0; font-size: calc(12px + var(--app-font-increase, 1pt)); }
.reference-role-card[data-reference-role="typography"] #promptPresetDetailField label small { display: block; margin-top: 3px; font-size: calc(10px + var(--app-font-increase, 1pt)); }
.reference-role-card[data-reference-role="typography"] #promptPresetDetail,
.reference-role-card[data-reference-role="typography"] #posterSubCopy { min-width: 0; height: 76px; margin: 0; }

.has-generation-activity:not(.has-generation-result) #canvasImageLink { visibility: hidden; pointer-events: none; }
.has-generation-activity #canvasEmpty { visibility: hidden; }

/* Reference cards share a compact tile until their inline detail fields open. */
.composer-fields .reference-role-grid { align-items: start; }
.composer-fields .reference-role-grid > .reference-role-card {
  grid-column: auto; aspect-ratio: 1.2; min-height: 140px;
  padding-bottom: 34px; box-sizing: border-box;
}
.composer-fields .reference-role-grid > .reference-role-card .reference-role-picker {
  min-height: 96px; padding-right: 10px;
}
.composer-fields .reference-role-grid > .reference-role-custom .custom-reference-heading {
  display: block; padding-right: 0;
}
.composer-fields .reference-role-grid > .reference-role-custom .custom-reference-refine {
  position: absolute; right: 9px; bottom: 9px;
}
.composer-fields .reference-role-grid > .reference-role-card[data-reference-role="background"] .background-color-picker {
  right: 9px; bottom: 9px;
}
.composer-fields .reference-role-grid > .reference-role-card[data-reference-role="typography"].has-reference,
.composer-fields .reference-role-grid > .reference-role-custom:has(.custom-reference-fields:not([hidden])) {
  grid-column: 1 / -1; aspect-ratio: auto; min-height: 0; padding-bottom: 12px;
}
.composer-fields .reference-role-grid > .reference-role-custom:has(.custom-reference-fields:not([hidden])) .custom-reference-heading {
  display: flex; padding-right: 40px;
}
.composer-fields .reference-role-grid > .reference-role-custom:has(.custom-reference-fields:not([hidden])) .custom-reference-refine {
  position: static;
}

.has-generation-result .generation-activity { inset: auto 12px 12px auto; padding: 8px 12px; border-radius: 12px; pointer-events: none; }
.has-generation-activity:not(.has-generation-result) #previewHideButton { visibility: hidden; }

.moodboard-copy > .asset-sync-label { display: none; }
#createMoodboardDock .moodboard-copy > .asset-sync-label { display: inline-flex; align-items: center; gap: 5px; font-size: calc(11px + var(--app-font-increase, 1pt)); color: var(--muted); font-weight: 400; }
#createMoodboardDock .asset-sync-icon { width: 14px; height: 14px; flex: 0 0 14px; }

@media (min-width: 1100px) {
  body[data-active-view="create"] #canvasPanel:not(.has-contained-viewer) {
    align-self: start;
    grid-template-rows: auto var(--asset-preview-height, minmax(0, 1fr)) auto;
  }
  body[data-active-view="create"] #canvasPanel:not(.has-contained-viewer) #canvasSurface {
    height: var(--asset-preview-height, auto);
  }
  body[data-active-view="create"] #canvasPanel:not(.has-contained-viewer) .canvas-image-link {
    padding-block: 0;
  }
}

/* Library: one horizontal strip of square assets for each reference role. */
body[data-active-view="moodboard"] #moodboardPanel {
  grid-template-rows: auto minmax(0, 1fr); gap: 14px;
}
#moodboardGrid.is-reference-library {
  display: flex; flex-direction: column; grid-row: 2; gap: 14px;
  padding: 0 4px 12px 0; overflow: auto; contain: none;
}
.reference-library-section {
  flex: 0 0 auto; min-width: 0; padding: 14px; border: 1px solid var(--line);
  border-radius: 16px; background: var(--surface-raised);
}
.reference-library-section > header { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; flex-wrap: wrap; }
.reference-library-section.is-drop-target { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: -2px; background: color-mix(in srgb, var(--accent) 8%, var(--surface-raised)); }
.reference-library-section h3 { margin: 0; font-size: calc(14px + var(--app-font-increase, 1pt)); color: var(--text); }
.reference-library-section header > span { font-size: calc(11px + var(--app-font-increase, 1pt)); color: var(--muted); }
.reference-library-actions { margin-left: auto; display: flex; gap: 6px; }
.reference-library-actions button { border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; background: var(--composer-card-solid); color: var(--text); font: inherit; font-size: calc(11px + var(--app-font-increase, 1pt)); cursor: pointer; }
.reference-library-actions button:disabled { opacity: .4; cursor: default; }
.reference-library-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.reference-library-row { display: grid; grid-auto-flow: column; grid-auto-columns: 160px; grid-template-rows: 160px; gap: 10px; overflow-x: auto; overflow-y: hidden; padding-bottom: 6px; align-content: start; justify-content: start; }
.reference-library-row .moodboard-card { width: 160px; height: 160px; aspect-ratio: 1; }
.reference-library-row .moodboard-image-wrap img { object-fit: cover; }
.reference-library-empty { display: grid; place-items: center; width: 260px; max-width: 100%; height: 160px; margin: 0; padding: 12px; box-sizing: border-box; font-size: calc(12px + var(--app-font-increase, 1pt)); color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }

#workboardPanel { display: none !important; }

body[data-active-view="moodboard"] #moodboardPanel { grid-template-columns: minmax(0, 1fr); }
body[data-active-view="moodboard"] #moodboardPanel > .moodboard-header { grid-row: 1; grid-column: 1; }
#moodboardGrid.is-reference-library { grid-column: 1; }

.reference-selection-delete { padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-raised); color: var(--danger, #d94151); font: inherit; font-size: calc(11px + var(--app-font-increase, 1pt)); cursor: pointer; }
.reference-selection-delete:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.reference-selection-delete:disabled { opacity: .4; cursor: default; }

/* Every image removal X uses the same upper-left anchor. */
.reference-role-thumbnail-remove { left: 1px; right: auto; }
.reference-preview-remove { left: 3px; right: auto; }
.reference-role-remove { left: 6px; right: auto; }
.workboard-remove { left: 4px; right: auto; }
.moodboard-import-cancel { left: 5px; right: auto; }
.moodboard-card-actions { left: 8px; right: auto; }
.moodboard-card .moodboard-selection-check,
.workboard-card .moodboard-selection-check { left: auto; right: 10px; }
/* Dialog X controls lead the header without overlapping its title. */
.app-options-dialog > header,
.generation-instructions-dialog > header,
.reference-preview-dialog > header { justify-content: flex-start; }
.app-options-dialog > header > button,
.generation-instructions-dialog > header > button,
.reference-preview-dialog > header > button { order: -1; flex-shrink: 0; align-self: flex-start; }
.gallery-viewer-chrome .gallery-viewer-close { grid-column: 1; grid-row: 1; justify-self: start; }
.background-color-heading .background-color-dismiss { order: -1; flex-shrink: 0; }
.background-color-popover .background-color-heading { justify-content: flex-start; }
.reference-region-editor .reference-region-header { justify-content: flex-start; }
.reference-region-header > [data-close] { order: -1; flex-shrink: 0; align-self: flex-start; }

/* Align the preview's actual edges, not just its height, with the asset pane. */
@media (min-width: 1100px) {
  body[data-active-view="create"] .stage > #canvasPanel:not(.has-contained-viewer) {
    position: relative; grid-column: 2; grid-row: 2 / 5; align-self: start;
    margin: 8px 16px 0; padding: 0;
    grid-template-rows: var(--asset-preview-height, minmax(0, 1fr)) auto;
  }
  body[data-active-view="create"] #canvasPanel:not(.has-contained-viewer) > .canvas-toolbar {
    position: absolute; top: 8px; right: 8px; z-index: 6;
    min-height: 0; padding: 0; max-width: calc(100% - 64px);
  }
  body[data-active-view="create"] #canvasPanel:not(.has-contained-viewer) #canvasSurface {
    grid-row: 1; padding-block: 0; border-radius: 14px;
  }
  body[data-active-view="create"] #canvasPanel:not(.has-contained-viewer) #previewNavigation { grid-row: 2; }
  body[data-active-view="create"] .stage:not(.has-contained-board) > #completedResultsButton {
    grid-column: 2; grid-row: 2; z-index: 7; margin: 48px 24px 0;
  }
}

#createSideRail #generationJobsPanel { box-sizing: border-box; padding-bottom: 18px; scroll-padding-bottom: 18px; }

/* The three empty asset sections share a short rail. Keep each label readable
   and let the existing library scroller reveal the rest instead of clipping
   vertically when a user has reduced the asset pane. */
#createSideRail #moodboardGrid.is-reference-library { gap: 7px; min-height: 0; overflow-y: auto; }
#createSideRail .reference-library-section { padding: 8px; border-radius: 10px; }
#createSideRail .reference-library-section > header { margin-bottom: 6px; gap: 6px; }
#createSideRail .reference-library-section h3 { font-size: calc(12px + var(--app-font-increase, 1pt)); }
#createSideRail .reference-library-section header > span { font-size: calc(10px + var(--app-font-increase, 1pt)); }
#createSideRail .reference-library-row,
#createSideRail .reference-library-row.is-empty { grid-template-rows: 72px; min-height: 72px; padding-bottom: 0; }
#createSideRail .reference-library-row .reference-library-empty { height: 72px; min-height: 72px; padding: 5px 8px; gap: 2px; overflow: visible; }
#createSideRail .reference-empty-icon { width: 20px; height: 20px; margin: 0; border-radius: 7px; }
#createSideRail .reference-empty-icon svg { width: 14px; height: 14px; }
#createSideRail .reference-library-empty strong { font-size: calc(11px + var(--app-font-increase, 1pt)); line-height: 1.25; }
#createSideRail .reference-library-empty > span:last-child { font-size: calc(10px + var(--app-font-increase, 1pt)); line-height: 1.25; }

.reference-library-row.is-empty { display: flex; align-items: center; justify-content: center; min-height: 160px; }
.reference-library-row .reference-library-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; width: 100%; max-width: none; height: 160px; margin: 0; padding: 12px; border: 0; text-align: center; }
.reference-empty-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 3px; border-radius: 13px; color: var(--accent); background: var(--accent-faint); }
.reference-empty-icon svg { width: 24px; height: 24px; }
.reference-library-empty strong { font-size: calc(13px + var(--app-font-increase, 1pt)); font-weight: 600; color: var(--text); }
.reference-library-empty > span:last-child { font-size: calc(12px + var(--app-font-increase, 1pt)); line-height: 1.5; color: var(--muted); }

.reference-library-row { min-width: 0; max-width: 100%; scrollbar-width: thin; scrollbar-color: var(--scroll-thumb, #a4aab5) transparent; padding-bottom: 10px; }
.reference-library-row::-webkit-scrollbar { height: 8px; }
.reference-library-row::-webkit-scrollbar-track { background: var(--surface-subtle); border-radius: 8px; }
.reference-library-row::-webkit-scrollbar-thumb { background: var(--scroll-thumb, #a4aab5); border-radius: 8px; border: 0; }

@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/fonts/InterVariable.woff2") format("woff2");
}
.app-brand-tagline { font-family: "Inter", sans-serif; font-weight: 500; font-size: calc(20px + var(--app-font-increase, 1pt)); line-height: 1.25; letter-spacing: -0.035em; color: var(--text); margin-left: 10px; }
@media (max-width: 700px) {
  .app-brand-tagline { max-width: 135px; margin-left: 2px; font-size: calc(16px + var(--app-font-increase, 1pt)); }
  .app-topbar .app-brand { flex-shrink: 1; gap: 6px; }
}
@media (max-width: 480px) {
  .app-topbar { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; }
  .app-topbar .app-topbar-actions { grid-column: 1; grid-row: 2; }
  .app-brand-tagline { max-width: none; }
}

/* Use the full right-hand height and anchor thumbnail navigation at its foot. */
@media (min-width: 1100px) {
  body[data-active-view="create"] .stage > #canvasPanel:not(.has-contained-viewer) {
    height: var(--create-preview-height, calc(100dvh - 200px));
    box-sizing: border-box; grid-template-rows: minmax(0, 1fr) auto;
  }
  body[data-active-view="create"] #canvasPanel:not(.has-contained-viewer) #canvasSurface {
    height: auto; min-height: 0; align-self: stretch;
  }
  body[data-active-view="create"] #canvasPanel:not(.has-contained-viewer) #previewNavigation {
    align-self: end; min-height: 0; margin-bottom: 0;
  }
}

.prompt-field #generationInstructionsButton { display: none; }
.prompt-field #promptRatioControl { flex: 0 0 68px; margin-left: 3px; }
.prompt-field #promptRatioControl[hidden] { display: none; }
#promptRatioControl .ratio-picker-trigger { height: 31px; padding: 0 6px; gap: 5px; border-radius: 8px; font-size: calc(11px + var(--app-font-increase, 1pt)); }
#promptRatioControl .ratio-picker-shape { display: none; }
#promptRatioControl .ratio-picker-chevron { margin-left: auto; }
.prompt-field .prompt-field-actions { flex-wrap: wrap; }

/* Primary creation mode and secondary editing mode, with a clear active state. */
.prompt-field .prompt-preset-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 10px 12px 6px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-subtle); }
.prompt-field .prompt-preset-button { min-height: 38px; border: 1px solid transparent; border-radius: 8px; gap: 7px; color: var(--muted); }
.prompt-field .prompt-preset-button .prompt-preset-visual { display: flex; }
.prompt-field .prompt-preset-button[aria-selected="true"] { border: 1px solid var(--accent-line); background: var(--accent-faint); color: var(--accent); box-shadow: 0 1px 3px rgb(0 0 0 / 6%); }
.prompt-field .prompt-preset-button[aria-selected="true"]::after { display: none; }
.prompt-field .prompt-preset-button[aria-selected="true"] .prompt-preset-label { font-weight: 700; }
.prompt-field .prompt-preset-button[aria-selected="false"] .prompt-preset-label { font-weight: 500; }

/* Keep mode navigation in the same place while only the body scrolls. */
.composer-panel .composer-mode-header {
  flex: 0 0 auto;
  margin: 12px 18px 0;
  padding: 0;
  min-height: 0;
}
.composer-mode-header .prompt-preset-list { margin: 6px; }

#moodboardGrid.is-reference-library {
  display: grid; height: 100%; box-sizing: border-box; min-height: 0;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: var(--library-row-0, 180px) 12px var(--library-row-1, 180px) 12px var(--library-row-2, 180px) 12px var(--library-row-3, 180px) 12px var(--library-row-4, 180px);
  grid-auto-rows: auto !important; gap: 0; overflow: hidden; padding-bottom: 0;
}
.is-reference-library > .reference-library-section { display: flex; flex-direction: column; min-height: 0; box-sizing: border-box; overflow: hidden; }
.is-reference-library .reference-library-section > header { flex: 0 0 auto; margin-bottom: 8px; }
.is-reference-library .reference-library-row { flex: 1 1 auto; min-height: 0; grid-auto-columns: var(--library-tile-size, 160px); grid-template-rows: var(--library-tile-size, 160px); }
.is-reference-library .reference-library-row .moodboard-card { width: var(--library-tile-size, 160px); height: var(--library-tile-size, 160px); }
.is-reference-library .reference-library-row.is-empty { min-height: 0; }
.is-reference-library .reference-library-empty { height: 100%; min-height: 0; padding: 4px; }
.library-splitter { position: relative; min-width: 0; cursor: row-resize; touch-action: none; border-radius: 6px; }
.library-splitter::after { content: ""; position: absolute; top: 4px; left: calc(50% - 16px); width: 32px; height: 3px; border-radius: 3px; background: #a4aab5; }
.is-resizing-sections, .is-resizing-sections * { cursor: row-resize !important; user-select: none; }

/* Privacy stays inside the rendered image; surrounding canvas remains clear. */
.canvas-image-link.is-privacy-obscured { background: transparent; }
.canvas-image-link.is-privacy-obscured img {
  opacity: 1; transform: none;
  filter: blur(11px) brightness(0.3) saturate(0.68);
  clip-path: inset(0 round 16px);
}

/* Quiet brand masthead: compact mark, editorial phrase, separate utilities. */
.app-topbar { padding: 10px 18px; border-radius: 18px; border-color: var(--line); background: linear-gradient(110deg, var(--composer-card-solid) 65%, var(--accent-faint)); box-shadow: 0 2px 8px rgb(0 0 0 / 2%); }
.app-topbar .app-brand { gap: 20px; }
.app-topbar .app-brand-logo { width: 32px; height: 38px; border-radius: 6px; }
.app-topbar .app-brand-tagline { display: flex; align-items: center; flex-wrap: wrap; column-gap: 7px; margin-left: 0; padding-left: 20px; border-left: 1px solid var(--line); font-size: calc(21px + var(--app-font-increase, 1pt)); font-weight: 500; line-height: 1.35; letter-spacing: -0.045em; color: var(--muted); }
.brand-drag-phrase { display: inline-flex; align-items: center; gap: 9px; color: var(--accent); }
.brand-drag-phrase svg { width: 19px; height: 19px; flex: 0 0 auto; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.app-topbar .app-topbar-actions { gap: 9px; padding-left: 16px; border-left: 1px solid var(--line); }
.app-topbar .topbar-engine .model-select { border-color: transparent; background: transparent; font-size: calc(11px + var(--app-font-increase, 1pt)); }
@media (max-width: 900px) {
  .app-topbar .app-brand { gap: 12px; }
  .app-topbar .app-brand-tagline { padding-left: 12px; font-size: calc(18px + var(--app-font-increase, 1pt)); }
  .app-topbar .app-topbar-actions { padding-left: 8px; }
}
@media (max-width: 700px) {
  .app-topbar .app-brand-tagline { max-width: 150px; font-size: calc(16px + var(--app-font-increase, 1pt)); }
  .brand-drag-phrase svg { width: 15px; height: 15px; }
}
@media (max-width: 480px) {
  .app-topbar { padding: 10px 12px; }
  .app-topbar .app-brand-tagline { max-width: none; font-size: calc(18px + var(--app-font-increase, 1pt)); }
  .app-topbar .app-topbar-actions { border-left: 0; padding-left: 0; padding-top: 6px; }
}

/* Compact single-row generation controls; preserve the existing font sizes. */
.prompt-field .prompt-field-actions { flex-wrap: nowrap; gap: 4px; }
.compact-quality-control { position: relative; display: inline-flex; flex: 0 0 54px; }
.prompt-field .compact-quality-control .prompt-quality-select { width: 54px; padding-left: 3px; padding-right: 15px; color: transparent; }
.compact-quality-label { position: absolute; left: 3px; top: 50%; transform: translateY(-50%); pointer-events: none; font-size: calc(11px + var(--app-font-increase, 1pt)); color: var(--muted); }
.compact-quality-label::after { content: "최고"; }
.compact-quality-control:has(option[value="medium"]:checked) .compact-quality-label::after { content: "균형"; }
.compact-quality-control:has(option[value="low"]:checked) .compact-quality-label::after { content: "빠르게"; }
.prompt-field .prompt-quality-select option { color: var(--text); }
.prompt-field #promptCountControl { flex: 0 0 auto; padding: 1px; }
.prompt-field .prompt-count-grid { gap: 0; }
.prompt-field .prompt-count-grid .count-button { width: 21px; min-width: 21px; }
.prompt-field .candidate-variation-inline { margin-left: 2px; padding-left: 2px; }
.prompt-field .candidate-variation-toggle { min-width: 53px; padding-inline: 3px; }
.prompt-field #promptRatioControl { flex: 0 0 58px; margin-left: 0; }
#promptRatioControl .ratio-picker-trigger { height: 31px; padding-inline: 5px; gap: 3px; }
.ratio-picker-custom { border-top: 1px solid var(--line); margin-top: 4px; }

/* All library roles share square tiles and independent vertical scrolling. */
.is-reference-library .reference-library-row {
  grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 240px));
  grid-auto-columns: auto; grid-template-rows: none; grid-auto-rows: max-content;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain;
  scrollbar-gutter: stable; padding: 0 4px 10px 0; align-content: start;
}
.is-reference-library .reference-library-row .moodboard-card { width: 100%; height: auto; aspect-ratio: 1; }
.reference-library-row::-webkit-scrollbar { width: 8px; }

/* Compact asset sections reuse the library classification and live image objects. */
#createMoodboardDock #moodboardGrid.is-asset-sections {
  display: grid; grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: repeat(4, minmax(0, 1fr)); grid-auto-rows: auto;
  height: 100%; min-height: 0; overflow: hidden; gap: 8px; padding: 0;
}
#createMoodboardDock .reference-library-section { display: flex; flex-direction: column; min-height: 0; padding: 8px; border-radius: 10px; overflow: hidden; }
#createMoodboardDock .reference-library-section > header { flex: 0 0 auto; margin-bottom: 6px; gap: 6px; }
#createMoodboardDock .reference-library-section h3 { font-size: calc(12px + var(--app-font-increase, 1pt)); }
#createMoodboardDock .reference-library-row { display: grid; flex: 1 1 auto; min-height: 0; grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0,1fr)); grid-auto-columns: auto; grid-template-rows: none; grid-auto-rows: max-content; gap: 6px; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-gutter: stable; padding: 0 2px 4px 0; }
#createMoodboardDock .reference-library-row .moodboard-card { width: 100%; height: auto; min-height: 0; aspect-ratio: 1; }
#createMoodboardDock .reference-library-row .moodboard-image-wrap { height: 100%; min-height: 0; }
#createMoodboardDock .reference-library-row.is-empty { display: flex; }
#createMoodboardDock .reference-library-empty { min-height: 150px; height: 100%; gap: 7px; padding: 16px 12px; }
#createMoodboardDock .reference-empty-icon { display: grid; flex-shrink: 0; width: 44px; height: 44px; margin-bottom: 3px; border-radius: 13px; }
#createMoodboardDock .reference-empty-icon svg { width: 24px; height: 24px; }
#createMoodboardDock .reference-library-empty strong { font-size: calc(13px + var(--app-font-increase, 1pt)); line-height: 1.5; }
#createMoodboardDock .reference-library-empty > span:last-child { font-size: calc(12px + var(--app-font-increase, 1pt)); line-height: 1.5; text-wrap: pretty; }
#createMoodboardDock .reference-library-section > header { flex-wrap: wrap; }

/* Empty reference cards keep room for labels and bottom controls without square-tile whitespace. */
.composer-fields .reference-role-grid > .reference-role-card:not(.has-reference):not(:has(.custom-reference-fields:not([hidden]))) {
  aspect-ratio: auto; min-height: 114px; padding-bottom: 36px;
}
.composer-fields .reference-role-grid > .reference-role-card:not(.has-reference):not(:has(.custom-reference-fields:not([hidden]))) .reference-role-picker {
  min-height: 76px; padding-top: 16px; padding-bottom: 6px;
}

#moodboardGrid.is-reference-library { overflow-y: auto; }
.is-reference-library .reference-library-row { grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--library-adaptive-tile, 240px)), var(--library-adaptive-tile, 240px))); }

/* Give the main prompt more vertical reading room. */
.prompt-field #prompt { min-height: 120px; height: 120px; }

/* Override the old dock aspect-ratio reset so empty intrinsic content cannot collapse tiles. */
#createMoodboardDock .reference-library-row .moodboard-card { aspect-ratio: 1 / 1 !important; }
#createMoodboardDock .reference-library-row .moodboard-image-wrap { height: auto; inset: 5px; }

/* Keep compact drop targets above the preview instead of sharing its grid cell. */
@media (max-width: 1099px) {
  body[data-active-view="create"] .stage:where(.has-asset-rail):not(#createSideRail):not(.has-contained-preview):not(#canvasPanel) {
    grid-template-rows: auto max(760px, 85dvh) minmax(440px, 1fr); overflow-y: auto;
  }
  body[data-active-view="create"] .stage > #createSideRail { height: auto; max-height: none; align-self: stretch; grid-template-rows: minmax(0, 1fr) minmax(0, 180px); }
  #createMoodboardDock .reference-library-row { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  body[data-active-view="create"] .stage > #canvasPanel:not(.has-contained-viewer) { grid-column: 1; grid-row: 3; }
}

/* Keep the selected ratio shape visible in the compact control. */
#promptRatioControl .ratio-picker-shape { display: block; width: 15px; height: 15px; flex: 0 0 15px; }
.prompt-field #promptRatioControl { flex-basis: 76px; }

/* Attaching images alone must not resize reference cards. */
.composer-fields .reference-role-grid > .reference-role-card:not([data-reference-role="typography"].has-reference):not(:has(.custom-reference-fields:not([hidden]))) {
  aspect-ratio: auto; height: 120px; min-height: 120px; min-width: 0; padding-bottom: 43px;
}
.composer-fields .reference-role-grid > .reference-role-card:not([data-reference-role="typography"].has-reference):not(:has(.custom-reference-fields:not([hidden]))) .reference-role-picker {
  min-height: 64px; height: 64px; box-sizing: border-box; padding: 12px 10px 0; align-items: start;
}
.composer-fields .reference-role-grid > .reference-role-card .reference-role-copy { align-self: start; padding-top: 0; }
.composer-fields .reference-role-grid > .reference-role-card .reference-role-copy strong { display: block; min-height: 16px; line-height: 16px; }
.composer-fields .reference-role-grid > .reference-role-card .reference-role-visual { align-self: start; }
.composer-fields .reference-role-grid > .reference-role-card.has-reference:not([data-reference-role="typography"]):not(:has(.custom-reference-fields:not([hidden]))) .reference-role-picker {
  min-height: 64px; height: 64px; box-sizing: border-box; padding: 12px 10px 0; grid-template-columns: 36px minmax(0,1fr); grid-template-rows: auto; gap: 8px;
}
.composer-fields .reference-role-grid > .reference-role-card.has-reference:not([data-reference-role="typography"]):not(:has(.custom-reference-fields:not([hidden]))) .reference-role-action { position: absolute; left: 54px; bottom: 12px; top: auto; right: auto; }
.composer-fields .reference-role-grid > .has-multiple-references:not(:has(.custom-reference-fields:not([hidden]))) .reference-role-visual { grid-column: 1; grid-row: 1; width: 36px; height: 38px; overflow-x: auto; gap: 3px; }
.composer-fields .reference-role-grid > .has-multiple-references:not(:has(.custom-reference-fields:not([hidden]))) .reference-role-copy { grid-column: 2; grid-row: 1; }

/* Additional attachments sit beside the count, with individual preview and removal. */
.composer-fields .reference-count-thumbnails { position: absolute; left: 98px; right: 38px; bottom: 9px; height: 33px; display: flex; gap: 3px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.composer-fields .reference-count-thumbnails .reference-role-thumbnail { width: 30px; height: 33px; flex: 0 0 30px; border-radius: 4px; overflow: hidden; }
.composer-fields .reference-count-thumbnails .reference-role-image { width: 100%; height: 100%; object-fit: cover; }
.composer-fields .reference-count-thumbnails .reference-role-thumbnail-remove { width: 12px; height: 12px; font-size: calc(10px + var(--app-font-increase, 1pt)); line-height: 12px; padding: 0; }

.composer-fields .reference-count-thumbnails .reference-role-thumbnail-remove { width: 8px; height: 8px; font-size: calc(8px + var(--app-font-increase, 1pt)); line-height: 8px; }

/* Four results share one compact history row. */
.generation-jobs-panel .job-result-thumbnails, #createSideRail .job-result-thumbnails { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }

/* Frosted toolbar with a repeating fill: activity, not a measured percentage. */
.app-topbar {
  position: relative; isolation: isolate; overflow: hidden;
  background: linear-gradient(120deg, color-mix(in srgb, var(--composer-card-solid) 88%, transparent), color-mix(in srgb, var(--composer-card-solid) 65%, transparent));
  backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 55%), 0 5px 22px rgb(32 60 100 / 5%);
}
.app-topbar > .app-brand, .app-topbar > .app-topbar-actions { position: relative; z-index: 1; }
@media (max-width: 900px) { .app-topbar { position: sticky; } }
.topbar-generation-progress { position: absolute; inset: 0; z-index: 0; overflow: hidden; border-radius: inherit; pointer-events: none; background: rgb(87 166 255 / 5%); }
.topbar-generation-progress[hidden] { display: none; }
.topbar-generation-fill {
  position: absolute; inset: 0; transform-origin: left center;
  background: linear-gradient(100deg, rgb(79 173 255 / 16%), rgb(89 204 247 / 26%) 52%, rgb(149 169 255 / 32%) 87%, rgb(225 247 255 / 62%));
  border-right: 1px solid rgb(255 255 255 / 70%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 60%), inset 0 -1px 0 rgb(101 175 255 / 18%), 6px 0 22px rgb(98 187 255 / 25%);
  animation: topbar-generation-fill 8s cubic-bezier(.22, .55, .35, 1) infinite;
}
.app-topbar[data-generation-status="queued"] .topbar-generation-fill { animation-duration: 12s; }
.app-topbar[data-generation-status="stopping"] .topbar-generation-fill { animation-play-state: paused; }
:root[data-theme="dark"] .app-topbar { box-shadow: inset 0 1px 0 rgb(255 255 255 / 12%), 0 5px 22px rgb(0 0 0 / 14%); }
:root[data-theme="dark"] .topbar-generation-fill { opacity: .75; }
@keyframes topbar-generation-fill {
  0% { transform: scaleX(0); opacity: .4; }
  12% { opacity: 1; }
  88% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .topbar-generation-fill { animation: none; transform: scaleX(1); opacity: .5; }
}
.generation-jobs-panel .job-result-thumbnails .job-result-select { height: auto; min-width: 0; aspect-ratio: 1; padding: 4px; overflow: hidden; }

/* Reserve the pose button area; fit all three reference thumbnails beside the count. */
.composer-fields .reference-role-grid > .reference-role-card.has-multiple-references .reference-role-action { left: 10px !important; }
.composer-fields .reference-count-thumbnails { left: 54px; right: 42px; gap: 3px; }

/* The compiled request stays separate from the persisted scene input. */
.applied-prompt-panel { margin: 4px 12px 8px; min-width: 0; padding: 10px 0 8px; border-bottom: 1px solid var(--line); }
.applied-prompt-heading { display: flex; align-items: center; gap: 7px; min-width: 0; }
.applied-prompt-heading label { margin-right: auto; color: var(--text); font-size: calc(12px + var(--app-font-increase, 1pt)); font-weight: 600; }
.applied-prompt-heading select, .applied-prompt-heading button { flex: 0 0 auto; width: auto; min-height: 27px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); }
.applied-prompt-heading select[hidden] { display: none; }
#appliedPromptContent[hidden] { display: none; }
.applied-prompt-tools { display: flex; justify-content: flex-end; align-items: center; gap: 7px; margin-top: 8px; }
.applied-prompt-tools select, .applied-prompt-tools button { min-height: 27px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); }
#appliedPromptToggle { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 5px; cursor: pointer; }
#appliedPromptToggle svg { width: 18px; height: 18px; }
#appliedPromptToggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#appliedPromptToggle .applied-prompt-eye-slash { display: none; }
#appliedPromptToggle[aria-expanded="true"] { color: var(--accent); border-color: var(--accent-line); }
#appliedPromptToggle[aria-expanded="true"] .applied-prompt-eye-slash { display: block; }
.prompt-field #appliedPrompt { display: block; width: 100%; height: 240px; min-height: 160px; max-height: 65vh; margin-top: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-subtle); font: inherit; font-size: calc(13px + var(--app-font-increase, 1pt)); line-height: 1.7; overflow: auto; overflow-wrap: anywhere; resize: vertical; }
.applied-prompt-panel[data-state="idle"] #appliedPrompt { height: 54px; min-height: 54px; resize: none; }
.prompt-field #appliedPrompt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#appliedPromptStatus { margin: 6px 0 0; color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); line-height: 1.5; overflow-wrap: anywhere; }
.applied-prompt-panel[data-state="error"] #appliedPromptStatus { color: var(--danger); }
.composition-assistant { margin: 4px 12px 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.composition-assistant-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; min-width: 0; }
.composition-assistant-heading strong { grid-column: 1 / -1; white-space: nowrap; font-size: calc(12px + var(--app-font-increase, 1pt)); }
.composition-assistant select, .composition-assistant button { min-height: 28px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit; font-size: calc(12px + var(--app-font-increase, 1pt)); padding: 3px 7px; }
.composition-assistant select { min-width: 0; width: 100%; }
.composition-assistant button { flex: none; white-space: nowrap; }
#prepareCompositionButton { background: var(--surface-raised); border-color: var(--accent-line); color: var(--accent); }
#prepareCompositionButton:disabled { opacity: .6; }
#compositionSummary { margin: 8px 0 0; color: var(--muted); font-size: calc(12px + var(--app-font-increase, 1pt)); line-height: 1.6; overflow-wrap: anywhere; }
.prompt-draft-label { display: block; padding: 0 15px; color: var(--muted); font-size: calc(12px + var(--app-font-increase, 1pt)); font-weight: 600; }
.prompt-draft-label small { margin-left: 6px; font-weight: 400; }

/* Hover stays neutral; component selection and focus-visible retain blue. */
@media (hover: hover) and (pointer: fine) {
  :is(.moodboard-card, .gallery-card, .preview-thumbnail, .job-result-select,
    .reference-role-card, .reference-preview-open, .ratio-picker-trigger,
    .candidate-variation-toggle, .workboard-button, .compact-button,
    .secondary-button, .reference-library-actions button):not(:disabled):not([aria-disabled="true"]):hover {
    border-color: var(--line-strong);
  }
}

/* Full quality names and the adjacent native-resolution selector. */
.prompt-field .compact-quality-control { flex-basis: 86px; }
.prompt-field .compact-quality-control .prompt-quality-select { width: 86px; color: var(--text); }
.compact-quality-label { display: none; }
.prompt-field .resolution-select { width: 54px; }

/* The asset cabinet contains three open folders; only their contents scroll. */
#createSideRail #createMoodboardDock { background: color-mix(in srgb, var(--surface-raised) 55%, var(--bg)); }
#createMoodboardDock .moodboard-header { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
#createMoodboardDock .moodboard-copy { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
#createMoodboardDock .moodboard-copy h2 { font-size: calc(15px + var(--app-font-increase, 1pt)); font-weight: 750; }
#createMoodboardDock .moodboard-copy > .asset-sync-label { flex-basis: 100%; font-size: calc(11px + var(--app-font-increase, 1pt)); }
#createMoodboardDock #moodboardGrid.is-asset-sections { gap: 12px; grid-template-rows: repeat(4, minmax(120px, 1fr)); overflow-y: auto; }
#createMoodboardDock .reference-library-section { --folder-tone: #426eac; padding: 0; border: 0; border-radius: 0; background: transparent; }
#createMoodboardDock .reference-library-section[data-library-section="model"] { --folder-tone: #8264ad; }
#createMoodboardDock .reference-library-section[data-library-section="mood"] { --folder-tone: #397d75; }
#createMoodboardDock .reference-library-section > header {
  align-self: flex-start; margin: 0; padding: 7px 12px; gap: 8px; min-height: 32px; box-sizing: border-box;
  border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 14px 0 0;
  background: color-mix(in srgb, var(--folder-tone) 10%, var(--surface-raised));
}
#createMoodboardDock .reference-library-section h3 { display: inline-flex; align-items: center; gap: 7px; font-size: calc(12px + var(--app-font-increase, 1pt)); font-weight: 650; }
#createMoodboardDock .reference-library-section header > span { border-radius: 5px; padding: 1px 5px; background: var(--surface-raised); color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); }
#createMoodboardDock .reference-library-row { container-type: size; padding: 8px; border: 1px solid var(--line); border-radius: 0 12px 12px 12px; background: var(--surface-raised); }
#createMoodboardDock .reference-library-row .moodboard-card { width: min(100%, max(64px, 100cqh)); justify-self: center; }

/* macOS-style cabinets: one quiet surface, a toolbar, and inset photo wells. */
#createMoodboardDock .reference-library-section,
#moodboardGrid.is-reference-library > .reference-library-section {
  --folder-tone: var(--accent);
  padding: 0; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-raised); overflow: hidden;
  box-shadow: 0 1px 2px rgb(0 0 0 / 3%);
}
#createMoodboardDock .reference-library-section > header,
#moodboardGrid.is-reference-library > .reference-library-section > header {
  align-self: stretch; margin: 0; padding: 9px 12px; min-height: 38px;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: color-mix(in srgb, var(--surface-raised) 65%, var(--bg));
  gap: 8px;
}
#createMoodboardDock .reference-library-section h3,
#moodboardGrid.is-reference-library .reference-library-section h3 {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: calc(12px + var(--app-font-increase, 1pt)); font-weight: 650; letter-spacing: -.15px;
}
#createMoodboardDock .reference-library-section header > span,
#moodboardGrid.is-reference-library .reference-library-section header > span {
  padding: 2px 6px; border-radius: 6px; font-size: calc(10px + var(--app-font-increase, 1pt)); color: var(--muted);
  background: color-mix(in srgb, var(--muted) 8%, transparent);
}
#createMoodboardDock .reference-library-row,
#moodboardGrid.is-reference-library .reference-library-row {
  padding: 9px; border: 0; border-radius: 0; background: transparent;
}
.reference-library-row:focus { outline: none; }
.reference-library-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; border-radius: 8px; }
#createMoodboardDock .reference-library-row .moodboard-card,
#moodboardGrid.is-reference-library .reference-library-row .moodboard-card {
  border-radius: 9px; box-shadow: 0 1px 2px rgb(0 0 0 / 3%);
}

/* Archive tiles share the library's quiet, uniform image buttons. */
#historyPanel .gallery { overscroll-behavior: contain; scrollbar-gutter: stable; }
#historyPanel .gallery-card {
  aspect-ratio: auto; border-radius: 9px; padding: 5px;
  background: var(--surface); border-color: var(--line);
  box-shadow: 0 1px 2px rgb(0 0 0 / 3%); transform: none;
}
#historyPanel .gallery-image-wrap { border-radius: 5px; background: var(--surface-subtle); }
#historyPanel .gallery-image-wrap img { object-fit: contain; transform: none; filter: none; }
#historyPanel .gallery-select {
  height: auto; aspect-ratio: 1; cursor: pointer; border-radius: 5px;
  /* The square button, rather than its content-sized padded article, reserves
     exact geometry while offscreen image descendants skip rendering. */
  content-visibility: auto;
}
#historyPanel .gallery-card.is-previewing { border-color: var(--accent); }

/* Two rows keep generation controls inside narrow composer panels. */
.prompt-field .prompt-field-actions {
  display: grid; grid-template-columns: minmax(0, 1fr) 68px 76px;
  gap: 8px; width: 100%; min-width: 0; align-items: center;
}
.prompt-field .compact-quality-control { grid-column: 1; grid-row: 1; min-width: 0; }
.prompt-field .compact-quality-control .prompt-quality-select { width: 100%; max-width: 110px; }
.prompt-field .resolution-select { grid-column: 2; grid-row: 1; width: 68px; min-width: 0; padding-left: 6px; padding-right: 4px; }
.prompt-field #promptRatioControl { grid-column: 3; grid-row: 1; margin-left: 0; width: 76px; min-width: 0; }
.prompt-field #promptCountControl { grid-column: 1 / -1; grid-row: 2; width: 100%; min-width: 0; box-sizing: border-box; padding: 3px; }
.prompt-field .prompt-count-grid { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.prompt-field .prompt-count-grid .count-button { width: 100%; min-width: 0; min-height: 28px; }
.prompt-field .candidate-variation-toggle { min-width: 64px; height: 28px; }

/* Hide per-photo grouping and pose controls in the attachment preview. */
.reference-preview-card .reference-meta-control { display: none; }

/* A writing card: setup, prompt, output controls, then optional request details. */
#promptField { padding-top: 4px; }
#promptField .composition-assistant { margin: 10px 14px 16px; padding: 10px; border: 0; border-radius: 10px; background: var(--surface-subtle); }
#promptField .composition-assistant-heading { gap: 7px 8px; }
#promptField .composition-assistant-heading strong { color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); font-weight: 500; }
#promptField .composition-assistant select { background: var(--composer-card-solid); min-height: 32px; }
#promptField #prepareCompositionButton { min-height: 32px; background: var(--composer-card-solid); border-color: var(--accent-line); color: var(--accent); }
#promptField .prompt-draft-label { padding: 0 16px; color: var(--text); font-size: calc(13px + var(--app-font-increase, 1pt)); }
#promptField .prompt-draft-label small { color: var(--muted); font-size: calc(10px + var(--app-font-increase, 1pt)); }
#promptField #prompt { padding: 10px 16px; line-height: 1.7; }
#promptField .prompt-field-header { padding: 8px 14px 4px; gap: 6px; }
#promptField .applied-prompt-panel { margin: 4px 14px 12px; padding: 0; border: 0; }
#promptField .applied-prompt-heading { justify-content: flex-end; gap: 6px; }
#promptField .applied-prompt-heading label { margin-right: 0; color: var(--muted); font-size: calc(11px + var(--app-font-increase, 1pt)); font-weight: 400; }
#promptField #appliedPromptToggle { width: 28px; height: 28px; border-color: transparent; background: transparent; }
#promptField #appliedPromptToggle:hover { background: var(--accent-faint); color: var(--accent); }
#promptField #appliedPromptToggle[aria-expanded="true"] { color: var(--accent); background: var(--accent-faint); }

/* Give quality and resolution the same visible control surface as ratio. */
#promptField .compact-quality-control { width: 100%; }
#promptField .compact-quality-control .prompt-quality-select,
#promptField .resolution-select {
  height: 34px; min-height: 34px; max-width: none;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface-subtle); color: var(--text);
  padding-left: 10px; padding-right: 4px;
  font-size: calc(12px + var(--app-font-increase, 1pt)); font-weight: 600;
  box-shadow: 0 1px 2px rgb(0 0 0 / 3%);
}
#promptField .compact-quality-control .prompt-quality-select:hover,
#promptField .resolution-select:hover { background: var(--surface-hover); border-color: var(--accent-line); }
#promptField .compact-quality-control .prompt-quality-select:focus-visible,
#promptField .resolution-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#promptField #promptRatioControl .ratio-picker-trigger { height: 34px; min-height: 34px; }
/* Native desktop window pin shares the compact toolbar style. */
.window-pin[aria-pressed="true"] { color: #2671d9; background: rgba(70, 137, 230, .14); border-color: rgba(70, 137, 230, .35); }
.window-pin:disabled { opacity: .4; cursor: default; }
.window-pin:focus-visible { outline: 2px solid #438ce8; outline-offset: 2px; }

/* Keep role deletion off the photo and reveal it only while interacting. */
.composer-fields .reference-role-card > .reference-role-remove {
  top: 5px; right: 5px; left: auto;
  width: 20px; height: 20px; min-width: 0; min-height: 0;
  font-size: calc(16px + var(--app-font-increase, 1pt)); line-height: 1;
  color: var(--muted); background: var(--surface); border: 1px solid var(--line);
  box-shadow: none; backdrop-filter: none;
}
@media (hover: hover) and (pointer: fine) {
  .composer-fields .reference-role-card > .reference-role-remove { opacity: 0; pointer-events: none; }
  .composer-fields .reference-role-card:hover > .reference-role-remove,
  .composer-fields .reference-role-card:focus-within > .reference-role-remove { opacity: 1; pointer-events: auto; }
}
.composer-fields .reference-role-card > .reference-role-remove:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.composer-fields .reference-role-card > .reference-role-remove:hover { color: var(--danger-text); background: var(--danger-soft); }

/* A dedicated flow row keeps both hit targets away from the photo and text. */
.typography-card-actions { position: absolute; top: 8px; right: 8px; z-index: 3; display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin: 0; }
.reference-role-card[data-reference-role="typography"].has-reference .reference-role-picker { padding-right: 88px; }
.reference-role-card:not(.has-reference) .typography-card-actions { display: none; }
.typography-card-actions #resetTypographyTextButton,
.composer-fields .typography-card-actions .reference-role-remove,
.typography-card-actions .reference-role-remove {
  position: static; inset: auto; flex: 0 0 28px; width: 28px; height: 28px;
  min-width: 28px; min-height: 28px; margin: 0; padding: 0;
  display: grid; place-items: center; font-size: calc(18px + var(--app-font-increase, 1pt)); line-height: 1;
  border: 1px solid var(--line); border-radius: 7px; background: var(--surface);
  color: var(--muted); box-shadow: none; backdrop-filter: none;
}
@media (hover: hover) and (pointer: fine) {
  .typography-card-actions { opacity: 0; pointer-events: none; }
  .reference-role-card:hover .typography-card-actions,
  .reference-role-card:focus-within .typography-card-actions { opacity: 1; pointer-events: auto; }
}
.typography-card-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Keep attachments visible without count/limit labels. */
#referenceCount,
.reference-role-card.has-reference .reference-role-action { display: none; }
.composer-fields .reference-count-thumbnails { left: 10px; }

.asset-splitter { position: relative; height: 12px; min-height: 12px; cursor: row-resize; touch-action: none; border-radius: 6px; }
.asset-splitter::after { content: ""; position: absolute; top: 4px; left: calc(50% - 16px); width: 32px; height: 3px; border-radius: 3px; background: #a4aab5; }
body :is(.library-splitter, .asset-splitter):is(:hover, :focus, :active) { background: transparent; border-color: transparent; outline: none; box-shadow: none; }
body :is(.library-splitter, .asset-splitter):is(:hover, :focus, :active)::after { background: #727985; }
body :is(.library-splitter, .asset-splitter):focus-visible::after { outline: 1px solid var(--accent); outline-offset: 3px; }
body :is(.library-splitter, .asset-splitter)::after { opacity: 0; }
body :is(.library-splitter, .asset-splitter):is(:hover, :focus-visible, :active)::after { opacity: 1; }
#createMoodboardDock #moodboardGrid.is-asset-sections:has(> .asset-splitter) { grid-template-rows: var(--asset-split-rows); gap: 0; }
#moodboardGrid.is-reference-library > .asset-splitter { display: none; }

#promptField { position: relative; }
#resetPromptButton { position: absolute; top: 8px; right: 8px; z-index: 3; width: 28px; height: 28px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--muted); }
#promptField .composition-assistant-heading { padding-right: 36px; }
#promptField > #generationComposerFields > .prompt-draft-label { padding-right: 36px; }

.stage > .preview-header-actions { display: none; }
body[data-active-view="create"] .stage > .preview-header-actions {
  display: flex; grid-column: 2; grid-row: 1; justify-self: end; align-self: center;
  margin: 8px 16px; z-index: 2;
}
body[data-active-view="create"] .stage.has-contained-board > .preview-header-actions { display: none; }
@media (max-width: 1099px) {
  body[data-active-view="create"] .stage > .preview-header-actions { grid-column: 1; align-self: end; margin-top: 56px; }
}

.app-tooltip { position: fixed; inset: auto; margin: 0; box-sizing: border-box; width: max-content; max-width: min(260px, calc(100vw - 16px)); padding: 5px 8px; border: 1px solid color-mix(in srgb, var(--line) 80%, transparent); border-radius: 6px; background: color-mix(in srgb, var(--composer-card-solid) 94%, transparent); color: var(--text); box-shadow: 0 2px 8px rgb(20 35 60 / 10%); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); font-family: inherit; font-size: 11px; font-weight: 400; line-height: 1.4; text-align: left; white-space: pre-line; overflow-wrap: anywhere; pointer-events: auto; }
.app-tooltip:popover-open { animation: tooltip-appear 120ms ease-out; }
@keyframes tooltip-appear { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .app-tooltip:popover-open { animation: none; } }
.app-tooltip.is-immediate:popover-open { animation: none; }
@media (prefers-reduced-transparency: reduce) { .app-tooltip { background: var(--composer-card-solid); backdrop-filter: none; } }

#browserPanel { grid-row: 2; grid-column: 1 / -1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface-raised); }
.browser-controls { display: flex; align-items: center; gap: 6px; padding: 12px; border-bottom: 1px solid var(--line); }
.browser-controls button, .browser-controls a { flex: none; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--surface-raised); color: var(--text); font: inherit; font-size: calc(12px + var(--app-font-increase, 1pt)); text-decoration: none; cursor: pointer; }
.browser-controls button:disabled { opacity: .35; cursor: default; }
#browserAddress { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-subtle); color: var(--text); padding: 9px 12px; font: inherit; font-size: calc(12px + var(--app-font-increase, 1pt)); }
#browserStatus { margin: 0; padding: 6px 14px; min-height: 18px; font-size: calc(10px + var(--app-font-increase, 1pt)); color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#browserViewport { flex: 1; min-height: 0; position: relative; background: var(--surface); }
.browser-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 32px; color: var(--muted); text-align: center; }
.browser-empty p { max-width: 440px; line-height: 1.7; font-size: calc(12px + var(--app-font-increase, 1pt)); }
body[data-active-view="browser"] .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
body[data-active-view="browser"] #browserPanel { grid-row: 2 / -1; }
.browser-bookmarks { display: flex; flex: none; align-items: center; gap: 3px; padding: 5px 10px; min-height: 34px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; background: var(--surface-raised); }
.browser-bookmark { display: inline-flex; flex: none; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: calc(11px + var(--app-font-increase, 1pt)); white-space: nowrap; }
.browser-bookmark:hover { background: var(--surface-hover); }
.browser-bookmark:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.bookmark-mark { display: grid; place-items: center; width: 18px; height: 18px; font-weight: 800; font-size: 13px; background: #fff; border-radius: 4px; }

#workspaceNav .workspace-tab svg { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
#workspaceNav .workspace-tab { gap: 9px; }

/* Selection animation supplies the compact work-assets dock's only blue edge. */
#createMoodboardDock .moodboard-card.is-selected { border-color: var(--line); box-shadow: none; }


/* Board gestures use an arrow; native drag feedback shows the selected image stack. */
.workboard-grid, .moodboard-grid, .workboard-image, .moodboard-select { cursor: default; }

/* Keep view-size choices beside the gallery title at every width. */
.history-copy { align-items: center; flex-wrap: wrap; gap: 12px; }
.history-copy > .gallery-density-control { width: auto; flex: 0 0 auto; }

/* Reference previews fit their actual frame instead of clipping a larger flex item. */
.composer-fields .reference-role-grid > .reference-role-card .reference-role-visual {
  width: 36px; height: 36px; min-height: 36px; padding: 0; display: grid;
  overflow: hidden; border-radius: 6px; gap: 0;
}
.composer-fields .reference-role-visual .reference-role-thumbnail { width: 100%; height: 100%; min-width: 0; }
.composer-fields .reference-role-visual .reference-role-image,
.composer-fields .reference-count-thumbnails .reference-role-image {
  position: absolute; inset: 0; width: 100%; height: 100%; min-width: 0;
  object-fit: contain; border: 0; border-radius: 0;
}

/* Round the image itself as well as its frame, including letterboxed references. */
.composer-fields .reference-role-visual .reference-role-image,
.composer-fields .reference-count-thumbnails .reference-role-image {
  border-radius: 6px;
  clip-path: inset(0 round 6px);
}
.composer-fields .reference-count-thumbnails .reference-role-thumbnail { border-radius: 6px; }

.composer-fields .reference-thumbnail-open { display: grid; place-items: center; }
.composer-fields .reference-role-visual .reference-role-image,
.composer-fields .reference-count-thumbnails .reference-role-image {
  position: static; width: auto; height: auto; max-width: 100%; max-height: 100%;
}
.composer-fields .reference-role-visual .reference-role-image { max-height: 36px; max-width: 36px; }
.composer-fields .reference-count-thumbnails .reference-role-image { max-height: 33px; max-width: 30px; }

#generationReferences > .section-minihead { display: flex; align-items: center; gap: 10px; }
#generationReferences .reference-expand-button { margin-left: auto; padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; white-space: nowrap; }
#generationReferences .reference-expand-button:disabled { opacity: .4; cursor: default; }
.reference-preview-navigation { display: flex; justify-content: center; align-items: center; gap: 16px; padding: 10px; }
.reference-preview-navigation button { padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); color: var(--text); }
#referencePreviewDialog > .reference-preview-section { padding: 12px; }

/* Always-visible attached image strip beside the reference heading. */
#generationReferences > .section-minihead > div:first-child { flex: 0 0 auto; }
#generationReferences .reference-header-previews { flex: 1 1 0; min-width: 0; margin-left: auto; }
.reference-header-previews .reference-preview-list { grid-auto-columns: 96px; gap: 8px; padding: 2px 1px 4px; }
.reference-header-previews .reference-preview-open { width: 96px; height: 80px; border-radius: 6px; }
.reference-header-previews .reference-preview-open img { object-fit: contain; border-radius: 6px; }
.reference-header-previews .reference-preview-open > span { display: none; }
.reference-header-previews .reference-preview-card > strong { font-size: 10px; line-height: 14px; }
.reference-header-previews .reference-preview-remove { width: 14px; height: 14px; font-size: 11px; top: 1px; right: 1px; opacity: 0; }
.reference-header-previews .reference-preview-card:hover .reference-preview-remove,
.reference-header-previews .reference-preview-card:focus-within .reference-preview-remove { opacity: 1; }
#generationReferences #clearReferencesButton { flex-shrink: 0; }

#generationReferences #referencePreviewSection { width: 100%; margin: 12px 0 0; }
#generationReferences #clearReferencesButton { margin-left: auto; }

/* A distinct thumbnail panel, using the same archive symbol as the history tab. */
#previewNavigation {
  box-sizing: border-box; padding: 12px; gap: 12px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel-soft); box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 2px 6px rgba(20,35,60,.04);
}
#carouselArchiveIcon { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#carouselArchiveIcon[hidden] { display: none; }
@media (max-width: 580px) { #previewNavigation { padding: 8px; gap: 8px; } }

/* Square two-row scope and image-position card. */
#carouselCounter { box-sizing: border-box; width: 80px; height: 80px; padding: 9px 5px; display: flex; flex-direction: column; justify-content: center; gap: 7px; border-radius: 11px; }
#carouselCounter[hidden] { display: none; }
.carousel-counter-heading { display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; min-width: 0; }
.carousel-counter-heading #carouselScope { overflow: hidden; text-overflow: ellipsis; font-size: 11px; font-weight: 600; color: var(--muted); }
.carousel-counter-heading #carouselArchiveIcon { width: 16px; height: 16px; flex-basis: 16px; }
.carousel-counter-numbers { display: flex; align-items: baseline; justify-content: center; gap: 5px; font-size: 12px; }
.carousel-counter-numbers #carouselPosition { font-size: 16px; }

/* Each asset folder owns its scroll; the surrounding board stays fixed. */
#createMoodboardDock #moodboardGrid.is-asset-sections { overflow: hidden; min-height: 0; }

/* Main copy has stronger visual hierarchy; supporting copy retains its size. */
.reference-role-card[data-reference-role="typography"] #promptPresetDetailLabel { font-size: calc(15px + var(--app-font-increase, 1pt)); font-weight: 700; line-height: 1.4; }
.reference-role-card[data-reference-role="typography"] #promptPresetDetail { font-size: calc(18px + var(--app-font-increase, 1pt)); font-weight: 600; line-height: 1.45; }

/* The main viewer is a distinct window, including its controls and empty state. */
#canvasPanel #canvasSurface {
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 2px 8px rgb(20 35 60 / 4%);
}

/* Match the reference section heading outside the prompt card. */
.prompt-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; }
.prompt-section-heading .prompt-draft-label { margin: 0; padding: 0; color: var(--text); font-size: calc(13px + var(--app-font-increase, 1pt)); font-weight: 700; }
.prompt-section-heading .prompt-draft-label small { color: var(--muted); font-size: calc(10px + var(--app-font-increase, 1pt)); font-weight: 400; }
.prompt-section-heading #resetPromptButton { position: static; flex: 0 0 28px; background: transparent; border-color: transparent; }

/* Separate the prompt card from the reference-image controls. */
#generationReferences {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* Shared section-title typography for the work assets panel. */
#createMoodboardDock .moodboard-copy h2 { font-size: calc(13px + var(--app-font-increase, 1pt)); font-weight: 700; letter-spacing: normal; color: var(--text); }

/* Match section headings to the reference-image title. */
.prompt-section-heading .prompt-draft-label,
#createMoodboardDock .moodboard-copy h2 { font-weight: 600; }

/* Keep the work-assets heading open; section cards provide the separation. */
#createMoodboardDock .moodboard-header { border-bottom: 0; padding-bottom: 0; }

/* Compact prompt card, retaining scroll for longer drafts. */
#promptField { padding-top: 4px; }
#promptField #prompt { min-height: 52px; height: 52px; padding: 8px 16px; overflow-y: auto; }
#promptField .prompt-field-header { min-height: 24px; padding-top: 2px; padding-bottom: 2px; }
#promptField .applied-prompt-panel { margin-top: 0; margin-bottom: 4px; }

#promptField .applied-prompt-heading > .prompt-character-count { flex: 0 0 auto; margin: 0 auto 0 0; text-align: left; }

/* Match the work-assets outer surface to the app composer background. */
#createSideRail #createMoodboardDock { background: var(--composer-solid); }

/* Reserve the same scrollbar space, revealing only the thumb on interaction. */
.reference-library-row { scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.reference-library-row:hover, .reference-library-row:focus-within, .reference-library-row.is-scrolling { scrollbar-color: var(--muted) transparent; }
@supports selector(::-webkit-scrollbar) {
  .reference-library-row { scrollbar-width: auto; scrollbar-color: auto; }
  .reference-library-row:hover, .reference-library-row:focus-within, .reference-library-row.is-scrolling { scrollbar-color: auto; }
  .reference-library-row::-webkit-scrollbar { width: 6px; height: 6px; }
  .reference-library-row::-webkit-scrollbar-track, .reference-library-row::-webkit-scrollbar-corner { background: transparent; }
  .reference-library-row::-webkit-scrollbar-thumb { background: transparent; border: 0; border-radius: 8px; }
  .reference-library-row:hover::-webkit-scrollbar-thumb,
  .reference-library-row:focus-within::-webkit-scrollbar-thumb,
  .reference-library-row.is-scrolling::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 45%, transparent); }
  .reference-library-row::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
}

.workboard-card.is-selected::after,
.workboard-card.is-deselecting::after,
.moodboard-card.is-selected::after,
.moodboard-card.is-deselecting::after,
.gallery-card.is-selected::after,
.gallery-card.is-deselecting::after {
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: inherit;
  background: var(--photo-selection-wash, rgb(220 224 232 / 16%));
  box-shadow: inset 0 0 0 2px var(--photo-selection-edge, rgb(225 229 237 / 78%));
  content: "";
  pointer-events: none;
}

@property --selection-progress {
  syntax: "<angle>";
  inherits: false;
  initial-value: 360deg;
}

.workboard-card.is-selected::after,
.moodboard-card.is-selected::after,
.gallery-card.is-selected::after {
  --selection-progress: 360deg;
}

.workboard-card.is-selected.is-selecting::after,
.moodboard-card.is-selected.is-selecting::after,
.gallery-card.is-selected.is-selecting::after {
  animation: thumbnail-select 160ms ease-out forwards;
}

.workboard-card.is-deselecting::after,
.moodboard-card.is-deselecting::after,
.gallery-card.is-deselecting::after {
  animation: thumbnail-deselect 160ms ease-out forwards;
}

@keyframes thumbnail-select {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes thumbnail-deselect {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .workboard-card.is-selecting::after,
  .moodboard-card.is-selecting::after,
  .gallery-card.is-selecting::after,
  .workboard-card.is-deselecting::after,
  .moodboard-card.is-deselecting::after,
  .gallery-card.is-deselecting::after { animation: none; }
}

@media (hover: hover) and (pointer: fine) {
  .workboard-card:hover,
  .moodboard-card:hover,
  .gallery-card:hover {
    z-index: 3;
    box-shadow: 0 8px 18px 3px rgb(28 48 76 / 30%);
    transform: none;
  }
  .workboard-card:hover,
  .gallery-card:hover,
  #createMoodboardDock .moodboard-card:hover { border-color: var(--line); }
  .moodboard-card:hover { border-color: var(--line); }
  #createMoodboardDock .moodboard-card:hover { border-color: var(--line); }
  .gallery-card:hover .gallery-image-wrap img,
  .moodboard-card:hover .moodboard-image-wrap img {
    filter: none;
    transform: none;
  }
}

/* Pointer clicks must not leave a second blue frame after selection clears. */
.moodboard-select:focus-visible,
.workboard-image:focus-visible,
.gallery-select:focus-visible {
  outline: none;
}

.moodboard-card:has(.moodboard-select:focus-visible),
.workboard-card:has(.workboard-image:focus-visible),
.gallery-card:has(.gallery-select:focus-visible) {
  z-index: 3;
  box-shadow: 0 8px 18px 3px rgb(28 48 76 / 30%);
}

/* Unified hierarchy for composer sections, reference cards and asset folders. */
:root {
  --ui-section-title-size: calc(13px + var(--app-font-increase, 1pt));
  --ui-card-title-size: calc(12px + var(--app-font-increase, 1pt));
  --ui-card-copy-size: calc(11px + var(--app-font-increase, 1pt));
  --ui-card-radius: 12px;
  --ui-card-gap: 10px;
  --ui-card-inline: 12px;
  --ui-card-header-height: 44px;
}

.prompt-section-heading .prompt-draft-label,
.composer-fields .section-minihead strong,
#createMoodboardDock .moodboard-copy h2,
.shared-settings-heading strong {
  margin: 0;
  color: var(--text);
  font-size: var(--ui-section-title-size);
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0;
}

.prompt-section-heading,
#generationReferences > .section-minihead,
#createMoodboardDock .moodboard-header,
.shared-settings-heading {
  min-height: 28px;
  align-items: center;
}

.composer-fields .reference-role-grid {
  gap: var(--ui-card-gap);
  align-items: stretch;
}

.composer-panel .reference-role-card {
  min-height: 100px;
  border: 1px solid var(--line);
  border-radius: var(--ui-card-radius);
  background: var(--composer-card-solid);
  overflow: hidden;
}

.composer-fields .reference-role-card:not(.reference-role-custom),
.composer-fields .reference-role-card[data-reference-role="background"],
.composer-fields .reference-role-custom {
  min-height: 100px;
}

.composer-fields .reference-role-card .reference-role-picker,
.composer-fields .reference-role-card[data-reference-role="typography"] .reference-role-picker,
.composer-fields .reference-role-card[data-reference-role="background"] .reference-role-picker,
.composer-fields .reference-role-custom .reference-role-picker {
  box-sizing: border-box;
  min-height: 68px;
  padding: 12px 10px 8px;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.composer-fields .reference-role-copy {
  align-self: center;
  gap: 3px;
  padding: 0;
}

.composer-fields .reference-role-copy strong {
  color: var(--text);
  font-size: var(--ui-card-title-size);
  font-weight: 600;
  line-height: 1.3;
}

.composer-fields .reference-role-copy small {
  color: var(--muted);
  font-size: var(--ui-card-copy-size);
  font-weight: 400;
  line-height: 1.4;
}

.composer-fields .reference-role-card:not(.has-reference) .reference-role-action {
  top: 9px;
  right: 9px;
}

/* Expanded reference cards retain their details below the same stable heading row. */
.composer-fields .reference-role-card[data-reference-role="typography"].has-reference .reference-role-picker,
.composer-fields .reference-role-custom:has(.custom-reference-fields:not([hidden])) .reference-role-picker {
  min-height: 68px;
  padding-top: 12px;
}

.composer-fields .reference-role-card[data-reference-role="typography"] .basic-copy-options,
.composer-fields .reference-role-custom .custom-reference-fields {
  margin-inline: var(--ui-card-inline);
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

#createMoodboardDock #moodboardGrid.is-asset-sections {
  gap: 0;
}

#createMoodboardDock .reference-library-section,
#moodboardGrid.is-reference-library > .reference-library-section {
  border: 1px solid var(--line);
  border-radius: var(--ui-card-radius);
  background: var(--surface-raised);
  box-shadow: none;
}

#createMoodboardDock .reference-library-section > header,
#moodboardGrid.is-reference-library > .reference-library-section > header {
  box-sizing: border-box;
  height: var(--ui-card-header-height);
  min-height: var(--ui-card-header-height);
  padding: 0 var(--ui-card-inline);
  gap: 8px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: color-mix(in srgb, var(--surface-raised) 65%, var(--bg));
}

#createMoodboardDock .reference-library-section h3,
#moodboardGrid.is-reference-library .reference-library-section h3 {
  margin: 0;
  gap: 8px;
  color: var(--text);
  font-size: var(--ui-card-title-size);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
}

#createMoodboardDock .reference-library-section header > span,
#moodboardGrid.is-reference-library .reference-library-section header > span {
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 8%, transparent);
  font-size: var(--ui-card-copy-size);
  line-height: 1.3;
}

#createMoodboardDock .reference-library-row,
#moodboardGrid.is-reference-library .reference-library-row {
  padding: 10px;
}

/* Keep two prompt lines visible before the textarea needs its own scrollbar. */
#promptField #generationComposerFields #prompt {
  box-sizing: border-box;
  min-height: 54px;
  height: 54px;
  padding-block: 3px;
  padding-inline: 16px;
  line-height: 1.55;
  overflow-y: auto;
}

/* A single, ordered layout for the expanded typography reference card. */
.composer-fields .reference-role-card[data-reference-role="typography"] {
  padding-bottom: 14px;
}
.composer-fields .reference-role-grid > .reference-role-card[data-reference-role="typography"].has-reference {
  padding-bottom: 14px;
}
.composer-fields .reference-role-card[data-reference-role="typography"].has-reference .reference-role-picker {
  min-height: 68px;
  padding: 10px 76px 9px 10px;
}
.reference-role-card[data-reference-role="typography"] .typography-card-actions {
  top: 10px;
  right: 10px;
  gap: 6px;
}
.composer-fields .reference-role-card[data-reference-role="typography"] .basic-copy-options {
  margin: 0 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.reference-role-card[data-reference-role="typography"] #promptPresetDetailField {
  grid-template-columns: minmax(0, 1fr);
  column-gap: 12px;
  row-gap: 7px;
  align-items: start;
}
.reference-role-card[data-reference-role="typography"] #promptPresetDetailField > label,
.reference-role-card[data-reference-role="typography"] #posterCopySecondary > label {
  display: flex;
  align-items: center;
  min-height: 20px;
  margin: 0;
  color: var(--text);
  font-size: var(--ui-card-title-size);
  font-weight: 600;
  line-height: 1.35;
}
.reference-role-card[data-reference-role="typography"] #promptPresetDetail,
.reference-role-card[data-reference-role="typography"] #posterSubCopy {
  height: 48px;
  min-height: 48px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
}
.reference-role-card[data-reference-role="typography"] #posterDetailsToggle {
  min-height: 32px;
  margin-top: 1px;
  padding: 4px 0;
}
.reference-role-card[data-reference-role="typography"] #posterDetailsField {
  margin-top: 2px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.reference-role-card[data-reference-role="typography"] #posterDetailsField > label {
  margin-bottom: 7px;
  color: var(--text);
  font-weight: 600;
}
.reference-role-card[data-reference-role="typography"] #posterDetailsCopy {
  min-height: 72px;
  margin: 0;
  padding: 10px 12px;
}
.reference-role-card[data-reference-role="typography"] .typography-layout-options {
  display: flex;
  align-items: center;
  gap: 8px 18px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.reference-role-card[data-reference-role="typography"] .typography-layout-options label {
  min-height: 24px;
  gap: 6px;
}

/* Asset size controls share archive icons and sit beside sorting at the trailing edge. */
#createMoodboardDock .reference-library-section > header { flex-wrap: wrap; }
#createMoodboardDock .asset-density-buttons { display: inline-flex; flex: 0 0 auto; gap: 2px; padding: 2px; margin-left: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised); }
#createMoodboardDock .asset-density-button { display: grid; place-items: center; width: 26px; height: 26px; padding: 5px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
#createMoodboardDock .asset-density-button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }
#createMoodboardDock .asset-density-button:hover { background: var(--accent-faint); color: var(--accent); }
#createMoodboardDock .asset-density-button[aria-pressed="true"] { background: var(--density-selected-bg); color: var(--muted); }
#createMoodboardDock .asset-density-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#createMoodboardDock .reference-library-section header .library-sort-trigger { margin-left: 0; }
#createMoodboardDock .reference-library-row:not(.is-empty) { grid-template-columns: repeat(var(--asset-columns, 4), minmax(0, 1fr)); }
#createMoodboardDock .reference-library-row .moodboard-card { width: 100%; }

.composer-fields .reference-role-grid > .reference-role-card:has(> .reference-role-region-actions) { padding-bottom: 44px; }
.reference-role-region-actions { position: absolute; bottom: 8px; right: 8px; left: 8px; display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.reference-role-region-actions select { width: auto; min-width: 0; max-width: 48%; height: 28px; padding: 2px 5px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-raised); color: var(--text); font: inherit; font-size: 11px; }
.reference-role-region-actions .custom-reference-refine { position: static; flex: 0 0 auto; margin: 0; min-height: 28px; padding: 4px 8px; font-size: 11px; }


/* Compact ratio menu, aligned within its owning panel. */
.ratio-picker-menu { padding: 5px; border-radius: 11px; background: var(--surface-raised); box-shadow: 0 6px 22px rgb(20 35 60 / 14%); scrollbar-gutter: stable; scrollbar-color: var(--line-strong) transparent; }
.ratio-picker-option { min-height: 32px; padding: 0 7px; gap: 7px; border-radius: 7px; font-size: 12px; }
.ratio-picker-option .ratio-picker-shape { width: 19px; height: 19px; flex: 0 0 19px; }
.ratio-picker-number { font-size: 11px; }
.ratio-picker-option[aria-selected="true"] { background: var(--accent-faint); color: var(--accent); }
.ratio-picker-option[aria-selected="true"] .ratio-picker-number { color: var(--accent); }
.ratio-picker-option.is-active { border-color: transparent; box-shadow: inset 0 0 0 1px var(--accent-line); }
.ratio-picker-menu::-webkit-scrollbar { width: 6px; }
.ratio-picker-menu::-webkit-scrollbar-track { background: transparent; margin-block: 8px; }
.ratio-picker-menu::-webkit-scrollbar-thumb { border-radius: 6px; background: var(--line-strong); }
.ratio-picker-menu::-webkit-scrollbar-button { display: none; width: 0; height: 0; }

/* Each multi-reference region has an explicit photo target. */
.composer-fields .reference-role-grid > .reference-role-card.has-multiple-references:has(> .reference-role-region-actions) { height: 180px; min-height: 180px; padding-bottom: 101px; }
.composer-fields .reference-role-card:has(> .reference-role-region-actions) > .reference-count-thumbnails { display: none; }
.reference-role-region-actions { flex-wrap: wrap; }
.reference-region-targets { display: flex; flex: 1 0 100%; min-width: 0; gap: 6px; overflow-x: auto; padding: 3px 2px; scrollbar-width: thin; }
.reference-region-targets[hidden] { display: none; }
.reference-region-target { position: relative; flex: 0 0 57px; }
.reference-region-target-button { position: relative; display: block; width: 57px; height: 51px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-raised); overflow: hidden; }
.reference-region-target-button[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: -2px; }
.reference-region-target-button img { width: 100%; height: 100%; object-fit: contain; }
.reference-region-target-button span { position: absolute; bottom: 1px; left: 2px; font-size: 9px; line-height: 12px; padding: 0 3px; border-radius: 3px; background: var(--surface-raised); color: var(--text); }
.reference-region-target-remove { position: absolute; top: -3px; right: -2px; width: 14px; height: 14px; padding: 0; line-height: 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-raised); color: var(--text); font-size: 11px; }

/* Keep tile size consistent across pane heights; overflow scrolls within each pane. */
#createMoodboardDock .reference-library-row:not(.is-empty) { align-content: start; }
#createMoodboardDock .reference-library-row .moodboard-card { width: 100%; height: auto; aspect-ratio: 1; justify-self: stretch; }

/* Personal references and shipped models occupy equal library columns. */
body[data-active-view="moodboard"] #moodboardPanel { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 16px; }
body[data-active-view="moodboard"] #moodboardPanel > .moodboard-header { grid-column: 1 / -1; }
body[data-active-view="moodboard"] #moodboardPanel > #moodboardGrid { grid-column: 1; grid-row: 2 / 4; min-width: 0; }
.builtin-model-library { display: none; min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: var(--ui-card-radius); background: var(--surface-raised); overflow: hidden; }
body[data-active-view="moodboard"] #builtinModelLibrary { display: flex; flex-direction: column; grid-column: 2; grid-row: 2 / 4; }
.builtin-model-library > header { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; flex: 0 0 auto; min-height: var(--ui-card-header-height); padding: 0 var(--ui-card-inline); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface-raised) 65%, var(--bg)); }
.builtin-model-library h2 { margin: 0; font-size: var(--ui-card-title-size); font-weight: 600; color: var(--text); }
.builtin-model-badge { color: var(--muted); font-size: var(--ui-card-copy-size); }
.builtin-model-content { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.builtin-model-empty { display: flex; min-height: 220px; height: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; color: var(--muted); }
.builtin-model-empty strong { font-size: 14px; color: var(--text); font-weight: 600; }
.builtin-model-empty p { max-width: 280px; margin: 0; font-size: 12px; line-height: 1.6; }
@media (max-width: 900px) {
  body[data-active-view="moodboard"] #moodboardPanel { grid-template-columns: minmax(0, 1fr); overflow-y: auto; }
  body[data-active-view="moodboard"] #builtinModelLibrary { grid-column: 1; grid-row: 4; min-height: 320px; }
}
/* Text colors share the background palette, beside each copy label. */
.reference-role-card[data-reference-role="typography"] #promptPresetDetailField { grid-template-columns: minmax(0, 1fr) auto; }
.reference-role-card[data-reference-role="typography"] #mainTextColorPicker { grid-column: 2; grid-row: 1; }
.reference-role-card[data-reference-role="typography"] #subTextColorPicker { grid-column: 2; grid-row: 3; }
.reference-role-card[data-reference-role="typography"] #promptPresetDetail,
.reference-role-card[data-reference-role="typography"] #posterSubCopy { grid-column: 1 / -1; }
.reference-role-card[data-reference-role="typography"] .typography-color-control { justify-self: end; align-self: center; }
.reference-role-card[data-reference-role="typography"] .typography-color-control .background-color-trigger { max-width: 116px; min-height: 28px; }
.reference-role-card[data-reference-role="typography"] #posterDetailsField:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; align-items: center; }
.reference-role-card[data-reference-role="typography"] #posterDetailsCopy { grid-column: 1 / -1; }

/* Keep library keyboard focus inside a card, not around the full scroll column. */
#moodboardGrid.is-reference-library:focus-visible { outline: none; }
#moodboardGrid.is-reference-library:focus-visible > .reference-library-section:first-of-type > header { box-shadow: inset 0 -2px var(--accent-line); }

/* Empty canvas: reference-only creation tutorial; never submits a request. */
#canvasEmpty { width: min(100%, 480px); max-width: 480px; }
.empty-drag-demo { position: relative; direction: ltr; width: 304px; height: 294px; margin: 0 0 24px; pointer-events: none; user-select: none; }
.empty-demo-panel { position: absolute; top: 0; width: 128px; height: 238px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-raised); text-align: start; box-shadow: 0 3px 12px #17243a05; }
.empty-demo-target { left: 0; }
.empty-demo-source { right: 0; }
.empty-demo-label { display: block; color: var(--text); font-size: 11px; font-weight: 600; line-height: 16px; min-height: 32px; overflow-wrap: anywhere; }
.empty-demo-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; height: 58px; margin-bottom: 4px; color: var(--dim); font-size: 10px; }
.empty-demo-row > span { min-width: 0; overflow-wrap: anywhere; }
.empty-demo-row > img, .empty-demo-slot { flex: 0 0 46px; width: 46px; height: 52px; object-fit: cover; border-radius: 6px; }
.empty-demo-slot { position: relative; display: grid; place-items: center; border: 1px dashed var(--accent-line); background: var(--accent-soft); }
.empty-demo-plus { color: var(--accent); font-size: 22px; font-weight: 300; }
.empty-demo-result { position: absolute; width: 100%; height: 100%; object-fit: cover; border-radius: 5px; opacity: 0; }
.empty-demo-check { position: absolute; bottom: -4px; right: -4px; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: white; font-size: 11px; text-align: center; opacity: 0; }
.empty-demo-drag { position: absolute; left: 245px; top: 47px; width: 46px; height: 52px; opacity: 0; }
.empty-demo-drag.empty-demo-step-1 { top: 109px; }
.empty-demo-drag.empty-demo-step-2 { top: 171px; }
.empty-demo-drag img { width: 100%; height: 100%; object-fit: cover; border: 2px solid var(--accent); border-radius: 6px; box-shadow: 0 6px 16px #17243a25; }
.empty-demo-drag svg, .empty-demo-click svg { position: absolute; width: 23px; height: 27px; right: -12px; bottom: -15px; fill: var(--text); stroke: var(--surface-raised); stroke-width: 1.5; }
.empty-demo-create { position: absolute; top: 252px; left: 100px; width: 104px; min-height: 34px; padding: 8px; border-radius: 8px; color: white; background: var(--accent); font-size: 12px; font-weight: 600; animation: empty-create-press 12s infinite; }
.empty-demo-click { position: absolute; bottom: 10px; right: 12px; opacity: 0; animation: empty-create-cursor 12s infinite; }
@keyframes empty-create-cursor { 0%, 67% { opacity: 0; transform: translate(18px, -28px); } 73%, 84% { opacity: 1; transform: translate(0, 0); } 89%, 100% { opacity: 0; transform: translate(0, 0); } }
@keyframes empty-create-press { 0%, 77%, 83%, 100% { transform: scale(1); } 80% { transform: scale(.94); } }
.empty-demo-drag.empty-demo-step-0 { animation: empty-drag-0 12s infinite; }
.empty-demo-step-0 .empty-demo-result, .empty-demo-step-0 .empty-demo-check { animation: empty-result-0 12s infinite; }
@keyframes empty-drag-0 {
  0%, 5% { opacity: 0; transform: translate(0, 0); }
  8% { opacity: 1; transform: translate(0, -3px) scale(1.06); animation-timing-function: cubic-bezier(.4,0,.2,1); }
  18% { opacity: 1; transform: translate(-176px, 0); }
  20%, 100% { opacity: 0; transform: translate(-176px, 0); }
}
@keyframes empty-result-0 { 0%, 18% { opacity: 0; } 20%, 91% { opacity: 1; } 97%, 100% { opacity: 0; } }
.empty-demo-drag.empty-demo-step-1 { animation: empty-drag-1 12s infinite; }
.empty-demo-step-1 .empty-demo-result, .empty-demo-step-1 .empty-demo-check { animation: empty-result-1 12s infinite; }
@keyframes empty-drag-1 {
  0%, 25% { opacity: 0; transform: translate(0, 0); }
  28% { opacity: 1; transform: translate(0, -3px) scale(1.06); animation-timing-function: cubic-bezier(.4,0,.2,1); }
  38% { opacity: 1; transform: translate(-176px, 0); }
  40%, 100% { opacity: 0; transform: translate(-176px, 0); }
}
@keyframes empty-result-1 { 0%, 38% { opacity: 0; } 40%, 91% { opacity: 1; } 97%, 100% { opacity: 0; } }
.empty-demo-drag.empty-demo-step-2 { animation: empty-drag-2 12s infinite; }
.empty-demo-step-2 .empty-demo-result, .empty-demo-step-2 .empty-demo-check { animation: empty-result-2 12s infinite; }
@keyframes empty-drag-2 {
  0%, 45% { opacity: 0; transform: translate(0, 0); }
  48% { opacity: 1; transform: translate(0, -3px) scale(1.06); animation-timing-function: cubic-bezier(.4,0,.2,1); }
  58% { opacity: 1; transform: translate(-176px, 0); }
  60%, 100% { opacity: 0; transform: translate(-176px, 0); }
}
@keyframes empty-result-2 { 0%, 58% { opacity: 0; } 60%, 91% { opacity: 1; } 97%, 100% { opacity: 0; } }
#canvasEmpty[hidden] .empty-drag-demo *, .has-generation-activity .empty-drag-demo *, body:not([data-active-view="create"]) .empty-drag-demo * { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .empty-drag-demo * { animation: none !important; }
  .empty-demo-result, .empty-demo-check { opacity: 1; }
  .empty-demo-drag { display: none; }
  .empty-demo-click { display: none; }
}
@media (max-width: 420px) { #canvasEmpty { padding: 16px 8px; } .empty-drag-demo { zoom: .82; } }

#createMoodboardDock .reference-library-section[data-library-section="wardrobe"] { --folder-tone: #a5754d; }

/* Keep the fifth library pane reachable on shorter windows. */
#moodboardGrid.is-reference-library { overflow-y: auto; }

/* Shared surface roles: canvas background, workspace panels, and editable content. */
:root {
  --workspace-base: #18191b;
  --workspace-panel: #222326;
  --workspace-heading: #292a2e;
  --workspace-content: #303136;
  --workspace-preview: #1d1e20;
  --workspace-empty: #25262a;
  --bg: var(--workspace-base);
  --stage: var(--workspace-panel);
  --composer-solid: var(--workspace-panel);
  --composer-card-solid: var(--workspace-content);
  --rail-solid: var(--workspace-panel);
  --surface: var(--workspace-panel);
  --surface-raised: var(--workspace-content);
  --panel: var(--workspace-panel);
  --panel-soft: var(--workspace-heading);
  --image-well: var(--workspace-preview);
}
:root[data-theme="light"] {
  --workspace-base: #e5e7eb;
  --workspace-panel: #f3f4f6;
  --workspace-heading: #edeef1;
  --workspace-content: #ffffff;
  --workspace-preview: #e8e8ea;
  --workspace-empty: #f0f1f3;
  --bg: var(--workspace-base);
  --stage: var(--workspace-panel);
  --composer-solid: var(--workspace-panel);
  --composer-card-solid: var(--workspace-content);
  --rail-solid: var(--workspace-panel);
  --surface: var(--workspace-panel);
  --surface-raised: var(--workspace-content);
  --panel: var(--workspace-panel);
  --panel-soft: var(--workspace-heading);
  --image-well: var(--workspace-preview);
  --line: #d5d8de;
  --line-strong: #b9bec7;
  --density-selected-bg: #e6e8ed;
  --option-bg: #edeef1;
}

/* My images shares the sample category navigation, preserving its existing panels. */
#createMoodboardDock #userLibraryCategories { flex-wrap: nowrap; overflow-x: auto; min-height: 56px; box-sizing: border-box; }
#createMoodboardDock.show-samples #userLibraryCategories { display: none; }
#createMoodboardDock #moodboardGrid.has-category-tabs { display: flex; flex-direction: column; flex: 1 1 auto; grid-template-rows: none; }
#createMoodboardDock #moodboardGrid.has-category-tabs > .reference-library-section { flex: 1 1 auto; min-height: 0; }
#createMoodboardDock #moodboardGrid.has-category-tabs > .reference-library-section[hidden],
#createMoodboardDock #moodboardGrid.has-category-tabs > .asset-splitter { display: none; }
