:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --muted: #f4f4f5;
  --border: #e4e4e7;
  --text: #111113;
  --text-2: #52525b;
  --text-3: #71717a;
  --primary: #111113;
  --on-primary: #ffffff;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c0d; --surface: #151517; --muted: #1d1d20; --border: #2b2b30;
    --text: #f4f4f5; --text-2: #b4b4bb; --text-3: #8b8b94;
    --primary: #f4f4f5; --on-primary: #111113; --danger: #f97066;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
/* Same dark colours when someone picks dark with the switch */
:root[data-theme="dark"] {
  --bg: #0c0c0d; --surface: #151517; --muted: #1d1d20; --border: #2b2b30;
  --text: #f4f4f5; --text-2: #b4b4bb; --text-3: #8b8b94;
  --primary: #f4f4f5; --on-primary: #111113; --danger: #f97066;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { display: block; max-width: 100%; }
h1, h2, h3 { line-height: 1.1; letter-spacing: -0.03em; margin: 0; }
p { margin: 0; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px clamp(16px, 3vw, 32px); border-bottom: 1px solid var(--border);
  background: var(--bg); position: sticky; top: 0; z-index: 10;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 18px; letter-spacing: -0.02em; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 700; font-size: 16px; }
.nav { display: flex; align-items: center; gap: 20px; font-size: 15px; }
.nav a:not(.btn), .link-btn { text-decoration: none; color: var(--text); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.nav a:not(.btn):hover, .link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.nav .muted { color: var(--text-3); }
@media (max-width: 640px) { .nav .hide-sm { display: none; } .nav { gap: 14px; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 500; font-size: 15px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { opacity: .88; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 8px; border: 0; background: none; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--muted); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.is-on { color: #d4a000; }
.icon-btn.is-on svg { fill: currentColor; }

/* Forms */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 13px; color: var(--text-3); }
.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
.input:focus { outline: 2px solid var(--text); outline-offset: -1px; border-color: transparent; }
.form-error { color: var(--danger); font-size: 14px; margin: -4px 0 14px; min-height: 0; }
.form-error:empty { display: none; }
.divider { text-align: center; color: var(--text-3); font-size: 13px; margin: 14px 0; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--text-2); }

/* Cards / dialogs */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto;
  border: 1px solid var(--border); border-radius: 16px; padding: 28px; background: var(--surface); color: var(--text);
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(10,10,12,.45); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 6px; }
.dialog-head h2 { font-size: 26px; }
.dialog-sub { color: var(--text-2); font-size: 15px; margin-bottom: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.section-sep { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--primary); color: var(--on-primary); padding: 12px 18px; border-radius: 10px; font-size: 15px;
  transition: .2s ease; pointer-events: none; z-index: 100; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* Generated + image covers */
.cover { aspect-ratio: 3 / 4; width: 100%; border-radius: 6px; overflow: hidden; background: var(--muted); position: relative; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
/* Generated cover: soft tint of the subject's colour, bold title, and a big subject mark in the corner.
   Sizes use cqw (percent of the cover's width) so it looks the same at any size. */
.cover-gen {
  --bg: hsl(var(--h) 80% 94%); --ink: hsl(var(--h) 55% 16%); --pill: hsl(var(--h) 75% 86%); --mark: hsl(var(--h) 80% 84%);
  container-type: inline-size;
  background: var(--bg); color: var(--ink); isolation: isolate;
}
.cover-gen .cg-inner { position: absolute; inset: 0; padding: 8cqw 8cqw 7cqw; display: flex; flex-direction: column; align-items: flex-start; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cover-gen {
    --bg: hsl(var(--h) 30% 17%); --ink: hsl(var(--h) 80% 93%); --pill: hsl(var(--h) 30% 27%); --mark: hsl(var(--h) 32% 24%);
  }
}
:root[data-theme="dark"] .cover-gen {
  --bg: hsl(var(--h) 30% 17%); --ink: hsl(var(--h) 80% 93%); --pill: hsl(var(--h) 30% 27%); --mark: hsl(var(--h) 32% 24%);
}
.cover-gen .cg-mark {
  position: absolute; z-index: -1; right: -3.4cqw; bottom: -7.6cqw;
  font-size: 62cqw; font-weight: 800; line-height: 1; letter-spacing: -0.07em; color: var(--mark); white-space: nowrap;
}
.cover-gen .cg-mark-long { font-size: 37cqw; bottom: -4.2cqw; }
.cover-gen .cg-mark-svg { width: 52cqw; height: 52cqw; right: -2.5cqw; bottom: -2.5cqw; line-height: 0; }
.cover-gen .cg-mark-svg svg { width: 100%; height: 100%; display: block; }
.cover-gen .cg-subject { font-size: 5.4cqw; font-weight: 600; background: var(--pill); padding: 1.35cqw 3.7cqw; border-radius: 999px; line-height: 1.3; }
.cover-gen .cg-title { font-size: 11cqw; font-weight: 700; line-height: 1.08; letter-spacing: -0.035em; margin-top: 5cqw; overflow-wrap: anywhere; }
.cover-gen .cg-pub { font-size: 5.2cqw; font-weight: 500; opacity: .7; margin-top: auto; }

/* Demo banner */
.demo-banner { background: #fff7e0; color: #5c4300; font-size: 14px; text-align: center; padding: 8px 16px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .demo-banner { background: #2b2410; color: #f3d98b; } }
:root[data-theme="dark"] .demo-banner { background: #2b2410; color: #f3d98b; }

/* Light/dark switch: show the moon in light mode, the sun in dark mode */
.theme-btn .sun { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .theme-btn .sun { display: block; } :root:not([data-theme="light"]) .theme-btn .moon { display: none; } }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }

/* Loading placeholders */
.skeleton { background: var(--muted); border-radius: 6px; position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } * { transition: none !important; } }

/* Footer */
.site-footer { border-top: 1px solid var(--border); padding: 28px clamp(16px, 3vw, 32px); color: var(--text-3); font-size: 14px; display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; }
.site-footer nav { display: flex; gap: 20px; flex-wrap: wrap; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--text); }

/* Prose pages */
.prose { max-width: 720px; margin: 0 auto; padding: 56px 16px 80px; }
.prose h1 { font-size: clamp(34px, 5vw, 44px); margin-bottom: 8px; }
.prose h2 { font-size: 22px; margin: 36px 0 10px; letter-spacing: -0.02em; }
.prose p, .prose li { color: var(--text-2); }
.prose p + p { margin-top: 12px; }
.prose ul { padding-left: 20px; }
.prose li { margin: 6px 0; }
.prose .updated { color: var(--text-3); font-size: 14px; }
