/* ============================================================
   Life in Perspective — Editorial Journal Design System
   ============================================================ */

:root {
  color-scheme: light;

  /* Tier 1: Core Palette — Warm Paper, Ink, Terracotta, Sage, Indigo */
  --paper-50: #fcfaf6;
  --paper-100: #f7f2e8;
  --paper-200: #ede5d6;
  --paper-300: #ddd2bd;

  --ink-900: #1f1d1a;
  --ink-700: #423e38;
  --ink-500: #665f55;

  --terracotta-600: #b54d2b;
  --terracotta-500: #c75b36;
  --terracotta-100: #f8e7e0;

  --sage-600: #3d6149;
  --sage-100: #e3efe6;

  --indigo-600: #344c73;
  --indigo-100: #e4eaf4;

  --gold-600: #916919;
  --gold-100: #f7eed6;

  --rose-600: #9e3845;
  --rose-100: #f8e3e6;

  /* Tier 2: Semantic Tokens */
  --bg-page: var(--paper-100);
  --bg-surface: var(--paper-50);
  --bg-subtle: var(--paper-200);
  --bg-card-hover: #fffdf9;

  --text-primary: var(--ink-900);
  --text-secondary: var(--ink-700);
  --text-muted: var(--ink-500);

  --border-subtle: #ded5c4;
  --border-strong: #b9ac95;

  --accent: var(--terracotta-600);
  --accent-hover: #963c1f;
  --accent-soft: var(--terracotta-100);

  --stage-prep: var(--gold-600);
  --stage-prep-soft: var(--gold-100);
  --stage-past: var(--terracotta-600);
  --stage-past-soft: var(--terracotta-100);
  --stage-present: var(--sage-600);
  --stage-present-soft: var(--sage-100);
  --stage-future: var(--indigo-600);
  --stage-future-soft: var(--indigo-100);
  --stage-complete: #6a457a;
  --stage-complete-soft: #efe6f4;

  /* Typography */
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Radius & Elevation */
  --radius-sm: 0.5rem;
  --radius-md: 0.875rem;
  --radius-lg: 1.25rem;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgb(31 29 26 / 0.05);
  --shadow-md: 0 6px 20px rgb(31 29 26 / 0.07), 0 1px 3px rgb(31 29 26 / 0.05);
  --shadow-lg: 0 18px 42px rgb(31 29 26 / 0.14);

  --sidebar-width: 19rem;
  --topbar-height: 4rem;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg-page: #171614;
  --bg-surface: #201e1b;
  --bg-subtle: #2a2723;
  --bg-card-hover: #26231f;

  --text-primary: #f2ece1;
  --text-secondary: #d4cbbd;
  --text-muted: #a69c8e;

  --border-subtle: #38332c;
  --border-strong: #585046;

  --accent: #e07b55;
  --accent-hover: #ed916e;
  --accent-soft: #3a241c;

  --stage-prep: #dfb052;
  --stage-prep-soft: #352b17;
  --stage-past: #e07b55;
  --stage-past-soft: #3a241c;
  --stage-present: #7cb38e;
  --stage-present-soft: #1d3124;
  --stage-future: #87a8de;
  --stage-future-soft: #1e2a3d;
  --stage-complete: #bd97cf;
  --stage-complete-soft: #2e2036;

  --rose-600: #e47885;
  --rose-100: #391d22;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.28);
  --shadow-md: 0 8px 24px rgb(0 0 0 / 0.35);
  --shadow-lg: 0 20px 48px rgb(0 0 0 / 0.5);
}

/* Targeted Box Sizing & Base Layout (avoiding global * reset) */
:where(html, body, main, aside, header, section, article, div, nav, ul, ol, li, form, fieldset, dialog, input, textarea, select, button, table, th, td, label) {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Accessibility Utilities */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link:focus {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 2000;
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 3px;
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 500;
  line-height: 1.22;
  color: var(--text-primary);
  margin: 0;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.85rem, 1.4rem + 1.5vw, 2.75rem);
  letter-spacing: -0.015em;
}

h2 {
  font-size: clamp(1.4rem, 1.2rem + 0.7vw, 1.85rem);
}

h3 {
  font-size: clamp(1.12rem, 1.05rem + 0.25vw, 1.32rem);
}

p {
  margin: 0 0 1rem;
  text-wrap: pretty;
  overflow-wrap: break-word;
}

a {
  color: var(--accent);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

.muted {
  color: var(--text-muted);
}

.muted-small {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0;
}

.prose {
  max-width: 66ch;
}

/* ============================================================
   App Shell & Topbar
   ============================================================ */
.app-shell {
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  min-block-size: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 1.25rem;
  background: color-mix(in oklab, var(--bg-surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  inline-size: 2.15rem;
  block-size: 2.15rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.15rem;
  flex-shrink: 0;
}

.brand-title {
  display: block;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.15;
}

.brand-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Timer Pill */
.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.45rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
}

.timer-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-pill);
  min-block-size: 32px;
}

.timer-pill.is-running {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.timer-select {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.2rem;
}

.timer-reset {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 50%;
  min-inline-size: 28px;
  min-block-size: 28px;
}

.timer-reset:hover {
  color: var(--text-primary);
  background: color-mix(in oklab, var(--text-primary) 8%, transparent);
}

/* Buttons */
.btn,
.pill-btn,
.icon-btn {
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  text-decoration: none;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, box-shadow 150ms ease-out, scale 120ms ease-out;
}

.btn:active:not(:disabled),
.pill-btn:active:not(:disabled),
.icon-btn:active:not(:disabled) {
  scale: 0.98;
}

.pill-btn {
  min-block-size: 38px;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.85rem;
}

.pill-btn:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.pill-btn-accent {
  background: var(--accent-soft);
  border-color: color-mix(in oklab, var(--accent) 35%, transparent);
  color: var(--accent);
}

.pill-btn-accent:hover {
  border-color: var(--accent);
}

.count-badge {
  display: inline-grid;
  place-items: center;
  min-inline-size: 1.35rem;
  padding: 0 0.35rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

.icon-btn {
  min-inline-size: 38px;
  min-block-size: 38px;
  padding: 0.4rem;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 1rem;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.btn {
  min-block-size: 42px;
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.9rem;
}

.btn-sm {
  min-block-size: 34px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--rose-100);
  color: var(--rose-600);
  border-color: color-mix(in oklab, var(--rose-600) 35%, transparent);
}

.btn-danger:hover {
  background: var(--rose-600);
  color: #fff;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.mobile-only {
  display: none;
}

/* ============================================================
   Workspace Grid & Sidebar
   ============================================================ */
.workspace-grid {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  flex: 1;
}

.sidebar {
  position: sticky;
  top: var(--topbar-height);
  block-size: calc(100dvh - var(--topbar-height));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: 1.15rem 0.9rem;
  gap: 1rem;
}

.progress-summary {
  padding: 0.9rem;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.45rem;
}

.progress-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.progress-pct {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.progress-track {
  block-size: 7px;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-fill {
  block-size: 100%;
  inline-size: 0%;
  background: linear-gradient(90deg, var(--stage-prep), var(--stage-past), var(--stage-present), var(--stage-future));
  border-radius: var(--radius-pill);
  transition: inline-size 300ms ease-out;
}

.progress-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.7rem 0.65rem 0.25rem;
}

.nav-item {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.87rem;
  font-weight: 500;
  cursor: pointer;
  min-block-size: 42px;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.nav-item:hover {
  background: var(--bg-page);
  color: var(--text-primary);
}

.nav-item[aria-current="page"] {
  background: var(--accent-soft);
  border-color: color-mix(in oklab, var(--accent) 30%, transparent);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-item-icon {
  font-size: 1rem;
  text-align: center;
}

.nav-item-meta {
  display: block;
  font-size: 0.73rem;
  font-weight: 400;
  color: var(--text-muted);
}

.nav-status-dot {
  inline-size: 0.55rem;
  block-size: 0.55rem;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  flex-shrink: 0;
}

.nav-status-dot.is-partial {
  background: var(--stage-prep);
  border-color: var(--stage-prep);
}

.nav-status-dot.is-done {
  background: var(--stage-present);
  border-color: var(--stage-present);
}

.sidebar-footer {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.save-indicator {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.save-dot {
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background: var(--stage-present);
}

.pace-reminder {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.45rem 0 0;
}

/* ============================================================
   Main Content & Module Cards
   ============================================================ */
.main-content {
  padding: clamp(1.25rem, 1rem + 2vw, 2.75rem) clamp(1rem, 1rem + 2.5vw, 3rem) 5rem;
  min-width: 0;
}

.module-container {
  max-width: 58rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Hero Banner */
.module-hero {
  padding: clamp(1.4rem, 1rem + 1.5vw, 2.25rem);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.module-hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  block-size: 4px;
  background: var(--module-accent, var(--accent));
}

.stage-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: var(--module-accent-soft, var(--accent-soft));
  color: var(--module-accent, var(--accent));
  margin-bottom: 0.8rem;
}

.hero-quote {
  margin: 1.1rem 0 0;
  padding: 0.85rem 1.1rem;
  border-left: 3px solid var(--module-accent, var(--accent));
  background: var(--bg-page);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--text-secondary);
}

.hero-quote cite {
  display: block;
  margin-top: 0.35rem;
  font-style: normal;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Cards & Sections */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: clamp(1.15rem, 1rem + 1vw, 1.75rem);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.card-kicker {
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--module-accent, var(--accent));
  margin-bottom: 0.25rem;
}

.callout {
  padding: 1rem 1.15rem;
  border-radius: var(--radius-md);
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  margin: 1rem 0;
}

.callout-warm {
  background: var(--stage-prep-soft);
  border-color: color-mix(in oklab, var(--stage-prep) 30%, transparent);
}

.callout-sage {
  background: var(--stage-present-soft);
  border-color: color-mix(in oklab, var(--stage-present) 30%, transparent);
}

.callout-indigo {
  background: var(--stage-future-soft);
  border-color: color-mix(in oklab, var(--stage-future) 30%, transparent);
}

.callout-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Grids */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17.5rem), 1fr));
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0.9rem;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: 0.85rem;
}

/* Form Elements */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.field-group:last-child {
  margin-bottom: 0;
}

label,
.field-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.field-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.68rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.55;
  transition: border-color 150ms ease, background-color 150ms ease;
}

textarea {
  resize: vertical;
  min-block-size: 5.5rem;
}

textarea.tall {
  min-block-size: 11rem;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.72;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  background: var(--bg-surface);
}

/* Custom Checkboxes & Option Cards */
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.check-item:hover {
  border-color: var(--border-strong);
}

.check-item input[type="checkbox"] {
  inline-size: 1.15rem;
  block-size: 1.15rem;
  margin-top: 0.15rem;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.check-item.is-checked {
  background: color-mix(in oklab, var(--stage-present-soft) 65%, var(--bg-surface));
  border-color: color-mix(in oklab, var(--stage-present) 45%, transparent);
}

.check-item.is-checked .check-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.check-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Chips & Toggle Pills */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  min-block-size: 36px;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.chip.is-active,
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* Option Cards (Personalization) */
.option-card {
  text-align: left;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-page);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

.option-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

.option-card[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
}

.option-card-title {
  font-weight: 700;
  font-size: 0.96rem;
}

.option-card-desc {
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* PACE Principle Cards */
.pace-card {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
}

.pace-letter {
  display: inline-grid;
  place-items: center;
  inline-size: 2rem;
  block-size: 2rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.pace-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

.pace-card p {
  font-size: 0.87rem;
  color: var(--text-secondary);
  margin: 0;
}

/* Interactive ARC Wheel */
.arc-wheel-layout {
  display: grid;
  grid-template-columns: minmax(0, 21rem) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: center;
}

.arc-wheel-svg {
  width: 100%;
  max-width: 21rem;
  height: auto;
  display: block;
  margin: 0 auto;
}

.wheel-slice {
  cursor: pointer;
  transition: opacity 150ms ease, transform 150ms ease;
}

.wheel-slice:hover {
  opacity: 0.88;
}

/* Question Selector ("Menu, not a test") */
.q-category-block {
  margin-bottom: 1.15rem;
}

.q-category-title {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.q-select-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
  margin-bottom: 0.45rem;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.q-select-card.is-selected {
  border-color: var(--module-accent, var(--accent));
  background: color-mix(in oklab, var(--module-accent-soft, var(--accent-soft)) 55%, var(--bg-surface));
}

.q-select-btn {
  flex: 1;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  line-height: 1.5;
  cursor: pointer;
  padding: 0;
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
}

.q-mark {
  display: inline-grid;
  place-items: center;
  inline-size: 1.35rem;
  block-size: 1.35rem;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.q-select-card.is-selected .q-mark {
  background: var(--module-accent, var(--accent));
  border-color: var(--module-accent, var(--accent));
  color: #fff;
}

.q-writing-card {
  padding: 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
  margin-bottom: 1rem;
}

.q-writing-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.q-writing-title {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* Gratitude List */
.gratitude-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: start;
  padding: 0.65rem;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
}

.gratitude-num {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  padding-top: 0.45rem;
  text-align: right;
}

/* Interactive Excitement Map */
.excitement-canvas-wrap {
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.excitement-svg {
  width: 100%;
  min-width: 560px;
  height: auto;
  display: block;
}

.branch-card {
  padding: 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
}

.branch-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.sub-branch-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.sub-branch-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
}

.sub-branch-tag button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.15rem;
  font-size: 0.8rem;
}

/* Backcasting Timeline */
.timeline-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.timeline-step-btn {
  padding: 0.85rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-page);
  text-align: left;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-sans);
}

.timeline-step-btn[aria-selected="true"] {
  border-color: var(--stage-future);
  background: var(--stage-future-soft);
}

.timeline-step-date {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--stage-future);
  font-weight: 600;
}

/* Project List Manager */
.capacity-meter {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  margin-bottom: 1rem;
}

.capacity-bar {
  block-size: 10px;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin: 0.5rem 0;
}

.capacity-fill {
  block-size: 100%;
  background: var(--stage-present);
  transition: inline-size 250ms ease, background-color 250ms ease;
}

.capacity-fill.is-warn {
  background: var(--stage-prep);
}

.capacity-fill.is-over {
  background: var(--rose-600);
}

.project-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
  margin-bottom: 0.6rem;
}

.project-rank-controls {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.rank-btn {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-radius: 0.35rem;
  inline-size: 28px;
  block-size: 24px;
  cursor: pointer;
  font-size: 0.72rem;
}

.rank-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 600;
}

.status-active { background: var(--stage-present-soft); color: var(--stage-present); }
.status-someday { background: var(--stage-prep-soft); color: var(--stage-prep); }
.status-pause { background: var(--stage-future-soft); color: var(--stage-future); }
.status-cancel { background: var(--rose-100); color: var(--rose-600); }

/* Annual Letter Studio */
.letter-studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 0.95fr);
  gap: 1.25rem;
  align-items: start;
}

.gems-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 1rem);
  max-block-size: calc(100dvh - var(--topbar-height) - 2rem);
  overflow-y: auto;
  padding: 1.1rem;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.gem-snippet {
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.84rem;
  margin-bottom: 0.45rem;
}

/* 2x2 Matrix & Discovery-Driven Planning */
.matrix-2x2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.matrix-quad {
  padding: 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
  min-block-size: 9rem;
}

.matrix-quad h4 {
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
}

.ddp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.ddp-table th,
.ddp-table td {
  padding: 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  vertical-align: top;
}

.ddp-table th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.risk-high {
  background: color-mix(in oklab, var(--rose-100) 60%, transparent);
}

/* Code / Prompt Copy Box */
.prompt-box {
  background: var(--bg-page);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-x: auto;
  max-block-size: 16rem;
  overflow-y: auto;
}

/* Session Table */
.session-table {
  width: 100%;
  border-collapse: collapse;
}

.session-table th,
.session-table td {
  padding: 0.45rem;
  border-bottom: 1px solid var(--border-subtle);
}

.session-table th {
  text-align: left;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Accordion / Details (note: no heading inside summary per a11y guide) */
.disclosure {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  margin: 0.75rem 0;
}

.disclosure summary {
  padding: 0.85rem 1rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.disclosure summary::after {
  content: "＋";
  font-size: 1rem;
  color: var(--text-muted);
}

.disclosure[open] summary::after {
  content: "−";
}

.disclosure-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.9rem;
}

/* Resource Cards */
.resource-link-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 140ms ease, transform 140ms ease;
}

.resource-link-card:hover {
  border-color: var(--accent);
  background: var(--bg-surface);
}

.resource-link-title {
  font-weight: 600;
  font-size: 0.92rem;
}

.resource-link-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Module Footer Nav */
.module-footer-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

/* ============================================================
   Dialogs & Drawer
   ============================================================ */
dialog {
  padding: 0;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgb(20 18 15 / 0.55);
  backdrop-filter: blur(4px);
}

.drawer-dialog {
  margin: 0 0 0 auto;
  max-inline-size: min(94vw, 30rem);
  inline-size: 100%;
  max-block-size: 100dvh;
  block-size: 100dvh;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.drawer-inner {
  display: flex;
  flex-direction: column;
  block-size: 100%;
  padding: 1.35rem;
  gap: 1rem;
  overflow-y: auto;
}

.modal-dialog {
  margin: auto;
  max-inline-size: min(94vw, 42rem);
  inline-size: 100%;
  max-block-size: 90dvh;
  border-radius: var(--radius-lg);
}

.modal-inner {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  gap: 1.1rem;
  overflow-y: auto;
  max-block-size: 90dvh;
}

.drawer-header,
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.drawer-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.3rem 0 0;
}

.resonance-form {
  padding: 0.9rem;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.resonance-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: end;
}

.resonance-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.resonance-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  flex: 1;
}

.resonance-entry {
  padding: 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
}

.resonance-entry-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.resonance-entry-text {
  font-size: 0.92rem;
  margin: 0;
  white-space: pre-wrap;
}

/* Somatic Dialog */
.somatic-fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.somatic-fieldset legend {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}

.somatic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0.55rem;
}

.somatic-verdict {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
  font-size: 0.92rem;
}

.somatic-verdict.is-yes {
  background: var(--stage-present-soft);
  border-color: var(--stage-present);
  color: var(--text-primary);
}

/* Export Cards */
.export-cards {
  display: grid;
  gap: 0.85rem;
}

.export-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-page);
}

.export-card h3 {
  font-family: var(--font-sans);
  font-size: 0.98rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.export-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.danger-zone {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  border: 1px dashed var(--rose-600);
  flex-wrap: wrap;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  background: var(--ink-900);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
}

[data-theme="dark"] .toast {
  background: var(--paper-100);
  color: var(--ink-900);
}

/* Motion */
@media (prefers-reduced-motion: no-preference) {
  .drawer-dialog[open] {
    animation: slide-in-right 220ms ease-out both;
  }
  .modal-dialog[open] {
    animation: modal-pop 200ms ease-out both;
  }
  .toast {
    animation: fade-up 200ms ease-out both;
  }
}

@keyframes slide-in-right {
  from { translate: 100% 0; opacity: 0.6; }
}

@keyframes modal-pop {
  from { scale: 0.96; opacity: 0; }
}

@keyframes fade-up {
  from { translate: 0 0.75rem; opacity: 0; }
}

/* Responsive */
@media (max-width: 960px) {
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-only {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    inset: var(--topbar-height) auto 0 0;
    inline-size: min(85vw, 20rem);
    z-index: 150;
    translate: -105% 0;
    transition: translate 220ms ease-out;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.is-open {
    translate: 0 0;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: var(--topbar-height) 0 0 0;
    background: rgb(0 0 0 / 0.45);
    z-index: 140;
  }

  .arc-wheel-layout,
  .letter-studio-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .gems-panel {
    position: static;
    max-block-size: none;
  }

  .timeline-steps,
  .matrix-2x2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .pill-btn .btn-text {
    display: none;
  }
  .resonance-form-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (pointer: coarse) {
  .btn, .pill-btn, .icon-btn, .chip, .nav-item {
    min-block-size: 44px;
  }
}

@media (forced-colors: active) {
  .card, .module-hero, .check-item, .option-card, .chip, dialog {
    border: 1px solid CanvasText;
  }
  .nav-item[aria-current="page"],
  .chip.is-active {
    border: 2px solid Highlight;
  }
}

/* Print Styles for Annual Letter */
.print-only {
  display: none;
}

@media print {
  .app-shell,
  dialog,
  .toast-container {
    display: none !important;
  }

  .print-only {
    display: block !important;
    font-family: Georgia, "Times New Roman", serif;
    color: #111;
    background: #fff;
    padding: 0.5in;
    line-height: 1.65;
  }

  .print-only h1 {
    font-size: 24pt;
    margin-bottom: 0.2in;
  }

  .print-only h2 {
    font-size: 14pt;
    margin-top: 0.25in;
    margin-bottom: 0.08in;
    border-bottom: 1px solid #ccc;
    padding-bottom: 4pt;
  }

  .print-only p,
  .print-only li {
    font-size: 11pt;
    white-space: pre-wrap;
  }
}
