/* Image Illustrator SaaS interface layer.
 * The base stylesheet retains behavior-specific states; this file owns presentation.
 */

:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --surface-3: #edf2f0;
  --text: #17211f;
  --text-muted: #596561;
  --text-faint: #87928f;
  --line: #dfe6e3;
  --line-strong: #c8d2ce;
  --accent: #0f766e;
  --accent-hover: #0b5f59;
  --accent-soft: #e7f4f1;
  --accent-text: #ffffff;
  --accent-glow: rgba(15, 118, 110, 0.17);
  --success: #18794e;
  --success-soft: #eaf7f0;
  --warning: #9a5b09;
  --warning-soft: #fff5df;
  --danger: #b42318;
  --danger-soft: #fff0ee;
  --info: #2459a9;
  --info-soft: #edf4ff;
  --shadow-xs: 0 1px 2px rgba(23, 33, 31, 0.04);
  --shadow-sm: 0 1px 3px rgba(23, 33, 31, 0.07), 0 1px 1px rgba(23, 33, 31, 0.03);
  --shadow-md: 0 8px 24px rgba(23, 33, 31, 0.09);
  --shadow-lg: 0 18px 48px rgba(23, 33, 31, 0.14);
  --ring: 0 0 0 3px var(--accent-glow);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 8px;
  --radius-xl: 8px;
  --sidebar-w: 264px;
  --topbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #101513;
    --surface: #171d1b;
    --surface-2: #1c2321;
    --surface-3: #242d2a;
    --text: #f1f5f3;
    --text-muted: #a8b3af;
    --text-faint: #73807c;
    --line: #2a3531;
    --line-strong: #3b4844;
    --accent: #5eead4;
    --accent-hover: #99f6e4;
    --accent-soft: rgba(45, 212, 191, 0.12);
    --accent-text: #10201d;
    --accent-glow: rgba(94, 234, 212, 0.18);
    --success: #6ee7a3;
    --success-soft: rgba(34, 197, 94, 0.12);
    --warning: #f8c36a;
    --warning-soft: rgba(245, 158, 11, 0.12);
    --danger: #ff8b82;
    --danger-soft: rgba(239, 68, 68, 0.12);
    --info: #8ab4ff;
    --info-soft: rgba(59, 130, 246, 0.13);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.22);
    --shadow-sm: 0 2px 5px rgba(0, 0, 0, 0.28);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.34);
    --shadow-lg: 0 20px 54px rgba(0, 0, 0, 0.5);
  }
}

html { background: var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}
body * { letter-spacing: 0 !important; }
h1, h2, h3, h4, h5, h6,
button, input, select, textarea, label, a {
  letter-spacing: 0;
}
h1 { font-size: 24px; line-height: 1.25; font-weight: 650; }
h2 { font-size: 15px; line-height: 1.4; font-weight: 650; }
h3 { font-size: 13px; line-height: 1.4; font-weight: 650; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* Application shell */
.app-shell {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
}
.main-area { min-width: 0; min-height: 100dvh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 40;
}
.sidebar-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.sidebar .brand,
.public-topbar .brand {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
  margin: 0;
  color: var(--text);
}
.brand-mark,
.user-chip .avatar,
.profile-avatar {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: none;
}
.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 17px;
}
.brand-copy {
  min-width: 0;
  display: grid;
  gap: 0;
}
.brand-copy strong {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.35;
  font-weight: 650;
  white-space: nowrap;
}
.brand-copy small {
  color: var(--text-faint);
  font-size: 10.5px;
  line-height: 1.3;
}
.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 12px 10px 20px;
}
.sidebar-nav-group + .sidebar-nav-group { margin-top: 14px; }
.sidebar-section-label {
  padding: 0 10px 6px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: 0;
}
.sidebar nav { gap: 2px; }
.sidebar nav a {
  min-height: 36px;
  padding: 8px 10px;
  gap: 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12.75px;
  font-weight: 520;
  box-shadow: none;
}
.sidebar nav a .bi {
  width: 18px;
  flex: 0 0 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 15px;
}
.sidebar nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}
.sidebar nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: none;
  font-weight: 650;
}
.sidebar nav a[aria-current="page"] .bi { color: var(--accent); }
.sidebar-foot {
  margin: 0;
  padding: 10px;
  gap: 4px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.user-chip {
  min-height: 48px;
  padding: 7px 8px;
  gap: 9px;
  border: 1px solid transparent;
}
.user-chip:hover,
.user-chip.is-current {
  background: var(--surface-2);
  border-color: var(--line);
}
.user-chip > .bi { color: var(--text-faint); font-size: 12px; }
.user-chip .avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 6px;
}
.sidebar-foot form.inline { display: block; }
.sidebar-foot .logout {
  width: 100%;
  min-height: 34px;
  justify-content: flex-start;
  padding: 7px 10px;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--text-muted);
}
.sidebar-foot .logout:hover {
  background: var(--surface-2);
  color: var(--text);
}
.sidebar-close,
.topbar-menu { display: none; }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(12, 20, 18, 0.42);
  box-shadow: none;
  z-index: 35;
}
button.sidebar-backdrop,
button.sidebar-backdrop:hover,
button.sidebar-backdrop:focus {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(12, 20, 18, 0.42);
  box-shadow: none;
}

.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  padding: 0 28px;
  gap: 12px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar .crumbs {
  gap: 8px;
  font-size: 12.75px;
}
.topbar .crumbs strong { font-weight: 650; }
.topbar .crumbs .sep { width: 11px; color: var(--text-faint); font-size: 10px; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  flex: 0 0 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: none;
}
.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}
.topbar-create { min-height: 36px; }

.content {
  width: 100%;
  max-width: 1540px;
  padding: 28px 30px 56px;
}
.content.narrow { max-width: 820px; }
.page-head {
  min-height: 54px;
  align-items: center;
  margin-bottom: 22px;
}
.page-head .title { gap: 4px; }
.page-head .title h1 { letter-spacing: 0; }
.page-head .title p {
  max-width: 760px;
  color: var(--text-muted);
  font-size: 13px;
}
.page-actions { gap: 8px; }

/* Commands, panels and form controls */
button,
.button {
  min-height: 36px;
  padding: 7px 13px;
  border-radius: 6px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12.75px;
  font-weight: 650;
  box-shadow: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
button:hover,
.button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:active,
.button:active { transform: none; }
button.secondary,
.button.secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: none;
}
button.secondary:hover,
.button.secondary:hover { background: var(--surface-2); border-color: var(--text-faint); }
button.ghost,
.button.ghost { color: var(--text-muted); }
button.sm,
.button.sm { min-height: 30px; padding: 4px 9px; }
button.lg,
.button.lg { min-height: 42px; padding: 9px 16px; }
a.chip,
button.chip,
.chip {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-weight: 600;
}
.panel {
  padding: 20px;
  border-color: var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.panel-head {
  min-height: 32px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 14px; }
label { gap: 6px; color: var(--text); font-size: 12px; font-weight: 620; }
input,
select,
textarea,
.reference-prompt-editor {
  min-height: 38px;
  padding: 8px 10px;
  border-color: var(--line-strong);
  border-radius: 6px;
  background-color: var(--surface);
  color: var(--text);
  font-size: 13px;
  box-shadow: none;
}
textarea { min-height: 110px; }
input:hover,
select:hover,
textarea:hover,
.reference-prompt-editor:hover { border-color: var(--text-faint); }
input:focus,
select:focus,
textarea:focus,
.reference-prompt-editor:focus,
.reference-prompt-editor:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
input:disabled,
select:disabled,
textarea:disabled { background: var(--surface-3); }
fieldset.panel-subsection {
  border-color: var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}
.toggle-row,
label.row:has(input[type="checkbox"]) {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}
.segmented-control { border-color: var(--line-strong); border-radius: 6px; }
.file-dropzone {
  min-height: 126px;
  border-radius: 8px;
  background: var(--surface-2);
}
.file-dropzone:hover,
.file-dropzone:focus-within,
.file-dropzone.is-dragover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: none;
}
.file-dropzone-body { min-height: 126px; gap: 5px; }
.file-dropzone-icon { color: var(--accent); font-size: 24px; line-height: 1; margin-bottom: 4px; }
.file-dropzone-meta { border-radius: 5px; }
.reference-image-editor {
  display: grid;
  gap: 14px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.reference-image-current {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}
.reference-image-current > a {
  display: block;
  width: 160px;
  height: 140px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}
.reference-image-current img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.reference-image-current > div { display: grid; gap: 4px; min-width: 0; }
.reference-image-current strong { font-size: 13.5px; }
.reference-image-current span { color: var(--text-muted); font-size: 12.5px; }
.reference-file-actions { display: flex; justify-content: flex-end; }
.reference-file-actions [hidden] { display: none !important; }
.reference-prompt-editor .prompt-chip {
  border-radius: 5px;
  background: var(--info-soft);
  border-color: color-mix(in srgb, var(--info) 26%, var(--line));
  box-shadow: inset 3px 0 0 var(--info);
}
.reference-upload-card,
.reference-alias-option { border-radius: 8px; box-shadow: none; }
.reference-upload-section-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.reference-upload-card-remove { border-radius: 6px; }

/* Generation workspace */
.generate-form.panel {
  padding: 0;
  overflow: visible;
}
.generation-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(330px, 0.75fr);
  align-items: stretch;
  min-height: 620px;
}
.generation-primary {
  min-width: 0;
  padding: 24px;
}
.generation-config {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border-left: 1px solid var(--line);
}
.form-section { min-width: 0; display: grid; gap: 14px; }
.form-section + .form-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.generation-config .form-section {
  padding: 20px;
}
.generation-config .form-section + .form-section {
  margin-top: 0;
  border-top: 1px solid var(--line);
}
.form-section-head {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 28px;
}
.form-section-head h2 { font-size: 13px; }
.form-section-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
}
.generation-brief .reference-prompt-editor { min-height: 230px; padding: 14px; line-height: 1.65; }
.generation-references { margin-top: 26px; }
.generation-manual-placement[hidden] { display: none; }
.manual-placement-head { min-width: 0; }
.manual-placement-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.manual-placement-toolbar .icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  flex-basis: 34px;
}
.manual-placement-toolbar .icon-button:disabled { opacity: 0.42; cursor: not-allowed; }
.manual-placement-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.manual-placement-stage-shell {
  min-width: 0;
  padding: 12px;
  display: grid;
  place-items: center;
  overflow: auto;
  background: #17191d;
}
.manual-placement-canvas {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #26292f;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 12px 28px rgba(0, 0, 0, 0.26);
  user-select: none;
  -webkit-user-select: none;
}
.manual-placement-background {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.manual-placement-pieces {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}
.manual-placement-piece {
  position: absolute;
  box-sizing: border-box;
  min-width: 24px;
  min-height: 24px;
  border: 1px solid transparent;
  outline: 0;
  cursor: grab;
  touch-action: none;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  will-change: left, top, width, height;
}
.manual-placement-piece:hover { border-color: rgba(255, 255, 255, 0.76); }
.manual-placement-piece.is-selected,
.manual-placement-piece:focus-visible {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--accent), 0 8px 22px rgba(0, 0, 0, 0.3);
}
.manual-placement-piece.is-dragging { cursor: grabbing; }
.manual-placement-piece > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.28));
}
.manual-placement-resize-handle {
  position: absolute;
  z-index: 2;
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
}
.manual-placement-piece.is-selected .manual-placement-resize-handle,
.manual-placement-piece:focus-visible .manual-placement-resize-handle { opacity: 1; pointer-events: auto; }
.manual-placement-resize-handle[data-manual-resize="nw"] { left: -2px; top: -2px; cursor: nwse-resize; }
.manual-placement-resize-handle[data-manual-resize="ne"] { right: -2px; top: -2px; cursor: nesw-resize; }
.manual-placement-resize-handle[data-manual-resize="sw"] { left: -2px; bottom: -2px; cursor: nesw-resize; }
.manual-placement-resize-handle[data-manual-resize="se"] { right: -2px; bottom: -2px; cursor: nwse-resize; }
.manual-placement-layers {
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--surface-2);
}
.manual-placement-layers-title {
  min-height: 38px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.manual-placement-background-layer,
.manual-placement-layer {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 50px;
  padding: 7px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  box-shadow: none;
}
.manual-placement-background-layer img,
.manual-placement-layer img {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  pointer-events: none;
}
.manual-placement-background-layer span,
.manual-placement-layer span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 600;
}
.manual-placement-background-layer .bi { color: var(--text-faint); justify-self: center; }
.manual-placement-layer { cursor: pointer; }
.manual-placement-layer:hover { background: var(--surface); color: var(--text); }
.manual-placement-layer.is-selected {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.manual-placement-layer .manual-placement-layer-order {
  justify-self: center;
  color: var(--text-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.manual-placement-toggle {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}
.manual-placement-toggle:has(input:disabled) { opacity: 0.56; cursor: not-allowed; }
body.is-manual-placement-dragging,
body.is-manual-placement-dragging * { cursor: grabbing !important; }
@media (max-width: 1080px) {
  .manual-placement-workspace { grid-template-columns: minmax(0, 1fr) 168px; }
}
@media (max-width: 760px) {
  .manual-placement-workspace { grid-template-columns: 1fr; }
  .manual-placement-layers { border-left: 0; border-top: 1px solid var(--line); }
  .manual-placement-layer-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manual-placement-layer-list .manual-placement-layer:nth-child(odd) { border-right: 1px solid var(--line); }
}
@media (max-width: 480px) {
  .manual-placement-layer-list { grid-template-columns: 1fr; }
  .manual-placement-layer-list .manual-placement-layer:nth-child(odd) { border-right: 0; }
  .manual-placement-stage-shell { padding: 8px; }
}
.generation-model-grid { display: grid; gap: 12px; }
.generation-model-grid > .grid-2 { gap: 10px; }
.generation-workflow-settings { gap: 12px; }
.blocking-plate-option {
  align-items: flex-start;
  flex-wrap: nowrap;
  cursor: pointer;
}
.blocking-plate-option > input { margin-top: 2px; }
.blocking-plate-option-copy { display: grid; gap: 2px; min-width: 0; }
.blocking-plate-option-copy strong { font-size: 12.5px; font-weight: 680; }
.blocking-plate-option-copy small { color: var(--text-muted); font-size: 11.5px; font-weight: 450; line-height: 1.35; }
.blocking-plate-option.is-disabled { opacity: 0.55; cursor: not-allowed; }
.generation-submit {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 18px 20px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.generation-submit small { display: flex; align-items: center; gap: 6px; }
.generation-submit button { width: 100%; min-height: 42px; }

/* Book-page extension */
.book-page-extension-form { padding: 0; overflow: hidden; }
.book-page-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(310px, 0.7fr);
}
.book-source-fieldset { padding: 22px; }
.book-source-fieldset > legend,
.book-direction-fieldset > legend { font-size: 12px; font-weight: 700; }
.book-page-settings {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: var(--surface-2);
  border-left: 1px solid var(--line);
}
.book-page-settings .book-page-submit-row {
  margin-top: auto;
  display: grid;
  align-items: stretch;
}
.book-page-settings .book-page-submit-row button { width: 100%; }
.book-source-grid {
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  max-height: 590px;
  padding: 2px 6px 2px 2px;
}
.book-source-option { border-radius: 8px; box-shadow: none; }
.book-source-option:has(input:checked) { box-shadow: 0 0 0 2px var(--accent); }
.book-source-check { border-radius: 6px; }
.book-direction-control { border-radius: 6px; }

/* Data display */
.metrics { gap: 12px; }
.metric {
  min-height: 112px;
  padding: 16px;
  border-radius: 8px;
  box-shadow: none;
}
.metric::before { display: none; }
.metric > small:first-child {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}
.metric strong { font-size: 24px; font-weight: 650; }
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
}
table { font-size: 12.5px; }
th {
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}
td { padding: 11px 12px; border-color: var(--line); }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 32%, var(--surface)); }
.badge {
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 5px;
  border-color: var(--line);
  font-size: 10.5px;
  font-weight: 700;
}

/* Album and media cards */
.album-shell { grid-template-columns: 228px minmax(0, 1fr); gap: 18px; }
.album-sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 18px);
  border-radius: 8px;
  box-shadow: none;
}
.album-sidebar-section { padding: 10px; }
.album-sidebar-header { padding: 4px 6px 8px; }
.album-folder-link {
  min-height: 44px;
  padding: 7px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
}
.album-folder-link:hover { background: var(--surface-2); border-color: var(--line); }
.album-folder-link.is-current,
.album-folder-row.is-current .album-folder-link {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}
.album-folder-icon {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 13px;
}
.album-toolbar.panel { padding: 10px 12px; box-shadow: none; }
.album-filter-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(145px, 1fr)) auto;
  align-items: end;
  gap: 9px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.album-filter-control {
  display: grid;
  min-width: 0;
  gap: 4px;
}
.album-filter-control > span {
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
}
.album-filter-control select {
  width: 100%;
  min-width: 0;
}
.album-filter-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
}
.album-view-toggle {
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}
.album-view-toggle button { border: 0; background: transparent; }
.album-view-toggle button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.results-grid { grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 16px; }
.image-card {
  border-radius: 8px;
  border-color: var(--line);
  box-shadow: var(--shadow-xs);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.image-card:hover {
  transform: none;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.image-card-thumb { background: var(--surface-2); }
.image-card img { object-fit: contain; }
.image-card-badge { border-radius: 5px; backdrop-filter: none; }
.image-card-badge-mode {
  max-width: calc(100% - 16px);
  background: rgba(49, 46, 129, 0.92);
}
.image-card-badge-mode > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.image-card-controls { padding: 8px 10px 0; }
.image-card-select-row { border-radius: 5px; }
.image-card-favorite,
.image-card-menu summary { border-radius: 6px; }
.image-card-meta { padding: 10px 12px; }
.image-card-meta strong { font-size: 12.75px; }
.image-card-footer {
  padding: 9px 10px;
  gap: 6px;
  background: var(--surface-2);
  border-top-color: var(--line);
}
.image-card-menu-panel { border-radius: 8px; box-shadow: var(--shadow-md); }
.image-card.placeholder { background: var(--surface); }
.job-card-status { background: rgba(20, 31, 28, 0.46); }
.image-card.failed .job-card-status { background: rgba(116, 25, 21, 0.52); }
.album-selection-bar-inner { border-radius: 8px; }
.empty,
.empty-state {
  border-radius: 8px;
  background: var(--surface);
}
.shared-card,
.shared-preview-card,
.share-preview-single,
.virtual-book-card { border-radius: 8px; box-shadow: var(--shadow-xs); }
.shared-card:hover,
.virtual-book-card:hover { transform: none; box-shadow: var(--shadow-sm); }
.shared-card-thumb-folder { background: var(--surface-2); }

/* Account, sharing and administrative forms */
.profile-overview { padding: 16px 18px; }
.profile-avatar { border-radius: 7px; }
.profile-form { grid-template-columns: minmax(180px, 240px) minmax(0, 1fr); }
.profile-form-copy { padding-right: 18px; }
.profile-form-fields { max-width: 680px; }
.share-list-item { border-radius: 8px; }
.share-list-icon,
.share-unlock-icon { border-radius: 7px; }
.flash {
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 7px;
  box-shadow: none;
}
.flash::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: currentColor;
}
.usage-banner { border-radius: 7px; }

/* Dialogs and overlays */
.toast { border-radius: 7px; box-shadow: var(--shadow-md); }
.modal-overlay { background: rgba(12, 20, 18, 0.54); backdrop-filter: blur(3px); }
.modal-dialog { border-radius: 8px; box-shadow: var(--shadow-lg); }
.modal-head,
.modal-foot { background: var(--surface-2); }
.modal-close { border-radius: 6px; }
.cookie-banner-panel {
  border-radius: 8px;
  background: var(--surface);
  backdrop-filter: none;
}
.cookie-banner-list li { border-radius: 6px; }
.lightbox { background: rgba(8, 12, 11, 0.94); }
.lb-close,
.lb-nav,
.lb-info-toggle { border-radius: 6px; }
.lb-info { border-radius: 8px 0 0 8px; }

/* Public and authentication surfaces */
.public-shell {
  min-height: 100dvh;
  grid-template-rows: 72px 1fr;
  background: var(--bg);
}
.public-topbar {
  min-height: 72px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.public-topbar .brand { max-width: 240px; }
.public-content {
  width: min(440px, 100%);
  padding: 56px 20px 72px;
  gap: 18px;
}
.public-content.wide { width: min(980px, 100%); }
.public-content .page-head { min-height: 0; margin-bottom: 2px; text-align: left; justify-content: flex-start; }
.public-content .page-head .title h1 { font-size: 26px; }
.public-content .panel { padding: 24px; border-radius: 8px; box-shadow: var(--shadow-sm); }
.share-unlock-card { border-radius: 8px; }

/* Virtual books inherit the same operational surface language. */
.virtual-books-head,
.virtual-book-editor-header,
.virtual-book-view-head { align-items: center; }
.virtual-book-create,
.virtual-book-editor-grid,
.virtual-book-media-panel,
.virtual-book-inspector,
.virtual-book-canvas-panel { border-radius: 8px; }
.virtual-book-format-toolbar,
.virtual-book-canvas-toolbar { background: var(--surface-2); }

/* Semi-automatic workflow review */
.workflow-title-line,
.workflow-row-title,
.workflow-row-meta,
.workflow-section-head,
.workflow-review-actions {
  display: flex;
  align-items: center;
}
.workflow-title-line { gap: 12px; flex-wrap: wrap; }
.workflow-title-line h1 { margin: 0; }
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.status-badge.warning { color: var(--warning); background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 28%, transparent); }
.status-badge.info { color: var(--info); background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.status-badge.success { color: var(--success); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.status-badge.danger { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.status-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: workflow-pulse 1.4s ease-in-out infinite;
}
@keyframes workflow-pulse { 50% { opacity: 0.35; transform: scale(0.78); } }

.workflow-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.workflow-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
}
.workflow-list-head strong { color: var(--text); font-size: 13px; }
.workflow-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 116px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.workflow-row:last-child { border-bottom: 0; }
.workflow-row:hover { background: var(--surface-2); }
.workflow-row-thumb {
  width: 112px;
  height: 84px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-3);
}
.workflow-row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.workflow-row-thumb > span { display: grid; width: 100%; height: 100%; place-items: center; color: var(--text-faint); font-size: 24px; }
.workflow-row-main { min-width: 0; }
.workflow-row-title { justify-content: space-between; gap: 12px; }
.workflow-row-title > div { display: grid; min-width: 0; }
.workflow-row-title strong { color: var(--text); font-size: 14px; }
.workflow-row-title small { color: var(--text-muted); }
.workflow-row-main > p { margin: 7px 0 9px; color: var(--text-muted); overflow-wrap: anywhere; }
.workflow-row-meta { gap: 14px; flex-wrap: wrap; color: var(--text-faint); font-size: 12px; }
.workflow-row-meta span { display: inline-flex; align-items: center; gap: 5px; }
.workflow-row-actions { display: flex; align-items: center; gap: 4px; }
.workflow-row-actions form { margin: 0; }
.workflow-delete { color: var(--text-muted); }
.workflow-delete:hover { color: var(--danger); background: var(--danger-soft); }
.workflow-open { color: var(--text-muted); }
.workflow-empty { min-height: 320px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 18px; }
.pagination > span { color: var(--text-muted); font-size: 12px; }

.character-asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 16px;
}
.character-asset-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.character-asset-preview {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: var(--asset-aspect, 1 / 1);
  max-height: 360px;
  overflow: hidden;
  background: var(--surface-2);
}
.character-asset-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.character-asset-body { display: grid; gap: 12px; padding: 14px; }
.character-asset-title { display: grid; gap: 3px; min-width: 0; }
.character-asset-title strong { overflow-wrap: anywhere; font-size: 14px; }
.character-asset-title small,
.character-asset-meta { color: var(--text-muted); font-size: 12px; }
.character-asset-meta { display: grid; gap: 3px; }
.character-asset-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.character-asset-body form,
.character-asset-body .button { width: 100%; }

.workflow-progress {
  width: 100%;
  height: 5px;
  margin: -6px 0 18px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-3);
}
.workflow-progress span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 180ms ease; }
.workflow-review-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 410px);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.workflow-review-media {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 24px;
  background: #202624;
}
.workflow-review-media img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 72vh;
  object-fit: contain;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.26);
}
.workflow-markup-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
}
.workflow-markup-stage > a { display: block; line-height: 0; }
.workflow-markup-stage > a > img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
}
[data-edit-form] .workflow-markup-stage {
  display: block;
  width: fit-content;
  margin: 0 auto 20px;
}
[data-edit-form] .workflow-markup-stage > a > img { max-height: 68vh; }
.workflow-markup-stage > img { box-shadow: 0 10px 32px rgba(0, 0, 0, 0.26); }
.workflow-markup-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
  touch-action: none;
  user-select: none;
}
.workflow-markup-stage.is-marking .workflow-markup-layer {
  pointer-events: auto;
  cursor: crosshair;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.88);
}
.workflow-markup-marker {
  position: absolute;
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #e5484d;
  color: #fff;
  box-shadow: 0 2px 9px rgba(0, 0, 0, 0.48);
  font: 700 11px/1 system-ui, sans-serif;
  transform: translate(-50%, -50%);
  cursor: pointer;
}
.workflow-markup-marker:hover { background: #c62f35; transform: translate(-50%, -50%) scale(1.08); }
.workflow-markup-marker.has-note { background: #b86716; }
.workflow-markup-marker.has-note:hover { background: #96500f; }
.workflow-markup-marker.is-selected {
  box-shadow: 0 0 0 3px #69c7b5, 0 3px 10px rgba(0, 0, 0, 0.52);
}
.workflow-markup-marker:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.workflow-markup-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 5px 6px 5px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(25, 30, 29, 0.9);
  color: #fff;
  font-size: 12px;
  line-height: 1.2;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
}
.workflow-markup-toolbar[hidden] { display: none; }
.workflow-markup-toolbar .icon-button {
  width: 28px;
  height: 28px;
  min-height: 28px;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.workflow-media-placeholder { display: grid; width: 100%; min-height: 420px; place-items: center; color: #8d9894; font-size: 42px; }
.workflow-review-controls {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
  border-left: 1px solid var(--line);
}
.workflow-control-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 22px; }
.workflow-control-head h2,
.workflow-processing-state h2,
.workflow-failed-state h2,
.workflow-complete-state h2 { margin: 0 0 5px; font-size: 17px; }
.workflow-control-head p,
.workflow-processing-state p,
.workflow-failed-state p,
.workflow-complete-state p { margin: 0; color: var(--text-muted); }
.workflow-control-icon {
  display: inline-grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 17px;
}
.workflow-control-icon.danger { background: var(--danger-soft); color: var(--danger); }
.workflow-control-icon.success { background: var(--success-soft); color: var(--success); }
.workflow-review-controls form { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.workflow-review-controls textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.55;
}
.workflow-marker-note {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.workflow-marker-note[hidden] { display: none; }
.workflow-marker-note-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.workflow-marker-note-head .icon-button { width: 30px; height: 30px; min-height: 30px; }
.workflow-marker-note label { display: grid; gap: 6px; color: var(--text-muted); font-size: 12px; }
.workflow-marker-note textarea {
  min-height: 72px;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.workflow-review-actions [data-workflow-markup-toggle].is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.workflow-review-actions { justify-content: flex-end; gap: 10px; margin-top: auto; padding-top: 18px; }
.workflow-review-actions .button { min-width: 118px; justify-content: center; }
.workflow-review-actions.has-limb-markup { display: grid; grid-template-columns: 1fr 1fr; }
.workflow-review-actions.has-limb-markup .button { min-width: 0; width: 100%; }
.form-error { margin-top: 10px; padding: 9px 11px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 12px; }
.workflow-processing-state,
.workflow-failed-state,
.workflow-complete-state { display: flex; flex: 1; flex-direction: column; align-items: flex-start; justify-content: center; }
.processing-spinner {
  width: 32px;
  height: 32px;
  margin-bottom: 18px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: workflow-spin 0.8s linear infinite;
}
@keyframes workflow-spin { to { transform: rotate(360deg); } }
.workflow-processing-state dl { width: 100%; margin: 24px 0 0; border-top: 1px solid var(--line); }
.workflow-processing-state dl > div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.workflow-processing-state dt { color: var(--text-faint); }
.workflow-processing-state dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.workflow-failed-state .workflow-control-icon,
.workflow-complete-state .workflow-control-icon { margin-bottom: 16px; }
.workflow-failed-state .button,
.workflow-complete-state .button { margin-top: 22px; }

.workflow-history { margin-top: 24px; padding: 20px 22px; border-top: 1px solid var(--line); }
.workflow-section-head { justify-content: space-between; gap: 16px; }
.workflow-section-head h2 { margin: 0; font-size: 16px; }
.workflow-section-head p { margin: 3px 0 0; color: var(--text-muted); }
.workflow-section-head > span { color: var(--text-faint); font-size: 12px; }
.workflow-timeline { margin: 18px 0 0; padding: 0; list-style: none; }
.workflow-timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  min-height: 64px;
  padding: 8px 0;
}
.workflow-timeline li::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 1px; background: var(--line); }
.workflow-timeline li:first-child::before { top: 50%; }
.workflow-timeline li:last-child::before { bottom: 50%; }
.workflow-timeline-marker { position: relative; z-index: 1; width: 15px; height: 15px; border: 3px solid var(--surface); border-radius: 50%; background: var(--line-strong); box-shadow: 0 0 0 1px var(--line); }
.workflow-timeline li.is-current .workflow-timeline-marker { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.workflow-timeline-copy { display: grid; min-width: 0; }
.workflow-timeline-copy small { color: var(--text-faint); }
.workflow-timeline-actions { display: flex; align-items: center; gap: 8px; }
.workflow-fork-button { width: 36px; height: 36px; min-height: 36px; }
.workflow-history-image { width: 54px; height: 46px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-xs); }
.workflow-history-image img { width: 100%; height: 100%; object-fit: cover; }
.workflow-fork-form { display: grid; gap: 12px; }
.workflow-fork-form > p { margin: 0; color: var(--text-muted); }
.workflow-fork-form label { display: grid; gap: 7px; color: var(--text-muted); font-size: 12px; }
.workflow-fork-form textarea { min-height: 230px; max-height: 50vh; resize: vertical; font: inherit; line-height: 1.5; }

@media (max-width: 1220px) {
  .generation-workspace,
  .book-page-workspace { grid-template-columns: minmax(0, 1fr) 330px; }
  .results-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 1040px) {
  .generation-workspace,
  .book-page-workspace { grid-template-columns: 1fr; }
  .generation-config,
  .book-page-settings { border-left: 0; border-top: 1px solid var(--line); }
  .generation-config { display: grid; grid-template-columns: 1fr 1fr; }
  .generation-config .form-section + .form-section { border-top: 0; border-left: 1px solid var(--line); }
  .generation-submit { grid-column: 1 / -1; }
  .book-page-settings { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  .book-page-settings .book-page-submit-row { grid-column: 1 / -1; }
  .workflow-review-shell { grid-template-columns: minmax(0, 1fr) 350px; }
}

@media (max-width: 960px) {
  :root { --sidebar-w: 280px; }
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-w), calc(100vw - 44px));
    height: 100dvh;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    transform: translateX(-102%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open { overflow: hidden; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .sidebar-header { display: flex; }
  .sidebar-close,
  .topbar-menu { display: inline-flex; }
  .sidebar-scroll { display: block; flex: 1 1 auto; width: 100%; padding: 12px 10px 20px; }
  .sidebar nav { flex-direction: column; flex-wrap: nowrap; width: 100%; }
  .sidebar-section-label { display: block; }
  .sidebar-foot { display: grid; flex: none; width: 100%; }
  .topbar { padding: 0 16px; }
  .content { padding: 24px 18px 48px; }
  .album-shell { grid-template-columns: 1fr; }
  .album-sidebar { position: static; }
  .album-filter-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .album-filter-actions { grid-column: 1 / -1; }
  .workflow-review-shell { grid-template-columns: 1fr; }
  .workflow-review-media { min-height: 420px; }
  .workflow-review-controls { border-top: 1px solid var(--line); border-left: 0; }
}

@media (max-width: 720px) {
  h1 { font-size: 21px; }
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions > .button,
  .page-actions > form { flex: 1; }
  .page-actions > form button { width: 100%; }
  .topbar-create span { display: none; }
  .topbar-create { width: 36px; padding: 0; }
  .generation-primary { padding: 18px; }
  .generation-config { display: block; }
  .generation-config .form-section + .form-section { border-left: 0; border-top: 1px solid var(--line); }
  .generation-brief .reference-prompt-editor { min-height: 180px; }
  .book-page-settings { grid-template-columns: 1fr; padding: 18px; }
  .book-page-settings .book-page-submit-row { grid-column: auto; }
  .book-source-fieldset { padding: 18px; }
  .profile-form { grid-template-columns: 1fr; }
  .profile-form-copy { padding-right: 0; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
  .album-toolbar-row { align-items: flex-start; }
  .album-view-toggle { margin-left: auto; }
  .album-filter-form { grid-template-columns: 1fr; }
  .album-filter-actions { grid-column: auto; }
  .image-card-action-label { display: none; }
  .public-content { padding-top: 36px; }
  .reference-image-current { grid-template-columns: 120px minmax(0, 1fr); gap: 14px; }
  .reference-image-current > a { width: 120px; height: 108px; }
  .workflow-row { grid-template-columns: 84px minmax(0, 1fr) auto; gap: 12px; }
  .workflow-row-thumb { width: 84px; height: 72px; }
  .workflow-open { display: none; }
  .workflow-row-title { align-items: flex-start; }
  .workflow-row-meta span:nth-child(n+3) { display: none; }
  .workflow-review-media { min-height: 320px; padding: 14px; }
  .workflow-review-controls { padding: 20px; }
}

@media (max-width: 480px) {
  .content { padding-inline: 12px; }
  .topbar { padding-inline: 10px; }
  .topbar .crumbs span:not(:last-child),
  .topbar .crumbs a,
  .topbar .crumbs .sep { display: none; }
  .topbar-actions .icon-button { display: none; }
  .panel { padding: 16px; }
  .generation-primary { padding: 14px; }
  .generation-config .form-section { padding: 16px; }
  .generation-submit { padding: 16px; }
  .generation-model-grid .grid-2,
  .grid-4 { grid-template-columns: 1fr; }
  .book-source-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .results-grid { grid-template-columns: 1fr; }
  .public-topbar { padding-inline: 14px; }
  .public-content { padding-inline: 12px; }
  .workflow-row { grid-template-columns: 64px minmax(0, 1fr) auto; padding: 12px; }
  .workflow-row-thumb { width: 64px; height: 58px; }
  .workflow-row-title { display: grid; }
  .workflow-row-title .status-badge { margin-top: 5px; }
  .workflow-row-main > p { display: none; }
  .workflow-review-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .workflow-review-actions .button { min-width: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  .status-pulse,
  .processing-spinner { animation: none; }
}
