/* ═══════════════════════════════════════════════════════
   Design tokens — never change these
═══════════════════════════════════════════════════════ */
:root {
  --bg: #f3efe5;
  --paper: rgba(255, 250, 241, 0.88);
  --ink: #1d241f;
  --muted: #58645a;
  --line: rgba(29, 36, 31, 0.12);
  --accent: #af3f2f;
  --accent-2: #1d6c63;
  --accent-3: #d79b2b;
  --shadow: 0 20px 60px rgba(58, 46, 24, 0.13);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;

  /* --- Type scale --- */
  --text-xs:   0.72rem;
  --text-sm:   0.82rem;
  --text-base: 0.94rem;
  --text-md:   1.05rem;
  --text-lg:   1.25rem;
  --text-xl:   1.5rem;
  --text-2xl:  2rem;
  --text-hero: clamp(2.8rem, 6vw, 5rem);

  /* --- Font families --- */
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-ui:    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;

  /* --- Easing --- */
  --ease-appear: cubic-bezier(0.22, 0.8, 0.4, 1);
  --ease-leave:  cubic-bezier(0.4, 0, 0.8, 0.6);
  --ease-settle: cubic-bezier(0.34, 1.0, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);

  /* --- Timing --- */
  --dur-fast:   140ms;
  --dur-base:   240ms;
  --dur-slow:   320ms;
  --dur-appear: 280ms;

  /* --- Interactive states --- */
  --state-hover-bg:    rgba(29, 36, 31, 0.05);
  --state-active-bg:   rgba(29, 36, 31, 0.10);
  --state-focus-ring:  rgba(29, 108, 99, 0.45);
  --state-disabled-op: 0.38;
  --state-error-bg:    rgba(175, 63, 47, 0.08);
  --state-success-bg:  rgba(29, 108, 99, 0.08);
}

/* ═══════════════════════════════════════════════════════
   Base reset & typography
═══════════════════════════════════════════════════════ */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left,  rgba(175, 63, 47, 0.14),  transparent 32%),
    radial-gradient(circle at 85% 15%,   rgba(29, 108, 99, 0.14),  transparent 28%),
    linear-gradient(180deg, #efe7d8 0%, #f7f3ea 40%, #efe8d8 100%);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

/* UI functional text — sans-serif */
.nav-link, .btn, label,
.layer-status-badge, .layer-desc, .entry-date,
.detail-item-sub, input, textarea, select, .tag,
.home-eyebrow, .journal-year-marker, .journal-char-count,
.module-subtitle, .card-hint, .radio-pill span {
  font-family: var(--font-ui);
}

/* Narrative / reflective text — serif */
.north-star-title, .entry-content, .chat-msg,
.detail-item-body, .detail-direction, h1, h2, h3 {
  font-family: var(--font-serif);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url('/assets/topographic-paper-texture.webp');
  background-size: 600px 600px;
  background-repeat: repeat;
  mix-blend-mode: multiply;
  opacity: 0.06;
}

button, input, textarea, select { font: inherit; }

h1, h2, h3, strong { font-weight: 700; }

p { margin: 0 0 0.8em; line-height: 1.7; }
p:last-child { margin-bottom: 0; }

a { color: inherit; text-decoration: none; }

.hidden { display: none !important; }

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 clamp(16px, 4vw, 48px);
  height: 56px;
  background: rgba(243, 239, 229, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.nav-brand {
  font-weight: 700;
  font-size: var(--text-md);
  letter-spacing: 0.04em;
  color: var(--ink);
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.nav-link {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: var(--text-sm);
  color: var(--muted);
  transition: background var(--dur-fast), color var(--dur-fast);
}

.nav-link:hover { background: rgba(29, 36, 31, 0.06); color: var(--ink); }
.nav-link.active { background: var(--ink); color: #fffcf5; }

.app-main {
  flex: 1;
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 80px;
}

.app-main > * {
  animation: fadeIn var(--dur-appear) var(--ease-appear) both;
}

/* ═══════════════════════════════════════════════════════
   Footer
═══════════════════════════════════════════════════════ */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.footer-storage-note {
  font-size: var(--text-xs);
  color: var(--muted);
}

.footer-link {
  font-size: var(--text-xs);
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--dur-fast);
}
.footer-link:hover { color: var(--ink); }

/* ═══════════════════════════════════════════════════════
   Privacy page
═══════════════════════════════════════════════════════ */
.privacy-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 0 60px;
}

.privacy-page h1 {
  font-size: var(--text-xl);
  margin: 0 0 12px;
}

.privacy-lead {
  font-size: var(--text-md);
  color: var(--muted);
  margin: 0 0 36px;
  line-height: 1.7;
}

.privacy-page h2 {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 28px 0 8px;
}

.privacy-page p {
  font-size: var(--text-sm);
  line-height: 1.8;
  color: var(--muted);
  margin: 0 0 12px;
}

.privacy-page strong { color: var(--ink); }

.privacy-updated {
  margin-top: 40px !important;
  font-size: var(--text-xs) !important;
}


.home-hero {
  text-align: center;
  padding: 72px 0 56px;
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background-image: url('/assets/hero-life-atlas-final.webp');
  background-size: cover;
  background-position: 65% center;
}

.home-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    rgba(239, 231, 216, 0.92) 0%,
    rgba(239, 231, 216, 0.72) 50%,
    rgba(239, 231, 216, 0.2) 100%
  );
  pointer-events: none;
}

.home-hero > * {
  position: relative;
  z-index: 1;
}

.home-eyebrow {
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 11px;
  color: var(--muted);
}

.home-hero h1 {
  margin: 0 0 20px;
  font-size: var(--text-hero);
  line-height: 1.05;
}

.home-subtext {
  color: var(--muted);
  font-size: var(--text-md);
  line-height: 1.75;
  max-width: 42ch;
  margin: 0 auto;
}

.module-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 8px;
}

.module-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px 24px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
  transition: transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
  cursor: pointer;
}

.module-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 28px 70px rgba(58, 46, 24, 0.18);
}

.module-card-icon {
  font-size: var(--text-xl);
  line-height: 1;
}

.module-card h2 {
  margin: 0;
  font-size: var(--text-lg);
}

.module-card p {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-base);
  line-height: 1.6;
  flex: 1;
}

.module-card-cta {
  font-size: var(--text-sm);
  color: var(--accent);
  font-weight: 600;
}

.module-card--discovery { border-top: 3px solid var(--accent); }
.module-card--decompose  { border-top: 3px solid var(--accent-2); }
.module-card--journal    { border-top: 3px solid var(--accent-3); }

/* ═══════════════════════════════════════════════════════
   Module sections
═══════════════════════════════════════════════════════ */
.module-section {
  display: grid;
  gap: 20px;
}

.module-header {
  padding: 8px 0 4px;
}

.module-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.module-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.module-icon {
  font-size: var(--text-lg);
  display: block;
  margin-bottom: 6px;
}

.module-header h2 {
  margin: 0 0 4px;
  font-size: var(--text-2xl);
}

.module-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-base);
}

/* ═══════════════════════════════════════════════════════
   Card
═══════════════════════════════════════════════════════ */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 28px;
}

.card-hint {
  color: var(--muted);
  font-size: var(--text-base);
  margin-bottom: 20px;
}

/* ═══════════════════════════════════════════════════════
   Form elements
═══════════════════════════════════════════════════════ */
.field-group {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field-group label,
.field-group > span {
  font-size: var(--text-base);
  color: var(--ink);
}

textarea, input[type="text"], select {
  width: 100%;
  border: 1px solid rgba(29, 36, 31, 0.16);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: rgba(255, 253, 248, 0.92);
  color: var(--ink);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  resize: vertical;
}

textarea:focus, input[type="text"]:focus, select:focus {
  outline: none;
  border-color: rgba(175, 63, 47, 0.55);
  box-shadow: 0 0 0 4px rgba(175, 63, 47, 0.09);
}

/* Horizon radio pills */
.horizon-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-pill input { display: none; }

.radio-pill span {
  display: block;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.92);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}

.radio-pill input:checked + span {
  background: var(--ink);
  color: #fffcf5;
  border-color: var(--ink);
}

/* ═══════════════════════════════════════════════════════
   Buttons
═══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: var(--text-base);
  cursor: pointer;
  transition: transform var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), opacity var(--dur-fast);
  white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: default; transform: none !important; }
.btn:not(:disabled):hover { transform: translateY(-1px); }

.btn-primary {
  background: linear-gradient(135deg, #a43f32 0%, #c85b43 100%);
  color: #fff7f2;
  box-shadow: 0 8px 20px rgba(164, 63, 50, 0.25);
}

.btn-accent {
  background: linear-gradient(135deg, #1c5b55 0%, #2f7d76 100%);
  color: #ecf7f5;
  box-shadow: 0 8px 20px rgba(29, 108, 99, 0.2);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.52);
  border-color: var(--line);
  color: var(--ink);
}

.btn-sm {
  padding: 6px 12px;
  font-size: var(--text-sm);
}

/* ═══════════════════════════════════════════════════════
   Tags / chips
═══════════════════════════════════════════════════════ */
.tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(29, 108, 99, 0.1);
  border: 1px solid rgba(29, 108, 99, 0.14);
  font-size: var(--text-sm);
}

/* ═══════════════════════════════════════════════════════
   Empty state
═══════════════════════════════════════════════════════ */
.empty-state {
  padding: 48px 28px;
  text-align: center;
  border: 1px dashed rgba(29, 36, 31, 0.18);
  border-radius: var(--radius-lg);
  color: var(--muted);
}

.empty-state p { margin: 0; line-height: 1.7; }
.empty-state a { color: var(--accent); text-decoration: underline; }

.empty-state--guided {
  display: grid;
  gap: 16px;
  justify-items: center;
}

.empty-state-link {
  text-decoration: none !important;
}

.discovery-chat-empty {
  padding: 20px 18px;
  margin-bottom: 4px;
}

/* ═══════════════════════════════════════════════════════
   Seeds & north star (discovery)
═══════════════════════════════════════════════════════ */
.seeds-form { display: grid; gap: 0; }
.seeds-form .field-group:last-of-type { margin-bottom: 20px; }

.chat-card { display: flex; flex-direction: column; gap: 14px; padding: 20px; }

.chat-messages {
  min-height: 200px;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.chat-msg {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  line-height: 1.65;
  font-size: var(--text-base);
  max-width: 88%;
}

.chat-msg--user {
  background: var(--ink);
  color: #fffcf5;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-msg--assistant {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-msg.error-msg {
  background: rgba(175, 63, 47, 0.08);
  border-color: rgba(175, 63, 47, 0.25);
  color: var(--accent);
}

.chat-msg.typing::after {
  content: '…';
  display: inline-block;
  animation: blink 1s steps(3, end) infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input-row textarea {
  flex: 1;
  resize: none;
  border-radius: var(--radius-md);
}

.chat-actions {
  display: flex;
  justify-content: flex-end;
}

/* Escape hatch for manual extraction */
.chat-escape {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

.btn-link-subtle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-xs);
  color: var(--text-muted);
  opacity: 0.5;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  transition: opacity 0.2s;
}
.btn-link-subtle:hover { opacity: 0.9; }

/* AI-initiated ready prompt bubble */
.chat-ready-bubble {
  margin: 12px 0 4px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(139,109,56,0.08), rgba(139,109,56,0.04));
  border: 1px solid rgba(139,109,56,0.25);
  border-radius: 12px;
  text-align: center;
}
.ready-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0 0 10px;
}
.ready-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.btn.btn-sm {
  padding: 6px 14px;
  font-size: var(--text-sm);
}

.north-star-card { text-align: center; }
.north-star-card.confirmed { border-top: 3px solid var(--accent); }
.north-star-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.18em; color: var(--muted); margin-bottom: 10px; }
.north-star-title { margin: 0 0 12px; font-size: var(--text-xl); line-height: 1.3; font-style: italic; letter-spacing: 0.02em; }
.north-star-essence { color: var(--muted); margin-bottom: 16px; }
.north-star-meta { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 20px; }
.north-star-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════
   Decompose workshop — settings card
═══════════════════════════════════════════════════════ */
.settings-card { border-left: 4px solid var(--accent-3); }
.settings-title { margin: 0 0 20px; font-size: var(--text-md); }

/* ═══════════════════════════════════════════════════════
   Layer cards
═══════════════════════════════════════════════════════ */
.layers-list { display: grid; gap: 12px; }

.layer-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: 0 4px 16px rgba(58, 46, 24, 0.06);
  transition: box-shadow var(--dur-fast);
  animation: fadeIn var(--dur-appear) var(--ease-appear) both;
}

.layer-card--confirmed { border-left: 4px solid var(--accent-2); }
.layer-card--stale     { border-left: 4px solid var(--accent-3); opacity: 0.85; }
.layer-card--pending   { border-left: 4px solid var(--line); }

.layer-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.layer-icon { font-size: var(--text-lg); flex-shrink: 0; }

.layer-info {
  flex: 1;
  display: grid;
  gap: 2px;
}

.layer-info strong { font-size: var(--text-md); }
.layer-desc { font-size: var(--text-sm); color: var(--muted); }

.layer-status-badge {
  font-size: var(--text-xs);
  padding: 3px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.status-confirmed { background: rgba(29, 108, 99, 0.12); color: var(--accent-2); }
.status-stale     { background: rgba(215, 155, 43, 0.15); color: #8a6210; }
.status-pending   { background: rgba(29, 36, 31, 0.06);  color: var(--muted); }

.stale-banner {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(215, 155, 43, 0.1);
  font-size: var(--text-sm);
  color: #6d4d0e;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.layer-preview {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preview-text {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0;
}

/* ── Layer detail (expanded) ── */
.layer-card-header--clickable { cursor: pointer; user-select: none; }
.layer-card-header--clickable:hover .layer-info strong { color: var(--accent-2); }

.layer-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.layer-expand-icon {
  font-size: var(--text-xs);
  color: var(--muted);
}

.detail-section {
  font-size: var(--text-base);
  line-height: 1.65;
  margin-bottom: 12px;
  color: var(--ink);
}

.detail-direction {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 14px;
  padding: 10px 14px;
  background: rgba(29, 108, 99, 0.06);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-2);
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-item {
  padding: 12px 14px;
  background: rgba(29, 36, 31, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.detail-item--warn {
  background: rgba(215, 155, 43, 0.07);
  border-color: rgba(215, 155, 43, 0.3);
}

.detail-item-title {
  font-weight: 600;
  font-size: var(--text-base);
  margin-bottom: 4px;
  color: var(--ink);
}

.detail-item-sub {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: 4px;
}

.detail-item-body {
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--text-secondary, var(--ink));
  margin-top: 6px;
  opacity: 0.85;
}

.tradeoff { color: #7a5c00; }

/* Pathway nodes inside a dimension */
.pathway-nodes {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 10px;
  border-left: 2px solid var(--line);
}

.pathway-node {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: var(--text-sm);
}

.node-year {
  font-weight: 700;
  color: var(--accent-2);
  flex-shrink: 0;
  min-width: 36px;
}

.node-title { color: var(--ink); }

.node-desc {
  color: var(--muted);
  font-size: var(--text-sm);
  margin-left: 4px;
}

.text-ok   { color: var(--accent-2); }
.text-warn { color: #8a5e00; }
.text-muted { color: var(--muted); }

.layer-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.layer-error {
  margin-top: 8px;
  font-size: var(--text-sm);
  color: var(--accent);
  padding: 8px 12px;
  background: rgba(175, 63, 47, 0.06);
  border-radius: var(--radius-sm);
}

.progress-steps {
  font-size: var(--text-sm);
  color: var(--muted);
  padding: 4px 0;
}

/* ═══════════════════════════════════════════════════════
   Journal
═══════════════════════════════════════════════════════ */
.journal-write-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.journal-write-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.journal-write-top .card-hint {
  margin-bottom: 0;
}

.journal-char-count {
  color: var(--muted);
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.journal-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.journal-inline-status {
  font-size: var(--text-sm);
  color: var(--accent-2);
}

.mood-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mood-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}

.mood-btn:hover  { background: rgba(29, 36, 31, 0.06); }
.mood-btn.active { background: rgba(29, 36, 31, 0.1); border-color: var(--line); }

.journal-calibration-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px;
}

.journal-calibration-callout--nudge {
  border-left: 4px solid var(--accent-3);
  background: linear-gradient(135deg, rgba(215, 155, 43, 0.12), rgba(255, 250, 241, 0.88));
}

.journal-calibration-title {
  font-size: var(--text-md);
  font-weight: 700;
  margin-bottom: 4px;
}

.journal-calibration-copy,
.journal-chat-copy {
  color: var(--muted);
  font-size: var(--text-base);
  margin: 0;
}

.journal-calibration-card {
  gap: 16px;
}

.journal-chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.journal-chat-messages {
  min-height: 220px;
}

.journal-empty { margin-top: 4px; }

/* journal-timeline, journal-milestone, journal-entry — moved to Phase D section below */

.journal-year-marker {
  font-size: var(--text-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 6px;
}

.journal-milestone {
  position: relative;
  padding-left: 18px;
}

.journal-milestone::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent-3);
  box-shadow: 0 0 0 6px rgba(215, 155, 43, 0.1);
}

.journal-milestone-body {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(215, 155, 43, 0.35);
  background: rgba(255, 248, 233, 0.72);
}

.journal-milestone-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.journal-milestone-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.journal-milestone-text {
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* journal-entry — with position: relative added in Phase D section */

.journal-entry--fresh {
  animation: slideInLeft var(--dur-slow) ease both;
}

.entry-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.entry-date { font-size: var(--text-sm); color: var(--muted); }
.entry-mood { font-size: var(--text-md); }

.entry-content {
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.entry-observation {
  margin-top: 10px;
  padding: 8px 12px;
  border-left: 2px solid var(--accent-3);
  font-size: var(--text-sm);
  color: var(--accent-2);
  font-style: italic;
  font-family: var(--font-serif);
  opacity: 0.9;
}

.entry-observation--pending {
  color: var(--muted);
  font-style: normal;
  border-left-color: var(--line);
}

/* ═══════════════════════════════════════════════════════
   Phase D — Empty state illustration
═══════════════════════════════════════════════════════ */
.empty-visual {
  display: block;
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin: 0 auto 20px;
  opacity: 0.75;
}

/* ═══════════════════════════════════════════════════════
   Phase D — Discovery module visual treatments
═══════════════════════════════════════════════════════ */
/* AI chat bubbles get a subtle gold left accent line */
.chat-msg--assistant {
  border-left: 2px solid rgba(215, 155, 43, 0.45);
  animation: bubbleIn var(--dur-slow) var(--ease-appear) both;
}

/* North-star READY glow pulse */
@keyframes northStarGlow {
  0%   { box-shadow: 0 0 0 0   rgba(29, 108, 99, 0.25); }
  50%  { box-shadow: 0 0 0 12px rgba(29, 108, 99, 0.08); }
  100% { box-shadow: 0 0 0 0   rgba(29, 108, 99, 0); }
}
.north-star-card.confirmed {
  animation: northStarGlow 1.8s var(--ease-settle) 1;
}

/* ═══════════════════════════════════════════════════════
   Phase D — Decompose module: status-only border (no per-layer variation)
═══════════════════════════════════════════════════════ */
/* (status borders .layer-card--confirmed / --stale already defined above) */

/* Pathway node dot decoration */
.pathway-node {
  position: relative;
  padding-left: 14px;
}
.pathway-node::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-3);
  opacity: 0.7;
}

/* ═══════════════════════════════════════════════════════
   Phase D — Journal module: timeline vertical line
═══════════════════════════════════════════════════════ */
.journal-timeline {
  display: grid;
  gap: 14px;
  position: relative;
  padding-left: 28px;
}

.journal-timeline::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--line);
}

/* Entry anchor dot on the timeline */
.journal-entry {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: 0 4px 16px rgba(58, 46, 24, 0.05);
  position: relative;
}

.journal-entry::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 20px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--muted);
}

/* Milestone already has its own dot — offset to match new padding */
.journal-milestone {
  position: relative;
  padding-left: 0;
}

.journal-milestone::before {
  left: -20px;
  top: 10px;
}

/* Year marker needs no dot */
.journal-year-marker {
  font-size: var(--text-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 6px;
  padding-left: 0;
}

/* ═══════════════════════════════════════════════════════
   Phase D — Theme toggle button
═══════════════════════════════════════════════════════ */
.theme-toggle-btn {
  margin-left: auto;
  flex-shrink: 0;
  font-size: var(--text-md);
  padding: 4px 8px;
  line-height: 1;
  border-radius: var(--radius-sm);
}

/* ═══════════════════════════════════════════════════════
   Phase E — Dark / night mode
═══════════════════════════════════════════════════════ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:    #1a2420;
    --paper: rgba(28, 36, 30, 0.92);
    --ink:   #e8e0d0;
    --muted: #8a9488;
    --line:  rgba(232, 224, 208, 0.10);
    --accent:   #c4584a;
    --accent-2: #4a9e92;
    --accent-3: #c8912a;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    --state-hover-bg:  rgba(232, 224, 208, 0.06);
    --state-active-bg: rgba(232, 224, 208, 0.12);
    --state-focus-ring: rgba(74, 158, 146, 0.5);
  }

  body {
    background:
      radial-gradient(circle at top left,  rgba(175, 63, 47, 0.07), transparent 32%),
      radial-gradient(circle at 85% 15%,   rgba(29, 108, 99, 0.09), transparent 28%),
      linear-gradient(180deg, #1a2420 0%, #1e2a24 40%, #1a2420 100%);
  }

  .app-nav {
    background: rgba(26, 36, 32, 0.88);
  }

  .home-hero::before {
    background: linear-gradient(
      100deg,
      rgba(26, 36, 32, 0.95) 0%,
      rgba(26, 36, 32, 0.75) 50%,
      rgba(26, 36, 32, 0.25) 100%
    );
  }

  .empty-visual {
    opacity: 0.45;
    mix-blend-mode: lighten;
  }

  body::before {
    mix-blend-mode: screen;
    opacity: 0.04;
  }
}

/* Manual theme override — [data-theme="dark"] wins over prefers-color-scheme */
[data-theme="dark"] {
  --bg:    #1a2420;
  --paper: rgba(28, 36, 30, 0.92);
  --ink:   #e8e0d0;
  --muted: #8a9488;
  --line:  rgba(232, 224, 208, 0.10);
  --accent:   #c4584a;
  --accent-2: #4a9e92;
  --accent-3: #c8912a;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --state-hover-bg:  rgba(232, 224, 208, 0.06);
  --state-active-bg: rgba(232, 224, 208, 0.12);
  --state-focus-ring: rgba(74, 158, 146, 0.5);
}

[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left,  rgba(175, 63, 47, 0.07), transparent 32%),
    radial-gradient(circle at 85% 15%,   rgba(29, 108, 99, 0.09), transparent 28%),
    linear-gradient(180deg, #1a2420 0%, #1e2a24 40%, #1a2420 100%);
}

[data-theme="dark"] .app-nav {
  background: rgba(26, 36, 32, 0.88);
}

[data-theme="dark"] .home-hero::before {
  background: linear-gradient(
    100deg,
    rgba(26, 36, 32, 0.95) 0%,
    rgba(26, 36, 32, 0.75) 50%,
    rgba(26, 36, 32, 0.25) 100%
  );
}

[data-theme="dark"] .empty-visual {
  opacity: 0.45;
  mix-blend-mode: lighten;
}

[data-theme="dark"] body::before {
  mix-blend-mode: screen;
  opacity: 0.04;
}

[data-theme="light"] {
  /* Force light — overrides system dark preference */
  --bg:    #f3efe5;
  --paper: rgba(255, 250, 241, 0.88);
  --ink:   #1d241f;
  --muted: #58645a;
  --line:  rgba(29, 36, 31, 0.12);
  --accent:   #af3f2f;
  --accent-2: #1d6c63;
  --accent-3: #d79b2b;
  --shadow: 0 20px 60px rgba(58, 46, 24, 0.13);
}
@keyframes moduleEnter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes moduleExit {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.module-enter {
  animation: moduleEnter var(--dur-appear) var(--ease-appear) both;
}
.module-exit {
  animation: moduleExit var(--dur-fast) var(--ease-leave) both;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════
   Phase B — Layer detail CSS Grid expand
═══════════════════════════════════════════════════════ */
.layer-detail-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-appear) var(--ease-appear);
  overflow: hidden;
}
.layer-detail-wrapper.is-open {
  grid-template-rows: 1fr;
}
.layer-detail-wrapper > .layer-detail {
  min-height: 0;
  overflow: hidden;
}

/* Remove the old .layer-detail animation since wrapper handles it now */
.layer-detail {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* ═══════════════════════════════════════════════════════
   Phase B — Shimmer loading state
═══════════════════════════════════════════════════════ */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
.layer-card--loading {
  background: linear-gradient(
    90deg,
    var(--paper) 25%,
    rgba(255, 250, 241, 0.5) 50%,
    var(--paper) 75%
  );
  background-size: 1200px 100%;
  animation: shimmer 1.8s infinite linear;
}
.layer-card--loading .layer-actions .btn { opacity: var(--state-disabled-op); pointer-events: none; }

/* ═══════════════════════════════════════════════════════
   Phase B — Chat bubble entrance animation
═══════════════════════════════════════════════════════ */
@keyframes bubbleIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes bubbleInRight {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.chat-msg--assistant {
  animation: bubbleIn var(--dur-slow) var(--ease-appear) both;
}
.chat-msg--user {
  animation: bubbleInRight var(--dur-slow) var(--ease-appear) both;
}

/* ═══════════════════════════════════════════════════════
   Phase B — Unified interactive states
═══════════════════════════════════════════════════════ */
/* focus-visible outline for all buttons */
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--state-focus-ring);
}

/* Unified disabled state */
:disabled, [disabled] {
  opacity: var(--state-disabled-op);
  cursor: not-allowed;
  pointer-events: none;
}

/* Override: btn already has its own disabled style, defer to existing */
.btn:disabled {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
  transform: none !important;
}

/* Input hover state */
textarea:hover:not(:focus),
input[type="text"]:hover:not(:focus),
select:hover:not(:focus) {
  border-color: var(--muted);
}

/* Card hover state using state var */
.module-card:hover {
  background: var(--paper);
}

/* ═══════════════════════════════════════════════════════
   Accessibility — reduced motion
═══════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════════════
   Responsive
═══════════════════════════════════════════════════════ */
@media (max-width: 720px) {
  .module-cards { grid-template-columns: 1fr; }

  .app-nav { gap: 12px; height: auto; padding: 10px 16px; flex-wrap: wrap; }
  .nav-links { gap: 2px; }
  .nav-link { padding: 5px 10px; font-size: 0.82rem; }

  .card { padding: 18px; border-radius: var(--radius-lg); }
  .home-hero { padding: 32px 0 32px; }
  .home-hero h1 { font-size: 2.6rem; }

  .chat-input-row { flex-direction: column; }
  .chat-input-row .btn { align-self: flex-end; }
}

@media (max-width: 640px) {
  .app-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 10px;
  }

  .nav-links {
    margin-left: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    white-space: nowrap;
    padding-bottom: 2px;
  }

  .module-header-row,
  .journal-calibration-callout,
  .journal-chat-header,
  .journal-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .module-header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .module-header-actions .btn,
  .journal-controls .btn,
  .journal-calibration-callout .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .layer-card,
  .journal-entry,
  .journal-milestone-body {
    padding: 14px 16px;
  }

  .pathway-node {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
  }

  .node-year {
    min-width: 0;
    font-size: 0.82rem;
  }

  .node-desc {
    margin-left: 0;
  }

  .journal-timeline {
    width: 100%;
  }

  .settings-card .btn,
  .settings-card input,
  .settings-card textarea {
    width: 100%;
  }

  .settings-card .radio-pill {
    flex: 1 1 calc(50% - 8px);
  }

  .settings-card .radio-pill span {
    width: 100%;
    text-align: center;
  }

  .chat-card,
  .journal-calibration-card {
    min-height: calc(100vh - 160px);
  }

  .chat-messages,
  .journal-chat-messages {
    max-height: none;
    flex: 1;
  }
}
