/* Guidance — airy, warm, minimal. */
:root {
  /* Black & white on beige. Color is semantic only, always muted:
     green = goals/progress/ahead, red = behind pace. */
  --bg: #F5EEE1;
  --surface: #FFFDF9;
  --surface-warm: #EBE2D0;
  --ink: #262320;
  --muted: #877E72;
  --faint: #B7AC9C;
  --line: #E3D8C5;
  --terra: #262320;      /* UI accent = near-black (buttons, FAB, flags, tabs) */
  --terra-soft: #D8CDBB;
  --sand: #D8C6A8;
  --ahead: #6E8760;      /* muted green — goals, progress, ahead of pace */
  --behind: #AC5A50;     /* muted red — behind pace */
  --shadow: 0 1px 2px rgba(38,35,32,.05), 0 8px 30px rgba(38,35,32,.07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg); color: var(--ink); font-weight: 400;
  -webkit-font-smoothing: antialiased; letter-spacing: .01em;
  display: flex; flex-direction: column; min-height: 100vh; overflow-x: hidden;
}
.serif { font-family: Fraunces, Georgia, serif; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---- Screens (loading / login) ---- */
.screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 22rem; text-align: center; }
.login-card h1 { font-family: Fraunces, serif; font-weight: 500; font-size: 30px; }
.login-card h1 .dot { color: var(--terra); }
.login-card p.tag { color: var(--muted); margin: 6px 0 20px; }
#login-form { display: flex; flex-direction: column; gap: 10px; }
#login-form input { font: inherit; font-size: 15px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); color: var(--ink); text-align: center; }
#login-form input:focus { outline: none; border-color: var(--terra); }
#login-form button { font: inherit; font-size: 15px; font-weight: 500; padding: 13px; border: none;
  border-radius: 12px; background: var(--terra); color: #fff; cursor: pointer; }
#login-msg { color: var(--muted); font-size: 13px; margin-top: 12px; min-height: 18px; }
.warning { color: var(--behind); font-size: 13px; margin-top: 14px; }
code { background: rgba(150,130,100,.15); padding: 0 .3em; border-radius: 5px; font-size: .9em; }

/* ---- Top bar ---- */
header.top { display: flex; align-items: baseline; justify-content: space-between;
  padding: 22px 26px 10px; max-width: 1040px; width: 100%; margin: 0 auto; }
.wordmark { font-family: Fraunces, serif; font-weight: 500; font-size: 20px; letter-spacing: .02em; }
.wordmark .dot { color: var(--terra); }
.top-right { display: flex; align-items: center; gap: 14px; }
.today-date { font-size: 12.5px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.menu-btn { background: none; border: none; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; padding: 2px 6px; }
.menu-btn:hover { color: var(--terra); }
.menu { position: absolute; right: 22px; top: 58px; z-index: 45; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; min-width: 160px; }
.menu button { display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; padding: 11px 16px;
  background: none; border: none; color: var(--ink); cursor: pointer; }
.menu button:hover { background: var(--surface-warm); }

/* ---- Breadcrumb ---- */
.crumbs { max-width: 1040px; width: 100%; margin: 0 auto; padding: 4px 26px 0;
  display: flex; align-items: center; gap: 8px; min-height: 26px; }
.crumb { background: none; border: none; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; padding: 3px 0; }
.crumb:hover { color: var(--terra); }
.crumb.here { color: var(--ink); }
.crumb-sep { color: var(--faint); font-size: 12px; }

/* ---- Stage / views ---- */
main.stage { flex: 1; max-width: 1040px; width: 100%; margin: 0 auto; padding: 0 20px 150px; position: relative; }
.view { display: none; animation: fade .5s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: scale(.985) translateY(6px); } to { opacity: 1; transform: none; } }
.view-intro { text-align: center; padding: 18px 0 6px; }
.view-intro h1 { font-family: Fraunces, serif; font-weight: 400; font-size: 27px; letter-spacing: .01em; }
.view-intro p { color: var(--muted); font-size: 14px; margin-top: 6px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.empty button { margin-top: 14px; font: inherit; font-size: 14px; padding: 10px 18px; border-radius: 22px;
  background: var(--terra); color: #fff; border: none; cursor: pointer; }

/* ---- Range SVG ---- */
.range-wrap { width: 100%; }
svg.range { width: 100%; height: auto; display: block; overflow: visible; }
.peak-hit { cursor: pointer; }
.peak-fill { fill: #CFC0A2; transition: fill .3s; }   /* shaded left face */
.peak-hit:hover .peak-fill { fill: #C8B896; }
.peak-light { fill: #E7DECB; }                        /* lighter right face */
.trail { stroke: var(--faint); stroke-width: 1.4; stroke-dasharray: 2 5; stroke-linecap: round; fill: none; }
.pace-ring { fill: var(--bg); stroke: var(--muted); stroke-width: 1.6; }
.prog-dot { fill: var(--terra); }
.prog-dot.ahead { fill: var(--ahead); }
.prog-dot.behind { fill: var(--behind); }
.summit-flag { fill: var(--terra); }
.flag-pole { stroke: var(--terra); stroke-width: 1.8; stroke-linecap: round; }
.dname { font-family: Fraunces, serif; font-size: 17px; fill: var(--ink); text-anchor: middle; }
.dnote { font-family: Inter, sans-serif; font-size: 11.5px; text-anchor: middle; letter-spacing: .02em; }
.dnote.ahead { fill: var(--ahead); }
.dnote.behind { fill: var(--behind); }
.dpct { font-family: Inter, sans-serif; font-size: 11px; fill: var(--muted); text-anchor: middle; }
.legend { display: flex; gap: 22px; justify-content: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.lg-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--terra); display: inline-block; }
.lg-ring { width: 9px; height: 9px; border-radius: 50%; border: 1.6px solid var(--muted); display: inline-block; }

/* ---- Domain (zoomed) view ---- */
.domain-head { text-align: center; padding: 10px 0 2px; }
.domain-head h2 { font-family: Fraunces, serif; font-weight: 400; font-size: 25px; }
.domain-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
svg.climb { width: 100%; height: auto; display: block; overflow: visible; max-height: 62vh; }
.waypoint-hit { cursor: pointer; }
.wp-node { fill: var(--surface); stroke: var(--line); stroke-width: 1.4; transition: stroke .25s; }
.waypoint-hit:hover .wp-node { stroke: var(--terra); }
.wp-prog { fill: none; stroke: var(--ahead); stroke-width: 3.2; stroke-linecap: round; }
.wp-tier { font-family: Inter, sans-serif; font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; fill: var(--faint); }
.wp-label { font-family: Inter, sans-serif; font-size: 12.5px; fill: var(--ink); }
.wp-sub { font-family: Inter, sans-serif; font-size: 11px; fill: var(--muted); }
.climb-trail { fill: none; stroke: var(--faint); stroke-width: 1.6; stroke-dasharray: 2 6; stroke-linecap: round; }
.you-marker { fill: var(--ahead); }
.add-sub-btn { display: block; margin: 8px auto 0; font: inherit; font-size: 13px; padding: 9px 18px;
  border-radius: 22px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); cursor: pointer; }
.add-sub-btn:hover { border-color: var(--terra); color: var(--terra); }

/* ---- Detail view ---- */
.detail-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 22px; box-shadow: var(--shadow); margin-top: 14px; }
.detail-card h2 { font-family: Fraunces, serif; font-weight: 400; font-size: 22px; }
.detail-tier { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-bottom: 3px; }
.pace-bar-wrap { margin: 16px 0 6px; }
.pace-bar { position: relative; height: 10px; background: var(--surface-warm); border-radius: 20px; }
.pace-fill { position: absolute; inset: 0 auto 0 0; background: var(--ahead); border-radius: 20px; }
.pace-tick { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--muted); border-radius: 2px; }
.pace-legend { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.detail-progress { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.detail-progress input[type=range] { flex: 1; accent-color: var(--ahead); }
.daytracker { margin-top: 16px; }
.daygrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 6px; max-width: 360px; }
.daycell { aspect-ratio: 1; border-radius: 4px; background: #E7DECB; min-width: 0; }
.daycell.blank { background: transparent; }
.daycell.future { background: #F0E9DB; }
.daycell.l0 { background: #E7DECB; }
.daycell.l1 { background: #C3D0B4; }
.daycell.l2 { background: #94AE82; }
.daycell.l3 { background: #6E8760; }
.daycell.is-today { outline: 1.7px solid var(--ink); outline-offset: -1.7px; }
.day-legend { display: flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.day-legend .daycell { width: 11px; height: 11px; aspect-ratio: auto; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 22px 0 8px; }
.sg, .task-row { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.sg .sg-title { flex: 1; font-size: 14.5px; }
.sg .mini-bar { width: 82px; height: 5px; background: var(--surface-warm); border-radius: 20px; overflow: hidden; }
.sg .mini-fill { height: 100%; background: var(--ahead); }
.sg .sg-pct { font-size: 11.5px; color: var(--muted); width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.sg .chev { color: var(--faint); font-size: 15px; cursor: pointer; }
.task-row .cbox { width: 18px; height: 18px; border-radius: 50%; border: 1.6px solid var(--faint); flex: none;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.task-row .cbox.on { background: var(--ahead); border-color: var(--ahead); }
.task-row .cbox svg { width: 10px; height: 10px; stroke: #fff; opacity: 0; }
.task-row .cbox.on svg { opacity: 1; }
.task-row .tt { flex: 1; font-size: 14.5px; }
.task-row.done .tt { text-decoration: line-through; color: var(--muted); }
.task-row .q { font-size: 10px; color: var(--muted); background: var(--surface-warm); border-radius: 20px; padding: 2px 8px; }

/* ---- Today strip ---- */
.today { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(245,238,225,.9); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.today-inner { max-width: 1040px; margin: 0 auto; padding: 12px 22px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 16px; }
.today-label { font-family: Fraunces, serif; font-size: 14px; color: var(--terra); white-space: nowrap;
  display: flex; align-items: center; gap: 8px; }
.today-label .badge { font-family: Inter, sans-serif; font-size: 10.5px; color: var(--muted);
  background: var(--surface-warm); border-radius: 20px; padding: 2px 8px; }
.today-tasks { display: flex; gap: 10px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.today-tasks::-webkit-scrollbar { display: none; }
.today-empty { color: var(--muted); font-size: 13px; }
.tchip { display: flex; align-items: center; gap: 9px; white-space: nowrap; background: var(--surface);
  border: 1px solid var(--line); border-radius: 22px; padding: 8px 14px 8px 10px; font-size: 13px; cursor: pointer;
  transition: opacity .4s, transform .4s; }
.tchip .box { width: 17px; height: 17px; border-radius: 50%; border: 1.6px solid var(--faint); flex: none;
  display: inline-flex; align-items: center; justify-content: center; transition: all .3s; }
.tchip .box svg { width: 10px; height: 10px; opacity: 0; transform: scale(.4); transition: all .3s; stroke: #fff; }
.tchip .dom-tag { font-size: 10px; color: var(--muted); background: var(--surface-warm); border-radius: 20px; padding: 1px 7px; }
.tchip.done { opacity: .45; }
.tchip.done .box { background: var(--ahead); border-color: var(--ahead); }
.tchip.done .box svg { opacity: 1; transform: scale(1); }
.tchip.done .tt { text-decoration: line-through; }
.tchip.pop { animation: pop .45s ease; }
@keyframes pop { 30% { transform: scale(1.06); } 100% { transform: scale(1); } }
.fab { position: fixed; right: 22px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 31;
  width: 54px; height: 54px; border-radius: 50%; background: var(--terra); color: #fff; border: none;
  font-size: 26px; font-weight: 300; cursor: pointer; box-shadow: 0 6px 20px rgba(38,35,32,.26);
  display: flex; align-items: center; justify-content: center; transition: transform .2s; }
.fab:hover { transform: scale(1.06) rotate(90deg); }

/* ---- Sheets (guided add + sub-goal) ---- */
.sheet-scrim { position: fixed; inset: 0; background: rgba(46,42,37,.28); z-index: 40; opacity: 0;
  pointer-events: none; transition: opacity .3s; backdrop-filter: blur(2px); }
.sheet-scrim.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translate(-50%, 100%); width: 100%; max-width: 480px;
  background: var(--surface); border-radius: 22px 22px 0 0; z-index: 41; padding: 8px 22px 30px;
  transition: transform .34s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -10px 40px rgba(60,45,30,.14);
  max-height: 90vh; overflow-y: auto; }
.sheet.open { transform: translate(-50%, 0); }
.grip { width: 38px; height: 4px; background: var(--line); border-radius: 4px; margin: 8px auto 16px; }
.sheet h3 { font-family: Fraunces, serif; font-weight: 400; font-size: 20px; margin-bottom: 4px; }
.sheet .hint { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 7px; }
.field input[type=text], .field input[type=date] { width: 100%; font: inherit; font-size: 15px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); }
.field input:focus { outline: none; border-color: var(--terra); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt { font: inherit; font-size: 13px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--bg); color: var(--ink); cursor: pointer; transition: all .18s; text-align: center; }
.chip-opt[aria-pressed=true] { background: var(--terra); color: #fff; border-color: var(--terra); }
.chip-opt small { display: block; font-size: 10px; opacity: .7; }
.sheet-actions { display: flex; gap: 12px; margin-top: 22px; }
.btn { flex: 1; font: inherit; font-size: 15px; padding: 13px; border-radius: 12px; cursor: pointer; border: 1px solid var(--line); }
.btn.ghost { background: var(--bg); color: var(--muted); }
.btn.primary { background: var(--terra); color: #fff; border-color: var(--terra); font-weight: 500; }

/* ---- List views (delegate / archive) ---- */
.list-view h2 { font-family: Fraunces, serif; font-weight: 400; font-size: 24px; margin: 10px 0 4px; }
.list-view .desc { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

/* ---- Toast ---- */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px);
  background: var(--ink); color: var(--bg); font-size: 13px; padding: 10px 18px; border-radius: 22px; z-index: 50;
  opacity: 0; pointer-events: none; transition: all .4s; display: flex; align-items: center; gap: 9px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .spark { color: var(--sand); }
#sync { font-size: 11px; color: var(--faint); }
@media (max-width: 560px) {
  .view-intro h1 { font-size: 23px; }
  .today-label span.txt { display: none; }
}
