/* Blog-Studio — Schweizer Editorial-Präzision
   Warm white paper, deep navy ink, Fraunces display + Instrument Sans. */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400..700;1,9..144,400..700&family=Instrument+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --paper: #F6F5F1;
  --card: #FFFFFF;
  --ink: #0A2342;
  --ink-soft: #3D5878;
  --ink-faint: #8DA0B8;
  --navy-deep: #071A33;
  --cobalt: #1F5EFF;
  --cobalt-soft: #EAF0FF;
  --line: #E4E2DA;
  --line-navy: rgba(10, 35, 66, 0.12);
  --amber: #B45309;  --amber-soft: #FCF4E8;
  --green: #0E7C3F;  --green-soft: #EAF6EE;
  --red: #B3261E;    --red-soft: #FBEDEC;
  --slate: #5B6B7E;  --slate-soft: #EEF1F4;
  --font-display: 'Fraunces', Georgia, serif;
  --font-ui: 'Instrument Sans', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --radius: 10px;
  --shadow-card: 0 1px 2px rgba(10, 35, 66, 0.05), 0 4px 16px rgba(10, 35, 66, 0.04);
  --shadow-lift: 0 2px 4px rgba(10, 35, 66, 0.08), 0 12px 32px rgba(10, 35, 66, 0.10);
}

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

html { font-size: 16px; }
body {
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(31, 94, 255, 0.16), transparent 60%),
    var(--navy-deep);
  color: #fff;
  display: flex; flex-direction: column;
  padding: 28px 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar::after { /* paper grain */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}
.wordmark {
  font-family: var(--font-display); font-style: italic; font-weight: 600;
  font-size: 1.45rem; padding: 0 26px 6px; letter-spacing: -0.01em;
}
.wordmark span { color: var(--cobalt); }
.tagline {
  font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.14em; color: rgba(255,255,255,0.45); padding: 0 26px 30px;
}
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 14px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  color: rgba(255,255,255,0.72); text-decoration: none;
  font-size: 0.92rem; font-weight: 500;
  padding: 10px 12px; border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav a.active { background: rgba(31, 94, 255, 0.22); color: #fff; }
.nav a .ico { font-size: 1rem; width: 20px; text-align: center; }
.sidebar .spacer { flex: 1; }
.sidebar .foot { padding: 0 26px; }
.sidebar .foot button {
  background: none; border: 1px solid rgba(255,255,255,0.18); color: rgba(255,255,255,0.6);
  font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.1em; padding: 7px 14px; border-radius: 6px; cursor: pointer;
  transition: all 0.15s;
}
.sidebar .foot button:hover { color: #fff; border-color: rgba(255,255,255,0.45); }

.main { flex: 1; padding: 44px 52px 80px; max-width: 1240px; }

/* ---------- Typography ---------- */
.page-head { margin-bottom: 36px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
h1.display {
  font-family: var(--font-display); font-weight: 550; font-size: 2.6rem;
  letter-spacing: -0.02em; line-height: 1.05;
}
h1.display em { font-style: italic; color: var(--cobalt); }
.page-head .sub { color: var(--ink-soft); margin-top: 10px; font-size: 0.95rem; max-width: 60ch; }

.section-head {
  display: flex; align-items: baseline; gap: 12px;
  margin: 40px 0 16px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.section-head h2 {
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 600;
  letter-spacing: -0.01em;
}
.section-head .count {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink-faint);
  background: var(--slate-soft); border-radius: 99px; padding: 2px 9px;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-ui); font-weight: 600; font-size: 0.88rem;
  border: none; border-radius: 8px; padding: 10px 18px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.15s; text-decoration: none;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--cobalt); transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.btn-cobalt { background: var(--cobalt); color: #fff; }
.btn-cobalt:hover { background: #1448D8; transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line-navy); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid currentColor; }
.btn-danger:hover { background: var(--red-soft); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* ---------- Cards / board ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 16px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-card); cursor: pointer;
  transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
  animation: rise 0.4s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.cards .card:nth-child(2) { animation-delay: 0.04s; }
.cards .card:nth-child(3) { animation-delay: 0.08s; }
.cards .card:nth-child(4) { animation-delay: 0.12s; }
.cards .card:nth-child(n+5) { animation-delay: 0.16s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: var(--ink-faint); }
.card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--rail, var(--slate));
}
.card[data-status="review"] { --rail: var(--cobalt); }
.card[data-status="generating"] { --rail: var(--amber); }
.card[data-status="published"] { --rail: var(--green); }
.card[data-status="failed"] { --rail: var(--red); }
.card h3 {
  font-family: var(--font-display); font-size: 1.08rem; font-weight: 600;
  letter-spacing: -0.01em; line-height: 1.3; margin-bottom: 10px;
}
.card .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.card .notes { color: var(--ink-soft); font-size: 0.84rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .foot-row { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; }
.card .date { font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink-faint); }

/* status + type chips */
.chip {
  font-family: var(--font-mono); font-size: 0.64rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.09em;
  padding: 3px 9px; border-radius: 99px; white-space: nowrap;
}
.chip-idea       { background: var(--slate-soft); color: var(--slate); }
.chip-generating { background: var(--amber-soft); color: var(--amber); }
.chip-review     { background: var(--cobalt-soft); color: var(--cobalt); }
.chip-published  { background: var(--green-soft); color: var(--green); }
.chip-failed     { background: var(--red-soft); color: var(--red); }
.chip-archived   { background: var(--slate-soft); color: var(--ink-faint); }
.chip-type { background: transparent; border: 1px solid var(--line-navy); color: var(--ink-soft); }

.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.empty {
  border: 1px dashed var(--line-navy); border-radius: var(--radius);
  padding: 34px; text-align: center; color: var(--ink-faint); font-size: 0.9rem;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(7, 26, 51, 0.55);
  backdrop-filter: blur(3px); display: none; align-items: flex-start;
  justify-content: center; padding: 8vh 20px; z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card); border-radius: 14px; width: 100%; max-width: 560px;
  padding: 32px 34px; box-shadow: 0 24px 80px rgba(7, 26, 51, 0.35);
  animation: rise 0.25s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.modal h2 { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; margin-bottom: 4px; }
.modal .hint { color: var(--ink-soft); font-size: 0.86rem; margin-bottom: 22px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label {
  display: block; font-family: var(--font-mono); font-size: 0.66rem;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-soft);
  margin-bottom: 7px;
}
.field input, .field select, .field textarea {
  width: 100%; font-family: var(--font-ui); font-size: 0.95rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 13px; transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(31, 94, 255, 0.13);
  background: #fff;
}
.field .help { font-size: 0.76rem; color: var(--ink-faint); margin-top: 5px; line-height: 1.4; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }

/* ---------- Login ---------- */
.login-body {
  background:
    radial-gradient(90% 70% at 80% -10%, rgba(31, 94, 255, 0.25), transparent 55%),
    var(--navy-deep);
  display: grid; place-items: center; min-height: 100vh; padding: 20px;
}
.login-card {
  background: var(--card); border-radius: 16px; padding: 46px 44px 40px;
  width: 100%; max-width: 400px; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.4);
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.login-card .brand {
  font-family: var(--font-display); font-style: italic; font-weight: 600;
  font-size: 2rem; letter-spacing: -0.02em; margin-bottom: 2px;
}
.login-card .brand span { color: var(--cobalt); }
.login-card .sub {
  font-family: var(--font-mono); font-size: 0.64rem; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--ink-faint); margin-bottom: 32px;
}
.login-card .btn { width: 100%; justify-content: center; padding: 12px; }

.error-text { color: var(--red); font-size: 0.84rem; margin-top: 12px; min-height: 1.2em; }
.ok-text { color: var(--green); font-size: 0.84rem; margin-top: 12px; }

/* ---------- Draft review ---------- */
.draft-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.preview-pane {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 48px 54px; min-height: 400px;
}
.preview-pane.editing { padding: 0; }
.preview-pane textarea {
  width: 100%; min-height: 70vh; border: none; resize: vertical;
  font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.65;
  padding: 28px 30px; border-radius: var(--radius); background: #FDFDFB; color: var(--ink);
}
.preview-pane textarea:focus { outline: 2px solid var(--cobalt); outline-offset: -2px; }

/* rendered blog preview, editorial styling */
.prose { font-size: 1.0rem; line-height: 1.72; color: #1C2B3A; max-width: 68ch; }
.prose h1 { font-family: var(--font-display); font-size: 2rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 20px; color: var(--ink); }
.prose h2 { font-family: var(--font-display); font-size: 1.45rem; font-weight: 600; letter-spacing: -0.01em; margin: 38px 0 14px; color: var(--ink); }
.prose h3 { font-size: 1.08rem; font-weight: 600; margin: 26px 0 10px; color: var(--ink); }
.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 16px 22px; }
.prose li { margin-bottom: 6px; }
.prose a { color: var(--cobalt); }
.prose blockquote { border-left: 3px solid var(--cobalt); padding-left: 16px; color: var(--ink-soft); margin: 0 0 16px; font-style: italic; }
.prose table { border-collapse: collapse; margin: 0 0 20px; width: 100%; font-size: 0.88rem; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 11px; text-align: left; }
.prose th { background: var(--paper); font-weight: 600; }
.prose code { font-family: var(--font-mono); font-size: 0.84em; background: var(--slate-soft); padding: 1px 5px; border-radius: 4px; }
.prose img { max-width: 100%; border-radius: 8px; }
.prose hr { border: none; border-top: 1px solid var(--line); margin: 28px 0; }

.side-rail { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 30px; }
.rail-box {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: 20px;
}
.rail-box h4 {
  font-family: var(--font-mono); font-size: 0.64rem; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--ink-soft); margin-bottom: 12px;
}
.rail-box .kv { display: flex; justify-content: space-between; font-size: 0.82rem; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.rail-box .kv:last-child { border: none; }
.rail-box .kv .k { color: var(--ink-faint); }
.rail-box .kv .v { font-weight: 500; text-align: right; max-width: 60%; overflow-wrap: anywhere; }
.rail-box .stack { display: flex; flex-direction: column; gap: 9px; }
.rail-box .stack .btn { justify-content: center; }
.hero-img { width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; }
.hero-missing { background: var(--paper); border: 1px dashed var(--line-navy); border-radius: 8px; padding: 26px; text-align: center; color: var(--ink-faint); font-size: 0.8rem; }

/* ---------- Tables (posts page) ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card); }
.table th {
  font-family: var(--font-mono); font-size: 0.64rem; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--ink-soft); text-align: left;
  padding: 13px 18px; border-bottom: 1px solid var(--line); background: #FBFAF7;
}
.table td { padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 0.9rem; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #FBFBF8; }
.table .title-cell { font-weight: 600; max-width: 420px; }
.table .actions-cell { white-space: nowrap; text-align: right; }
.table .actions-cell .btn { margin-left: 6px; }

/* toast */
#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 99px;
  font-size: 0.88rem; font-weight: 500; opacity: 0; transition: all 0.3s; z-index: 99;
  box-shadow: var(--shadow-lift); max-width: 90vw;
}
#toast.show { transform: translateX(-50%); opacity: 1; }
#toast.err { background: var(--red); }

@media (max-width: 980px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px 16px; }
  .tagline, .sidebar .spacer { display: none; }
  .wordmark { padding: 0 14px 0 4px; font-size: 1.15rem; }
  .nav { flex-direction: row; flex: 1; padding: 0; }
  .nav a { padding: 8px 10px; font-size: 0.82rem; }
  .nav a .ico { display: none; }
  .main { padding: 26px 18px 60px; }
  .draft-layout { grid-template-columns: 1fr; }
  .side-rail { position: static; }
  .preview-pane { padding: 26px 22px; }
}
