:root {
  --bg: #F6F0E4;
  --card: #FFFDF8;
  --card-2: #F1E8D8;
  --ink: #3B2A1A;
  --muted: #7A6650;
  --line: #E4D8C4;
  --acorn: #8A5A2B;
  --acorn-dark: #5E3B1A;
  --leaf: #5B8C3A;
  --pink: #D6407F;
  --pink-soft: #FBE1EC;
  --pink-ink: #A42A5E;
  --relationship: #D4537A;
  --finance: #C08A1E;
  --health: #3F9256;
  --career: #3F6DB5;
  --bucket: #8A55BF;
  --shadow: 0 1px 2px rgba(59, 42, 26, .06), 0 6px 18px rgba(59, 42, 26, .07);
  --radius: 18px;
  --tabs-h: 64px;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1C1611; --card: #271F18; --card-2: #30261D; --ink: #F3E9DA; --muted: #B5A28A; --line: #3D3126;
    --acorn: #C68A4E; --acorn-dark: #E2AE75; --leaf: #7DB15A; --pink: #F06BA4; --pink-soft: #3A1E2B; --pink-ink: #FF9CC6;
    --relationship: #EC7598; --finance: #E0AE45; --health: #62B577; --career: #6F98DB; --bucket: #AE80DE;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1C1611; --card: #271F18; --card-2: #30261D; --ink: #F3E9DA; --muted: #B5A28A; --line: #3D3126;
  --acorn: #C68A4E; --acorn-dark: #E2AE75; --leaf: #7DB15A; --pink: #F06BA4; --pink-soft: #3A1E2B; --pink-ink: #FF9CC6;
  --relationship: #EC7598; --finance: #E0AE45; --health: #62B577; --career: #6F98DB; --bucket: #AE80DE;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0; }

#view {
  max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 28px);
  min-height: 100dvh;
}
body.no-tabs #view { padding-bottom: calc(env(safe-area-inset-bottom) + 28px); }

/* ── Tabs ─────────────────────────────────────────────── */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs[hidden] { display: none; }
#tabs a {
  flex: 1; max-width: 112px; height: var(--tabs-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: 11.5px; font-weight: 500;
}
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#tabs a.on { color: var(--acorn-dark); }
#tabs a.on svg { stroke-width: 2.2; }

/* ── Building blocks ──────────────────────────────────── */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.head .sub { color: var(--muted); font-size: 14px; margin-bottom: 2px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 22px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.label { font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--acorn-dark); color: var(--bg); font-weight: 700; font-size: 16px;
  text-decoration: none; transition: transform .1s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.block { width: 100%; }
.btn.pink { background: var(--pink); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.linkbtn { background: none; border: 0; padding: 6px 0; color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow); font-weight: 700; font-size: 14px; white-space: nowrap;
}
.chip svg { width: 16px; height: 16px; }

input[type=text], input[type=email], input[inputmode=numeric], textarea, select {
  width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 13px 14px; font-size: 16px; outline: none; transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--acorn); }
textarea { resize: vertical; min-height: 92px; }
.code-input { font-family: var(--mono); font-size: 28px !important; letter-spacing: .3em; text-align: center; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--c, var(--acorn)); }
[data-area="relationship"] { --c: var(--relationship); }
[data-area="finance"] { --c: var(--finance); }
[data-area="health"] { --c: var(--health); }
[data-area="career"] { --c: var(--career); }
[data-area="bucket"] { --c: var(--bucket); }

/* ── Flingo ───────────────────────────────────────────── */
.flingo {
  font-family: var(--mono); font-weight: 700; color: var(--pink); white-space: pre; line-height: 1.12;
  margin: 0; user-select: none; cursor: pointer; flex: none;
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0;
}
.flingo.small { font-size: 17px; }
.flingo.big { font-size: clamp(9px, 2.6vw, 12px); }
.flingo.hop { animation: hop .45s ease; }
@keyframes hop { 30% { transform: translateY(-6px); } 60% { transform: translateY(0); } }

.coach { display: flex; gap: 12px; align-items: center; }
.bubble {
  position: relative; flex: 1; background: var(--pink-soft); color: var(--pink-ink);
  border-radius: 16px; padding: 12px 14px; font-weight: 500; font-size: 15px; line-height: 1.4; min-height: 48px;
}
.bubble::before {
  content: ''; position: absolute; left: -7px; top: 50%; margin-top: -7px;
  border: 7px solid transparent; border-left: 0; border-right-color: var(--pink-soft);
}
.coach.plain .bubble { background: var(--card-2); color: var(--ink); }
.coach.plain .bubble::before { border-right-color: var(--card-2); }
.acorn-mark { width: 44px; height: 52px; flex: none; }
.typing::after { content: '▍'; animation: blink 1s steps(1) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }

/* ── Login ────────────────────────────────────────────── */
.login { min-height: calc(100dvh - 60px); display: flex; flex-direction: column; justify-content: center; gap: 26px; }
.brand { text-align: center; }
.brand h1 { font-size: 46px; color: var(--acorn-dark); }
.brand p { color: var(--muted); margin-top: 4px; }
.brand .flingo { display: inline-block; margin-bottom: 8px; text-align: left; }
.or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ── Today ────────────────────────────────────────────── */
.banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--acorn-dark); color: var(--bg); text-decoration: none; box-shadow: var(--shadow);
}
.banner b { display: block; font-family: var(--serif); font-size: 17px; }
.banner span { font-size: 14px; opacity: .85; }
.banner .arrow { margin-left: auto; font-size: 22px; }

.group h3 { display: flex; align-items: center; gap: 8px; margin: 0 4px 8px; font-family: var(--sans); font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 12px;
  background: var(--card); touch-action: pan-y; transition: transform .2s ease, opacity .25s, background .2s;
}
.item + .item { border-top: 1px solid var(--line); }
.item .title { flex: 1; min-width: 0; font-size: 15.5px; }
.item.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.item.skipped .title { color: var(--muted); font-style: italic; }
.item .src { font-size: 11px; color: var(--muted); }
.tick {
  width: 30px; height: 30px; flex: none; border-radius: 50%; border: 2px solid var(--c, var(--acorn));
  background: transparent; display: grid; place-items: center; cursor: pointer; padding: 0; transition: background .15s, transform .15s;
}
.tick svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3; fill: none; opacity: 0; stroke-linecap: round; stroke-linejoin: round; }
.item.done .tick { background: var(--c, var(--acorn)); }
.item.done .tick svg { opacity: 1; }
.tick:active { transform: scale(.88); }
.x { background: none; border: 0; color: var(--muted); padding: 6px; cursor: pointer; font-size: 18px; line-height: 1; opacity: .7; }
.swipe-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding-right: 18px; background: var(--card-2); color: var(--muted); font-size: 13px; font-weight: 700; z-index: -1; }

.add-row { display: flex; gap: 8px; }
.add-row select { width: auto; flex: none; padding-right: 8px; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }

.thinking { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 28px 0; text-align: center; }
.thinking p { color: var(--muted); max-width: 280px; }

/* ── Tree ─────────────────────────────────────────────── */
.tree-wrap { position: relative; }
.tree { width: 100%; height: auto; display: block; overflow: visible; }
.tree .leaf { transform-box: fill-box; transform-origin: 0 50%; animation: grow .5s cubic-bezier(.3,1.6,.5,1) both; }
@keyframes grow { from { transform: scale(0); } }
.tree .branch-hit { cursor: pointer; }
.tree text { font: 700 11.5px var(--sans); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 12px; text-align: center; }
.stat b { display: block; font-family: var(--serif); font-size: 26px; }
.stat span { font-size: 12px; color: var(--muted); }
.tree-flingo { display: flex; gap: 10px; align-items: flex-end; }

/* ── Areas ────────────────────────────────────────────── */
.area-card { display: block; text-decoration: none; position: relative; padding-left: 22px; }
.area-card::before { content: ''; position: absolute; left: 0; top: 16px; bottom: 16px; width: 5px; border-radius: 0 6px 6px 0; background: var(--c); }
.area-card h2 { color: var(--c); }
.area-card .bar, .bar { height: 7px; border-radius: 99px; background: var(--card-2); overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--c, var(--acorn)); border-radius: 99px; transition: width .3s; }
/* Tinted rather than solid: white on gold or light green fails contrast, in both themes. */
.area-hero { border-radius: var(--radius); padding: 18px; background: color-mix(in srgb, var(--c) 16%, var(--card)); box-shadow: var(--shadow); }
.area-hero h1 { color: var(--c); }
.area-hero a, .area-hero .small { color: var(--muted); }
.area-hero .dream { cursor: pointer; }
.area-hero .dream { font-family: var(--serif); font-size: 19px; margin-top: 8px; line-height: 1.3; }
.horizon h2 { margin: 0 4px 8px; font-size: 18px; display: flex; align-items: baseline; justify-content: space-between; }
.horizon h2 small { font: 500 13px var(--sans); color: var(--muted); }
.goal { padding: 14px; }
.goal + .goal { border-top: 1px solid var(--line); }
.goal .row { align-items: flex-start; }
.goal .title { flex: 1; font-size: 15.5px; }
.goal.is-done .title { text-decoration: line-through; color: var(--muted); }
.goal input[type=range] { width: 100%; accent-color: var(--c); margin: 10px 0 0; }
.drift { margin-top: 8px; font-size: 13.5px; color: var(--pink-ink); background: var(--pink-soft); padding: 8px 10px; border-radius: 10px; }
.menu-btn { background: none; border: 0; color: var(--muted); font-size: 20px; padding: 0 4px; cursor: pointer; line-height: 1; }

/* ── Onboarding ───────────────────────────────────────── */
.steps { display: flex; gap: 6px; }
.steps i { flex: 1; height: 5px; border-radius: 9px; background: var(--line); }
.steps i.on { background: var(--c, var(--acorn)); }
.edit-list > * + * { margin-top: 8px; }
.edit-item { display: flex; gap: 6px; align-items: center; }
.edit-item input { padding: 11px 12px; font-size: 15px; }

/* ── Bucket ───────────────────────────────────────────── */
.seg { display: flex; background: var(--card-2); border-radius: 999px; padding: 4px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 999px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.wall { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.polaroid { background: var(--card); padding: 8px 8px 12px; border-radius: 6px; box-shadow: var(--shadow); transform: rotate(var(--r, 0deg)); }
.polaroid img, .polaroid .noimg { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 3px; display: block; background: var(--card-2); }
.polaroid .noimg { display: grid; place-items: center; font-size: 34px; }
.polaroid b { display: block; font-family: var(--serif); font-size: 14.5px; margin-top: 8px; line-height: 1.2; }
.polaroid span { font-size: 11.5px; color: var(--muted); }
.polaroid p { font-size: 12.5px; margin-top: 4px; color: var(--muted); font-style: italic; }

/* ── Me ───────────────────────────────────────────────── */
.setting { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.setting + .setting { border-top: 1px solid var(--line); }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + span { background: var(--pink); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--acorn); outline-offset: 2px; }

/* ── Check-in ─────────────────────────────────────────── */
.energy { display: flex; gap: 8px; }
.energy button { flex: 1; height: 48px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; font-size: 17px; cursor: pointer; }
.energy button.on { background: var(--acorn-dark); color: var(--bg); border-color: var(--acorn-dark); }
.weekbars > * + * { margin-top: 10px; }

/* ── Sheet, toast ─────────────────────────────────────── */
.sheet-bg { position: fixed; inset: 0; background: rgba(30, 20, 10, .45); z-index: 40; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 560px; margin: 0 auto;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 20px 16px calc(env(safe-area-inset-bottom) + 20px);
  animation: up .25s cubic-bezier(.2,.9,.3,1); max-height: 90dvh; overflow-y: auto;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: -6px auto 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
.photo-pick { display: grid; place-items: center; aspect-ratio: 4/3; border-radius: 16px; border: 2px dashed var(--line); background: var(--card); color: var(--muted); cursor: pointer; overflow: hidden; position: relative; }
.photo-pick img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px); z-index: 50;
  max-width: 528px; margin: 0 auto; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px;
  font-size: 14.5px; box-shadow: var(--shadow); animation: up .2s;
}

.demo-flag { font-size: 12.5px; text-align: center; color: var(--muted); background: var(--card-2); border-radius: 12px; padding: 8px 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.edit-item textarea { min-height: 0; padding: 11px 12px; font-size: 15px; line-height: 1.35; resize: none; overflow: hidden; }

/* ── Added: add sheet, install ────────────────────────── */
.add-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px;
  border: 1.5px dashed var(--line); border-radius: var(--radius); background: transparent; color: var(--muted);
  font-weight: 700; font-size: 15px; cursor: pointer;
}
.add-btn span { font-size: 20px; line-height: 1; }
.add-btn:active { background: var(--card-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.area-chip {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px;
  font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer;
}
.area-chip[aria-checked="true"] { background: var(--c); border-color: var(--c); color: #fff; }
.install-nudge { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; }
.install-nudge img { border-radius: 11px; flex: none; }
.install-nudge b { font-size: 15px; }
.app-icon { border-radius: 22px; box-shadow: var(--shadow); }
.steps-list { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps-list li {
  counter-increment: s; position: relative; padding: 14px 14px 14px 56px; background: var(--card);
  border-radius: 16px; box-shadow: var(--shadow); line-height: 1.45;
}
.steps-list li + li { margin-top: 10px; }
.steps-list li::before {
  content: counter(s); position: absolute; left: 14px; top: 12px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--pink); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 14px;
}
.ic { width: 20px; height: 20px; vertical-align: -4px; fill: none; stroke: var(--career); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
a.chip { text-decoration: none; color: var(--ink); }
.seg button { font-size: 14px; }
