/* ============================================================
   THE CARE CODE — Design Tokens
   ============================================================ */
:root {
  /* Palette — The Care Code brand: Deep Navy + Care Gold (dark mode) */
  --bg-0: #14263f;
  --bg-1: #1a2f4d;
  --bg-2: #20395c;
  --bg-3: #27436b;
  --line: rgba(244, 241, 234, 0.10);
  --line-2: rgba(244, 241, 234, 0.16);
  --line-strong: rgba(244, 241, 234, 0.32);

  --fg: #f4f1ea;
  --fg-dim: #cdc6b6;
  --fg-mute: #98917f;
  --fg-heading: #f4f1ea;

  --accent: #d9a93b;       /* Light Gold — better contrast on dark navy */
  --accent-warm: #e8c268;
  --accent-deep: #8a6a1f;
  --accent-glow: rgba(217, 169, 59, 0.20);

  --navy: #1f3a5f;         /* Deep Navy — brand primary */
  --gold: #b8860b;         /* Care Gold — brand accent */
  --gold-light: #d9a93b;   /* Light Gold — secondary accent */
  --cream: #f4f1ea;        /* Warm Cream — backgrounds */
  --warm-grey: #555555;    /* body text / captions */
  --ink: #222222;          /* primary body text on white */

  --ok: #8fbf87;
  --warn: #d9a93b;
  --err: #c9705f;

  /* Type — Georgia headings (brand serif), Inter/Calibri body */
  --f-display: Georgia, "Playfair Display", "Times New Roman", serif;
  --f-body: "Inter", Calibri, -apple-system, system-ui, sans-serif;
  --f-mono: ui-monospace, "SF Mono", Menlo, "Courier New", monospace;

  /* Radii — kept sharp */
  --r-sm: 2px;
  --r-md: 4px;
  --r-lg: 6px;

  /* Spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;
  --s-10: 128px;

  /* Layout */
  --shell-max: 1440px;
  --read-max: 760px;
}

/* WARM theme — Warm Cream background, navy + gold accents */
[data-theme="warm"] {
  --bg-0: #f4f1ea;
  --bg-1: #efe9db;
  --bg-2: #e8e0cd;
  --bg-3: #ded3ba;
  --line: rgba(31, 58, 95, 0.10);
  --line-2: rgba(31, 58, 95, 0.18);
  --line-strong: rgba(31, 58, 95, 0.36);
  --fg: #222222;
  --fg-dim: #555555;
  --fg-mute: #857e6d;
  --fg-heading: #1f3a5f;
  --accent: #b8860b;
  --accent-warm: #d9a93b;
  --accent-deep: #8a6608;
  --accent-glow: rgba(184, 134, 11, 0.16);
}

/* LIGHT theme — crisp white/cream, navy headings, gold accent (default) */
[data-theme="light"] {
  --bg-0: #ffffff;
  --bg-1: #f7f5ef;
  --bg-2: #f1ede1;
  --bg-3: #e9e2cf;
  --line: rgba(31, 58, 95, 0.08);
  --line-2: rgba(31, 58, 95, 0.16);
  --line-strong: rgba(31, 58, 95, 0.32);
  --fg: #222222;
  --fg-dim: #555555;
  --fg-mute: #837f76;
  --fg-heading: #1f3a5f;
  --accent: #b8860b;
  --accent-warm: #d9a93b;
  --accent-deep: #8a6608;
  --accent-glow: rgba(184, 134, 11, 0.14);
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--f-body);
  background: var(--bg-0);
  color: var(--fg);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; color: inherit; }

::selection { background: var(--accent); color: var(--bg-0); }

/* ============================================================
   Typography
   ============================================================ */
.display {
  font-family: var(--f-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 0.98;
  text-wrap: balance;
  color: var(--fg-heading);
}
.display-xl { font-size: clamp(56px, 10vw, 160px); }
.display-lg { font-size: clamp(44px, 7vw, 96px); }
.display-md { font-size: clamp(32px, 5vw, 64px); }
.display-sm { font-size: clamp(24px, 3.5vw, 40px); }

.eyebrow {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}
.eyebrow-dim { color: var(--fg-mute); }

.lead {
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.5;
  color: var(--fg-dim);
  text-wrap: pretty;
}
.body-lg { font-size: 19px; line-height: 1.65; }
.body { font-size: 17px; line-height: 1.6; }
.body-sm { font-size: 14px; line-height: 1.55; }

.mono { font-family: var(--f-mono); }
.tabular { font-variant-numeric: tabular-nums; }

/* ============================================================
   Shell / chrome
   ============================================================ */
.app {
  min-height: 100vh;
  background: var(--bg-0);
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: color-mix(in srgb, var(--bg-0) 80%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-left { display: flex; align-items: center; gap: 28px; }
.topbar-right { display: flex; align-items: center; gap: 20px; }

.brand {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.brand-mark {
  width: 24px; height: 24px;
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}
.brand-mark img {
  width: 100%; height: 100%;
  display: block;
  object-fit: contain;
}

.crumb-trail {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.crumb-trail .sep { opacity: 0.5; }
.crumb-trail .active { color: var(--fg); }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--line);
  border-radius: 100px;
  font-size: 13px;
}
.user-chip .avatar {
  width: 28px; height: 28px;
  background: var(--accent);
  color: var(--bg-0);
  border-radius: 100px;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 11px;
  font-family: var(--f-display);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 500;
  border-radius: var(--r-sm);
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: var(--bg-0);
}
.btn-primary:hover {
  background: var(--accent-warm);
  transform: translateY(-1px);
}
.btn-ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line-2);
}
.btn-ghost:hover {
  border-color: var(--fg);
  background: rgba(255,255,255,0.03);
}
.btn-dark {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--line);
}
.btn-dark:hover { background: var(--bg-3); border-color: var(--line-2); }
.btn-lg { padding: 18px 32px; font-size: 13px; }
.btn-sm { padding: 10px 16px; font-size: 11px; letter-spacing: 0.14em; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:disabled:hover { transform: none; }

.btn .arr {
  display: inline-block;
  transition: transform 0.25s ease;
}
.btn:hover .arr { transform: translateX(4px); }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-5);
}

/* ============================================================
   Progress
   ============================================================ */
.progress-rail {
  height: 2px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.6s cubic-bezier(.4,0,.2,1);
}

.progress-dots {
  display: flex; gap: 6px;
}
.progress-dots .dot {
  width: 24px; height: 2px;
  background: var(--line-2);
  transition: background 0.3s ease;
}
.progress-dots .dot.active { background: var(--accent); }
.progress-dots .dot.done { background: var(--fg); }

/* ============================================================
   Image slot — placeholder utility
   ============================================================ */
.img-slot {
  background: var(--bg-2);
  border: 1px dashed var(--line-2);
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--fg-mute);
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.img-slot::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent 0,
    transparent 18px,
    rgba(255,255,255,0.025) 18px,
    rgba(255,255,255,0.025) 19px
  );
  pointer-events: none;
}
.img-slot .label {
  position: relative;
  padding: 6px 10px;
  border: 1px solid var(--line-2);
  background: var(--bg-1);
  letter-spacing: 0.16em;
}
.img-slot-filled {
  border: 1px solid var(--line);
  background: var(--bg-1);
}
.img-slot-filled::before { display: none; }
.img-slot-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ============================================================
   Decorative bits
   ============================================================ */
.hr-tick {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.hr-tick::before, .hr-tick::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.diag-strip {
  background-image: repeating-linear-gradient(
    -55deg,
    var(--accent) 0,
    var(--accent) 8px,
    transparent 8px,
    transparent 16px
  );
}

.corner-frame {
  position: relative;
}
.corner-frame::before, .corner-frame::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--accent);
}
.corner-frame::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.corner-frame::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0.001; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp 0.55s cubic-bezier(.2,.7,.2,1) backwards; }
@media (prefers-reduced-motion: reduce) {
  .fade-up { animation: none; }
}
.fade-up.d1 { animation-delay: 0.06s; }
.fade-up.d2 { animation-delay: 0.12s; }
.fade-up.d3 { animation-delay: 0.18s; }
.fade-up.d4 { animation-delay: 0.24s; }
.fade-up.d5 { animation-delay: 0.30s; }
.fade-up.d6 { animation-delay: 0.36s; }

@keyframes scanline {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.scanline {
  position: relative;
  overflow: hidden;
}
.scanline::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
  animation: scanline 1.6s ease-in-out infinite;
}

@keyframes ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ============================================================
   Utilities
   ============================================================ */
.container { max-width: var(--shell-max); margin: 0 auto; padding: 0 32px; }
.reader { max-width: var(--read-max); margin: 0 auto; padding: 0 32px; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.spread { display: flex; align-items: center; justify-content: space-between; }
.dim { color: var(--fg-dim); }
.mute { color: var(--fg-mute); }
.accent { color: var(--accent); }
.fg { color: var(--fg); }
.uppercase { text-transform: uppercase; letter-spacing: 0.14em; }
.divider { border-top: 1px solid var(--line); }
.hidden { display: none !important; }

/* tight gap utilities */
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 24px; } .gap-6 { gap: 32px; } .gap-7 { gap: 48px; } .gap-8 { gap: 64px; }
