/* ============================================================
   StoryaLaunch — Light Editorial Design System
   Sibling of edit.storya.app and write.storya.app: paper bg,
   Lora + Inter, single brand teal accent, hairline rules.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Surfaces & ink */
  --paper:        oklch(0.98 0.01 90);
  --paper-deep:   oklch(0.95 0.015 85);
  --paper-inset:  oklch(0.93 0.02 80);
  --ink:          oklch(0.22 0.015 80);
  --ink-soft:     oklch(0.45 0.012 80);
  --ink-muted:    oklch(0.62 0.01 80);
  --ink-faint:    oklch(0.78 0.01 80);
  --rule:         oklch(0.88 0.02 80);
  --rule-strong:  oklch(0.78 0.015 80);

  /* Brand */
  --brand:        oklch(0.42 0.08 155);
  --brand-dark:   oklch(0.32 0.07 155);
  --brand-soft:   oklch(0.42 0.08 155 / 0.10);
  --brand-line:   oklch(0.42 0.08 155 / 0.30);

  /* State */
  --good:         oklch(0.45 0.10 155);
  --good-soft:    oklch(0.45 0.10 155 / 0.10);
  --bad:          oklch(0.50 0.13 25);
  --bad-soft:     oklch(0.50 0.13 25 / 0.08);
  --warn:         oklch(0.58 0.14 65);
  --warn-soft:    oklch(0.58 0.14 65 / 0.10);
  --info:         oklch(0.50 0.10 240);
  --info-soft:    oklch(0.50 0.10 240 / 0.08);

  /* Type */
  --font-serif:   'Lora', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;

  /* Shape */
  --radius-sm:    3px;
  --radius:       6px;
  --rule-mark:    32px;

  /* Layout */
  --col-main:     640px;
  --col-margin:   240px;
  --col-gap:      56px;
  --page-pad:     clamp(20px, 5vw, 64px);
  --max-width:    calc(640px + 240px + 56px + 64px * 2);

  /* Motion */
  --ease:         cubic-bezier(0.22, 1, 0.36, 1);
  --transition:   180ms var(--ease);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}

::selection { background: var(--brand-soft); color: var(--ink); }

/* ── Layout ───────────────────────────────────────────────── */

.container {
  max-width: 560px;
  margin: 64px auto;
  padding: 0 24px;
}

/* ── Logo ─────────────────────────────────────────────────── */

.logo {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.012em;
  margin-bottom: 32px;
  line-height: 1;
}

.logo em {
  font-style: italic;
  font-weight: 400;
  color: var(--brand);
}

.logo-rule {
  display: block;
  width: var(--rule-mark);
  height: 1px;
  background: var(--brand);
  opacity: 0.7;
  margin-top: 8px;
}

/* ── Cards ────────────────────────────────────────────────── */

.card {
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 36px 40px;
}

/* ── Typography ───────────────────────────────────────────── */

h1 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 6px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.subtitle {
  color: var(--ink-soft);
  font-size: 14.5px;
  margin-bottom: 28px;
}

label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

/* ── Inputs ───────────────────────────────────────────────── */

input[type="text"],
input[type="email"],
input[type="number"] {
  width: 100%;
  padding: 11px 14px;
  font-size: 14.5px;
  font-family: var(--font-sans);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  outline: none;
  transition: border-color var(--transition), background var(--transition);
  margin-bottom: 12px;
}

input[type="text"]::placeholder,
input[type="email"]::placeholder { color: var(--ink-faint); }

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus {
  border-color: var(--brand);
  background: var(--paper-deep);
}

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  display: inline-block;
  width: 100%;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
  color: var(--paper);
  background: var(--brand);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 16px;
  transition: background var(--transition);
  text-align: center;
  text-decoration: none;
}

.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--rule-strong);
}

.btn-secondary:hover { background: var(--paper-deep); color: var(--ink); }

.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  color: var(--ink-soft);
  transition: all var(--transition);
  width: auto;
  margin-top: 0;
}

.btn-sm:hover {
  background: var(--paper-deep);
  color: var(--ink);
  border-color: var(--rule-strong);
}

.btn-sm:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-sm-primary {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand-line);
}

.btn-sm-primary:hover {
  background: var(--brand);
  color: var(--paper);
  border-color: var(--brand);
}

.btn-sm-danger {
  background: transparent;
  color: var(--ink-faint);
  border-color: transparent;
}

.btn-sm-danger:hover {
  color: var(--bad);
  border-color: var(--rule);
  background: transparent;
}

/* ── Alerts (full borders, never side-stripes) ────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 20px;
  border: 1px solid;
  line-height: 1.55;
}

.alert-success {
  background: var(--good-soft);
  color: var(--good);
  border-color: oklch(0.45 0.10 155 / 0.30);
}

.alert-error {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: oklch(0.50 0.13 25 / 0.30);
}

.alert-info {
  background: var(--info-soft);
  color: var(--info);
  border-color: oklch(0.50 0.10 240 / 0.30);
}

/* ── Step labels ──────────────────────────────────────────── */

.step { margin-bottom: 8px; }

.step-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

/* ── Dividers ─────────────────────────────────────────────── */

.divider {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 24px 0;
}

/* ── Status rows ──────────────────────────────────────────── */

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 13.5px;
}

.status-row:last-child { border-bottom: none; }
.status-key { color: var(--ink-soft); }

/* ── Badges ───────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge-green  { background: var(--good-soft);  color: var(--good); }
.badge-red    { background: var(--bad-soft);   color: var(--bad); }
.badge-yellow { background: var(--warn-soft);  color: var(--warn); }
.badge-grey   { background: var(--paper-inset); color: var(--ink-soft); }
.badge-blue   { background: var(--info-soft);  color: var(--info); }

/* ── Metrics grid ─────────────────────────────────────────── */

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 32px;
  margin: 8px 0 4px;
}

.metric-cell { }

.metric-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 2px;
}

.metric-value {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ink);
  font-size: 16px;
  letter-spacing: -0.01em;
}

/* ── Book cards ───────────────────────────────────────────── */

.book-card { margin-bottom: 16px; }

.book-card .card {
  padding: 28px 32px;
  background: var(--paper);
  border: 1px solid var(--rule);
  transition: border-color var(--transition);
}

.book-card .card:hover { border-color: var(--rule-strong); }

/* ── Campaigns ────────────────────────────────────────────── */

.campaigns-wrap {
  border-top: 1px solid var(--rule);
  margin-top: 20px;
  padding-top: 16px;
}

.settings-wrap {
  border-top: 1px solid var(--rule);
  margin-top: 20px;
  padding-top: 16px;
}

.settings-wrap .settings-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  margin-top: 2px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 0 12px 10px 0;
  border-bottom: 1px solid var(--rule);
}

.table td {
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
  vertical-align: top;
}

.table td.name-cell {
  color: var(--ink);
  font-size: 12.5px;
  word-break: break-word;
  max-width: 220px;
  line-height: 1.4;
}

.table td.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink);
}

.table tr:last-child td { border-bottom: none; }

.table tr:hover td { background: var(--paper-deep); }

/* ── Card actions ─────────────────────────────────────────── */

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Spinner ──────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--rule);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
  flex-shrink: 0;
}

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

/* ── Navigation bar ───────────────────────────────────────── */

.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 36px;
}

.nav-bar .logo { margin-bottom: 0; }

.nav-actions { display: flex; align-items: center; gap: 8px; }

/* ── ASIN chip ────────────────────────────────────────────── */

.asin-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
}

/* ── Run status line ──────────────────────────────────────── */

.run-status-line {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 10px;
  display: none;
  padding: 8px 12px;
  background: var(--paper-deep);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
}

.run-status-line a { color: var(--brand); text-decoration: none; font-weight: 500; }
.run-status-line a:hover { text-decoration: underline; }

/* ── BSR inline row ───────────────────────────────────────── */

.bsr-row {
  display: flex;
  gap: 24px;
  font-size: 13.5px;
  flex-wrap: wrap;
}

.bsr-item { display: flex; flex-direction: column; gap: 1px; }
.bsr-item-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.bsr-item-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

/* ── Daily Brief header strip (book card) ─────────────────── */

.brief-header-strip {
  margin: 4px 0 14px 0;
  padding: 10px 0 12px 0;
  border-top: 1px dashed var(--rule);
  border-bottom: 1px dashed var(--rule);
}
.brief-header-strip .brief-tagline {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 6px 0;
}
.brief-header-strip .brief-footer-chip {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.brief-delta {
  font-size: 11px;
  margin-left: 4px;
  font-family: var(--font-mono);
}
.brief-delta.delta-good { color: var(--good); }
.brief-delta.delta-bad  { color: var(--bad); }

/* ── Page-level scrollbar ─────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--paper); }
::-webkit-scrollbar-thumb { background: var(--rule-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

/* ── Shared site footer (templates/_footer.html) ──────────── */

.sl-footer {
  max-width: calc(var(--col-main) + var(--page-pad) * 2);
  margin: 0 auto;
  padding: 32px var(--page-pad) 48px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px 24px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--ink-muted);
}
.sl-footer .foot-copy { font-family: var(--font-serif); }
.sl-footer .foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sl-footer a {
  color: var(--ink-muted);
  text-decoration: none;
  transition: color var(--transition);
}
.sl-footer a:hover { color: var(--brand); }
