:root {
  --bg: #f4f8f7; --card: #ffffff; --soft: #eef5f3; --line: #dde8e5; --ink: #0f172a; --muted: #5b6b78;
  --brand: #0f766e; --brand-2: #115e59; --brand-soft: #ccfbf1; --accent: #14b8a6; --danger: #dc2626; --warn: #f59e0b;
  --r: 18px; --shadow: 0 8px 24px rgba(15, 118, 110, .07);
  color-scheme: light;
  font-family: 'Figtree', system-ui, sans-serif; color: var(--ink);
}
:root[data-theme="dark"] {
  --bg: #0b1416; --card: #121e21; --soft: #182a2d; --line: #24393d; --ink: #e6f1ef; --muted: #93a8a9;
  --brand: #2dd4bf; --brand-2: #5eead4; --brand-soft: #123f3b; --accent: #2dd4bf; --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
body.noscroll { overflow: hidden; }
h1, h2 { font-family: 'Fraunces', Georgia, serif; line-height: 1.15; margin: 0 0 .3rem; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
h2 { font-size: 1.35rem; }
h3 { margin: .2rem 0 .6rem; font-size: 1.05rem; }
a { color: var(--brand); font-weight: 600; }
button { font: inherit; cursor: pointer; color: inherit; }
label { display: block; font-weight: 700; margin: .7rem 0 .35rem; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .88rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.spacer { flex: 1; }
.err { color: var(--danger); font-weight: 700; min-height: 1.2em; margin: .4rem 0; }
.input { width: 100%; font: inherit; padding: .75rem .9rem; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
textarea.input { resize: vertical; }

/* top bar + nav (bottom tab bar on phones) */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem; padding: .7rem clamp(1rem, 3vw, 2rem); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); font-size: 1.15rem; font-weight: 600; }
.brand b { color: var(--brand); font-weight: 800; }
.logo { width: 2rem; height: 2rem; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 900; }
:root[data-theme="dark"] .logo { color: #062b28; }
.nav { margin-left: auto; display: flex; gap: .3rem; }
.nav[hidden] { display: none; }
.nav a { display: flex; align-items: center; gap: .35rem; padding: .5rem .85rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 700; }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
@media (max-width: 720px) {
  .nav { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; justify-content: space-around; background: var(--card); border-top: 1px solid var(--line); padding: .35rem .3rem calc(.35rem + env(safe-area-inset-bottom)); z-index: 40; }
  .nav a { flex-direction: column; gap: .1rem; font-size: .75rem; padding: .35rem .6rem; border-radius: 12px; }
  .nav a span { font-size: 1.3rem; }
}

.app { width: min(1000px, 100%); margin: 0 auto; padding: 1rem clamp(.8rem, 3vw, 1.5rem) 2rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.loading { text-align: center; color: var(--muted); padding: 2rem; }
.page-head { margin: .4rem 0 1rem; }
.page-head p { margin: 0; }
.pill { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 800; padding: .2rem .6rem; border-radius: 999px; background: color-mix(in srgb, var(--sc, var(--brand)) 16%, transparent); color: var(--sc, var(--brand)); }
.empty { text-align: center; padding: 2rem 1rem; }
.empty .big { font-size: 3rem; }
.disclaimer { color: var(--muted); font-size: .82rem; text-align: center; max-width: 640px; margin: 1.5rem auto; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: .6rem 1rem; font-weight: 800; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #062b28; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.big { padding: .85rem 1.4rem; font-size: 1.05rem; }
.btn.wide { width: 100%; }
.btn.small { padding: .3rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: wait; }
.seg { display: flex; background: var(--soft); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; padding: .55rem .6rem; border-radius: 999px; font-weight: 800; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--brand); box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }

/* auth / landing */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 2rem; align-items: center; margin-top: 1.5rem; }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; gap: 1rem; } }
.hero h1 { font-size: clamp(2rem, 6vw, 3.1rem); }
.hero h1 em { color: var(--brand); font-style: normal; }
.lead { font-size: 1.15rem; color: var(--muted); }
.ticks { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .45rem; }
.ticks li::before { content: '✓'; color: var(--brand); font-weight: 900; margin-right: .5rem; }
.auth form label { margin-top: .8rem; }
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.ts-box { margin: .7rem 0; min-height: 65px; }
.code-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: clamp(1.1rem, 5vw, 1.6rem); font-weight: 800; letter-spacing: .08em; text-align: center; padding: 1rem; border-radius: 14px; background: var(--brand-soft); color: var(--brand); margin: .8rem 0; user-select: all; word-break: break-all; }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 700; margin: .9rem 0; }
.check input { width: 1.2rem; height: 1.2rem; accent-color: var(--brand); }

/* home tiles */
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: .7rem; margin-bottom: 1rem; }
@media (max-width: 720px) { .tiles { grid-template-columns: repeat(4, 1fr); gap: .55rem; } }
@media (max-width: 380px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile { border: 1px solid var(--line); background: var(--card); border-radius: 18px; padding: .9rem .4rem .75rem; display: flex; flex-direction: column; align-items: center; gap: .3rem; box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.tile span { font-size: 2rem; width: 3.2rem; height: 3.2rem; display: grid; place-items: center; border-radius: 16px; background: color-mix(in srgb, var(--tc) 13%, transparent); }
.tile b { font-size: .9rem; }
.tile:hover, .tile:focus-visible { transform: translateY(-2px); border-color: var(--tc); }
.tile:active { transform: scale(.97); }

.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .5rem; }
.q { display: flex; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; border-left: 5px solid var(--tc); }
.q-go { flex: 1; display: flex; align-items: center; gap: .5rem; border: 0; background: var(--card); padding: .6rem .7rem; text-align: left; min-width: 0; }
.q-go b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-go em { font-style: normal; font-weight: 900; color: #fff; background: var(--sc); border-radius: 8px; padding: .05rem .45rem; }
.q-go small { color: var(--muted); }
.q-go:hover { background: var(--soft); }
.q-edit { border: 0; border-left: 1px solid var(--line); background: var(--card); padding: 0 .8rem; color: var(--muted); }

/* entries */
.entries { display: grid; gap: .45rem; }
.entry { display: flex; align-items: center; gap: .7rem; text-align: left; width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: .65rem .8rem; border-left: 5px solid var(--tc); }
.entry:hover { background: var(--soft); }
.entry.pending { opacity: .7; border-style: dashed; }
.e-icon { font-size: 1.5rem; }
.e-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.e-main small { color: var(--muted); }
.e-note { font-style: italic; overflow: hidden; text-overflow: ellipsis; }
.e-sev { min-width: 2rem; height: 2rem; border-radius: 10px; display: grid; place-items: center; background: var(--sc); color: #fff; font-weight: 900; }
.e-time { color: var(--muted); font-size: .85rem; font-weight: 700; text-align: right; white-space: nowrap; }
.day { margin-bottom: 1.2rem; }
.day-head { display: flex; align-items: baseline; gap: .6rem; margin: 0 .2rem .5rem; }
.day-head h3 { margin: 0; }
.chips.filter { margin-bottom: 1rem; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: .45rem .85rem; font-weight: 700; font-size: .92rem; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
:root[data-theme="dark"] .chip.on { color: #062b28; }
.chip-add { border: 2px dashed var(--line); background: transparent; border-radius: 999px; padding: .45rem .85rem; font: inherit; font-size: .92rem; color: var(--ink); min-width: 170px; }
.chip-add:focus { outline: none; border-color: var(--brand); }

/* sheet (bottom sheet on phones, dialog on desktop) */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-bg { position: absolute; inset: 0; background: rgba(4, 20, 18, .5); backdrop-filter: blur(2px); animation: fade .2s; }
.sheet-card { position: relative; background: var(--card); width: min(640px, 100%); max-height: 94vh; overflow: auto; border-radius: 24px 24px 0 0; padding: 1.1rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom)); animation: up .25s cubic-bezier(.2, .9, .3, 1); }
@media (min-width: 721px) { .sheet { align-items: center; } .sheet-card { border-radius: 24px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sheet-x { position: absolute; top: .8rem; right: .8rem; width: 2.2rem; height: 2.2rem; border-radius: 50%; border: 0; background: var(--soft); z-index: 2; }
.sheet-head { display: flex; align-items: center; gap: .7rem; margin: 0 2.5rem .4rem 0; }
.sheet-icon { font-size: 1.8rem; width: 3rem; height: 3rem; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--tc, var(--brand)) 14%, transparent); }
.sheet-head h2 { margin: 0; }
.sheet-actions { display: flex; align-items: center; gap: .6rem; margin-top: 1rem; position: sticky; bottom: calc(-1.2rem - env(safe-area-inset-bottom)); background: var(--card); padding: .7rem 0; border-top: 1px solid var(--line); }
.field { margin-top: .4rem; }
.field.small label { font-size: .9rem; }
.with-unit { display: flex; align-items: center; gap: .4rem; }
.with-unit span { color: var(--muted); font-weight: 700; font-size: .9rem; white-space: nowrap; }

/* severity slider */
.sev { display: flex; align-items: center; gap: 1rem; --sev: #f59e0b; }
.sev input[type=range] { flex: 1; -webkit-appearance: none; appearance: none; height: 14px; border-radius: 999px; background: linear-gradient(90deg, #22c55e, #84cc16 30%, #f59e0b 55%, #f97316 75%, #dc2626); outline: none; }
.sev input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 5px solid var(--sev); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); cursor: pointer; }
.sev input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 5px solid var(--sev); cursor: pointer; }
.sev-read { min-width: 6.2rem; text-align: center; border-radius: 14px; padding: .35rem .5rem; background: color-mix(in srgb, var(--sev) 15%, transparent); color: var(--sev); }
.sev-read b { display: block; font-size: 1.7rem; line-height: 1; }
.sev-read span { font-weight: 800; font-size: .85rem; }
.sev-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: .75rem; font-weight: 600; margin-top: .3rem; padding-right: 7.2rem; }

/* 1–5 scale */
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; }
.scale button { border: 2px solid var(--line); background: var(--card); border-radius: 14px; padding: .6rem 0; font-weight: 800; font-size: 1.05rem; }
.scale button .face { font-size: 1.8rem; }
.scale button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); transform: scale(1.04); }

/* stepper */
.stepper { display: flex; align-items: center; gap: .5rem; }
.stepper button { width: 3rem; height: 3rem; border-radius: 14px; border: 2px solid var(--line); background: var(--card); font-size: 1.5rem; font-weight: 800; }
.stepper input { width: 6rem; text-align: center; font: inherit; font-size: 1.5rem; font-weight: 800; padding: .4rem; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
.stepper .unit { color: var(--muted); font-weight: 700; }
.big-picks { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.big-picks button { border: 2px solid var(--line); background: var(--card); border-radius: 16px; padding: .7rem 0; font-size: 1.4rem; font-weight: 900; display: flex; flex-direction: column; align-items: center; }
.big-picks button small { font-size: .75rem; color: var(--muted); font-weight: 700; }
.big-picks button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

/* reports */
.opts { margin: .8rem 0 .4rem; }
.opts summary { font-weight: 800; cursor: pointer; color: var(--brand); }
.export-row { margin-top: .9rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin: .5rem 0 1rem; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--soft); border-radius: 14px; padding: .7rem .8rem; display: flex; flex-direction: column; }
.stat span { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.stat b { font-size: 1.45rem; }
.stat small { color: var(--muted); font-size: .8rem; }
.insights { margin: .3rem 0; padding-left: 1.2rem; }
.insights li { margin: .3rem 0; }
canvas { display: block; max-width: 100%; margin: .3rem 0 .8rem; }
.chart-scroll { overflow-x: auto; }
.chart-scroll canvas { max-width: none; }
.legend-row { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); font-weight: 700; }
.legend-row span::before { content: ''; display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; background: var(--c); margin-right: .3rem; vertical-align: -1px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.note-row { border-left: 3px solid var(--line); padding-left: .7rem; margin: .6rem 0; }
.note-row p { margin: .2rem 0; white-space: pre-wrap; }

/* settings */
.list-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
details { margin: .6rem 0; }
details summary { cursor: pointer; font-weight: 800; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; background: var(--ink); color: var(--bg); padding: .75rem 1.2rem; border-radius: 999px; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: 92vw; text-align: center; }
.toast.bad { background: var(--danger); color: #fff; }
.toast[hidden] { display: none; }
@media (min-width: 721px) { .toast { bottom: 1.5rem; } }
