:root {
  color-scheme: light;
  --bg: oklch(96% 0.03 75);
  --surface: oklch(98% 0.015 85);
  --surface-strong: oklch(94% 0.04 82);
  --ink: oklch(28% 0.04 30);
  --muted: oklch(45% 0.03 45);
  --line: oklch(82% 0.04 75);
  --accent: oklch(67% 0.17 40);
  --accent-deep: oklch(53% 0.15 28);
  --accent-soft: oklch(88% 0.08 55);
  --sage: oklch(78% 0.08 150);
  --shadow: 0 20px 60px color-mix(in oklab, var(--ink) 12%, transparent);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Manrope', sans-serif;
  background:
    radial-gradient(circle at top left, color-mix(in oklab, var(--accent-soft) 85%, white) 0%, transparent 34%),
    radial-gradient(circle at bottom right, color-mix(in oklab, var(--sage) 40%, white) 0%, transparent 30%),
    var(--bg);
  color: var(--ink);
}

.page-shell {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), color-mix(in oklab, var(--line) 30%, transparent) calc(100% - 1px)),
    linear-gradient(transparent 0, transparent calc(100% - 1px), color-mix(in oklab, var(--line) 30%, transparent) calc(100% - 1px));
  background-size: 36px 36px;
  mask: linear-gradient(to bottom, rgba(0, 0, 0, 0.4), transparent 80%);
}

.app {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(1rem, 2vw, 1.5rem) 0 4rem;
}

.panel {
  background: color-mix(in oklab, var(--surface) 92%, white);
  border: 1px solid color-mix(in oklab, var(--line) 80%, white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.accent-panel {
  background:
    linear-gradient(140deg, color-mix(in oklab, var(--accent-soft) 82%, white), color-mix(in oklab, var(--surface) 90%, white));
}

.hero {
  display: grid;
  grid-template-columns: 1.5fr 0.9fr;
  gap: 1.5rem;
  padding: clamp(1.4rem, 4vw, 3rem);
  margin-top: 1rem;
}

.hero-copy h1,
.section-heading h2,
.history-header h3 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0;
}
.hero-copy h1 { font-size: clamp(2.8rem, 7vw, 5.6rem); line-height: 0.92; max-width: 8ch; }
.lede { max-width: 54ch; font-size: 1.05rem; color: var(--muted); line-height: 1.7; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent-deep);
  margin: 0 0 0.75rem;
}
.support-text { color: var(--muted); margin: 0; }

.hero-actions,
.form-actions,
.history-header,
.section-heading,
.section-heading.compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.hero-actions { margin-top: 1.5rem; justify-content: flex-start; flex-wrap: wrap; }

button,
input,
textarea { font: inherit; }
button {
  border: none;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}
button:hover { transform: translateY(-1px); }
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in oklab, var(--accent) 45%, white);
  outline-offset: 2px;
}
.primary-button,
.ghost-button,
.text-button {
  border-radius: 999px;
  padding: 0.9rem 1.2rem;
  font-weight: 700;
}
.primary-button {
  background: var(--accent-deep);
  color: color-mix(in oklab, white 92%, var(--accent-soft));
}
.ghost-button {
  background: transparent;
  color: var(--ink);
  border: 1px solid color-mix(in oklab, var(--line) 88%, white);
}
.text-button {
  padding: 0;
  background: transparent;
  color: var(--accent-deep);
}

.hero-stats {
  display: grid;
  gap: 1rem;
  align-content: end;
}
.hero-stats article,
.metric-card {
  padding: 1.15rem 1.2rem;
  border-radius: var(--radius-lg);
}
.hero-stats article {
  background: color-mix(in oklab, white 55%, var(--accent-soft));
  border: 1px solid color-mix(in oklab, var(--line) 75%, white);
}
.hero-stats span,
.metric-card span { display: block; color: var(--muted); margin-bottom: 0.35rem; }
.hero-stats strong,
.metric-card strong { font-size: clamp(1.5rem, 4vw, 2.25rem); line-height: 1; }
.metric-card small { color: var(--muted); line-height: 1.5; }
.metric-stack { display: grid; gap: 1rem; margin-top: 1.25rem; }
.metric-card.warm { background: color-mix(in oklab, var(--accent-soft) 65%, white); }
.metric-card.soft { background: color-mix(in oklab, var(--sage) 28%, white); }
.metric-card.ink { background: color-mix(in oklab, var(--surface-strong) 72%, white); }

.dashboard-grid,
.weekly-layout {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 1.25rem;
  margin-top: 1.25rem;
}
.weekly-layout { align-items: start; }
.today-panel,
.metrics-panel,
.weekly-panel,
.writing-panel { padding: clamp(1.2rem, 3vw, 1.8rem); }

.checklist {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.5rem;
}
.task-item {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: start;
  gap: 0.9rem;
  padding: 1rem 1rem 1rem 0.9rem;
  border-radius: var(--radius-md);
  background: color-mix(in oklab, var(--surface) 75%, white);
  border: 1px solid color-mix(in oklab, var(--line) 75%, white);
}
.task-item input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox-ui {
  inline-size: 1.35rem;
  block-size: 1.35rem;
  border-radius: 0.45rem;
  margin-top: 0.15rem;
  border: 1.5px solid color-mix(in oklab, var(--accent) 45%, var(--line));
  background: white;
  position: relative;
}
.task-item input:checked + .checkbox-ui {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
}
.task-item input:checked + .checkbox-ui::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  font-size: 0.85rem;
}
.task-copy strong { display: block; font-size: 1rem; margin-bottom: 0.2rem; }
.task-copy small { color: var(--muted); line-height: 1.55; }
.task-item.done { background: color-mix(in oklab, var(--sage) 20%, white); }

.mini-summary {
  margin-top: 1.2rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-lg);
  background: color-mix(in oklab, var(--surface-strong) 56%, white);
  color: var(--ink);
  line-height: 1.65;
}

.weekly-plan {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.4rem;
}
.week-row {
  display: grid;
  grid-template-columns: 120px 1fr 110px;
  gap: 0.85rem;
  align-items: center;
}
.week-row > * {
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in oklab, var(--line) 75%, white);
  background: color-mix(in oklab, var(--surface) 72%, white);
  min-height: 48px;
}
.week-row .day-badge {
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--accent-deep);
}
.week-row input,
.week-row select,
.field input,
.field textarea {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid color-mix(in oklab, var(--line) 75%, white);
  border-radius: var(--radius-sm);
  background: color-mix(in oklab, white 85%, var(--surface));
  color: var(--ink);
}
.field textarea { resize: vertical; min-height: 180px; }
.writing-form { display: grid; gap: 1rem; margin-top: 1.5rem; }
.field { display: grid; gap: 0.5rem; }
.field span { font-weight: 700; }
.save-status { color: var(--accent-deep); min-height: 1.4rem; margin: 0; }
.history-header { margin: 1.6rem 0 1rem; }
.writing-history { display: grid; gap: 0.9rem; }
.history-item {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-lg);
  background: color-mix(in oklab, var(--surface) 68%, white);
  border: 1px solid color-mix(in oklab, var(--line) 72%, white);
}
.history-item header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}
.history-date { color: var(--muted); margin: 0 0 0.25rem; font-size: 0.9rem; }
.history-topic { margin: 0; font-size: 1.1rem; }
.history-body { margin: 0.85rem 0 0; color: var(--ink); line-height: 1.7; white-space: pre-wrap; }
.empty-state {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-lg);
  background: color-mix(in oklab, var(--surface-strong) 42%, white);
  color: var(--muted);
}

@media (max-width: 920px) {
  .hero,
  .dashboard-grid,
  .weekly-layout { grid-template-columns: 1fr; }
  .hero-copy h1 { max-width: 12ch; }
}

@media (max-width: 640px) {
  .app { width: min(100% - 1rem, 1180px); }
  .section-heading,
  .history-header,
  .form-actions { align-items: start; flex-direction: column; }
  .week-row { grid-template-columns: 1fr; }
  .hero-stats strong,
  .metric-card strong { font-size: 1.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
