/* =========================================================
   Book Illustration Pipeline — style.css
   Light theme, pure CSS, no external dependencies
   ========================================================= */

/* ── Reset & Box-sizing ── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { height: 100%; }
body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }
img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; }
p, h1, h2, h3, h4 { overflow-wrap: break-word; }

/* ── CSS Variables ── */
:root {
  --bg:           #f7f8fa;
  --panel:        #ffffff;
  --ink:          #14213d;
  --ink-light:    #64748b;
  --accent:       #2563eb;
  --accent-hover: #1d4ed8;
  --success:      #16a34a;
  --warning:      #d97706;
  --error:        #dc2626;
  --border:       #e2e8f0;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,0.1);
  --shadow-md:    0 4px 12px rgba(0,0,0,0.08);
}

/* ── Base Typography ── */
body {
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1rem;    font-weight: 600; }
p  { color: var(--ink-light); }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: 'SF Mono', 'Fira Code', Consolas, monospace; font-size: 0.85em; }

/* ── Demo Banner ── */
.demo-banner {
  background: #fef3c7;
  border-bottom: 2px solid #f59e0b;
  color: #92400e;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.demo-banner__icon { margin-right: 0.4rem; }

/* ── Navbar ── */
.navbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.navbar__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar__logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
}
.navbar__logo-mark {
  color: var(--accent);
  font-size: 0.7rem;
}
.navbar__links {
  display: flex;
  gap: 0.25rem;
}
.navbar__link {
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  color: var(--ink-light);
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.navbar__link:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.navbar__link--active { background: var(--bg); color: var(--accent); }
.navbar__stop {
  margin-left: .75rem;
  padding: .3rem .85rem;
  background: transparent;
  color: #6b7280;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 500;
  letter-spacing: .02em;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.navbar__stop:hover { background: #fef2f2; color: #dc2626; border-color: #fca5a5; }
.navbar__stop:disabled { background: transparent; color: #9ca3af; border-color: #e5e7eb; cursor: default; }

/* ── Main Content ── */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* ── Page Header ── */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 0.75rem 1rem;
}
/* Title gets at least 320px; if there isn't enough room alongside the buttons
   it wraps to its own full-width row so the title never gets word-crushed. */
.page-header > div:first-child {
  flex: 1 1 320px;
  min-width: 0;
}
.page-header__title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
/* Actions never force the title to shrink — they wrap to the next line instead. */
.page-header__actions { display: flex; gap: 0.5rem; align-items: center; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
.page-title { margin-bottom: 0; word-break: break-word; }
.page-subtitle { color: var(--ink-light); font-size: 0.95rem; }
.back-link {
  display: inline-block;
  color: var(--ink-light);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  text-decoration: none;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

/* ── Flash Messages ── */
.flash-container {
  max-width: 1200px;
  margin: 0.75rem auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  animation: flashIn 0.2s ease;
}
.flash--success { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.flash--error   { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.flash--warning { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }
.flash--info    { background: #dbeafe; border: 1px solid #93c5fd; color: #1e40af; }
.flash__close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: inherit;
  opacity: 0.6;
  padding: 0 0.25rem;
}
.flash__close:hover { opacity: 1; }
@keyframes flashIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ── Panel / Card ── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.panel--dark {
  background: #0f172a;
  border-color: #1e293b;
  color: #e2e8f0;
}
.panel--table { padding: 0; overflow: hidden; }
.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 0.5rem;
}
.panel__title { color: var(--ink); }
.panel__subtitle { color: var(--ink-light); font-size: 0.9rem; margin-top: 0.25rem; }
.panel__count { color: var(--ink-light); font-size: 0.85rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; color: #fff; }
.btn--secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--border);
}
.btn--secondary:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.btn--danger { background: #fff; color: var(--error); border-color: #fca5a5; }
.btn--danger:hover { background: #fee2e2; }
.btn--success { background: var(--success); color: #fff; border-color: var(--success); }
.btn--success:hover { background: #15803d; }
.btn--ghost { background: transparent; color: var(--ink-light); border-color: var(--border); }
.btn--ghost:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.btn--disabled, .btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.btn--sm { padding: 0.3rem 0.75rem; font-size: 0.82rem; }
.btn--lg { padding: 0.7rem 1.5rem; font-size: 1rem; }
.btn--full { width: 100%; }

/* ── Forms ── */
.form-group { margin-bottom: 1.1rem; }
.form-row { display: grid; gap: 1rem; margin-bottom: 0; }
.form-row--2 { grid-template-columns: 1fr 1fr; }
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row--actions { display: flex; gap: 0.5rem; align-items: center; }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 0.35rem;
}
.form-label--required::after { content: ' *'; color: var(--error); }
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.form-input.is-invalid { border-color: var(--error); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }
.form-hint { display: block; font-size: 0.78rem; color: var(--ink-light); margin-top: 0.25rem; }
.form-input--readonly {
  background: var(--bg);
  color: var(--ink-light);
  border-color: var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  cursor: default;
}
.form-input--hero { font-size: 1.75rem; font-weight: 700; text-align: center; padding: 0.75rem; }

/* Radio / checkbox groups */
.radio-group { display: flex; flex-direction: column; gap: 0.5rem; padding-top: 0.25rem; }
.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink);
}
.radio-hint { font-size: 0.8rem; color: var(--ink-light); }
.radio-stack { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.radio-card:has(input:checked) { border-color: var(--accent); background: #eff6ff; }
.radio-card input[type="radio"] { margin-top: 0.2rem; flex-shrink: 0; }
.radio-card__content { display: flex; flex-direction: column; gap: 0.1rem; }
.radio-card__content strong { font-size: 0.9rem; color: var(--ink); }
.radio-card__content span { font-size: 0.82rem; color: var(--ink-light); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge--pending         { background: #f1f5f9; color: #64748b; }
.badge--stage1-running  { background: #dbeafe; color: #1d4ed8; }
.badge--stage1-complete { background: #dcfce7; color: #166534; }
.badge--complete        { background: #dcfce7; color: #166534; }
.badge--approved        { background: #d1fae5; color: #065f46; }
.badge--error           { background: #fee2e2; color: #991b1b; }
.badge--running         { background: #dbeafe; color: #1d4ed8; }
.badge--demo            { background: #fef3c7; color: #92400e; }
.badge--prod            { background: #dcfce7; color: #166534; }
.badge__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}
.badge__dot--pulse { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ── Type badges (plan table) ── */
.type-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.type-badge--icon      { background: #f1f5f9; color: #475569; }
.type-badge--vignette  { background: #ccfbf1; color: #0f766e; }
.type-badge--half-page { background: #ede9fe; color: #6d28d9; }

/* Weight badges (plan table) */
.weight-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s;
}
.weight-badge:hover { opacity: 0.8; }
.weight-badge--standard    { background: #f1f5f9; color: #475569; }
.weight-badge--highweight  { background: #fef3c7; color: #92400e; }
.weight-badge--fullbleed   { background: #dbeafe; color: #1d4ed8; }

/* Budget badges */
.budget-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.budget-badge--full-bleed  { background: #dbeafe; color: #1d4ed8; }
.budget-badge--high-weight { background: #fef3c7; color: #92400e; }
.budget-badge--standard    { background: #f1f5f9; color: #475569; }

/* Summary pills (plan page) */
.type-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.type-pill--icon       { background: #f1f5f9; color: #475569; }
.type-pill--vignette   { background: #ccfbf1; color: #0f766e; }
.type-pill--half       { background: #ede9fe; color: #6d28d9; }
.type-pill--full-bleed { background: #dbeafe; color: #1d4ed8; }
.type-pill--high-weight{ background: #fef3c7; color: #92400e; }
.type-pill--standard   { background: #f1f5f9; color: #475569; }

/* ── Cost Summary ── */
.cost-summary {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}
.cost-pill {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow);
  min-width: 120px;
}
.cost-pill__label { font-size: 0.75rem; color: var(--ink-light); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.cost-pill__value { font-size: 1.15rem; font-weight: 700; color: var(--ink); }

/* ── Books Grid ── */
.books-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}
.book-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.book-card:hover { box-shadow: var(--shadow-md); border-color: #cbd5e1; }
.book-card__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; }
.book-card__title { font-size: 1rem; font-weight: 600; color: var(--ink); line-height: 1.3; }
.book-card__penname { font-size: 0.82rem; color: var(--ink-light); margin-top: 0.1rem; }
.book-card__meta { display: flex; flex-direction: column; gap: 0.35rem; }
.book-card__meta-item { display: flex; align-items: baseline; gap: 0.5rem; font-size: 0.85rem; }
.meta-label { color: var(--ink-light); font-size: 0.78rem; min-width: 80px; font-weight: 500; }
.meta-value { color: var(--ink); }
.meta-value--file { color: var(--ink); font-family: 'SF Mono', Consolas, monospace; font-size: 0.78rem; }
.meta-value--missing { color: var(--warning); font-style: italic; }
.book-card__actions { display: flex; gap: 0.5rem; margin-top: auto; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty-state--sm { padding: 2rem 1rem; background: none; border: none; box-shadow: none; }
.empty-state__icon { font-size: 2.5rem; margin-bottom: 0.75rem; display: flex; align-items: center; justify-content: center; color: var(--ink-light); }
.empty-state__title { color: var(--ink); margin-bottom: 0.5rem; }
.empty-state__text { color: var(--ink-light); margin-bottom: 1.25rem; }

/* ── Wizard ── */
.wizard-progress {
  display: flex;
  align-items: center;
  margin-bottom: 2rem;
}
.wizard-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.wizard-step__num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--border);
  color: var(--ink-light);
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.wizard-step__label {
  font-size: 0.75rem;
  color: var(--ink-light);
  font-weight: 500;
  white-space: nowrap;
}
.wizard-step--active .wizard-step__num { background: var(--accent); color: #fff; }
.wizard-step--done .wizard-step__num { background: var(--success); color: #fff; }
.wizard-step--active .wizard-step__label,
.wizard-step--done .wizard-step__label { color: var(--ink); }
.wizard-connector { flex: 1; height: 2px; background: var(--border); margin: 0 0.5rem; margin-bottom: 1.3rem; }
.wizard-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 1.5rem; }

/* ── Budget Hero ── */
.budget-hero { text-align: center; margin-bottom: 1.5rem; }
.budget-hero .form-group { max-width: 200px; margin: 0 auto; }

/* ── Budget Builder ── */
.budget-builder {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1.25rem;
  background: var(--bg);
}
.budget-builder__header { margin-bottom: 1rem; }
.budget-builder__title { font-size: 1rem; color: var(--ink); }
.budget-builder__subtitle { font-size: 0.85rem; color: var(--ink-light); margin-top: 0.2rem; }

.budget-rows { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.budget-row {
  display: grid;
  grid-template-columns: 160px 70px 1fr 48px;
  align-items: center;
  gap: 0.75rem;
}
.budget-row__label { display: flex; align-items: center; gap: 0.5rem; }
.budget-row__desc { font-size: 0.82rem; color: var(--ink-light); }
.budget-row__input { max-width: 70px; text-align: center; padding: 0.35rem 0.5rem; }
.budget-row__input--auto {
  background: var(--bg);
  color: var(--ink-light);
  font-size: 0.9rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
}
.budget-row__bar-wrap { background: var(--border); border-radius: 100px; height: 8px; overflow: hidden; }
.budget-bar { height: 100%; border-radius: 100px; transition: width 0.3s ease; }
.budget-bar--full-bleed  { background: var(--accent); }
.budget-bar--high-weight { background: var(--warning); }
.budget-bar--standard    { background: #94a3b8; }
.budget-row__pct { font-size: 0.78rem; color: var(--ink-light); text-align: right; }
.budget-row--auto .budget-row__input { display: flex; align-items: center; justify-content: center; }

.budget-error {
  background: #fee2e2;
  color: var(--error);
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.budget-assignment { margin-top: 1.25rem; border-top: 1px solid var(--border); padding-top: 1rem; }

/* ── Review Step ── */
.review-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.review-section { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.review-section__title { font-size: 0.85rem; font-weight: 600; color: var(--ink-light); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.75rem; }
.review-dl dt { font-size: 0.78rem; color: var(--ink-light); font-weight: 500; margin-top: 0.5rem; }
.review-dl dd { font-size: 0.88rem; color: var(--ink); font-weight: 400; }

/* ── Dropzone ── */
.upload-section { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1.5rem; }
.upload-section__title { margin-bottom: 0.35rem; }
.upload-section__hint { font-size: 0.85rem; color: var(--ink-light); margin-bottom: 0.75rem; }
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: default;
}
.dropzone--active { border-color: var(--accent); background: #eff6ff; }
.dropzone__content { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.dropzone__icon { font-size: 2rem; }
.dropzone__text { font-weight: 500; color: var(--ink); margin: 0; }
.dropzone__subtext { color: var(--ink-light); font-size: 0.85rem; margin: 0; }
.dropzone__success { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.dropzone__filename { font-weight: 600; color: var(--success); font-size: 1rem; margin: 0; }
.dropzone__wordcount { color: var(--ink-light); font-size: 0.85rem; margin: 0; }

/* ── Detail Layout ── */
.detail-layout { display: grid; grid-template-columns: 60% 1fr; gap: 1.5rem; align-items: start; }
.detail-main { display: flex; flex-direction: column; gap: 1.25rem; }
.detail-sidebar { position: sticky; top: 72px; }

/* ── Config Display ── */
.config-dl dt { font-size: 0.78rem; color: var(--ink-light); font-weight: 500; margin-top: 0.75rem; }
.config-dl dd { font-size: 0.9rem; color: var(--ink); }
.config-budget { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-top: 1rem; background: var(--bg); }
.config-budget__title { font-size: 0.85rem; font-weight: 600; color: var(--ink); margin-bottom: 0.75rem; }
.mini-budget-row { display: grid; grid-template-columns: 100px 1fr 40px; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.mini-budget-bar-wrap { background: var(--border); border-radius: 100px; height: 6px; overflow: hidden; }
.mini-budget-num { font-size: 0.82rem; color: var(--ink-light); text-align: right; }
.mini-budget-total { font-size: 0.8rem; color: var(--ink-light); text-align: right; margin-top: 0.25rem; }

/* ── Manuscript Info ── */
.manuscript-info { display: flex; align-items: center; gap: 1rem; }
.manuscript-info__icon { font-size: 1.5rem; }
.manuscript-info__details { display: flex; flex-direction: column; }
.manuscript-info__meta { font-size: 0.82rem; color: var(--ink-light); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table thead { position: sticky; top: 0; }
.data-table th {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.data-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--ink);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }
.run-number { font-weight: 600; color: var(--ink-light); }
.run-datetime { color: var(--ink-light); font-size: 0.82rem; white-space: nowrap; }
.cost-cell { font-weight: 500; }
.table-action { color: var(--accent); font-size: 0.85rem; font-weight: 500; }
.table-action--disabled { color: var(--ink-light); font-size: 0.85rem; }

/* Plan table */
.plan-table .col-num     { width: 40px; }
.plan-table .col-preview { width: 88px; }
.plan-table .col-type    { width: 90px; }
.plan-table .col-chapter { width: 130px; }
.plan-table .col-brief   { }
.plan-table .col-layout  { width: 110px; }
.plan-table .col-filename{ width: 160px; }

.ill-thumb-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  background: #f0f2f5;
}
.ill-thumb-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ill-thumb-spinner::after {
  content: '';
  width: 18px;
  height: 18px;
  border: 2px solid #d1d5db;
  border-top-color: var(--accent, #6366f1);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.ill-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.thumb-err {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  color: #9ca3af;
  font-size: 1.2rem;
}
.ill-thumb-wrap { cursor: zoom-in; }

/* Lightbox */
.ill-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.ill-lightbox__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 70vw;
}
.ill-lightbox__img {
  max-width: 70vw;
  max-height: 78vh;
  border-radius: 8px;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.ill-lightbox__caption {
  margin-top: 0.9rem;
  color: #e5e7eb;
  font-size: 0.9rem;
  text-align: center;
  max-width: 60vw;
  line-height: 1.5;
}
.ill-lightbox__nav {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 2.8rem;
  line-height: 1;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  margin: 0 1.2rem;
}
.ill-lightbox__nav:hover { background: rgba(255,255,255,0.25); }
.ill-lightbox__close {
  position: absolute;
  top: 1.2rem;
  right: 1.4rem;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 1.2rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
}
.ill-lightbox__close:hover { background: rgba(255,255,255,0.3); }
.brief-text {
  display: block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}
.filename-code { font-size: 0.75rem; color: var(--ink-light); word-break: break-all; }

/* ── Plan Page ── */
.plan-status-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--ink-light);
}
.plan-status-item { display: flex; align-items: center; gap: 0.35rem; }
.plan-status-sep { color: var(--border); }
.plan-summary-pills {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.plan-footer { margin-top: 1rem; }
.approved-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #dcfce7;
  color: #166534;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.approved-badge__check { font-size: 1rem; }

/* ── Run Page ── */
.run-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; align-items: start; }
.run-main { display: flex; flex-direction: column; gap: 1.25rem; }
.run-sidebar { position: sticky; top: 72px; }

.mode-selector { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.25rem; }
.mode-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.mode-card--demo:has(input:checked) { border-color: #f59e0b; background: #fffbeb; }
.mode-card--prod:has(input:checked) { border-color: var(--success); background: #f0fdf4; }
.mode-card__label { display: flex; align-items: center; gap: 0.75rem; flex: 1; cursor: pointer; }
.mode-card__badge {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.mode-card__badge--demo { background: #fef3c7; color: #92400e; }
.mode-card__badge--prod { background: #dcfce7; color: #166534; }
.mode-card__info { display: flex; flex-direction: column; }
.mode-card__info strong { font-size: 0.9rem; color: var(--ink); }
.mode-card__info span { font-size: 0.82rem; color: var(--ink-light); }
.mode-card__cost { color: var(--ink); font-weight: 500; }

.cost-estimate {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
}
.cost-estimate__label { color: var(--ink-light); }
.cost-estimate__value { font-weight: 600; color: var(--ink); }

.run-book-info { margin-bottom: 1.25rem; display: flex; flex-direction: column; gap: 0.4rem; }
.run-book-info__item { display: flex; gap: 0.5rem; font-size: 0.88rem; }
.run-book-info__label { color: var(--ink-light); min-width: 90px; font-weight: 500; }

.run-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  margin-bottom: 1.25rem;
  background: #f8fafc;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.run-dropzone--active {
  border-color: var(--accent, #6366f1);
  background: #eef2ff;
}
.run-dropzone__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1.4rem 1rem;
  cursor: pointer;
  text-align: center;
}
.run-dropzone__icon { font-size: 1.8rem; line-height: 1; }
.run-dropzone__cta { font-weight: 600; font-size: 0.95rem; color: var(--ink); }
.run-dropzone__filename { font-weight: 600; font-size: 0.92rem; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-dropzone__hint { font-size: 0.8rem; color: var(--ink-light); }
.run-dropzone__hint u { color: var(--accent, #6366f1); text-decoration: underline; }
.run-dropzone__status { text-align: center; font-size: 0.82rem; padding: 0 1rem 0.6rem; min-height: 1rem; }

/* Log terminal */
.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid #1e293b;
}
.log-header__title { color: #e2e8f0; font-size: 0.95rem; }
.log-header__meta { display: flex; align-items: center; gap: 0.5rem; }
.log-status { font-size: 0.82rem; color: #94a3b8; }
.log-terminal {
  height: 400px;
  overflow-y: auto;
  padding: 0.75rem 1.25rem;
  scroll-behavior: smooth;
}
.log-terminal__inner { display: flex; flex-direction: column; gap: 0.15rem; }
.log-line {
  font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  word-break: break-all;
}
.log-line--info    { color: #e2e8f0; }
.log-line--warn    { color: #fbbf24; }
.log-line--error   { color: #f87171; }
.log-line--success { color: #4ade80; }

.run-complete {
  text-align: center;
  padding: 3rem 2rem;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--radius);
}
.run-complete__icon { font-size: 2.5rem; color: var(--success); margin-bottom: 0.75rem; }
.run-complete__title { color: var(--success); margin-bottom: 0.5rem; }
.run-complete__text { margin-bottom: 1.25rem; }

.run-error {
  text-align: center;
  padding: 3rem 2rem;
  background: #fff0f0;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
}
.run-error__icon { font-size: 2.5rem; color: var(--error); margin-bottom: 0.75rem; }
.run-error__title { color: var(--error); margin-bottom: 0.5rem; }
.run-error__msg { margin-bottom: 1.25rem; }

.pipeline-steps { list-style: none; display: flex; flex-direction: column; gap: 1rem; margin-top: 0.75rem; }
.pipeline-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}
.pipeline-step__num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink-light);
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.15rem;
}
.pipeline-step strong { display: block; font-size: 0.88rem; color: var(--ink); }
.pipeline-step p { font-size: 0.8rem; color: var(--ink-light); margin: 0; }

/* ── Settings ── */
.settings-layout { display: flex; flex-direction: column; gap: 1.25rem; max-width: 720px; }
.api-key-status { margin-bottom: 0.5rem; }
.api-key-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.25rem; }
.api-key-label { font-size: 0.9rem; font-weight: 500; color: var(--ink); }
.api-key-input-wrap { display: flex; gap: 0.5rem; }
.api-key-input-wrap .form-input { flex: 1; }
.status-pill {
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
}
.status-pill--ok { background: #dcfce7; color: #166534; }
.status-pill--missing { background: #fee2e2; color: #991b1b; }
.optional-tag {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink-light);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.mode-display { display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; }
.mode-badge {
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.mode-badge--demo { background: #fef3c7; color: #92400e; }
.mode-badge--prod { background: #dcfce7; color: #166534; }
.mode-display__desc { color: var(--ink-light); font-size: 0.9rem; margin: 0; }

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner--sm { width: 14px; height: 14px; border-width: 2px; border-color: rgba(100,116,139,0.3); border-top-color: var(--ink-light); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Generating-state reveal animation ──
   Three-layer CSS3 effect that evokes ChatGPT's layer-by-layer image reveal
   without actually depicting one. Pure CSS, no JS, no images.
   Layer 1 (background): drifting greyscale gradient = the "latent" canvas.
   Layer 2 (::before):   SVG fractal noise that fades in & out = diffusion grain.
   Layer 3 (::after):    bright horizontal sweep band moving top→bottom = denoising pass.
*/
.gallery-card__placeholder[data-status="generating"] {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #f3f4f6 0%, #cbd5e1 50%, #f3f4f6 100%);
  background-size: 200% 200%;
  animation: gen-bg-shift 6s ease-in-out infinite;
}
.gallery-card__placeholder[data-status="generating"]::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.95' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100' height='100' filter='url(%23n)' opacity='0.55'/></svg>");
  background-size: 180px 180px;
  mix-blend-mode: multiply;
  animation: gen-noise-fade 4s ease-in-out infinite;
}
.gallery-card__placeholder[data-status="generating"]::after {
  content: '';
  position: absolute;
  left: -10%;
  right: -10%;
  height: 40%;
  top: -40%;
  pointer-events: none;
  background: linear-gradient(180deg,
    transparent 0%,
    rgba(255,255,255,0.55) 35%,
    rgba(255,255,255,0.9) 50%,
    rgba(255,255,255,0.55) 65%,
    transparent 100%);
  filter: blur(10px);
  animation: gen-sweep 2.8s ease-in-out infinite;
}
.gallery-card__placeholder[data-status="generating"] > * {
  position: relative;
  z-index: 2;
}
.gallery-card__placeholder[data-status="generating"] .spinner {
  /* Tone the spinner down — the bg animation is doing the work now. */
  border-color: rgba(21, 128, 61, 0.25);
  border-top-color: rgba(21, 128, 61, 0.95);
  width: 14px;
  height: 14px;
}
.gallery-card__placeholder[data-status="generating"] .placeholder-label {
  font-weight: 600;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(255,255,255,0.85);
}

@keyframes gen-bg-shift {
  0%, 100% { background-position: 0% 0%; }
  50%      { background-position: 100% 100%; }
}
@keyframes gen-noise-fade {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 0.25; }
}
@keyframes gen-sweep {
  0%   { top: -40%; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* Reduce motion: kill the animations, keep the static gradient */
@media (prefers-reduced-motion: reduce) {
  .gallery-card__placeholder[data-status="generating"],
  .gallery-card__placeholder[data-status="generating"]::before,
  .gallery-card__placeholder[data-status="generating"]::after {
    animation: none !important;
  }
  .gallery-card__placeholder[data-status="generating"]::after { display: none; }
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .books-grid { grid-template-columns: repeat(2, 1fr); }
  .run-layout { grid-template-columns: 1fr; }
  .run-sidebar { position: static; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-sidebar { position: static; }
}
@media (max-width: 768px) {
  .main-content { padding: 1.25rem 1rem 3rem; }
  .books-grid { grid-template-columns: 1fr; }
  .form-row--2, .form-row--3 { grid-template-columns: 1fr; }
  .review-grid { grid-template-columns: 1fr; }
  .budget-row { grid-template-columns: 140px 60px 1fr 40px; }
  .wizard-progress { gap: 0; }
  .wizard-step__label { display: none; }
  .plan-summary-pills { gap: 0.35rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .data-table th, .data-table td { padding: 0.5rem 0.75rem; }
  .mode-selector { flex-direction: column; }
}
@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  .navbar__inner { padding: 0 1rem; }
  .panel { padding: 1rem; }
}

/* ── History Table ── */
.history-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.history-table th { background: #f8f9fa; color: #495057; font-weight: 600; text-align: left; padding: 0.625rem 0.875rem; border-bottom: 2px solid #dee2e6; white-space: nowrap; }
.history-td { padding: 0.625rem 0.875rem; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.history-td--num { font-variant-numeric: tabular-nums; text-align: right; }
.history-td--date { white-space: nowrap; font-size: 0.8rem; color: #555; }
.history-td--tokens { font-variant-numeric: tabular-nums; white-space: nowrap; color: #666; font-size: 0.8rem; }
.history-td--cost { font-variant-numeric: tabular-nums; font-weight: 600; color: #333; }
.history-row:hover td { background: #f9f9f9; }
.history-row--error td { background: #fff8f8; }
.history-book-link { font-weight: 600; color: #2c3e50; text-decoration: none; }
.history-book-link:hover { text-decoration: underline; color: #3d5afe; }
.history-penname { display: block; font-size: 0.75rem; color: #888; margin-top: 0.1rem; }
.history-time { color: #aaa; font-size: 0.75rem; }
.history-error { color: #c0392b; font-size: 0.8rem; cursor: default; }
.history-error-row td { padding: 0.25rem 0.875rem 0.5rem; }
.history-error-msg { font-size: 0.8rem; color: #c0392b; background: #fff8f8; }
