/* Nervy — eucalyptus-on-bone design system (from Paper artboards) */

:root {
    --bone: #F7F4EE;
    --surface: #FFFFFF;
    --ink: #1E2B26;
    --muted: #5C6B64;
    --faint: #8A968F;
    --accent: #3E7C6B;
    --accent-deep: #2E5F52;
    --accent-tint: #E5EFEA;
    --green: #4E9C6F;
    --green-tint: #E4F0E7;
    --amber: #D9A13B;
    --amber-tint: #F7EDD6;
    --amber-text: #9C7220;
    --terra: #C26A52;
    --terra-tint: #F6E5DF;
    --border: #E8E4DA;
    --border-soft: #EEEBE3;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow: 0 1px 3px rgba(30, 43, 38, .06), 0 4px 14px rgba(30, 43, 38, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bone);
    color: var(--ink);
    font-family: 'Figtree', -apple-system, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.45;
    min-height: 100dvh;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

#view {
    max-width: 480px;
    margin: 0 auto;
    padding: max(14px, env(safe-area-inset-top)) 16px calc(84px + env(safe-area-inset-bottom));
}
.loading { text-align: center; color: var(--faint); padding: 48px 0; }

/* ---- login ---- */
.login { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.login-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 32px 28px; width: 100%; max-width: 360px; text-align: center;
}
.login-mark { font-size: 34px; margin-bottom: 8px; }
.login-card h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.login-card p { margin: 6px 0 18px; }
.login-card input {
    width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bone); margin-bottom: 12px;
}
.login-error { color: var(--terra); font-size: 13px; margin: 0 0 10px; }

/* ---- buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border-radius: 999px; padding: 12px 22px; font-weight: 600; transition: transform .05s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-deep); }
.btn-soft { background: var(--accent-tint); color: var(--accent-deep); }
.btn-block { width: 100%; padding: 15px 22px; font-size: 16px; }
.btn-ghost { color: var(--muted); padding: 10px 16px; }

/* ---- header ---- */
.screen-head { padding: 6px 2px 14px; }
.date-line { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.screen-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.phase-chip {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
    background: var(--accent-tint); color: var(--accent-deep);
    border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 700;
}

/* ---- cards ---- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.card-title { font-size: 16px; font-weight: 700; }
.card-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.habit-card { display: flex; gap: 12px; align-items: center; background: var(--accent-tint); border-color: transparent; box-shadow: none; }
.habit-ico { font-size: 22px; }
.habit-card .card-title { color: var(--accent-deep); font-size: 14.5px; }
.habit-card .card-sub { color: var(--accent); }

.session-card { display: flex; align-items: center; gap: 12px; }
.session-main { flex: 1; min-width: 0; }
.session-state { flex-shrink: 0; }
.session-done .card-title { text-decoration: line-through; color: var(--muted); }
.check-pill {
    display: inline-flex; align-items: center; gap: 6px; background: var(--green-tint); color: var(--green);
    border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700;
}
.up-next { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }

.dots { display: flex; gap: 6px; margin-top: 10px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--border); }
.dot.on { background: var(--accent); }
.mb-controls { display: flex; gap: 8px; flex-shrink: 0; }
.mb-btn {
    width: 40px; height: 40px; border-radius: 50%; background: var(--accent-tint); color: var(--accent-deep);
    font-size: 20px; font-weight: 700; display: grid; place-items: center;
}

/* traffic-light dots */
.tl { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.tl-green { background: var(--green); }
.tl-amber { background: var(--amber); }
.tl-red { background: var(--terra); }

/* ---- check-in ---- */
.slider-row { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--accent); }
.slider-val { font-size: 22px; font-weight: 800; min-width: 34px; text-align: center; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--border-soft); }
.switch { position: relative; width: 46px; height: 27px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch .knob {
    position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background .15s;
}
.switch .knob::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s;
}
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(19px); }

/* ---- player ---- */
.player { max-width: 480px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); min-height: 100dvh; display: flex; flex-direction: column; }
.player-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.player-close { font-size: 22px; color: var(--muted); width: 40px; height: 40px; border-radius: 50%; }
.player-count { font-weight: 700; color: var(--muted); font-size: 14px; }
.seg-bar { display: flex; gap: 4px; flex: 1; }
.seg { height: 4px; flex: 1; border-radius: 2px; background: var(--border); }
.seg.on { background: var(--accent); }
.player h1 { font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin-top: 8px; }
.player-dose { color: var(--muted); font-weight: 600; margin-top: 4px; }
.adjust-banner {
    margin-top: 10px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600;
}
.adjust-halve { background: var(--amber-tint); color: var(--amber-text); }
.adjust-rest { background: var(--terra-tint); color: var(--terra); }

.timer-wrap { display: grid; place-items: center; margin: 22px 0 10px; position: relative; }
.timer-ring { transform: rotate(-90deg); }
.timer-ring .track { stroke: var(--border-soft); }
.timer-ring .fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .3s linear; }
.timer-center { position: absolute; text-align: center; }
.timer-num { font-size: 48px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.timer-sub { color: var(--muted); font-size: 13px; font-weight: 600; }
.player-controls { display: flex; justify-content: center; gap: 14px; margin-bottom: 14px; }
.ctrl {
    width: 56px; height: 56px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border);
    display: grid; place-items: center; font-size: 20px; box-shadow: var(--shadow);
}

.why-drawer { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.why-head { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; font-weight: 700; font-size: 14.5px; text-align: left; }
.why-body { padding: 0 16px 14px; color: var(--muted); font-size: 14px; }
.caution-line { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; color: var(--amber-text); padding: 4px 4px 14px; }
.caution-line .tl { margin-top: 4px; flex-shrink: 0; }
.player-foot { margin-top: auto; }

/* ---- complete + rating ---- */
.complete-hero { text-align: center; padding: 34px 0 20px; }
.medallion {
    width: 84px; height: 84px; border-radius: 50%; background: var(--green-tint); color: var(--green);
    display: grid; place-items: center; font-size: 38px; margin: 0 auto 14px;
}
.complete-hero h1 { font-size: 26px; font-weight: 800; }
.rate-card {
    width: 100%; text-align: left; background: var(--surface); border: 2px solid var(--border);
    border-radius: var(--radius); padding: 15px 16px; margin-bottom: 10px; transition: border-color .1s, background .1s;
}
.rate-card .rc-title { font-weight: 700; display: flex; align-items: center; gap: 9px; font-size: 15.5px; }
.rate-card .rc-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.rate-card.sel-green { border-color: var(--green); background: var(--green-tint); }
.rate-card.sel-amber { border-color: var(--amber); background: var(--amber-tint); }
.rate-card.sel-red { border-color: var(--terra); background: var(--terra-tint); }
.reassure { text-align: center; color: var(--faint); font-size: 13px; margin: 14px 0; }
.culprit-select { width: 100%; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); margin-bottom: 12px; }

/* ---- progress ---- */
.stat-hero { text-align: center; padding: 18px 0 6px; }
.stat-hero .big { font-size: 52px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.stat-hero .big small { font-size: 20px; font-weight: 700; color: var(--muted); letter-spacing: 0; }
.stat-hero .leaf { font-size: 22px; }
.stat-sub { color: var(--muted); font-weight: 600; margin-top: 6px; }
.chart-card svg { display: block; width: 100%; height: auto; }
.flare-note { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--amber-text); margin-top: 10px; }
.flare-note .swatch { width: 12px; height: 12px; border-radius: 4px; background: var(--amber-tint); border: 1px solid var(--amber); margin-top: 2px; flex-shrink: 0; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat-card .v { font-size: 20px; font-weight: 800; }
.stat-card .k { font-size: 11px; color: var(--faint); font-weight: 600; margin-top: 2px; line-height: 1.3; }
.milestone { display: flex; gap: 11px; padding: 10px 0; border-top: 1px solid var(--border-soft); align-items: baseline; }
.milestone:first-of-type { border-top: 0; }
.milestone .m-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex-shrink: 0; position: relative; top: -1px; }
.milestone .m-date { font-size: 12px; color: var(--faint); font-weight: 700; white-space: nowrap; }
.milestone .m-del { margin-left: auto; color: var(--faint); font-size: 15px; padding: 0 4px; }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row input { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bone); min-width: 0; }

/* ---- library ---- */
.lib-group-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin: 18px 4px 8px; }
.lib-card { padding: 0; overflow: hidden; }
.lib-row { border-top: 1px solid var(--border-soft); }
.lib-row:first-child { border-top: 0; }
.lib-row-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 14px 16px; text-align: left; }
.lib-name { font-weight: 600; flex: 1; min-width: 0; }
.lib-name .inactive-tag { color: var(--faint); font-weight: 600; font-size: 12px; }
.lib-dose { color: var(--muted); font-size: 13px; white-space: nowrap; }
.lib-chev { color: var(--faint); flex-shrink: 0; width: 18px; text-align: center; }
.lib-body { padding: 0 16px 15px; }
.lib-body .why { color: var(--muted); font-size: 13.5px; margin-bottom: 10px; }
.chip-caution {
    display: inline-flex; gap: 7px; align-items: center; background: var(--amber-tint); color: var(--amber-text);
    font-size: 12px; font-weight: 600; border-radius: 999px; padding: 5px 11px; margin-bottom: 12px;
}
.lib-edit { display: flex; gap: 8px; align-items: center; }
.lib-edit input { flex: 1; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bone); min-width: 0; }
.lib-toggle { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 13.5px; color: var(--muted); font-weight: 600; }

/* ---- settings ---- */
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 13px 0; border-top: 1px solid var(--border-soft); }
.set-row:first-child { border-top: 0; }
.set-row input[type=date] { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--bone); }
pre.export {
    white-space: pre-wrap; background: var(--bone); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px; font-size: 12.5px; font-family: ui-monospace, monospace;
}

/* ---- tab bar ---- */
.tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
    display: flex; justify-content: space-around;
    background: rgba(255, 255, 255, .94); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--faint); padding: 4px 14px; border-radius: 12px; }
.tab .tab-ico { font-size: 19px; filter: grayscale(1) opacity(.55); }
.tab.active { color: var(--accent-deep); }
.tab.active .tab-ico { filter: none; }

.toast {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom));
    background: var(--ink); color: #fff; border-radius: 999px; padding: 10px 20px; font-size: 14px; font-weight: 600;
    z-index: 30; box-shadow: var(--shadow); animation: toast-in 2.4s forwards;
}
@keyframes toast-in { 0% { opacity: 0; translate: 0 8px; } 10%, 85% { opacity: 1; translate: 0 0; } 100% { opacity: 0; } }
