/* ============ Tokens ============ */
:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #fcfcfb;
  --surface-2: #f0efea;
  --surface-3: #e8e7e1;
  --ink: #1b1b19;
  --ink-2: #52514e;
  --muted: #7d7b75;
  --line: #e1e0d9;
  --line-strong: #c3c2b7;
  --accent: #2f7d5b;
  --accent-hover: #276b4d;
  --accent-ink: #ffffff;
  --accent-soft: #e1efe7;
  --good: #0a7d0a;
  --warn: #9a5b00;
  --warn-soft: #fdf2dc;
  --danger: #c23434;
  --shadow: 0 1px 2px rgba(20, 20, 18, .06), 0 4px 16px rgba(20, 20, 18, .06);
  --shadow-lg: 0 10px 40px rgba(20, 20, 18, .18);
  --radius: 16px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Skill colors — categorical slots in fixed order (validated palette, light steps) */
  --s-learning: #2a78d6;
  --s-fitness: #eb6834;
  --s-mind: #1baf7a;
  --s-home: #eda100;
  --s-creativity: #e87ba4;
  --s-social: #008300;
  --s-custom: #4a3aa7;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --surface-3: #2c2c2a;
    --ink: #f4f4f1;
    --ink-2: #c3c2b7;
    --muted: #8f8d86;
    --line: #2c2c2a;
    --line-strong: #45443f;
    --accent: #4fb383;
    --accent-hover: #63c494;
    --accent-ink: #0d1f16;
    --accent-soft: #1d3328;
    --good: #2fbf4f;
    --warn: #f0b443;
    --warn-soft: #3a2e14;
    --danger: #e66767;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .6);
    --s-learning: #3987e5;
    --s-fitness: #d95926;
    --s-mind: #199e70;
    --s-home: #c98500;
    --s-creativity: #d55181;
    --s-social: #008300;
    --s-custom: #9085e9;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2c2c2a;
  --ink: #f4f4f1; --ink-2: #c3c2b7; --muted: #8f8d86; --line: #2c2c2a; --line-strong: #45443f;
  --accent: #4fb383; --accent-hover: #63c494; --accent-ink: #0d1f16; --accent-soft: #1d3328;
  --good: #2fbf4f; --warn: #f0b443; --warn-soft: #3a2e14; --danger: #e66767;
  --s-learning: #3987e5; --s-fitness: #d95926; --s-mind: #199e70; --s-home: #c98500; --s-creativity: #d55181; --s-social: #008300; --s-custom: #9085e9;
}

/* ============ Base ============ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; margin-top: 8px; }
p { margin: 0; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.pad { padding: 20px; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }
.row.wrap { flex-wrap: wrap; }
.gap { gap: 10px; }
.gap-sm { gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.spacer { flex: 1; }
.ico { display: inline-flex; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.boot { display: grid; place-items: center; height: 100%; font-size: 56px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }

/* ============ Controls ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px;
  border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: .92rem; cursor: pointer;
  transition: background .15s, transform .1s, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost { background: var(--surface-2); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; border-color: var(--line); color: var(--danger); }
.btn-link { background: none; border: 0; color: var(--accent); padding: 4px 0; min-height: 0; font-weight: 600; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: .84rem; }
.btn-lg { min-height: 48px; padding: 10px 22px; font-size: 1rem; }
.btn-google { background: var(--surface); border: 1px solid var(--line-strong); align-self: flex-start; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.sm { width: 28px; height: 28px; }

.input {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font: inherit;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input-time { width: auto; min-width: 118px; }
.input-group { display: flex; gap: 6px; align-items: center; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .86rem; font-weight: 600; color: var(--ink-2); }
.field > span { display: flex; align-items: center; }
.hint { font-size: .82rem; color: var(--muted); }
.status { font-size: .86rem; display: inline-flex; gap: 6px; align-items: center; }
.status.good { color: var(--good); }
.status.warn { color: var(--warn); background: var(--warn-soft); padding: 8px 12px; border-radius: var(--radius-sm); display: block; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: .84rem; font-weight: 550; white-space: nowrap; cursor: pointer;
}
.chip[style*="--c"] { border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
.chip.filter.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip.filter[style*="--c"].on { background: color-mix(in srgb, var(--c) 20%, var(--surface)); color: var(--ink); border-color: var(--c); }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; align-self: flex-start; }
.seg button { border: 0; background: transparent; padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: .9rem; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg-sm button { padding: 5px 12px; font-size: .82rem; }

.day-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.day-chips button { min-width: 44px; height: 36px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.day-chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.day-chips.compact { gap: 4px; }
.day-chips.compact button { min-width: 26px; width: 26px; height: 26px; font-size: .7rem; padding: 0; }

.toggle { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.toggle span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 999px; transition: background .2s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(18px); }
.switch-row { display: flex; gap: 10px; align-items: center; font-size: .9rem; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }

.progress { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress.thin { height: 6px; margin: 4px 0 6px; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s; }
.meter { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--c, var(--accent)); border-radius: 999px; transition: width .9s cubic-bezier(.2, .8, .2, 1); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.tag { display: inline-flex; gap: 4px; align-items: center; font-size: .8rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.tag.good { color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--surface)); }

/* ============ Shell ============ */
#app { flex: 1; min-height: 0; }
.shell { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); height: 100%; }
.sidebar { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); border-right: 1px solid var(--line); }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top-nav { display: flex; align-items: center; gap: 4px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--bg); }
.nav-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font-weight: 600; cursor: pointer; }
.nav-btn:hover { background: var(--surface-2); }
.nav-btn.on { background: var(--accent-soft); color: var(--accent); }
.view { flex: 1; overflow-y: auto; padding: 24px; scroll-behavior: smooth; }
.view > * { max-width: 1100px; margin: 0 auto; }
.bottom-nav { display: none; }
.cloud-dot { color: var(--muted); display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; }
.cloud-dot.synced { color: var(--good); }
.cloud-dot.syncing, .cloud-dot.connecting { color: var(--accent); animation: pulse 1.2s infinite; }
.cloud-dot.error { color: var(--danger); }
.cloud-dot.locked { color: var(--warn); }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .sidebar { display: none; border-right: 0; }
  .shell[data-view="chat"] .sidebar { display: flex; grid-row: 1; }
  .shell[data-view="chat"] .main { display: none; }
  .main { grid-row: 1; }
  .top-nav { display: none; }
  .view { padding: 16px 16px 24px; }
  .bottom-nav {
    display: flex; grid-row: 2; justify-content: space-around;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav .nav-btn { flex-direction: column; gap: 2px; font-size: .72rem; padding: 6px 10px; border-radius: 12px; flex: 1; }
  .bottom-nav .nav-btn.on { background: var(--accent-soft); }
  h1 { font-size: 1.35rem; }
}

/* ============ Chat ============ */
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--line); padding-top: max(12px, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 1.15rem; letter-spacing: -.02em; }
.brand-logo { font-size: 1.4rem; }
.model-badge { display: inline-flex; align-items: center; gap: 6px; max-width: 170px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-size: .76rem; font-weight: 600; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; background: var(--muted); }
.dot.good { background: var(--good); }
.dot.idle { background: var(--s-home); }
.dot.warn { background: var(--danger); }
.chat-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 260px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.logo-big { font-size: 52px; line-height: 1; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.msg.user { justify-content: flex-end; }
.msg-avatar { width: 28px; height: 28px; display: grid; place-items: center; background: var(--accent-soft); border-radius: 50%; font-size: 15px; flex-shrink: 0; }
.msg-col { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; max-width: 86%; }
.msg.user .msg-col { align-items: flex-end; }
.msg-body { padding: 10px 14px; border-radius: 18px; background: var(--surface-2); border-bottom-left-radius: 6px; overflow-wrap: anywhere; }
.msg.user .msg-body { background: var(--accent); color: var(--accent-ink); border-radius: 18px; border-bottom-right-radius: 6px; }
.msg.error .msg-body { background: var(--warn-soft); }
.msg-body p + p, .msg-body p + ul, .msg-body ul + p { margin-top: 6px; }
.msg-body ul { margin: 4px 0; padding-left: 18px; }
.msg-body code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; font-size: .88em; }
.msg-status:empty { display: none; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-foot { border-top: 1px solid var(--line); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.quick-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.quick-row::-webkit-scrollbar { display: none; }
.quick-row .chip { font-size: .8rem; padding: 5px 11px; background: var(--surface-2); }
.composer { display: flex; align-items: flex-end; gap: 8px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 22px; padding: 5px 5px 5px 14px; }
.composer:focus-within { border-color: var(--accent); }
.chat-input { flex: 1; border: 0; background: transparent; resize: none; font: inherit; color: var(--ink); padding: 8px 0; max-height: 140px; outline: none; font-size: 16px; }
.send-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }

/* ============ Today ============ */
.today, .dash, .settings { display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.head-stats { display: flex; gap: 8px; }
.stat-pill { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: .88rem; }
.stat-pill.level { gap: 6px; }
.mini-meter { width: 48px; height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; display: inline-block; }
.mini-meter span { display: block; height: 100%; background: var(--accent); }

.hero {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 40%, var(--line));
}
.hero.calm { background: var(--surface); border-color: var(--line); }
.hero-emoji { font-size: 34px; width: 54px; height: 54px; display: grid; place-items: center; background: var(--surface); border-radius: 16px; flex-shrink: 0; box-shadow: var(--shadow); }
.hero-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.hero-text small { color: var(--ink-2); font-weight: 600; }
.hero-text strong { font-size: 1.15rem; }
@media (max-width: 520px) {
  .hero { flex-wrap: wrap; }
  .hero .btn { width: 100%; }
}

.cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.cols > * { min-width: 0; }
@media (max-width: 1100px) { .cols { grid-template-columns: minmax(0, 1fr); } }

.goal-list, .task-list, .event-list, .streak-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.goal-item, .streak-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.goal-item:first-child, .streak-list li:first-child { border-top: 0; }
.goal-emoji { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: color-mix(in srgb, var(--c) 16%, var(--surface)); flex-shrink: 0; }
.goal-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.goal-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-item.done .goal-main strong { color: var(--muted); }
.stars { color: #e0a100; letter-spacing: 1px; }
.stars span { color: var(--line-strong); font-size: 1.05rem; }
.stars span.on { color: #e9a800; }

.task { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.task:first-child { border-top: 0; }
.task label { flex: 1; display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.task input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }
.task-title { overflow-wrap: anywhere; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task.overdue .muted { color: var(--danger); }
.event-list li { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); cursor: pointer; }
.event-list li:first-child { border-top: 0; }
.event-date { min-width: 74px; font-weight: 650; color: var(--accent); font-size: .85rem; }

/* ============ Timeline ============ */
.tl-host { position: relative; width: 100%; min-height: 120px; }
.tl-wrap { position: relative; }
.tl-svg { display: block; overflow: visible; font-family: var(--font); }
.tl-grid { stroke: var(--line); stroke-width: 1; }
.tl-row { stroke: var(--line); stroke-width: 1; }
.tl-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tl-label { fill: var(--ink-2); font-size: 12px; font-weight: 600; }
.tl-label.strong { fill: var(--accent); }
.tl-work { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1; }
.tl-event { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.5; }
.tl-task { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.tl-task.done { fill: var(--good); stroke: var(--good); }
.tl-goal-bg { fill: color-mix(in srgb, var(--c) 22%, var(--surface)); stroke: var(--c); stroke-width: 1.5; }
.tl-goal-edge { fill: var(--c); }
.tl-goal.done .tl-goal-bg { fill: color-mix(in srgb, var(--c) 55%, var(--surface)); }
.tl-goal.covered .tl-goal-bg { fill: color-mix(in srgb, var(--c) 38%, var(--surface)); stroke-dasharray: 2 2; }
.tl-goal.missed .tl-goal-bg { fill: color-mix(in srgb, var(--c) 8%, var(--surface)); stroke-dasharray: 4 3; }
.tl-goal.missed .tl-in, .tl-goal.missed .tl-emoji { opacity: .55; }
.tl-goal.due .tl-goal-bg, .tl-goal.active .tl-goal-bg, .tl-goal.late .tl-goal-bg { stroke-width: 2.5; }
.tl-in { fill: var(--ink); font-size: 12px; font-weight: 600; pointer-events: none; }
.tl-emoji { font-size: 12px; pointer-events: none; }
.tl-now { stroke: var(--danger); stroke-width: 2; }
.tl-now-dot { fill: var(--danger); }
.tl-mark { cursor: pointer; outline: none; }
.tl-mark:hover .tl-goal-bg, .tl-mark:focus .tl-goal-bg { stroke-width: 3; }
.tl-tip {
  position: absolute; z-index: 5; pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity .12s, transform .12s;
  background: var(--ink); color: var(--surface); border-radius: 10px; padding: 8px 10px; font-size: .8rem; max-width: 240px; box-shadow: var(--shadow-lg);
}
.tl-tip.show { opacity: 1; transform: none; }
.tip-title { font-weight: 650; display: flex; align-items: center; gap: 6px; }
.tip-title i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tip-sub { opacity: .8; margin-top: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .78rem; color: var(--ink-2); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.lg.lg-work i { background: var(--surface-2); border: 1px solid var(--line-strong); }
.lg.lg-event i { background: var(--surface); border: 1.5px solid var(--ink-2); }
.lg.lg-task i { width: 9px; height: 9px; border: 2px solid var(--ink); transform: rotate(45deg); border-radius: 1px; }
.lg i.track { background: var(--surface-3); }

/* ============ Dashboard ============ */
.dash-top { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
@media (max-width: 760px) { .dash-top { grid-template-columns: 1fr; } }
.level-card { flex-direction: row; align-items: center; gap: 18px; }
.level-ring { flex-shrink: 0; }
.ring-num { fill: var(--ink); font-size: 30px; font-weight: 750; font-family: var(--font); }
.level-text { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.level-num { font-size: 1.5rem; font-weight: 750; }
.title-chip { align-self: flex-start; background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: .84rem; padding: 3px 10px; border-radius: 999px; }
.streak-card { justify-content: space-between; }
.streak-big { display: flex; align-items: center; gap: 12px; }
.streak-big .flame { font-size: 40px; }
.streak-big strong { font-size: 1.5rem; display: block; }
.week-stars { display: flex; justify-content: space-between; gap: 4px; }
.ws { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; color: var(--muted); }
.ws-star { font-size: 1.6rem; line-height: 1; color: var(--line-strong); }
.ws.on .ws-star { color: #e9a800; }
.bars { position: relative; display: flex; gap: 10px; height: 160px; align-items: stretch; padding-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; gap: 6px; align-items: center; outline: none; cursor: default; }
.bar-area { position: relative; flex: 1; width: 100%; max-width: 44px; display: flex; align-items: flex-end; justify-content: center; }
.bar-track { position: absolute; bottom: 0; left: 0; right: 0; background: var(--surface-3); border-radius: 4px 4px 0 0; min-height: 4px; }
.bar { position: relative; width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; transition: height .6s; }
.bar-col:hover .bar, .bar-col:focus .bar { filter: brightness(1.12); }
.bar-label { color: var(--muted); font-size: .75rem; }
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.skill-card { border: 1px solid color-mix(in srgb, var(--c) 35%, var(--line)); background: color-mix(in srgb, var(--c) 7%, var(--surface)); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.skill-emoji { font-size: 26px; }
.lvl-chip { font-weight: 750; font-size: .8rem; padding: 3px 9px; border-radius: 999px; background: var(--surface); border: 1px solid color-mix(in srgb, var(--c) 50%, var(--line)); }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding: 12px 8px; border-radius: 14px; border: 1px dashed var(--line-strong); color: var(--muted); }
.badge.got { border: 1px solid color-mix(in srgb, #e9a800 50%, var(--line)); background: color-mix(in srgb, #e9a800 9%, var(--surface)); color: var(--ink); }
.badge-emoji { font-size: 28px; }
.badge:not(.got) .badge-emoji { filter: grayscale(1); opacity: .6; }
.badge small { color: var(--muted); font-size: .74rem; }

/* ============ Settings ============ */
.settings-card h2 { margin-bottom: -4px; }
.ai-panel { display: flex; flex-direction: column; gap: 14px; }
.notif-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.goal-edit-list { display: flex; flex-direction: column; }
.goal-edit, .time-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.goal-edit:first-child, .time-row:first-child { border-top: 0; }
.goal-edit.off { opacity: .55; }
.time-main { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.account { display: flex; gap: 12px; align-items: center; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 22px; }
.g-logo { display: inline-flex; }

/* ============ Goal picker ============ */
.picker { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.picker-head { display: flex; gap: 10px; align-items: center; }
.picker-count { font-size: .8rem; color: var(--muted); white-space: nowrap; font-weight: 600; }
.picker-list { display: flex; flex-direction: column; gap: 6px; max-height: min(46vh, 420px); overflow-y: auto; padding: 2px 4px 2px 2px; overscroll-behavior: contain; scroll-padding-top: 36px; }
.picker-group { position: sticky; top: 0; z-index: 1; background: var(--surface); display: flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); padding: 8px 2px 4px; }
.picker-group .dot { width: 10px; height: 10px; border-radius: 3px; }
.pick {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  padding: 10px 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
  cursor: pointer; transition: border-color .15s, background .15s, transform .1s;
}
.pick:hover { border-color: color-mix(in srgb, var(--c) 50%, var(--line)); }
.pick:active { transform: scale(.99); }
.pick.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--surface)); }
.pick.added { opacity: .55; cursor: default; }
.pick-emoji { font-size: 22px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 15%, var(--surface)); flex-shrink: 0; }
.pick-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pick-text small { color: var(--muted); }
.pick-check { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.pick.on .pick-check, .pick.added .pick-check { background: var(--c); border-color: var(--c); }
.picker-custom { display: flex; gap: 8px; }

/* ============ Onboarding ============ */
.ob { min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-items: center; padding: 24px 16px; overflow-y: auto; height: 100%; background: radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 50%), var(--bg); }
.ob-card { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-height: calc(100dvh - 48px); }
.ob-top { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px 0; }
.ob-dots { display: flex; gap: 6px; }
.ob-dots span { width: 8px; height: 8px; border-radius: 999px; background: var(--line-strong); transition: width .25s, background .25s; }
.ob-dots span.on { width: 24px; background: var(--accent); }
.ob-dots span.done { background: var(--accent); opacity: .5; }
.ob-step { font-size: .78rem; color: var(--muted); font-weight: 600; }
.ob-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.ob-foot { display: flex; justify-content: space-between; padding: 14px 24px 20px; border-top: 1px solid var(--line); gap: 10px; }
.ob-welcome { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; }
.ob-welcome .logo-big { font-size: 64px; animation: grow .8s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes grow { from { transform: scale(.3); opacity: 0; } }
.ob-welcome .field { width: 100%; text-align: left; }
.lead { font-size: 1.02rem; color: var(--ink-2); max-width: 420px; }
.ob-perks { list-style: none; padding: 0; margin: 0; text-align: left; display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); }
.ob-more summary { cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: .9rem; padding: 4px 0; }
.ob-more[open] summary { margin-bottom: 10px; }
.time-list { display: flex; flex-direction: column; }
@media (max-width: 520px) {
  .ob { padding: 0; justify-items: stretch; align-items: stretch; }
  .ob-card { border-radius: 0; max-height: none; min-height: 100%; border: 0; }
  .ob-top { padding-top: max(18px, env(safe-area-inset-top)); }
  .ob-foot { padding-bottom: max(20px, env(safe-area-inset-bottom)); position: sticky; bottom: 0; background: var(--surface); }
  .ob-body { padding: 16px; }
  .time-row { flex-wrap: wrap; }
  .time-row .time-main { flex-basis: calc(100% - 56px); }
  .time-row .input-time { margin-left: 52px; }
}

/* ============ Toasts & modals ============ */
#toasts { position: fixed; z-index: 60; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--ink); color: var(--surface); padding: 10px 10px 10px 14px; border-radius: 14px; box-shadow: var(--shadow-lg); animation: drop .25s cubic-bezier(.2, 1.2, .4, 1); font-size: .9rem; }
.toast.leaving { opacity: 0; transform: translateY(-6px); transition: .2s; }
.toast-icon { font-size: 1.2rem; }
.toast-msg { flex: 1; min-width: 160px; }
.toast .btn-ghost { background: transparent; color: var(--surface); border-color: color-mix(in srgb, var(--surface) 35%, transparent); }
.toast .btn-primary { background: var(--accent); }
.toast-x { color: inherit; opacity: .7; width: 30px; height: 30px; font-size: 1.2rem; }
.toast-x:hover { background: transparent; color: inherit; opacity: 1; }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(10, 10, 8, .45); display: grid; place-items: center; padding: 16px; animation: fade .15s; backdrop-filter: blur(3px); }
.modal { width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border-radius: 22px; padding: 22px; box-shadow: var(--shadow-lg); animation: rise .22s cubic-bezier(.2, 1.1, .4, 1); position: relative; }
.modal-lg { width: min(600px, 100%); }
.modal .confirm p { margin-bottom: 18px; }
.big-emoji { font-size: 40px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(16px) scale(.98); opacity: 0; } }
@media (max-width: 520px) {
  .modal-backdrop { place-items: end stretch; padding: 0; }
  .modal { border-radius: 22px 22px 0 0; width: 100%; padding-bottom: max(22px, env(safe-area-inset-bottom)); }
}

/* ============ Timer ============ */
.timer-overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--c) 18%, var(--bg)); animation: fade .2s; }
.timer-card { width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.timer-top { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.timer-ring { position: relative; width: 240px; height: 240px; }
.timer-ring svg circle[data-role="arc"] { transition: stroke-dashoffset .3s linear; }
.timer-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.timer-emoji { font-size: 38px; }
.timer-time { font-size: 3rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.timer-label { color: var(--muted); font-size: .85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.timer-title { font-size: 1.5rem; }
.timer-pill {
  position: fixed; z-index: 35; right: 16px; bottom: 20px;
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px 8px 10px;
  border-radius: 999px; border: 2px solid var(--c); background: var(--surface); box-shadow: var(--shadow-lg);
  cursor: pointer; font-weight: 700; font-variant-numeric: tabular-nums; animation: rise .25s;
}
.pill-emoji { font-size: 20px; }
.pill-paused { font-size: .72rem; color: var(--muted); text-transform: uppercase; }
@media (max-width: 860px) { .timer-pill { bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* ============ Reward ============ */
.reward-modal { text-align: center; overflow: hidden; }
.reward { display: flex; flex-direction: column; align-items: center; gap: 10px; position: relative; }
.reward-emoji { font-size: 60px; animation: grow .7s cubic-bezier(.2, 1.6, .4, 1); }
.xp-gain { font-size: 2.2rem; font-weight: 800; color: var(--accent); animation: grow .6s .15s both cubic-bezier(.2, 1.6, .4, 1); }
.reward-stars { display: flex; align-items: center; gap: 2px; color: #e9a800; font-size: 1.6rem; }
.reward-stars span { animation: grow .4s both cubic-bezier(.2, 1.6, .4, 1); }
.reward-stars small { color: var(--ink-2); font-size: .85rem; margin-left: 8px; font-weight: 600; }
.reward-skill { width: 100%; display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.level-up { background: color-mix(in srgb, #e9a800 16%, var(--surface)); border: 1px solid color-mix(in srgb, #e9a800 50%, var(--line)); padding: 10px 14px; border-radius: 14px; font-weight: 700; width: 100%; animation: grow .5s .3s both; }
.level-up small { display: block; font-weight: 500; color: var(--ink-2); }
.new-badges { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.badge.pop { animation: grow .5s .5s both cubic-bezier(.2, 1.6, .4, 1); }
.confetti { position: absolute; inset: -22px -22px auto; height: 0; pointer-events: none; }
.confetti i { position: absolute; top: -10px; width: 8px; height: 12px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(520px) rotate(720deg); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (forced-colors: active) {
  .tl-goal-bg { stroke: CanvasText; }
}

/* ============ Calories ============ */
.stat-pill.over { color: var(--danger); }
.cal-summary { display: flex; align-items: center; gap: 16px; }
.cal-ring { flex-shrink: 0; }
.cal-ring-text { fill: var(--ink); font-size: 14px; font-weight: 700; font-family: var(--font); }
.cal-nums { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-big { font-size: 1.6rem; font-weight: 750; }
.cal-left { color: var(--ink-2); font-weight: 600; }
.cal-left.over, .over { color: var(--danger); font-weight: 600; }
.budget-btn { font-size: .82rem; gap: 4px; }
.cal-meals { display: flex; flex-direction: column; gap: 10px; }
.cal-meal-head { font-weight: 650; font-size: .9rem; }
.cal-items { list-style: none; margin: 4px 0 0; padding: 0; }
.cal-items li { display: flex; align-items: center; gap: 8px; padding: 3px 0 3px 26px; font-size: .88rem; }
.cal-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.meal-modal { gap: 12px; }
.meal-seg { flex-wrap: wrap; }
.meal-rows { display: flex; flex-direction: column; gap: 8px; }
.empty-meal { padding: 6px 2px; }
.meal-row { border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.meal-row.is-custom { border-style: dashed; }
.meal-row-main { display: flex; align-items: center; gap: 6px; }
.name-input { flex: 1; min-width: 0; font-weight: 600; }
.kcal-wrap { display: flex; align-items: center; gap: 4px; }
.kcal-input { width: 84px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.kcal-input:placeholder-shown { border-color: var(--s-home); }
.meal-row-detail { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qty-input { width: 70px; min-height: 36px; padding: 6px 8px; }
.portion-select { width: auto; flex: 1; min-width: 150px; min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: .86rem; }
.src-tag { font-size: .7rem; font-weight: 700; letter-spacing: .04em; padding: 3px 7px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.src-tag.custom { background: var(--warn-soft); color: var(--warn); }
.food-search { position: relative; display: flex; flex-direction: column; gap: 6px; }
.food-results { display: flex; flex-direction: column; max-height: 240px; overflow-y: auto; border-radius: 12px; overscroll-behavior: contain; }
.food-results:not(:empty) { border: 1px solid var(--line); }
.food-hit { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; padding: 9px 12px; border: 0; border-top: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.food-hit:first-child { border-top: 0; }
.food-hit:hover, .food-hit:focus-visible { background: var(--surface-2); }
.food-hit-name { flex: 1; min-width: 0; font-size: .9rem; display: inline-flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.food-hit-name small { color: var(--muted); }
.food-hit-kcal { display: flex; flex-direction: column; align-items: flex-end; font-weight: 700; font-size: .88rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.food-hit-kcal small { font-weight: 500; color: var(--muted); font-size: .72rem; }
.food-hit.custom { color: var(--accent); font-weight: 600; }
.meal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 6px; border-top: 1px solid var(--line); }
.meal-sum { display: flex; flex-direction: column; }
.meal-total { font-size: 1.3rem; }
@media (max-width: 520px) {
  .meal-row-main { flex-wrap: wrap; }
  .name-input { flex-basis: 100%; }
  .kcal-wrap { margin-right: auto; }
  .meal-foot .row { width: 100%; }
  .meal-foot .row .btn { flex: 1; }
}

/* ============ Weekly targets, clashes, icons ============ */
.emoji-edit { border: 0; cursor: pointer; font: inherit; position: relative; }
.emoji-edit:hover, .emoji-edit:focus-visible { box-shadow: 0 0 0 2px var(--c, var(--accent)); }
.goal-emoji.emoji-edit { font-size: 20px; }
.task-emoji { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); font-size: 16px; flex-shrink: 0; padding: 0; }
.task-emoji.emoji-edit:hover { box-shadow: 0 0 0 2px var(--accent); }
.week-pill { display: inline-block; padding: 0 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-weight: 600; font-size: .76rem; }
.week-pill.met { background: color-mix(in srgb, var(--good) 14%, var(--surface)); color: var(--good); }
.week-meter { height: 5px; margin-top: 5px; max-width: 220px; }
.week-line { width: 100%; display: flex; flex-direction: column; gap: 6px; font-weight: 650; font-size: .9rem; }
.week-line.met { color: var(--good); }
.target-select { width: auto; min-height: 28px; padding: 2px 30px 2px 10px; font-size: .78rem; border-radius: 999px; }
.goal-item.covered .goal-main strong { color: var(--muted); }
.clash-banner { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 14px; font-size: .9rem; }
.clash-banner strong { color: inherit; }
.clash-note { color: var(--warn); font-weight: 600; display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: baseline; text-decoration: none; }
.clash-note .btn-link { font-size: inherit; padding: 0; color: var(--accent); text-decoration: underline; }
.time-row.needs-review, .goal-edit.needs-review { background: var(--warn-soft); border-radius: 12px; padding-left: 8px; padding-right: 8px; border-top-color: transparent; }
.emoji-groups { display: flex; flex-direction: column; gap: 10px; max-height: 50vh; overflow-y: auto; }
.emoji-group small { display: block; margin-bottom: 4px; font-weight: 600; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 4px; }
.emoji-btn { height: 42px; border: 1px solid transparent; border-radius: 10px; background: var(--surface-2); font-size: 22px; cursor: pointer; }
.emoji-btn:hover { border-color: var(--line-strong); }
.emoji-btn.on { border-color: var(--accent); background: var(--accent-soft); }
.emoji-custom { flex: 1; }

/* ============ Mood & weight ============ */
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.checkin { gap: 16px; }
.checkin-q { display: flex; flex-direction: column; gap: 6px; }
.checkin-label { display: flex; gap: 8px; align-items: center; font-weight: 650; }
.star-input { display: flex; gap: 6px; }
.star-input button { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--line-strong); font-size: 26px; line-height: 1; cursor: pointer; transition: transform .1s, color .15s, background .15s; }
.star-input button:hover { transform: scale(1.06); }
.star-input button.on { color: #e9a800; background: color-mix(in srgb, #e9a800 14%, var(--surface)); border-color: color-mix(in srgb, #e9a800 45%, var(--line)); }
.star-scale { display: flex; justify-content: space-between; max-width: 262px; color: var(--muted); }
.journal-input { resize: vertical; min-height: 90px; font: inherit; line-height: 1.45; }
.stars-read span { color: var(--line-strong); font-size: 1rem; letter-spacing: 1px; }
.stars-read span.on { color: #e9a800; }
.mood-row { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; }
.journal-preview { white-space: pre-line; font-size: .88rem; color: var(--ink-2); font-style: italic; background: var(--surface-2); padding: 8px 12px; border-radius: 10px; overflow-wrap: anywhere; }
.mood-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.mood-day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; font-weight: 700; font-size: .82rem;
  background: color-mix(in srgb, var(--accent) var(--lvl, 0%), var(--surface)); color: var(--ink); }
.mood-day small { font-weight: 500; color: var(--ink-2); font-size: .7rem; }
.mood-day.empty { color: var(--muted); border-style: dashed; background: transparent; }
.weight-row { align-items: stretch; }
.weight-input { font-size: 1.5rem; font-weight: 700; max-width: 160px; }
.weight-summary { display: flex; flex-direction: column; gap: 8px; }
.weight-delta { font-weight: 600; color: var(--ink-2); }
.wchart { position: relative; width: 100%; }
.wchart-svg { display: block; width: 100%; height: 180px; overflow: visible; }
.wchart.compact .wchart-svg { height: 64px; }
.wchart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.wchart-goal { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.wchart-cross { stroke: var(--line-strong); stroke-width: 1; }
.wchart-ylab { position: absolute; left: 0; width: 11%; transform: translateY(-50%); text-align: right; padding-right: 6px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.wchart-goal-lab { position: absolute; right: 2px; transform: translateY(-120%); font-size: 11px; color: var(--muted); }
.wchart-xlab { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.wchart-dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }
.wchart-tip { pointer-events: none; }
.dash-two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 960px) { .dash-two { grid-template-columns: 1fr; } }
.mood-grid { display: grid; gap: 3px; align-items: center; }
.mg-day { text-align: center; color: var(--muted); font-size: .7rem; }
.mg-label { font-size: .8rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.mg-cell { height: 26px; border-radius: 5px; background: var(--surface-2); display: grid; place-items: center; font-size: .72rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.mg-cell.s1 { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.mg-cell.s2 { background: color-mix(in srgb, var(--accent) 32%, var(--surface)); }
.mg-cell.s3 { background: color-mix(in srgb, var(--accent) 52%, var(--surface)); }
.mg-cell.s4 { background: color-mix(in srgb, var(--accent) 74%, var(--surface)); color: var(--accent-ink); }
.mg-cell.s5 { background: var(--accent); color: var(--accent-ink); }
.mg-key { width: 24px; height: 18px; display: inline-grid; }
.journal-list { display: flex; flex-direction: column; gap: 8px; }
.journal-item { border-left: 3px solid var(--accent-soft); padding-left: 10px; }
.journal-item p { font-size: .9rem; overflow-wrap: anywhere; white-space: pre-line; }
@media (max-width: 520px) {
  .star-input button { width: 44px; height: 44px; }
}

/* ============ Install ============ */
.install-banner {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  padding: 10px 10px 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--accent-soft); border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  animation: drop .3s cubic-bezier(.2, 1.2, .4, 1);
}
.install-icon { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; box-shadow: var(--shadow); }
.install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.install-text strong { font-size: .95rem; }
.install-text small { color: var(--ink-2); font-size: .78rem; }
.install-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; }
.install-steps li { line-height: 1.5; }
.ios-share { display: inline-grid; place-items: center; width: 28px; height: 28px; margin: 0 4px; vertical-align: middle; border-radius: 7px; background: var(--surface-2); color: #0a84ff; }

/* ============ Notes ============ */
.notes-page { display: flex; flex-direction: column; gap: 14px; }
.view > .notes-page { max-width: 1200px; }
.notes-tools { display: flex; flex-direction: column; gap: 10px; }
.notes-split { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.notes-col { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.notes-list { display: flex; flex-direction: column; max-height: calc(100dvh - 260px); overflow-y: auto; }
.note-item { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 12px 14px; border: 0; border-top: 1px solid var(--line); background: transparent; cursor: pointer; width: 100%; }
.note-item:first-child { border-top: 0; }
.note-item:hover { background: var(--surface-2); }
.note-item.on { background: color-mix(in srgb, var(--c) 10%, var(--surface)); box-shadow: inset 3px 0 0 var(--c); }
.note-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.note-item-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-snippet { font-size: .84rem; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-imgs { color: var(--muted); }
.notes-empty { padding: 28px 16px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.notes-detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; box-shadow: var(--shadow); }
.note-head { display: flex; align-items: center; gap: 12px; }
.note-head-text { flex: 1; min-width: 0; }
.note-actions .icon-btn { font-size: 18px; }
.notes-back { display: none; font-size: 20px; }
@media (max-width: 860px) {
  .notes-split { grid-template-columns: minmax(0, 1fr); }
  .notes-page.has-selection .notes-col, .notes-page.has-selection .notes-tools, .notes-page.has-selection .page-head { display: none; }
  .notes-page:not(.has-selection) .notes-detail { display: none; }
  .notes-back { display: inline-grid; }
  .notes-list { max-height: none; }
  .note-head { flex-wrap: wrap; }
  .note-head-text { flex-basis: calc(100% - 110px); }
  .note-head-text h2 { font-size: 1.05rem; }
  .note-actions { margin-left: auto; }
}

.note-editor { display: flex; flex-direction: column; gap: 8px; text-align: left; width: 100%; }
.note-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-tools { display: flex; gap: 2px; flex-wrap: wrap; }
.note-tools.disabled { opacity: .4; pointer-events: none; }
.tool { min-width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; color: var(--ink-2); font-size: .95rem; display: inline-grid; place-items: center; }
.tool:hover { background: var(--surface-2); color: var(--ink); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }
.note-body { position: relative; border-radius: var(--radius-sm); }
.note-body.drag { outline: 2px dashed var(--accent); outline-offset: 2px; }
.note-area { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; line-height: 1.55; resize: vertical; min-height: 120px; }
.note-editor:not(.compact) .note-area { min-height: 320px; }
.note-preview { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; min-height: 120px; background: var(--surface); overflow-wrap: anywhere; }
.note-editor:not(.compact) .note-preview { min-height: 320px; }
.note-help { line-height: 1.4; }
.note-status { min-width: 52px; text-align: right; }

.md { line-height: 1.55; }
.md > * + * { margin-top: .55em; }
.md h1, .md h2, .md h3, .md h4 { margin-top: .9em; }
.md h1 { font-size: 1.35rem; } .md h2 { font-size: 1.15rem; } .md h3 { font-size: 1rem; }
.md ul, .md ol { padding-left: 22px; margin: 0; }
.md li.md-task { list-style: none; margin-left: -20px; }
.md li.md-task input { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -2px; }
.md blockquote { margin: 0; padding: 4px 12px; border-left: 3px solid var(--line-strong); color: var(--ink-2); }
.md code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; font-size: .88em; }
.md pre { background: var(--surface-2); padding: 10px 12px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md img { max-width: 100%; height: auto; border-radius: 10px; display: block; margin: 6px 0; }
.md hr { border: 0; border-top: 1px solid var(--line); }
.md a { color: var(--accent); }
.md-badimg { color: var(--muted); font-style: italic; }

.timer-overlay { overflow-y: auto; }
.timer-notes { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.timer-notes summary { cursor: pointer; font-weight: 650; padding: 2px 0; }
.timer-notes[open] summary { margin-bottom: 8px; }
.reward-notes { width: 100%; display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 12px; border-radius: 14px; background: var(--surface-2); }
@media (max-height: 760px) { .timer-overlay { place-items: start center; } .timer-ring { width: 200px; height: 200px; } .timer-ring svg { width: 200px; height: 200px; } }
@media (max-width: 860px) { .bottom-nav .nav-btn { padding: 6px 4px; font-size: .68rem; } }

/* ============ Long-term reminders ============ */
.upkeep { display: flex; flex-direction: column; gap: 16px; }
.up-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.up-stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); text-align: left; font: inherit; color: inherit; }
button.up-stat { cursor: pointer; }
.up-stat strong { font-size: 1.5rem; line-height: 1.1; }
.up-stat span { font-size: .82rem; color: var(--ink-2); font-weight: 600; }
.up-stat.overdue strong { color: var(--danger); }
.up-stat.soon strong { color: var(--warn); }
.up-stat.on { box-shadow: 0 0 0 2px var(--accent); }
.up-group h2 { font-size: 1rem; }
.up-list { display: flex; flex-direction: column; }
.up-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.up-row:first-child { border-top: 0; }
.up-emoji { width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--surface-2); font-size: 21px; display: grid; place-items: center; flex-shrink: 0; cursor: pointer; }
.up-row.overdue .up-emoji { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.up-row.soon .up-emoji { background: var(--warn-soft); }
.up-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.up-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-main small { overflow: hidden; text-overflow: ellipsis; }
.up-due { font-size: .82rem; font-weight: 650; color: var(--ink-2); }
.up-due.overdue { color: var(--danger); }
.up-due.soon { color: var(--warn); }
.up-meter { display: block; height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; max-width: 260px; margin-top: 3px; }
.up-meter span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.up-row.soon .up-meter span { background: var(--warn); }
.up-row.overdue .up-meter span { background: var(--danger); }
.up-empty { align-items: center; text-align: center; padding: 32px 20px; }
.up-custom { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.up-custom .input:first-child { flex: 1; min-width: 180px; }
.up-every { width: 74px; }
.up-unit { width: auto; }
.up-dates { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.up-date-row { display: flex; align-items: center; gap: 10px; }
.up-date-row .pick-emoji { --c: var(--accent); }
.up-date-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.up-date-row .input { width: auto; }
.up-name { font-weight: 700; font-size: 1.05rem; }
.up-status-line { font-weight: 600; color: var(--ink-2); font-size: .9rem; }
.up-history { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.up-history ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; font-size: .88rem; }
.up-history .btn-link { margin-left: 8px; }
@media (max-width: 520px) {
  .up-summary { gap: 6px; }
  .up-stat { padding: 10px; }
  .up-date-row { flex-wrap: wrap; }
  .up-date-row .input { margin-left: 52px; }
}

/* ============ Encryption ============ */
.enc-hero { font-size: 44px; text-align: center; }
.enc-ask h2, .enc-unlock h2 { text-align: center; }
.enc-ask > p.muted, .enc-unlock > p.muted { text-align: center; }
.enc-points { margin: 0; padding-left: 4px; list-style: none; display: flex; flex-direction: column; gap: 8px; color: var(--ink-2); }
.enc-code { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1rem; line-height: 1.6; letter-spacing: .04em; word-break: break-all; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 12px; padding: 14px; user-select: all; }
.enc-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; flex: 1; }
.enc-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .82rem; }
.enc-or::before, .enc-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.enc-panel { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.enc-state { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: 12px; width: 100%; }
.enc-state small { color: var(--ink-2); }
.enc-state.on { background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.enc-state.on strong { color: var(--good); }
.enc-state.locked { background: var(--warn-soft); }
.enc-state.off { background: var(--surface-2); }
