@font-face {
  font-family: "Cabin";
  src: url("fonts/Cabin-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Cabin";
  src: url("fonts/Cabin-Italic-Variable.ttf") format("truetype");
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #fff8f6;
  --surface: #ffffff;
  --surface-soft: #fff1ed;
  --surface-active: #ffe7df;
  --text: #30231e;
  --muted: #715f57;
  --border: #dfd0c9;
  --border-strong: #cdbab1;
  --brand: #a5360f;
  --brand-bright: #de5f36;
  --brand-dark: #7d280b;
  --success: #24764a;
  --success-soft: #e5f5ec;
  --warning: #9a5c00;
  --warning-soft: #fff2d6;
  --danger: #b3261e;
  --danger-soft: #fff0ed;
  --topbar-bg: rgba(255, 255, 255, 0.94);
  --readonly-bg: #f7f2ef;
  --code-bg: #251d19;
  --code-text: #f8eee9;
  --floating-shadow: 0 8px 24px rgba(63, 42, 34, 0.1);
  --sidebar-width: 218px;
  --sidebar-collapsed-width: 62px;
  --topbar-height: 68px;
  --radius: 12px;
  --radius-control: 9px;
  --focus: 0 0 0 3px rgba(222, 95, 54, 0.2);
  font-family: "Cabin", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17110f;
  --surface: #211c19;
  --surface-soft: #2c2521;
  --surface-active: #3b2b25;
  --text: #f5e9e3;
  --muted: #cbb8af;
  --border: #4c3e37;
  --border-strong: #665249;
  --brand: #f09370;
  --brand-bright: #de5f36;
  --brand-dark: #ffc0a8;
  --success: #79d6a0;
  --success-soft: #1b3928;
  --warning: #f2bd67;
  --warning-soft: #3b2d17;
  --danger: #ff9b93;
  --danger-soft: #442421;
  --topbar-bg: rgba(33, 28, 25, 0.94);
  --readonly-bg: #2b2522;
  --code-bg: #100d0b;
  --code-text: #f8eee9;
  --floating-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; }

button,
.publish-button,
.secondary-link,
.danger-button,
.secondary-button,
.icon-button {
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100dvh;
  transition: grid-template-columns 180ms ease;
}

html[data-sidebar="collapsed"] .app-shell {
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 18px 14px;
  background: var(--surface-soft);
  border-right: 1px solid var(--border);
  transition: padding 180ms ease;
}

.sidebar-header {
  display: flex;
  align-items: flex-start;
  min-width: 0;
}

.sidebar-toggle {
  position: absolute;
  top: 22px;
  right: -15px;
  z-index: 11;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--floating-shadow);
  font-size: 22px;
  line-height: 1;
}

.sidebar-toggle:hover {
  border-color: var(--brand-bright);
  background: var(--surface-active);
  color: var(--brand);
}

.sidebar-toggle span {
  display: block;
  transform: translateY(-1px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 42px;
  padding: 4px 7px 18px;
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
}

.brand:hover { color: var(--text); }
.brand > span:last-child { display: grid; line-height: 1.15; }
.brand strong { font-size: 15px; font-weight: 700; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 12px; }

.brand-logo {
  display: block;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
}

.sidebar-nav { display: grid; gap: 4px; margin-top: 8px; }

.sidebar-nav a {
  position: relative;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.sidebar-nav-icon,
.sidebar-footer-icon {
  display: none;
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-nav a.active,
.sidebar-nav a:hover { background: var(--surface-active); color: var(--brand); }

html[data-sidebar="collapsed"] .sidebar {
  padding-inline: 10px;
}

html[data-sidebar="collapsed"] .brand {
  justify-content: center;
  padding-inline: 0;
}

html[data-sidebar="collapsed"] .brand > span,
html[data-sidebar="collapsed"] .sidebar-nav-label,
html[data-sidebar="collapsed"] .sidebar-footer-label {
  display: none;
}

html[data-sidebar="collapsed"] .sidebar-nav {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

html[data-sidebar="collapsed"] .sidebar-nav a,
html[data-sidebar="collapsed"] .sidebar-footer {
  display: grid;
  place-items: center;
  width: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 8px;
}

html[data-sidebar="collapsed"] .sidebar-nav-icon,
html[data-sidebar="collapsed"] .sidebar-footer-icon {
  display: block;
}

html[data-sidebar="collapsed"] .sidebar-nav a::after,
html[data-sidebar="collapsed"] .sidebar-footer::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 9px);
  top: 50%;
  z-index: 30;
  width: max-content;
  max-width: 210px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--floating-shadow);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translate(4px, -50%);
  transition: opacity 120ms ease, transform 120ms ease;
}

html[data-sidebar="collapsed"] .sidebar-nav a:hover::after,
html[data-sidebar="collapsed"] .sidebar-nav a:focus-visible::after,
html[data-sidebar="collapsed"] .sidebar-footer:hover::after,
html[data-sidebar="collapsed"] .sidebar-footer:focus-visible::after {
  opacity: 1;
  transform: translate(0, -50%);
}

.sidebar-footer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px 9px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.sidebar-footer:hover { color: var(--brand); }

.environment-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.workspace { min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-height);
  padding: 10px 24px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.topbar h1 { margin: 1px 0 0; font-size: 21px; font-weight: 600; line-height: 1.15; }

.global-search {
  display: flex;
  flex: 1 1 420px;
  max-width: 590px;
  margin-inline: 28px;
}

.global-search input {
  min-width: 0;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: var(--radius-control) 0 0 var(--radius-control);
  background: var(--surface);
  color: var(--text);
}

.global-search button {
  border-radius: 0 var(--radius-control) var(--radius-control) 0;
  white-space: nowrap;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
}

.theme-switch button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  min-height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.theme-switch svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-switch button:hover {
  border: 0;
  background: var(--surface-active);
  color: var(--text);
}

.theme-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(63, 42, 34, 0.12);
}

.logout-form { display: flex; margin: 0; }
.logout-button { width: 38px; height: 38px; min-height: 38px; padding: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.logout-button:hover { border-color: var(--brand-bright); background: var(--surface-active); color: var(--brand); }
.logout-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.login-page { min-height: 100dvh; }
.login-shell { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login-panel { width: min(100%, 390px); padding: 32px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--floating-shadow); }
.login-logo { display: block; width: 54px; height: 54px; margin-bottom: 24px; }
.login-panel h1 { margin: 4px 0 0; font-size: 30px; line-height: 1.15; }
.login-intro { margin: 8px 0 24px; color: var(--muted); }
.login-panel .message { margin: 0 0 18px; }
.login-form { display: grid; gap: 9px; }
.login-form label { margin-top: 5px; font-weight: 700; }
.login-form input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-control); background: var(--surface); color: var(--text); }
.login-form button { min-height: 46px; margin-top: 12px; }
.login-form .remember-device { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-weight: 400; cursor: pointer; }
.login-form .remember-device input { width: 18px; height: 18px; min-height: 18px; margin: 0; padding: 0; flex-shrink: 0; accent-color: var(--brand); }
.remember-device-help { margin: 0 0 0 28px; color: var(--muted); font-size: .875rem; }

.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow.dark { color: var(--muted); }

.health {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.health span { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }

main { width: min(100%, 1440px); margin: 0 auto; padding: 24px; }

.panel {
  min-width: 0;
  margin: 0 0 16px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel[id] { scroll-margin-top: calc(var(--topbar-height) + 16px); }
h2, h3, p { margin-top: 0; }
h2 { margin-bottom: 8px; font-size: 22px; font-weight: 600; line-height: 1.2; }
h3 { margin-bottom: 6px; font-size: 17px; font-weight: 600; }
p { margin-bottom: 12px; color: var(--muted); }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding: 24px;
}

.hero h2 { font-size: 27px; font-weight: 500; }
.hero > div > p { max-width: 620px; margin-bottom: 0; font-size: 16px; }
.paths { display: grid; gap: 8px; margin: 0; }

.paths div {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
}

.paths dt { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.paths dd { margin: 2px 0 0; overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 13px; }
.source-processing-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 16px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.source-processing-mode legend { padding: 0 6px; font-weight: 600; }
.source-processing-mode label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.source-processing-mode input { width: auto; margin: 0; }
.source-processing-mode small { grid-column: 1 / -1; color: var(--muted); }

.upload-details { padding: 0; overflow: hidden; }
.upload-details > summary {
  display: flex;
  align-items: center;
  min-height: 76px;
  padding: 16px 20px 16px 48px;
  cursor: pointer;
  list-style: none;
}
.upload-details > summary::-webkit-details-marker { display: none; }
.upload-details > summary::before {
  content: "›";
  position: absolute;
  margin-left: -28px;
  color: var(--brand-bright);
  font-size: 25px;
  line-height: 1;
  transition: transform 150ms ease;
}
.upload-details[open] > summary::before { transform: rotate(90deg); }
.upload-details > summary:hover { background: var(--surface-soft); }
.upload-details[open] > summary { border-bottom: 1px solid var(--border); }
.upload-details summary > span { display: grid; gap: 2px; }
.upload-details summary strong { color: var(--text); font-size: 21px; font-weight: 600; }
.upload-details summary small { color: var(--muted); font-size: 12px; }
.upload-details-content { display: grid; gap: 18px; padding: 20px; }
.naming-rules { padding: 13px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-soft); }
.naming-rules > strong { display: block; margin-bottom: 7px; font-size: 13px; }
.naming-rules ul { display: grid; gap: 5px; margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.naming-rules code { padding: 1px 4px; border-radius: 4px; background: var(--surface); color: var(--text); font-size: 11px; }
.source-check-note { margin: 0; padding: 9px 11px; border-left: 3px solid var(--brand-bright); background: var(--surface-soft); color: var(--muted); font-size: 12px; }

label { display: grid; gap: 6px; color: var(--text); font-size: 13px; font-weight: 600; }

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-weight: 400;
}

textarea { min-height: 92px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #b9a49b; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-bright); }
input[type="file"] { padding: 5px; }

input[type="file"]::file-selector-button {
  min-height: 30px;
  margin-right: 10px;
  padding: 5px 10px;
  border: 0;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--brand);
  font-weight: 700;
  cursor: pointer;
}

input[readonly] { background: var(--readonly-bg); color: var(--muted); }

button,
.publish-button,
.secondary-link,
.danger-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid var(--brand-bright);
  border-radius: var(--radius-control);
  background: var(--brand-bright);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button:hover, .publish-button:hover { border-color: var(--brand); background: var(--brand); color: #fff; }
button:disabled { border-color: var(--border); background: #e8ded9; color: #8f7f77; cursor: not-allowed; }
.stack button { justify-self: start; }

.secondary-button,
.secondary-link,
.danger-button { border-color: var(--border-strong); background: var(--surface); color: var(--brand); }

.secondary-button:hover, .secondary-link:hover { border-color: var(--brand-bright); background: var(--surface-active); color: var(--brand-dark); }
.danger-button, .danger-icon { color: var(--danger); }
.danger-button:hover, .danger-icon:hover { border-color: #e6aaa4; background: var(--danger-soft); color: var(--danger); }

.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 15px; }
.section-heading h2, .section-heading p { margin-bottom: 4px; }

.count {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.proposal-generate-all { margin: 0; }
.proposal-generate-all button { display: inline-flex; align-items: center; gap: 7px; min-width: 138px; justify-content: center; white-space: nowrap; }
.proposal-generate-all button svg { width: 17px; height: 17px; fill: currentColor; }
.proposal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; }

.proposal-card {
  display: grid;
  grid-template-columns: 152px minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.proposal-preview { display: grid; align-content: start; gap: 9px; min-height: 228px; padding: 12px; background: var(--surface-soft); border-right: 1px solid var(--border); }
.cover-zoom-trigger { display: block; width: 100%; height: 100%; min-height: 204px; padding: 0; border: 0; background: var(--surface); cursor: zoom-in; }
.proposal-preview img, .preview-placeholder { width: 100%; height: 100%; min-height: 204px; object-fit: contain; background: var(--surface); }
.proposal-preparing { position: relative; width: 100%; height: 100%; min-height: 204px; overflow: hidden; background: var(--surface); }
.proposal-preparing > img { display: block; opacity: .52; }
.proposal-progress { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 34%, transparent); cursor: progress; }
.proposal-spinner { width: 42px; height: 42px; border: 4px solid color-mix(in srgb, var(--brand) 20%, var(--border)); border-top-color: var(--brand); border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 8px color-mix(in srgb, var(--surface) 78%, transparent); animation: vector-spin .9s linear infinite; }
.cover-zoom-trigger:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.preview-placeholder { display: grid; place-items: center; border: 1px dashed var(--border-strong); color: var(--muted); }
.proposal-content { display: grid; align-content: start; gap: 13px; padding: 16px; }
.proposal-content h3 { margin-top: 10px; }
.proposal-content p { margin-bottom: 0; }
.proposal-editorial-form { display: grid; gap: 10px; min-width: 0; }
.proposal-editorial-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.proposal-editorial-grid label { min-width: 0; }
.proposal-field-wide { grid-column: 1 / -1; }
.proposal-editorial-form input,
.proposal-editorial-form select,
.proposal-editorial-form textarea { width: 100%; }
.proposal-editorial-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.proposal-editorial-actions button { flex: 1 1 180px; }
.proposal-illustration-form { margin: 0; }
.proposal-illustration-button { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-control); color: var(--brand); font-size: 11px; font-weight: 700; line-height: 1.2; text-align: center; cursor: pointer; }
.proposal-illustration-button:hover { border-color: var(--brand); background: var(--surface-active); }
.proposal-illustration-button:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.proposal-illustration-button svg { flex: 0 0 auto; width: 15px; height: 15px; }
.proposal-illustration-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.status {
  display: inline-flex;
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.status-ready { background: var(--success-soft); color: var(--success); }
.status-error { background: var(--danger-soft); color: var(--danger); }
.status-review { background: var(--warning-soft); color: var(--warning); }
.retry-form { display: grid; gap: 8px; }
.proposal-cancel-form { display: grid; }
.source-check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; }
.source-check-card { display: grid; align-content: start; gap: 10px; min-width: 0; padding: 15px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.source-check-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; font-weight: 700; }
.source-check-card h3, .source-check-card p { margin: 0; }
.source-check-card p { color: var(--muted); font-size: 13px; }
.source-check-reasons { margin: 0; padding-left: 18px; color: var(--warning); font-size: 13px; }
.source-check-stats { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--muted); font-size: 11px; }
.button-link { display: inline-flex; align-items: center; justify-content: center; justify-self: start; min-height: 36px; padding: 7px 12px; border: 1px solid var(--brand-bright); border-radius: var(--radius-control); background: var(--brand-bright); color: #fff; font-weight: 700; }
.button-link:hover { border-color: var(--brand); background: var(--brand); color: #fff; }
.source-rejections { position: relative; margin-top: 12px; border-top: 1px solid var(--border); }
.source-rejections summary { min-height: 42px; padding: 12px 150px 8px 2px; color: var(--danger); font-weight: 700; cursor: pointer; }
.source-rejections-purge { position: absolute; top: 6px; right: 0; z-index: 1; margin: 0; }
.source-rejections-purge .danger-button { min-height: 32px; padding: 5px 9px; font-size: 12px; }
.source-check-panel-compact { padding: 10px 18px; }
.source-check-panel-compact > .section-heading { display: none; }
.source-check-panel-compact .source-rejections { margin-top: 0; border-top: 0; }
.source-check-panel-compact .source-rejections summary { padding-top: 8px; padding-bottom: 8px; }
.source-check-panel-compact .source-rejections-purge { top: 2px; }
.source-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 12px 20px; }
.source-group { min-width: 0; }
.source-group h3 { padding: 0 2px 8px; color: var(--brand); font-size: 13px; text-transform: uppercase; }

.managed-list,
.asset-list,
.cover-list,
.file-list,
.compact-list { margin: 0; padding: 0; list-style: none; }

.managed-list { border-top: 1px solid var(--border); }

.managed-list li,
.file-list li,
.compact-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
  padding: 11px 2px;
  border-bottom: 1px solid var(--border);
}

.file-details { display: grid; min-width: 0; gap: 3px; }
.file-details strong, .file-details a { overflow-wrap: anywhere; color: var(--text); font-size: 14px; }
.file-details span, .file-list span, .compact-list span { color: var(--muted); font-size: 12px; }
.file-details .product-code { color: var(--muted); font-size: 11px; font-weight: 600; }
.file-details .vector-error { color: var(--danger); font-size: 11px; line-height: 1.3; }
.file-list a { min-width: 0; overflow-wrap: anywhere; }
.source-actions { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: flex-end; gap: 8px; }
.source-genre-form { display: flex; align-items: end; gap: 7px; margin: 0; }
.source-genre-form label { display: grid; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 600; }
.source-genre-form select { min-width: 124px; min-height: 40px; padding: 7px 28px 7px 9px; font-size: 12px; }
.source-genre-form .secondary-button { min-height: 40px; padding: 8px 10px; font-size: 11px; }

.run-panel[hidden] {
  display: none !important;
}

.run-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto minmax(430px, auto);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-color: #efb8a4;
  background: var(--surface-soft);
}

.run-panel h2, .run-panel p { margin-bottom: 4px; }
.run-form { display: flex; align-items: center; justify-content: flex-end; flex-wrap: nowrap; gap: 13px; }
.strict-option { display: grid; max-width: 320px; gap: 2px; }
.strict-option small { color: var(--muted); font-size: 11px; line-height: 1.25; }
.embedded-details { position: relative; min-width: 190px; margin: 0; border: 0; }
.embedded-details > summary { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 24px; cursor: pointer; list-style: none; }
.embedded-details > summary::-webkit-details-marker { display: none; }
.embedded-details > summary::before { content: "›"; margin-left: -20px; color: var(--brand-bright); font-size: 24px; transition: transform 150ms ease; }
.embedded-details[open] > summary::before { transform: rotate(90deg); }
.embedded-details summary > span { display: grid; gap: 2px; }
.embedded-details summary small { color: var(--muted); font-size: 12px; }
.embedded-details > .accordion-content {
  position: absolute;
  z-index: 30;
  top: calc(100% + 12px);
  left: 0;
  width: min(720px, calc(100vw - 64px));
  max-height: 60vh;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 38px rgba(20, 13, 10, .28);
}
.check { display: inline-flex; grid-template-columns: none; align-items: center; gap: 7px; color: var(--muted); white-space: nowrap; }
.check input { width: 16px; min-height: 16px; accent-color: var(--brand-bright); }

.outputs-panel { padding: 0; overflow: hidden; }

.outputs-panel:has(.regeneration-menu[open]) {
  position: relative;
  z-index: 8;
  overflow: visible;
}

.outputs-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  padding: 15px 20px 15px 49px;
  cursor: pointer;
  list-style: none;
}

.outputs-panel > summary::-webkit-details-marker { display: none; }

.outputs-panel > summary::before {
  content: "›";
  position: absolute;
  margin-left: -29px;
  color: var(--brand-bright);
  font-size: 25px;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 150ms ease;
}

.outputs-panel[open] > summary::before { transform: rotate(90deg); }
.outputs-panel > summary:hover { background: var(--surface-soft); }
.outputs-panel[open] > summary { border-bottom: 1px solid var(--border); }
.outputs-panel summary > span:first-child { display: grid; gap: 2px; }
.outputs-panel summary strong { font-size: 18px; font-weight: 600; }
.outputs-panel summary small { color: var(--muted); font-size: 13px; }

.asset-list,
.cover-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 20px; }

.asset-list li,
.cover-list li {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-width: 0;
  min-height: 112px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.asset-list [data-book-row][hidden] { display: none; }
.book-classification { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px; }
.book-classification small { display: inline; }
.book-genre { color: var(--muted); }

.asset-list li:nth-child(odd), .cover-list li:nth-child(odd) { padding-right: 16px; }
.asset-list li:nth-child(even), .cover-list li:nth-child(even) { padding-left: 16px; border-left: 1px solid var(--border); }
.stock-panel .asset-list { grid-template-columns: 1fr; }
.stock-panel .asset-list li { grid-template-columns: 64px minmax(220px, 320px) auto minmax(0, 1fr) minmax(130px, .35fr); padding-inline: 0; border-left: 0; }

.asset-thumbnail,
.cover-list > li > img {
  width: 64px;
  height: 88px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface-soft);
}

.asset-thumbnail img, .cover-list > li > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.library-cover-button { position: relative; display: block; padding: 0; cursor: zoom-in; }
.library-cover-button:hover { border-color: var(--brand); }
.library-cover-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.library-publication-spinner { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 74%, transparent); }
.library-publication-spinner .proposal-spinner { width: 28px; height: 28px; border-width: 3px; box-shadow: none; }
.publishing-button { display: inline-flex; align-items: center; gap: 7px; }
.library-filters { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.library-search { position: relative; flex: 0 1 360px; width: min(100%, 360px); max-width: 360px; }
.library-search input { width: 100%; min-height: 38px; padding-right: 38px; }
.library-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.library-search-clear { position: absolute; top: 50%; right: 6px; display: grid; width: 27px; min-width: 27px; height: 27px; min-height: 27px; padding: 0; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 20px; font-weight: 400; line-height: 1; transform: translateY(-50%); }
.library-search-clear:hover { border: 0; background: var(--surface-active); color: var(--brand); }
.library-search-clear[hidden] { display: none; }
.filter-toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.category-filter-groups { flex: 1 0 100%; display: grid; gap: 8px; }
.category-filter-group { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.category-filter-label { margin-right: 3px; color: var(--muted); font-size: 12px; font-weight: 700; }
.category-filter-button { min-height: 30px; padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); color: var(--muted); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.category-filter-button:hover { border-color: var(--brand); color: var(--brand); }
.category-filter-button.is-selected { border-color: var(--brand); background: var(--brand); color: #fff; }
.category-filter-button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.library-filters--categories { display: grid; grid-template-columns: max-content minmax(220px, 420px) max-content max-content; align-items: center; justify-content: start; }
.library-filters--categories .category-filter-groups { display: contents; }
.library-filters--categories .category-filter-group:not(.category-filter-subgroup) { grid-column: 1; grid-row: 1; }
.library-filters--categories .library-search { grid-column: 2; grid-row: 1; max-width: none; }
.library-filters--categories .filter-toggle { grid-column: 3; grid-row: 1; }
.library-filters--categories .quality-audit-controls { grid-column: 4; grid-row: 1; }
.quality-audit-controls { display: flex; align-items: center; gap: 10px; }
.quality-audit-form button { min-height: 38px; white-space: nowrap; }
.library-filters--categories .category-filter-subgroup { grid-column: 1 / -1; grid-row: 2; }
.library-filter-status { display: flex; grid-column: 1 / -1; align-items: center; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 12px; }
.library-filter-count { color: var(--muted); font-size: 12px; }
.library-filter-count strong { color: var(--text); }
.quality-audit-summary strong { color: var(--success); }
.quality-audit-summary .quality-audit-problems { color: var(--danger); }
.filter-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.toggle-track { position: relative; width: 34px; height: 20px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); transition: background 150ms ease, border-color 150ms ease; }
.toggle-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform 150ms ease, background 150ms ease; }
.filter-toggle input:checked + .toggle-track { border-color: var(--brand); background: var(--surface-active); }
.filter-toggle input:checked + .toggle-track::after { background: var(--brand); transform: translateX(14px); }
.filter-toggle input:focus-visible + .toggle-track { outline: 2px solid var(--brand); outline-offset: 3px; }
.book-quality { display: grid; align-content: center; gap: 3px; min-width: 0; padding-left: 11px; border-left: 2px solid var(--border); }
.book-quality > span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.book-quality > strong { color: var(--muted); font-size: 13px; }
.book-quality > small { overflow-wrap: anywhere; color: var(--muted); font-size: 11px; line-height: 1.3; }
.book-quality--ok { border-left-color: var(--success); }
.book-quality--ok > strong { color: var(--success); }
.book-quality--error { border-left-color: var(--danger); }
.book-quality--error > strong, .book-quality--error > small { color: var(--danger); }
.book-quality--neutral { border-left-color: var(--warning); }
.book-quality--neutral > strong { color: var(--warning); }
.stock-panel .published-actions { grid-column: 3; grid-row: 1; }
.stock-panel .book-quality { grid-column: 5; grid-row: 1; }
.stock-panel.quality-column-hidden .asset-list li { grid-template-columns: 64px minmax(220px, 320px) auto minmax(0, 1fr); }
.stock-panel.quality-column-hidden .book-quality { display: none; }
.icon-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 9px; }
.icon-actions form:not(.page-count-form) { display: contents; }
.regenerate-book-button { flex: 0 0 auto; min-height: 38px; white-space: nowrap; }
[data-genre-dialog-trigger].is-loading {
  display: inline-grid;
  place-items: center;
  cursor: wait;
}
[data-genre-dialog-trigger].is-loading .chat-spinner {
  width: 16px;
  height: 16px;
}

.regeneration-menu { position: relative; }
.regeneration-menu > summary { list-style: none; }
.regeneration-menu > summary::-webkit-details-marker { display: none; }
.regeneration-menu[open] > summary { border-color: var(--brand); background: var(--surface-active); }
.regeneration-action-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: 166px;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(32, 20, 15, .18);
}
.regeneration-action-menu form { display: contents; }
.regeneration-action {
  display: flex;
  width: 100%;
  min-height: 36px;
  align-items: center;
  justify-content: flex-start;
  padding: 6px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.regeneration-action:hover,
.regeneration-action:focus-visible { background: var(--surface-active); color: var(--brand); }
.icon-actions .regeneration-form {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: 330px;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(32, 20, 15, .18);
}
.regeneration-form label { display: grid; gap: 7px; color: var(--text); font-size: 12px; font-weight: 600; }
.regeneration-form select { width: 100%; min-height: 40px; }
.regeneration-form button[type="submit"] { width: 100%; }
.regeneration-form .regeneration-cancel { width: 100%; }
.regeneration-form .genre-suggest-button { width: 100%; }
.genre-suggestion { display: grid; gap: 4px; margin: 0; padding: 9px 10px; border-left: 3px solid var(--brand-bright); background: var(--surface-soft); color: var(--muted); font-size: 11px; line-height: 1.4; }
.genre-suggestion[hidden] { display: none; }
.genre-suggestion strong { color: var(--text); font-size: 12px; }
.genre-suggestion.is-error { border-left-color: var(--danger); color: var(--danger); }
.genre-suggestion.is-error strong { color: var(--danger); }

.genre-dialog {
  width: min(520px, calc(100vw - 32px));
  max-width: none;
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(20, 13, 10, .38);
}
.genre-dialog::backdrop { background: rgba(20, 13, 10, .72); }
.genre-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.genre-dialog-header > div { display: grid; gap: 3px; }
.genre-dialog-header span { color: var(--muted); font-size: 12px; }
.genre-dialog-form { display: grid; gap: 14px; padding: 18px; }
.genre-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.genre-dialog-actions button { width: 100%; }
.regeneration-scope {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}
.regeneration-scope legend {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 700;
}
.regeneration-scope-options {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
}
.regeneration-scope label {
  position: relative;
  min-width: 0;
  cursor: pointer;
}
.regeneration-scope input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.regeneration-scope span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}
.regeneration-scope input:checked + span {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 1px 4px rgba(20, 13, 10, .14);
}
.regeneration-scope input:focus-visible + span {
  outline: 2px solid var(--brand-bright);
  outline-offset: 1px;
}


.cover-zoom-dialog {
  width: min(920px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(20, 13, 10, .38);
}
.cover-zoom-dialog::backdrop { background: rgba(20, 13, 10, .72); }
.cover-zoom-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.cover-zoom-dialog-header form { margin: 0; }
.cover-zoom-dialog > img { display: block; width: auto; max-width: 100%; height: auto; max-height: calc(100dvh - 168px); margin: 0 auto; object-fit: contain; background: var(--surface-soft); }
.cover-zoom-dialog-actions { display: flex; justify-content: flex-end; padding: 12px 14px; border-top: 1px solid var(--border); }
.cover-zoom-dialog-actions button { min-width: 140px; }

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
}

.icon-button:hover { border-color: var(--brand-bright); background: var(--surface-active); color: var(--brand-dark); }
.icon-button svg { width: 18px; height: 18px; fill: currentColor; stroke: currentColor; stroke-width: 1.8; }
.source-replace-button svg { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.chat-button { border-style: solid; background: var(--surface); }
.chat-button svg { fill: none; }
.media-button svg { stroke: none; }
.chat-ready { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); color: var(--success); }
.chat-failed { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.chat-start { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.chat-loading { border-color: var(--border-strong); color: var(--brand); cursor: progress; }
.chat-spinner { width: 17px; height: 17px; border: 2px solid color-mix(in srgb, var(--brand) 24%, var(--border)); border-top-color: var(--brand); border-radius: 50%; animation: vector-spin .9s linear infinite; }
.chat-disabled { color: var(--muted); cursor: not-allowed; opacity: .42; }
.chat-disabled:hover { border-color: var(--border-strong); background: var(--surface); color: var(--muted); }
.publish-button { min-height: 36px; padding: 7px 12px; font-size: 13px; }
.disabled-button { border-color: var(--border); background: var(--surface-soft); color: var(--muted); cursor: not-allowed; opacity: .65; }

.published-badge,
.inactive-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.inactive-badge { background: var(--warning-soft); color: var(--warning); }
.published-actions { align-items: flex-start; gap: 5px; }
.published-actions > .icon-button,
.published-actions > form > .icon-button,
.published-actions > .regeneration-menu,
.published-actions > .regenerate-book-button,
.published-actions > .chat-loading {
  margin-top: 17px;
}
.publication-inline-metadata {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  min-height: 50px;
}
.publication-inline-metadata .publication-status { padding-top: 17px; }
.page-count-form {
  display: grid;
  grid-template-columns: 62px 30px;
  grid-template-rows: 12px 30px;
  align-items: center;
  gap: 2px 4px;
  width: 102px;
  min-width: 102px;
  min-height: 50px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
}
.page-count-form label { display: contents; }
.page-count-form label > span {
  display: flex;
  grid-column: 1 / -1;
  grid-row: 1;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 12px;
  text-transform: uppercase;
}
.page-count-review { color: var(--success); font-size: 9px; font-weight: 800; white-space: nowrap; text-transform: none; }
.page-count-form:not(.is-verified) .page-count-review { display: none; }
.page-count-form.is-verified { border-color: color-mix(in srgb, var(--success) 42%, var(--border)); }
.page-count-form.is-verified .icon-button { border-color: var(--success); color: var(--success); }
.page-count-form input {
  grid-column: 1;
  grid-row: 2;
  width: 62px;
  min-height: 30px;
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 12px;
  text-align: center;
}
.page-count-form .icon-button {
  grid-column: 2;
  grid-row: 2;
  align-self: stretch;
  width: 30px;
  height: 30px;
  min-height: 30px;
  flex-basis: 30px;
  border-radius: 5px;
  font-size: 14px;
}
.publication-status { padding-top: 14px; }
.publication-status { display: grid; justify-items: center; gap: 4px; }
.product-page-link { color: var(--brand); font-size: 10px; font-weight: 600; text-align: center; white-space: nowrap; }
.product-page-link:hover { color: var(--brand-dark); text-decoration: underline; }
.button-tooltip { position: fixed; z-index: 1000; width: max-content; max-width: min(240px, calc(100vw - 20px)); padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--text); color: var(--surface); box-shadow: var(--floating-shadow); font-size: 11px; font-weight: 600; line-height: 1.35; text-align: center; pointer-events: none; }
.button-tooltip[hidden] { display: none; }
.empty { margin: 0; padding: 18px 20px; color: var(--muted); font-style: italic; }
.accordion-content { padding: 18px 20px 20px; }
.run-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.run-meta span { padding: 5px 8px; border-radius: 6px; background: var(--surface-soft); color: var(--muted); font-size: 12px; }

pre {
  max-height: 360px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
}

.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.message, .flash { margin: 0; padding: 11px 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.message.success { border-color: #add7bf; background: var(--success-soft); color: var(--success); }
.flash.warning { border-color: var(--warning); background: var(--warning-soft); color: var(--warning); }
.message.error, .flash.error { border-color: #efbbb6; background: var(--danger-soft); color: var(--danger); }
.muted { color: var(--muted); }
.error-text { color: var(--danger); }
.breadcrumb { margin: 0 0 13px; }
.breadcrumb a { color: var(--muted); font-size: 13px; font-weight: 600; }

.preview-button { background: var(--surface); color: var(--brand); }

/* Public-source search */
.search-intro,
.catalogue-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.search-intro > div,
.catalogue-heading > div { max-width: 720px; }
.search-intro h2,
.catalogue-heading h2 { margin: 4px 0 7px; }
.search-intro p,
.catalogue-heading p { margin-bottom: 0; }

.source-search-form {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) 130px auto;
  align-items: end;
  gap: 10px;
  min-width: min(100%, 560px);
}

.source-results { border-top: 1px solid var(--border); }
.source-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 28px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.source-result h3 { margin: 7px 0 2px; font-size: 19px; }
.source-result p { margin: 5px 0; }
.result-author { color: var(--muted); font-weight: 600; }
.result-metadata { color: var(--muted); font-size: 13px; }
.result-metadata span { margin-inline: 5px; color: var(--border-strong); }
.result-url { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.result-url a { font-weight: 500; }
.catalogue-filter-note { margin: 0 0 14px; padding: 9px 11px; border-radius: 7px; background: var(--surface-soft); color: var(--muted); font-size: 13px; }
.provider {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--surface-active);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.provider-gutenberg { background: var(--success-soft); color: var(--success); }
.result-links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 11px; font-weight: 600; }
.result-import {
  display: grid;
  grid-template-columns: 120px minmax(150px, 1fr) auto;
  align-items: end;
  gap: 9px;
}

/* Catalogue reconciliation */
.catalogue-actions { display: grid; justify-items: end; gap: 10px; min-width: 330px; }
.catalogue-table-tools { display: flex; flex-wrap: wrap; align-items: end; justify-content: flex-end; gap: 10px; }
.catalogue-refresh-form { margin: 0; }
.refresh-button svg { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.catalogue-upload { display: flex; align-items: end; gap: 8px; }
.catalogue-upload label { max-width: 225px; }
.connection-status { padding: 6px 9px; border-radius: 6px; background: var(--warning-soft); color: var(--warning); font-size: 12px; font-weight: 700; }
.catalogue-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.catalogue-stats div { display: grid; gap: 2px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.catalogue-stats strong { font-size: 25px; line-height: 1; }
.catalogue-stats span { color: var(--muted); font-size: 12px; }
.catalogue-production-toggle { min-height: 38px; }
.table-filter { width: min(100%, 280px); }
.table-scroll { overflow-x: auto; }
.catalogue-table { width: max-content; min-width: 100%; border-collapse: collapse; table-layout: auto; }
.catalogue-table th,
.catalogue-table td { padding: 11px 10px; border-bottom: 1px solid var(--border); overflow-wrap: break-word; text-align: left; vertical-align: middle; }
.catalogue-table th { position: sticky; top: 0; z-index: 1; padding: 10px; background: var(--surface); color: var(--muted); font-size: 12px; white-space: nowrap; text-transform: uppercase; }
.catalogue-table .catalogue-col-code { width: 105px; min-width: 105px; white-space: nowrap; }
.catalogue-table .catalogue-col-collection { width: 130px; min-width: 115px; }
.catalogue-table .catalogue-col-number { width: 46px; min-width: 46px; text-align: center; white-space: nowrap; }
.catalogue-table .catalogue-col-title { width: 270px; min-width: 230px; }
.catalogue-table .catalogue-col-subtitle { width: 190px; min-width: 160px; }
.catalogue-title, .catalogue-subtitle { display: block; }
.catalogue-title { color: var(--text); }
.catalogue-subtitle { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.catalogue-table .catalogue-col-author { width: 190px; min-width: 170px; }
.catalogue-table .catalogue-col-description { width: 250px; min-width: 220px; color: var(--muted); }
.catalogue-table .catalogue-col-bio { width: 210px; min-width: 180px; color: var(--muted); }
.catalogue-table .catalogue-col-contributors { width: 170px; min-width: 145px; }
.catalogue-table .catalogue-col-genre { width: 105px; min-width: 90px; }
.catalogue-table .catalogue-col-language { width: 66px; min-width: 60px; white-space: nowrap; }
.catalogue-table .catalogue-col-price { width: 62px; min-width: 58px; white-space: nowrap; }
.catalogue-table .catalogue-col-series { width: 150px; min-width: 125px; }
.catalogue-table .catalogue-col-source { width: 68px; min-width: 68px; }
.catalogue-table .catalogue-col-status { min-width: 96px; }
.catalogue-table .catalogue-col-production { width: 112px; min-width: 112px; }
.catalogue-table .catalogue-col-control { width: 190px; min-width: 160px; }
.catalogue-table .catalogue-col-link { width: 62px; min-width: 62px; }
.catalogue-production-form,
.catalogue-bulk-production { margin: 0; }
.catalogue-production-form .button,
.catalogue-bulk-production .button { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 7px 10px; white-space: nowrap; }
.catalogue-production-form .button svg,
.catalogue-bulk-production .button svg { width: 16px; height: 16px; fill: currentColor; }
.catalogue-bulk-production .button { min-width: 112px; justify-content: center; }
.catalogue-table .catalogue-col-select { width: 42px; min-width: 42px; padding-left: 12px; padding-right: 4px; text-align: center; }
.catalogue-col-select input { width: 17px; height: 17px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.catalogue-status { display: inline-block; padding: 4px 7px; border-radius: 5px; background: var(--warning-soft); color: var(--warning); font-size: 12px; font-weight: 700; white-space: nowrap; }
.catalogue-status.status-publie { background: var(--success-soft); color: var(--success); }
.catalogue-status.status-genere { background: var(--surface-active); color: var(--brand-dark); }
.catalogue-status.status-absent { background: var(--danger-soft); color: var(--danger); }
.catalogue-ok { color: var(--success); font-weight: 700; }
.issue-list { margin: 0; padding-left: 18px; color: var(--danger); }
.compact-list { display: grid; gap: 8px; }

/* In-browser EPUB reader */
.reader-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; min-width: 0; }
.reader-workspace.is-read-only { grid-template-columns: minmax(0, 1fr); }
.source-review-summary { display: grid; grid-template-columns: auto minmax(220px, 1fr) minmax(300px, auto); align-items: center; gap: 14px 20px; margin-bottom: 14px; }
.source-review-summary > .secondary-link { grid-column: 1; grid-row: 1; }
.source-review-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.source-review-title { grid-column: 2; grid-row: 1; }
.source-review-title h2, .source-review-title p { margin: 0; overflow-wrap: anywhere; }
.source-review-title p { color: var(--muted); font-size: 13px; }
.source-review-metrics { display: flex; grid-column: 3; grid-row: 1; flex-wrap: wrap; gap: 8px; margin: 0; }
.source-review-metrics div { display: grid; min-width: 78px; padding: 7px 9px; border-left: 2px solid var(--border-strong); }
.source-review-metrics dt { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.source-review-metrics dd { margin: 0; font-size: 13px; font-weight: 700; }
.source-review-alert { grid-column: 2 / 4; grid-row: 2; padding: 10px 12px; border-left: 3px solid var(--warning); background: var(--warning-soft); color: var(--warning); }
.source-review-alert ul { margin: 5px 0 0; padding-left: 18px; }
.source-review-decisions { display: flex; grid-column: 2 / 4; grid-row: 3; gap: 8px; justify-self: start; }
.source-review-decisions form { display: contents; }
.reader-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: calc(100dvh - var(--topbar-height) - 48px);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.reader-toolbar { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.reader-toolbar { grid-row: 1; }
.reader-book-meta { display: grid; min-width: 140px; max-width: 300px; gap: 2px; }
.reader-book-meta strong, .reader-book-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-book-meta span { color: var(--muted); font-size: 11px; }
.reader-batch-progress { flex: 0 0 auto; min-width: 48px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; white-space: nowrap; }
.reader-reading-controls { display: flex; align-items: center; gap: 6px; min-width: 0; }
.reader-reading-controls select { min-width: 170px; max-width: 320px; }
.reader-reading-controls button { flex: 0 0 auto; min-width: 52px; padding-inline: 9px; }
.reader-actions { display: flex; gap: 6px; margin-left: auto; }
.reader-publish-progress { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.reader-scan { display: flex; gap: 5px; }
.reader-scan button { min-width: 52px; padding-inline: 8px; }
.reader-actions form { display: contents; }
.reader-actions .reader-publish-form { display: flex; align-items: center; gap: 9px; }
.reader-revectorize-toggle { min-height: 36px; }
.reader-chat-button { flex: 0 0 36px; }
.reader-metadata-form { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: start; gap: 10px; padding: 12px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.reader-metadata-form { grid-row: 2; }
.reader-metadata-form:not([hidden]) { display: grid; }
.reader-metadata-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; margin-top: 25px; }
.reader-stage { display: grid; grid-template-columns: 50px minmax(0, 1fr) 50px; min-height: 0; background: var(--surface); }
.reader-stage { grid-row: 3; }
#reader-viewer { min-width: 0; min-height: 0; overflow: hidden; background: var(--surface); }
.reader-page-arrow { align-self: center; width: 40px; height: 56px; min-height: 56px; padding: 0; border: 0; background: transparent; color: var(--brand); font-size: 30px; }
.reader-page-arrow:hover { background: var(--surface-active); color: var(--brand-dark); }
.reader-loading { padding: 30px; color: var(--muted); text-align: center; }
.reader-progress { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 7px 12px 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.reader-progress { grid-row: 4; }
.reader-progress-meta { display: flex; justify-content: space-between; gap: 12px; }
.reader-scrubber { display: block; width: 100%; }
.reader-scrubber input { display: block; width: 100%; height: 18px; margin: 0; padding: 0; accent-color: var(--brand); cursor: pointer; }
.reader-scrubber input:disabled { cursor: wait; opacity: .45; }
.source-reader-shell { height: calc(100dvh - var(--topbar-height) - 205px); min-height: 520px; }
.reader-edit-chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; height: calc(100dvh - var(--topbar-height) - 48px); min-width: 0; min-height: 560px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.reader-edit-chat-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.reader-edit-chat-header > div { display: grid; gap: 2px; }
.reader-edit-chat-header strong { font-size: 18px; }
.reader-edit-chat-header span { color: var(--muted); font-size: 13px; }
.reader-edit-undo { min-height: 34px; padding: 7px 11px; border-radius: 6px; background: transparent; color: var(--brand); font-size: 13px; }
.reader-edit-messages { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; padding: 14px; }
.reader-edit-empty { display: grid; align-content: start; gap: 8px; color: var(--muted); font-size: 14px; }
.reader-edit-empty p { margin: 0 0 4px; }
.reader-edit-empty button { min-height: 38px; padding: 8px 10px; border-color: var(--border); background: var(--surface-soft); color: var(--text); text-align: left; font-size: 13px; }
.reader-edit-message { max-width: 94%; padding: 11px 12px; border-left: 2px solid var(--border-strong); background: var(--surface-soft); font-size: 15px; line-height: 1.55; }
.reader-edit-message.from-user { align-self: flex-end; border-left: 0; border-right: 2px solid var(--brand); background: var(--surface-active); }
.reader-edit-message.is-error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.reader-edit-message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.reader-edit-thinking { margin: 0; color: var(--brand); font-size: 13px; }
.reader-edit-composer { display: grid; grid-template-columns: minmax(0, 1fr) 38px; align-items: end; gap: 7px; padding: 10px 12px; border-top: 1px solid var(--border); }
.reader-edit-composer textarea { min-height: 82px; max-height: 170px; resize: vertical; font-size: 14px; line-height: 1.45; }
.reader-edit-composer button { display: grid; place-items: center; width: 38px; height: 38px; min-height: 38px; padding: 0; }
.reader-edit-composer svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.reader-edit-note { margin: 0; padding: 0 12px 10px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.reader-external-editor { display: grid; gap: 5px; padding: 11px 12px 12px; border-top: 1px solid var(--border); font-size: 12px; }
.reader-external-editor p { margin: 0; color: var(--muted); line-height: 1.4; }
.reader-external-editor-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 4px; }
.reader-external-editor-actions form { display: contents; }
.reader-external-editor-actions .secondary-button { display: grid; place-items: center; min-height: 36px; padding: 7px 9px; text-align: center; font-size: 11px; }
.reader-external-editor-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; margin-top: 2px; }
.reader-external-editor-links a,
.reader-external-editor-links label { color: var(--brand); font-size: 11px; text-decoration: underline; }
.reader-external-editor-links form { margin: 0; }
.reader-import-button { cursor: pointer; }
.reader-import-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.publish-heading { display: grid; grid-template-columns: minmax(0, 1fr) 96px; align-items: center; gap: 24px; }
.publish-heading h2 { margin: 5px 0 7px; overflow-wrap: anywhere; }
.publish-heading p { margin-bottom: 0; }
.publish-heading img { width: 84px; height: 118px; justify-self: end; border: 1px solid var(--border); border-radius: 3px; object-fit: cover; }
.publication-form { display: grid; gap: 16px; }
.publication-form .panel { margin-bottom: 0; }
.form-section .section-heading { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.form-grid { display: grid; gap: 15px; }
.form-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
label small { color: var(--muted); font-size: 11px; font-weight: 400; }

.publish-actions {
  position: sticky;
  bottom: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--topbar-bg);
  box-shadow: var(--floating-shadow);
  backdrop-filter: blur(12px);
}

/* Persistent IA PROD vectorization */
.vectorization-panel { display: grid; gap: 24px; max-width: 920px; margin-inline: auto; }
.vector-book { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: 18px; }
.vector-book img { width: 88px; height: 124px; border: 1px solid var(--border); border-radius: 4px; object-fit: cover; }
.vector-book h2 { margin: 4px 0; }
.vector-book p { margin: 0; color: var(--muted); }
.vector-status { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 15px; padding: 20px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.vector-status h3, .vector-status p { margin: 0; }
.vector-status p { margin-top: 4px; color: var(--muted); }
.vector-status-icon, .vector-spinner { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--surface); color: var(--muted); font-size: 24px; font-weight: 700; }
.vector-status-completed { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); background: var(--success-soft); }
.vector-status-completed .vector-status-icon { color: var(--success); }
.vector-status-failed { border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); background: var(--danger-soft); }
.vector-status-failed .vector-status-icon, .vector-status-failed h3 { color: var(--danger); }
.vector-spinner { border: 3px solid var(--border); border-top-color: var(--brand-bright); animation: vector-spin .9s linear infinite; }
@keyframes vector-spin { to { transform: rotate(360deg); } }
.vector-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.vector-actions form { display: contents; }
.vector-actions .publish-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 92px; }
.vector-publish-spinner { width: 15px; height: 15px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: vector-spin .8s linear infinite; }

/* Embedded Refonte DEV AI chatbot */
.embedded-chat { display: flex; flex-direction: column; height: calc(100dvh - var(--topbar-height) - 48px); min-width: 0; min-height: 560px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.studio-chat-head { display: flex; align-items: flex-start; gap: 15px; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.studio-icon-button { display: grid; flex-shrink: 0; place-items: center; width: 36px; height: 36px; min-height: 36px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text); }
.studio-icon-button:hover { background: var(--surface-active); color: var(--brand); }
.studio-icon-button svg, .studio-send svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.studio-icon-button svg { width: 20px; height: 20px; }
.studio-chat-book { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.studio-chat-reembed { margin: 0; }
.studio-reembed-button { min-height: 42px; padding: 10px 16px; border-color: var(--brand); background: var(--brand); color: #fff; font-size: 13px; white-space: nowrap; }
.studio-reembed-button:hover { border-color: var(--brand-bright); background: var(--brand-bright); color: #fff; }
.studio-chat-head h2 { margin: 0; font-size: 19px; }
.studio-chat-head p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.studio-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 22px max(24px, calc((100% - 730px) / 2)); scrollbar-gutter: stable both-edges; }
.studio-message { margin-bottom: 24px; font-size: 15px; }
.studio-message.from-user { width: fit-content; max-width: 62%; margin-left: auto; padding: 11px 16px; border: 1px solid color-mix(in srgb, var(--brand) 18%, var(--border)); border-radius: 22px 22px 5px 22px; background: var(--surface-active); }
.studio-message.from-assistant { padding: 0 4px; background: transparent; }
.studio-prose { overflow-wrap: anywhere; font-size: 15px; line-height: 1.65; }
.studio-prose p { margin: 0 0 17px; }
.studio-prose > :last-child { margin-bottom: 0; }
.studio-prose ul, .studio-prose ol { margin: 10px 0; padding-left: 22px; list-style: revert; }
.studio-prose h1, .studio-prose h2, .studio-prose h3 { margin: 15px 0 10px; font-size: 18px; font-weight: 500; }
.studio-prose pre { overflow-x: auto; padding: 12px; background: var(--surface-soft); }
.studio-prose code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.studio-prose blockquote { margin: 14px 0; padding-left: 12px; border-left: 2px solid var(--brand); color: var(--muted); }
.studio-prose a { color: var(--brand); text-decoration: underline; }
.studio-prose table { display: block; overflow-x: auto; border-collapse: collapse; }
.studio-prose th, .studio-prose td { min-width: 100px; padding: 10px; border-bottom: 1px solid var(--border); white-space: normal; }
.studio-message.from-user .studio-prose { font-size: 14px; line-height: 1.4; }
.studio-message details { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 11px; }
.studio-message summary { cursor: pointer; color: var(--brand); }
.studio-message blockquote { margin: 14px 0; padding-left: 12px; border-left: 2px solid var(--brand); color: var(--muted); }
.studio-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; padding: 55px 25px; color: var(--muted); text-align: center; font-size: 14px; }
.studio-empty h3 { margin: 16px 0 6px; color: var(--text); }
.studio-empty p { margin: 0; }
.studio-empty-icon { width: 36px; height: 36px; fill: none; stroke: var(--brand); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.studio-suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 25px; }
.studio-suggestions button { display: inline-flex; align-items: center; gap: 8px; min-height: 0; padding: 12px 16px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--brand); font-size: 12px; }
.studio-suggestions button:hover { background: var(--surface-active); color: var(--brand-dark); }
.studio-thinking { margin: 0 4px 18px; color: var(--brand); font-size: 12px; }
.studio-composer { display: flex; flex-shrink: 0; align-items: center; gap: 10px; width: min(calc(100% - 48px), 730px); min-height: 58px; margin: 12px auto 0; padding: 5px 6px 5px 18px; border: 1px solid color-mix(in srgb, var(--brand) 20%, var(--border)); border-radius: 28px; background: var(--surface); box-shadow: 0 8px 28px color-mix(in srgb, var(--text) 9%, transparent); }
.studio-composer:focus-within { box-shadow: 0 0 0 2px var(--border); }
.studio-composer textarea { flex: 1; min-width: 0; min-height: 0; max-height: 140px; resize: none; overflow-y: auto; padding: 8px 0; border: 0; border-radius: 0; background: transparent; font-size: 15px; line-height: 1.5; }
.studio-composer textarea:focus-visible { outline: none; box-shadow: none; }
.studio-composer .studio-send { display: grid; flex: 0 0 46px; place-items: center; width: 46px; height: 46px; min-height: 46px; padding: 0; border: 0; border-radius: 50%; background: var(--brand); color: var(--surface); }
.studio-composer .studio-send:disabled { background: var(--border); color: var(--muted); opacity: 1; }
.studio-send svg { width: 25px; height: 25px; }
.studio-composer-note { margin: 0; padding: 10px; color: var(--muted); text-align: center; font-size: 10px; }
.chat-error .studio-prose { color: var(--danger); }

@media (max-width: 1120px) {
  .reader-workspace { grid-template-columns: minmax(0, 1fr) 300px; }
  .asset-list, .cover-list { grid-template-columns: 1fr; }
  .asset-list li:nth-child(odd), .cover-list li:nth-child(odd),
  .asset-list li:nth-child(even), .cover-list li:nth-child(even) { padding-right: 0; padding-left: 0; border-left: 0; }
  .form-grid.three-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .source-result { grid-template-columns: 1fr; gap: 14px; }
  .source-review-summary { grid-template-columns: auto minmax(0, 1fr); }
  .source-review-summary > .secondary-link { grid-column: 1; grid-row: 1; }
  .source-review-title { grid-column: 2; grid-row: 1; }
  .source-review-metrics { grid-column: 1 / -1; grid-row: 2; }
  .source-review-alert { grid-column: 1 / -1; grid-row: 3; }
  .source-review-decisions { grid-column: 1 / -1; grid-row: 4; }
}

@media (max-width: 860px) {
  :root { --topbar-height: 60px; }
  .app-shell { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 20; display: block; width: 100%; height: auto; padding: 10px 14px 0; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-header { display: none; }
  .brand { display: none; }
  .sidebar-nav,
  html[data-sidebar="collapsed"] .sidebar-nav { display: flex; gap: 5px; margin: 0; overflow-x: auto; scrollbar-width: none; }
  .sidebar-nav a { flex: 0 0 auto; padding: 8px 11px; font-size: 12px; }
  html[data-sidebar="collapsed"] .sidebar-nav a { display: block; width: auto; min-height: 0; }
  html[data-sidebar="collapsed"] .sidebar-nav-label,
  html[data-sidebar="collapsed"] .sidebar-footer-label { display: inline; }
  html[data-sidebar="collapsed"] .sidebar-nav-icon,
  html[data-sidebar="collapsed"] .sidebar-footer-icon,
  html[data-sidebar="collapsed"] .sidebar-nav a::after,
  html[data-sidebar="collapsed"] .sidebar-footer::after { display: none; }
  .sidebar-footer {
    display: inline-flex;
    width: fit-content;
    margin: 7px 0 0;
    padding: 8px 11px;
  }
  html[data-sidebar="collapsed"] .sidebar-footer { display: inline-flex; width: fit-content; min-height: 0; }
  .topbar { position: static; padding: 9px 18px; }
  .global-search { margin-inline: 18px; }
  main { padding: 18px; }
  .reader-workspace { grid-template-columns: 1fr; }
  .reader-edit-chat { height: 440px; min-height: 380px; }
  .hero, .grid.two, .grid.three { grid-template-columns: 1fr; }
  .run-panel { grid-template-columns: 1fr; align-items: start; }
  .embedded-details { grid-column: 1; width: 100%; }
  .embedded-details > .accordion-content { position: static; width: 100%; max-height: none; margin-top: 10px; }
  .run-form { justify-content: flex-start; flex-wrap: wrap; }
  .search-intro, .catalogue-heading { align-items: stretch; flex-direction: column; }
  .catalogue-actions { justify-items: start; min-width: 0; }
  .catalogue-table-tools { justify-content: flex-start; }
  .catalogue-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reader-toolbar { flex-wrap: wrap; }
  .reader-scan { order: 4; flex: 1 1 100%; }
  .source-review-summary { grid-template-columns: 1fr; }
  .source-review-summary > .secondary-link { grid-column: 1 / -1; justify-self: start; }
  .source-review-title, .source-review-metrics, .source-review-alert { grid-column: 1 / -1; }
  .source-review-title { grid-row: 2; }
  .source-review-metrics { grid-row: 3; }
  .source-review-alert { grid-row: 4; }
  .source-review-decisions { grid-column: 1; grid-row: 5; }
  .source-reader-shell { height: calc(100dvh - var(--topbar-height) - 290px); }
  .reader-book-meta { max-width: calc(100% - 180px); }
  .reader-reading-controls { order: 3; flex: 1 1 100%; }
  .reader-reading-controls select { flex: 1 1 auto; max-width: none; }
  .reader-metadata-form:not([hidden]) { grid-template-columns: 1fr 1fr; }
  .reader-metadata-form label:nth-of-type(3) { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .login-shell { align-items: start; padding: 18px 14px; }
  .login-panel { margin-top: 8dvh; padding: 24px 20px; }
  main { padding: 12px; }
  .topbar { padding-inline: 14px; }
  .topbar h1 { font-size: 18px; }
  .topbar > div:first-child { display: none; }
  .global-search { margin: 0 8px 0 0; }
  .global-search input { padding-inline: 9px; }
  .global-search button { padding-inline: 9px; font-size: 0; }
  .global-search button::after { content: "⌕"; font-size: 18px; }
  .topbar-actions { gap: 6px; }
  .health { padding: 6px 8px; font-size: 0; }
  .health span { width: 8px; height: 8px; }
  .panel { padding: 16px; border-radius: 10px; }
  .hero { gap: 18px; padding: 18px; }
  .hero h2 { font-size: 24px; }
  .proposal-grid, .source-groups { grid-template-columns: 1fr; }
  .source-check-grid { grid-template-columns: 1fr; }
  .proposal-card { grid-template-columns: 116px minmax(0, 1fr); }
  .proposal-editorial-grid { grid-template-columns: 1fr; }
  .proposal-field-wide { grid-column: auto; }
  .proposal-preview { min-height: 174px; padding: 8px; }
  .proposal-preview img, .preview-placeholder, .cover-zoom-trigger, .proposal-preparing { min-height: 158px; }
  .cover-zoom-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .cover-zoom-dialog > img { max-height: calc(100dvh - 152px); }
  .section-heading { align-items: flex-start; }
  .managed-list li { align-items: flex-start; flex-direction: column; }
  .source-actions { width: 100%; justify-content: space-between; }
  .source-genre-form { flex: 1; }
  .file-list li { align-items: flex-start; flex-direction: column; }
  .run-form { display: grid; width: 100%; }
  .outputs-panel > summary { min-height: 64px; padding: 13px 14px 13px 40px; }
  .outputs-panel > summary::before { margin-left: -23px; }
  .outputs-panel summary strong { font-size: 16px; }
  .outputs-panel summary small { font-size: 11px; }
  .asset-list, .cover-list { padding: 0 14px; }
  .library-filters { align-items: stretch; flex-direction: column; gap: 10px; padding: 12px 14px; }
  .library-filters--categories { display: flex; }
  .library-filters--categories .category-filter-groups { display: grid; }
  .library-filters--categories .category-filter-group:not(.category-filter-subgroup),
  .library-filters--categories .library-search,
  .library-filters--categories .filter-toggle,
  .library-filters--categories .quality-audit-controls,
  .library-filters--categories .category-filter-subgroup,
  .library-filter-status { grid-column: auto; grid-row: auto; }
  .library-search { flex-basis: auto; width: 100%; max-width: none; }
  .quality-audit-controls { justify-content: flex-start; }
  .asset-list li, .cover-list li { grid-template-columns: 52px minmax(0, 1fr); min-height: 100px; }
  .stock-panel .asset-list li { grid-template-columns: 52px minmax(0, 1fr); }
  .stock-panel.quality-column-hidden .asset-list li { grid-template-columns: 52px minmax(0, 1fr); }
  .asset-thumbnail, .cover-list > li > img { width: 52px; height: 72px; }
  .stock-panel .book-quality { grid-column: 2; grid-row: auto; }
  .icon-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .stock-panel .published-actions { grid-column: 1 / -1; grid-row: auto; }
  .form-grid.two-columns, .form-grid.three-columns { grid-template-columns: 1fr; }
  .publish-heading { grid-template-columns: minmax(0, 1fr) 70px; }
  .publish-heading img { width: 64px; height: 90px; }
  .publish-actions { bottom: 8px; }
  .source-search-form, .result-import { grid-template-columns: 1fr; }
  .catalogue-upload { align-items: stretch; flex-direction: column; width: 100%; }
  .catalogue-upload label { max-width: none; }
  .catalogue-stats { gap: 8px; }
  .catalogue-stats div { padding: 12px; }
  .reader-shell { height: calc(100dvh - 146px); min-height: 480px; }
  .source-review-summary { display: flex; align-items: stretch; flex-direction: column; }
  .source-review-decisions { justify-self: auto; }
  .source-review-decisions button { flex: 1; }
  .reader-scan { overflow-x: auto; }
  .source-reader-shell { height: 64dvh; min-height: 440px; }
  .reader-actions { width: 100%; margin-left: 0; }
  .reader-actions button { flex: 1; min-width: 0; padding-inline: 7px; }
  .reader-actions .reader-publish-form { width: 100%; justify-content: space-between; }
  .reader-revectorize-toggle { flex: 0 1 auto; }
  .reader-metadata-form:not([hidden]) { grid-template-columns: 1fr; }
  .reader-metadata-form label:nth-of-type(3) { grid-column: auto; }
  .reader-stage { grid-template-columns: 38px minmax(0, 1fr) 38px; }
  .reader-page-arrow { width: 34px; }
  .vector-actions { align-items: stretch; flex-direction: column; }
  .embedded-chat { height: calc(100dvh - 146px); min-height: 480px; }
  .studio-chat-head { gap: 10px; padding: 14px; }
  .studio-chat-head h2 { font-size: 16px; }
  .studio-reembed-button { min-height: 36px; padding: 8px 10px; font-size: 11px; }
  .studio-messages { padding: 20px 14px; }
  .studio-message.from-user { max-width: 87%; padding: 9px 13px; }
  .studio-composer { gap: 6px; width: calc(100% - 28px); margin-top: 8px; }
  .studio-composer textarea { font-size: 14px; }
  .studio-composer .studio-send { flex-basis: 44px; width: 44px; height: 44px; min-height: 44px; }
  .studio-composer-note { padding: 7px 10px 9px; }
}


/* Graphic charter */
.charter-intro {
  margin-bottom: 20px;
}

.charter-intro h2,
.charter-rules h2,
.charter-palette-form h2 {
  margin: 0;
}

.charter-intro p:last-child {
  margin: 6px 0 0;
  color: var(--muted);
}

.charter-palette-form {
  margin-bottom: 20px;
}

.charter-palette-form .section-heading {
  align-items: center;
}

.palette-table {
  margin-top: 18px;
  border-top: 1px solid var(--border);
}

.palette-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(210px, 1fr) minmax(210px, 1fr) 96px;
  gap: 18px;
  align-items: center;
  min-height: 64px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.palette-header {
  min-height: 42px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.colour-field {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.colour-field input[type="color"] {
  width: 42px;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.colour-field input[type="text"] {
  width: 100%;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

.palette-preview {
  display: grid;
  place-items: center;
  width: 88px;
  height: 42px;
  border: 1px solid color-mix(in srgb, var(--palette-text) 35%, transparent);
  border-radius: 6px;
  background: var(--palette-background);
  color: var(--palette-text);
  font-weight: 700;
}

.charter-rules {
  margin-bottom: 20px;
}

.rule-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 40px;
  margin-top: 18px;
}

.rule-columns h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.rule-columns ul {
  margin: 0;
  padding-left: 20px;
}

.rule-columns li {
  margin: 0 0 8px;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .palette-header {
    display: none;
  }

  .palette-row {
    grid-template-columns: minmax(110px, 0.7fr) minmax(190px, 1fr) minmax(190px, 1fr) 88px;
    gap: 12px;
    overflow-x: auto;
  }

  .rule-columns {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 680px) {
  .charter-palette-form .section-heading {
    align-items: stretch;
  }

  .palette-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 16px 0;
  }

  .palette-preview {
    width: 100%;
  }
}
