/* Palette and shared values. Warm paper background, deep green primary,
   rust for the relational metric, gold for the projection line.
   Chart SVG markup (js/app.js) reads these same tokens via var(), so the
   charts follow light/dark mode without a separate palette to keep in sync. */
:root {
  --paper: #FFFDF8;
  --paper-soft: #FBF7EF;
  --paper-dim: #F3ECDD;
  --ink: #221F1A;
  --ink-soft: #453F35;
  --muted: #8A8272;
  --muted-2: #6E675B;
  --faint: #A99F8C;
  --faint-2: #B7AE9C;
  --line: #E3DACA;
  --line-soft: #E9E1D2;
  --line-dim: #EDE4D4;
  --green: #2C6A5D;
  --green-deep: #23413A;
  --green-wash: #EAF2EF;
  --rust: #BC6A3B;
  --rust-deep: #B4552F;
  --gold: #C99A3B;
  --even-line: #BBB09A;
  --axis-line: #D8CDB8;
  --marker: #23413A;
  --bg-grad-1: #F7F2E8;
  --bg-grad-2: #EFE8DA;
  --bg-grad-3: #EAE1D0;
  --bg-base: #F1EBDF;
  --header-bg: rgba(246, 242, 234, .82);
  /* Tooltip and toast chips stay a fixed dark surface in both themes, so
     their own text colors don't need to swap with the page. */
  --on-accent: #FBFAF7;
  --tooltip-accent: #9FD9C7;
  --serif: 'Newsreader', Georgia, serif;
  --sans: 'Instrument Sans', system-ui, sans-serif;
}

html[data-theme="dark"] {
  --paper: #24212E;
  --paper-soft: #1F1C29;
  --paper-dim: #302B3D;
  --ink: #F0ECF7;
  --ink-soft: #D0C8DC;
  --muted: #A99FB8;
  --muted-2: #C0B7CF;
  --faint: #81778F;
  --faint-2: #9388A4;
  --line: #3B354B;
  --line-soft: #342F42;
  --line-dim: #2C2838;
  --green: #8BCFB9;
  --green-deep: #2B2440;
  --green-wash: #292A38;
  --rust: #E7A078;
  --rust-deep: #E18A5E;
  --gold: #DFC06F;
  --even-line: #7A718A;
  --axis-line: #4B455B;
  --marker: #B9A8F5;
  --bg-grad-1: #312A43;
  --bg-grad-2: #241F31;
  --bg-grad-3: #1A1724;
  --bg-base: #1A1724;
  --header-bg: rgba(30, 27, 40, .84);
  --tooltip-accent: #D9CCFF;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  color: var(--ink);
  min-height: 100vh;
  background: radial-gradient(120% 120% at 100% 0%, var(--bg-grad-1) 0%, var(--bg-grad-2) 60%, var(--bg-grad-3) 100%) var(--bg-base);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); }
a:hover { color: #215147; }
input, select, textarea, button { font-family: inherit; }
input[type=number]::-webkit-inner-spin-button { opacity: .4; }
::selection { background: #d9c9ad; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.rel-ink { color: var(--rust); }
.total-ink { color: var(--green); }
.strong { font-weight: 600; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 11px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand { display: flex; align-items: center; gap: 11px; margin-right: auto; }
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px -1px rgba(44, 106, 93, .5);
}
.brand-text { line-height: 1.05; }
.brand-title { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.brand-subtitle { font-size: 11px; color: var(--muted); letter-spacing: .02em; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn:hover { background: var(--paper-dim); }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--paper-dim); color: var(--green); }
.theme-icon { display: block; }
.theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }

/* Page layout */
.page { max-width: 1120px; margin: 0 auto; padding: 18px 20px 40px; }

/* Affirmation banner */
.affirmation {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 14px;
  margin-bottom: 14px;
  background: linear-gradient(90deg, var(--green-wash), var(--paper-dim));
  border: 1px solid #DCE7E2;
  border-radius: 11px;
}
.affirmation svg { flex-shrink: 0; }
.affirmation-text {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: #3B4A44;
  line-height: 1.3;
}
.affirmation-refresh {
  margin-left: auto;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #7C8A83;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.affirmation-refresh:hover { background: rgba(255, 255, 255, .6); color: var(--green); }

/* Scope toggle */
.scope-row { display: flex; justify-content: center; margin-bottom: 14px; }
.scope-toggle {
  display: inline-flex;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
}
.scope-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 9px;
  text-align: center;
  cursor: pointer;
  line-height: 1.25;
  background: transparent;
  color: var(--muted-2);
}
.scope-btn.active { background: var(--green); color: #F6F2EA; }
.scope-btn-title { display: block; font-weight: 600; font-size: 13.5px; }
.scope-btn-sub { display: block; font-size: 11px; opacity: .72; }

/* Cards */
.card {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(30, 25, 15, .04);
  margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.card-head.wrap { align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.card-title { font-family: var(--serif); font-size: 17px; font-weight: 600; margin: 0; }
.card-note { font-size: 12px; color: var(--muted); }
.hint-icon {
  color: var(--faint-2);
  cursor: help;
  display: inline-flex;
  position: relative;
  align-items: center;
  outline: none;
}
.hint-icon[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  z-index: 80;
  width: max-content;
  max-width: min(320px, calc(100vw - 32px));
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--green-deep);
  color: var(--on-accent);
  box-shadow: 0 12px 28px -12px rgba(25, 20, 36, .55);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -2px);
  transition: opacity .12s ease .12s, transform .12s ease .12s;
}
.hint-icon[data-tip]:hover::after,
.hint-icon[data-tip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}
.legend-toggle .hint-icon[data-tip]::after {
  right: 0;
  left: auto;
  transform: translate(0, -2px);
}
.legend-toggle .hint-icon[data-tip]:hover::after,
.legend-toggle .hint-icon[data-tip]:focus-visible::after {
  transform: translate(0, 0);
}
.link-btn {
  margin-left: auto;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
}
.link-btn:hover { color: var(--green); }

/* Hours & dates inputs */
.inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px 22px;
}
.hours-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
}
.hours-label { font-size: 12.5px; font-weight: 600; }
.hours-number {
  width: 72px;
  height: 32px;
  text-align: right;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
}
.hours-range { width: 100%; cursor: pointer; accent-color: var(--green); }
.hours-range.rel-accent { accent-color: var(--rust); }

.field { display: block; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted-2); margin-bottom: 6px; }
.field-label.small { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.date-input {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper-soft);
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
}

.footnote { font-size: 11px; color: var(--faint); margin-top: 8px; }
.divider { height: 1px; background: var(--line-dim); margin: 16px 0 14px; }

.subhead-row { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; flex-wrap: wrap; }
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.eyebrow.center { letter-spacing: .12em; }
.chip-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper-soft);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--green);
  cursor: pointer;
}
.chip-btn:hover { background: var(--paper-dim); }
.dates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

/* Charts */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 6px;
}
.chart { min-width: 0; }
.chart-head { display: flex; align-items: center; gap: 7px; margin-bottom: 2px; }
.chart-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.chart-count { margin-left: auto; font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.rel-dot { background: var(--rust); }
.total-dot { background: var(--green); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: none; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted-2);
  align-items: center;
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.swatch-logged { width: 20px; height: 4px; border-radius: 2px; background: var(--green); }
.swatch-even { width: 20px; height: 2px; background: var(--even-line); }
.legend-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-weight: 500;
}
.legend-toggle input { width: 15px; height: 15px; accent-color: var(--gold); cursor: pointer; }

/* Summary */
.summary-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px; margin-bottom: 18px; }
.summary-title { font-family: var(--serif); font-size: 18px; font-weight: 600; line-height: 1.1; margin: 0; }
.summary-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.status-chip {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-text { font-size: 12.5px; font-weight: 600; }
.status-chip.ontrack { background: #E8F3EE; border-color: #C4E1D4; }
.status-chip.ontrack .status-dot { background: var(--green); }
.status-chip.ontrack .status-text { color: var(--green); }
.status-chip.watch { background: #FBF1DD; border-color: #EBD9AF; }
.status-chip.watch .status-dot { background: var(--gold); }
.status-chip.watch .status-text { color: #9A7420; }
.status-chip.behind { background: #F7E8DF; border-color: #EAC9B4; }
.status-chip.behind .status-dot { background: var(--rust-deep); }
.status-chip.behind .status-text { color: var(--rust-deep); }

.week-target {
  text-align: center;
  padding: 16px;
  margin-bottom: 20px;
  background: linear-gradient(90deg, #F7EEE4, #EFF4F1);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
}
.week-target-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 14px 40px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.week-target-item { display: flex; align-items: baseline; gap: 8px; }
.week-target-value { font-family: var(--serif); font-size: 38px; font-weight: 500; line-height: 1; }
.week-target-unit { font-size: 13px; color: var(--muted-2); }
.week-target-sep { width: 1px; height: 34px; background: var(--line); align-self: center; }

.progress-block { margin-bottom: 16px; }
.progress-block.last { margin-bottom: 0; }
.progress-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.progress-head .dot { align-self: center; width: 8px; height: 8px; }
.progress-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.progress-count { font-size: 13px; color: var(--muted); }
.progress-count strong { font-size: 15px; }
.progress-remaining { margin-left: auto; font-size: 12px; color: var(--muted); }
.progress-track { position: relative; height: 12px; border-radius: 999px; }
.rel-track { background: #F1E7D7; }
.total-track { background: #E7EEE9; }
.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .4s cubic-bezier(.2, .7, .3, 1);
}
.rel-fill { background: linear-gradient(90deg, #C97B49, var(--rust)); }
.total-fill { background: linear-gradient(90deg, #38826F, var(--green)); }
.pace-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 20px;
  background: var(--marker);
  border-radius: 2px;
  transform: translateX(-1px);
}

.marker-note { display: flex; align-items: center; gap: 7px; margin-top: 12px; font-size: 11.5px; color: var(--muted); }
.marker-swatch { width: 2px; height: 13px; background: var(--marker); border-radius: 2px; flex-shrink: 0; }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(35, 31, 26, .42);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 500px;
  background: var(--paper-soft);
  border-radius: 18px;
  box-shadow: 0 30px 70px -20px rgba(35, 31, 26, .5);
  overflow: hidden;
}
.modal.wide { max-width: 560px; }
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-dim);
  display: flex;
  align-items: center;
}
.modal-title { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.modal-subtitle { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.modal-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: #F1EADD;
  color: var(--muted-2);
  cursor: pointer;
  font-size: 18px;
}
.modal-body { padding: 20px 22px; max-height: 60vh; overflow-y: auto; }
.modal-body.prose { max-height: 66vh; font-size: 14px; line-height: 1.6; color: var(--ink-soft); }
.modal-body.prose p { margin: 0 0 14px; }
.modal-body.prose p:last-child { margin-bottom: 0; }
.modal-body.prose strong { color: var(--ink); }
.modal-body.prose .divider { background: var(--line-dim); margin: 16px 0; }
.privacy-callout { padding: 12px 14px; background: var(--green-wash); border-radius: 10px; color: #3B4A44; }
.modal-note { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line-dim);
  display: flex;
  justify-content: flex-end;
}

.pause-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.pause-row .date-input { flex: 1; background: var(--paper); font-size: 13px; padding: 0 10px; }
.pause-row .to { color: var(--faint); font-size: 13px; }
.pause-remove {
  width: 34px;
  height: 38px;
  border-radius: 9px;
  border: none;
  background: #F6E9DE;
  color: var(--rust-deep);
  cursor: pointer;
  flex-shrink: 0;
}
.empty-note { font-size: 13px; color: var(--faint-2); padding: 8px 0 12px; text-align: center; }
.dashed-btn {
  width: 100%;
  margin-top: 8px;
  height: 40px;
  border-radius: 10px;
  border: 1px dashed #CDBFA6;
  background: var(--paper-soft);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--green);
  cursor: pointer;
}
.primary-btn {
  height: 40px;
  padding: 0 22px;
  border-radius: 10px;
  border: none;
  background: var(--green);
  color: #F6F2EA;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn:hover { background: #25594E; }

/* Toast */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--green-deep);
  color: var(--on-accent);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 30px -8px rgba(35, 65, 58, .6);
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 90vw;
}
.toast svg { flex-shrink: 0; }

/* Placed after every base rule above so these direct-selector overrides
   win the cascade when the saved dark theme is active. */
html[data-theme="dark"] ::selection { background: #4B4260; }
html[data-theme="dark"] a:hover { color: #A9DDCE; }
html[data-theme="dark"] .affirmation { border-color: #413A52; }
html[data-theme="dark"] .affirmation-text { color: #DED7EF; }
html[data-theme="dark"] .affirmation-refresh { color: #A99FC0; }
html[data-theme="dark"] .affirmation-refresh:hover { background: rgba(255, 255, 255, .08); }
html[data-theme="dark"] .scope-btn.active { color: #191626; }
html[data-theme="dark"] .status-chip.ontrack { background: #23352F; border-color: #46705F; }
html[data-theme="dark"] .status-chip.watch { background: #3B321F; border-color: #64522D; }
html[data-theme="dark"] .status-chip.watch .status-text { color: #E4C16C; }
html[data-theme="dark"] .status-chip.behind { background: #3B2B27; border-color: #684A3C; }
html[data-theme="dark"] .week-target { background: linear-gradient(90deg, #332638, #242D3A); }
html[data-theme="dark"] .rel-track { background: #3A2E31; }
html[data-theme="dark"] .total-track { background: #253236; }
html[data-theme="dark"] .modal-close { background: #302B3D; }
html[data-theme="dark"] .privacy-callout { color: #DED7EF; }
html[data-theme="dark"] .pause-remove { background: #412D2A; }
html[data-theme="dark"] .dashed-btn { border-color: #5E566D; }
html[data-theme="dark"] .primary-btn { color: #191626; }

@media print {
  [data-noprint] { display: none !important; }
  body { background: #fff; }
  .card-print { box-shadow: none !important; break-inside: avoid; }
}
