/* Citations, in the Calm look (same tokens as Calm, Calm Money and Habits). */
:root {
    --ground: #f3f4f1;
    --card: #ffffff;
    --text: #18201c;
    --text-2: #4e5752;
    --text-3: #646d68;
    --line: #daddd8;
    --line-soft: #e6e8e4;
    --ring: #9aa29d;
    --border: #c9cec9;
    --pill: #e3eae6;
    --accent: #23614f;
    --accent-hover: #174236;
    --overdue: #b4561b;
    --overdue-text: #9a4a15;

    --sans: 'IBM Plex Sans', system-ui, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html {
    background: var(--ground);
    color: var(--text);
    font-family: var(--sans);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}
body { margin: 0; background: var(--ground); }
button { font-family: inherit; color: inherit; }
/* No double-tap zoom: quick taps on + were read as "zoom in" on the iPhone. Pinch zoom still works.
   Set on the controls too, because the strip of days is its own scroll area. */
html, button, input, label { touch-action: manipulation; }
p, ul, h1 { margin: 0; }
ul { padding: 0; list-style: none; }
.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }
.bad { color: var(--overdue-text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.label {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

/* ---- Frame ---- */
.top {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--ground);
    padding-top: env(safe-area-inset-top);
    border-bottom: 1px solid var(--line);
}
.dateline, .tabs {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 24px;
}
.dateline { padding-top: 14px; font-size: 15px; }
.weekday { font-weight: 500; }
.dateline .mono { color: var(--text-2); font-size: 13px; margin-left: 4px; }
.tabs { display: flex; gap: 22px; }
.tabs button {
    min-height: 44px;
    padding: 0;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    font-size: 16px;
    color: var(--text-2);
    cursor: pointer;
}
.tabs button.on { color: var(--text); font-weight: 500; border-bottom-color: var(--accent); }

.page {
    max-width: 640px;
    margin: 0 auto;
    padding: 28px 24px calc(48px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.problem {
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    font-size: 15px;
    color: var(--overdue-text);
}
.page-problem { max-width: 592px; margin: 16px auto 0; cursor: pointer; }

/* ---- Hero ---- */
.hero-line { display: flex; align-items: baseline; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.hero { font-size: 72px; line-height: 1; font-weight: 500; letter-spacing: -0.02em; }
.hero-word { font-size: 19px; }
.say { font-size: 16px; line-height: 1.55; color: var(--text-2); margin-top: 14px; }
.say .em { color: var(--accent); font-weight: 500; }
.say .strong { color: var(--text); font-weight: 500; }
.say .bad { color: var(--overdue-text); }
.month-say { margin-top: 0; margin-bottom: 14px; }

/* ---- Today: day switch and habit rows ---- */
.day-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
}
.day-name { font-weight: 500; font-size: 16px; }
.day-back {
    min-height: 44px;
    padding: 0 0 0 12px;
    border: 0;
    background: none;
    color: var(--accent);
    font-size: 15px;
    cursor: pointer;
}

/* Strip of days: today at the right end, older days off to the left. */
.days {
    position: relative;
    display: flex;
    gap: 2px;
    overflow-x: auto;
    margin: 0 -24px;
    padding: 0 24px 10px;
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.days::-webkit-scrollbar { display: none; }
.day {
    flex: 0 0 46px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 0 9px;
    border: 0;
    border-radius: 12px;
    background: none;
    color: var(--text);
    cursor: pointer;
}
.day-wd { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.day.first .day-wd { color: var(--text); font-weight: 500; }
.day-num { font-size: 17px; line-height: 1.2; }
.day.today .day-num { color: var(--accent); font-weight: 500; }
.day.on { background: var(--pill); }
.day.on .day-num { font-weight: 500; }
.day-dots { display: flex; gap: 2px; height: 4px; margin-top: 2px; }
.day-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.day-dots i.bad { background: var(--overdue); }
.arrow-text.dim { color: var(--border); cursor: default; }

.habit-rows li + li { border-top: 1px solid var(--line-soft); }
.habit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    min-height: 64px;
    padding: 10px 0;
    border: 0;
    background: none;
    text-align: left;
    cursor: pointer;
}
.habit-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.habit-name { font-size: 17px; }
.habit-sub { font-size: 12px; color: var(--text-3); }

.tick {
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1.5px solid var(--ring);
    display: grid;
    place-items: center;
    transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
}
.tick svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.tick.done { background: var(--accent); border-color: var(--accent); }
.tick.done svg { opacity: 1; }
.habit-row:active .tick { transform: scale(0.9); }

.pill {
    flex: none;
    min-width: 64px;
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    font-size: 14px;
    text-align: center;
    color: var(--text-2);
}
.pill.set { color: var(--accent); border-color: var(--accent); font-weight: 500; }
.pill.bad, .pill.bad.set { color: var(--overdue-text); }
.pill.bad.set { border-color: var(--overdue); }

.foot { display: flex; justify-content: center; }
.linkish {
    min-height: 44px;
    padding: 0 12px;
    border: 0;
    background: transparent;
    color: var(--text-2);
    font-size: 14px;
    text-decoration: underline;
    cursor: pointer;
}

/* ---- Month / Year controls ---- */
.period-nav { display: flex; align-items: center; justify-content: space-between; }
.period-name { font-size: 20px; font-weight: 500; }
.arrow-text {
    min-height: 44px;
    min-width: 64px;
    padding: 0;
    border: 0;
    background: none;
    font-size: 16px;
    color: var(--accent);
    cursor: pointer;
}
.arrow-text:last-child { text-align: right; }

.chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin: -12px -24px 0;
    padding: 0 24px;
    scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: none;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: none;
    font-size: 15px;
    color: var(--text-2);
    white-space: nowrap;
    cursor: pointer;
}
.chip.on { background: var(--pill); color: var(--text); font-weight: 500; }

.switches { display: flex; flex-wrap: wrap; gap: 10px; margin-top: -12px; }
.seg {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
}
.seg button {
    min-height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 9px;
    background: none;
    font-size: 14px;
    color: var(--text-2);
    cursor: pointer;
}
.seg button.on { background: var(--pill); color: var(--text); font-weight: 500; }

/* ---- Charts (drawn as SVG in app.js) ---- */
.chart { touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.chart svg { display: block; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.legend > span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2.5px solid var(--accent); }
.legend i.bad { border-top-color: var(--overdue); }
.legend i.prev { border-top: 1.5px solid var(--ring); }
.legend i.ly { border-top: 1.5px dashed var(--border); }
.legend i.box { width: 10px; height: 10px; border: 0; background: var(--accent); }
.legend i.box.bad { background: var(--overdue); }
.legend i.box.prev { background: var(--border); }
.legend i.box.open { background: none; border: 1.5px solid var(--accent); }
.legend i.box.open.bad { border-color: var(--overdue); }
.legend i.dot { width: 9px; height: 9px; border: 0; border-radius: 50%; background: var(--accent); }
.legend i.dot.prev { width: 7px; height: 7px; background: var(--ring); }

/* Sleep: what the day before had to do with it */
.links .say.small { font-size: 15px; margin-top: 8px; }
.measures-label { margin-bottom: 4px; }

.multiples {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
    margin-top: 12px;
}
.multiple {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 8px 6px;
    margin: 0 -8px;
    border: 0;
    border-radius: 10px;
    background: none;
    text-align: left;
    cursor: pointer;
}
.multiple.on { background: var(--card); }
.multiple-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 13px; }
.multiple-head b { font-weight: 500; color: var(--accent); }
.multiple-head b.bad { color: var(--overdue-text); }
.mini svg { display: block; }

.year-rows { margin-top: 8px; }
.year-rows li + li { border-top: 1px solid var(--line-soft); }
.year-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 0 8px;
    margin: 0 -8px;
    width: calc(100% + 16px);
    border: 0;
    border-radius: 10px;
    background: none;
    font-size: 16px;
    text-align: left;
    cursor: pointer;
}
.year-row.on { background: var(--card); }
.year-row .mono { font-size: 14px; }

/* ---- Number sheet ---- */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(24, 32, 28, 0.35);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.sheet {
    width: 100%;
    max-width: 480px;
    padding: 24px 24px calc(24px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
    background: var(--ground);
    display: flex;
    flex-direction: column;
    gap: 20px;
}
@media (min-width: 560px) {
    .sheet-backdrop { align-items: center; }
    .sheet { border-radius: 20px; }
}
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.step {
    flex: none;
    width: 56px;
    height: 56px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    font-size: 26px;
    color: var(--accent);
    cursor: pointer;
}
.step:active { background: var(--pill); }
.step { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

.score-list { display: flex; flex-direction: column; gap: 8px; }
.score {
    min-height: 50px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    font-size: 17px;
    color: var(--text);
    cursor: pointer;
}
.score:active { background: var(--pill); }
.score.on { background: var(--pill); border-color: var(--accent); color: var(--accent); font-weight: 500; }
.step-value { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.step-value input {
    width: 100%;
    max-width: 160px;
    border: 0;
    background: none;
    text-align: center;
    font-size: 48px;
    font-weight: 500;
    color: var(--text);
    outline: none;
}
.step-unit { font-size: 14px; color: var(--text-3); }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 22px;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
}
.btn.primary { border: 0; background: var(--accent); color: #fff; font-weight: 500; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.secondary { border: 1px solid var(--border); background: var(--card); color: var(--text); }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ---- Login ---- */
.login {
    min-height: 100vh;
    max-width: 360px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    text-align: center;
}
.login-mark { width: 64px; height: 64px; }
.login h1 { font-size: 28px; font-weight: 500; }
.login form { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.login input {
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    font-family: inherit;
    font-size: 17px;           /* 16px or more, or iOS zooms on focus */
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
}
.login input:focus { border-color: var(--accent); }
.login-note { font-size: 14px; color: var(--text-3); }

/* Text inside the charts */
.chart text, .mini text { font-family: var(--mono); font-size: 11px; fill: var(--text-3); }
.chart text.tip { fill: #fff; }
.chart text.end { font-size: 13px; font-weight: 500; }

/* ================= Citations ================= */
a { color: var(--accent); }
.em { color: var(--accent); font-weight: 500; }
.small { font-size: 13px; line-height: 1.5; }
.note { margin-top: 10px; }
.hero.mid { font-size: 48px; }
.small-say { font-size: 14px; margin: 4px 0 10px; }

.stats { display: flex; gap: 28px; margin-top: 18px; }
.stats > div { display: flex; flex-direction: column; gap: 2px; }
.stat { font-size: 26px; font-weight: 500; }
.stat-l { font-family: var(--mono); font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 18px 14px; }
.edge-big { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0 8px; }
.edge-big > span:first-child { font-size: 30px; font-weight: 500; }
.edge-need { color: var(--accent); font-weight: 500; font-size: 16px; }
.need-list li + li { border-top: 1px solid var(--line-soft); }
.need { display: flex; justify-content: space-between; align-items: center; gap: 14px; width: 100%; min-height: 48px; padding: 8px 0; border: 0; background: none; text-align: left; cursor: pointer; }
.need-t { font-size: 15px; line-height: 1.35; }
.need-n { flex: none; font-size: 12px; color: var(--text-3); }
.need-n b { color: var(--accent); font-weight: 500; }
.edge .small { margin-top: 8px; }
.edge .small b { color: var(--accent); font-weight: 500; }

.rows { margin-top: 6px; }
.rows li + li { border-top: 1px solid var(--line-soft); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; min-height: 52px; padding: 10px 0; border: 0; background: none; text-align: left; cursor: pointer; font-size: 15px; }
.row.static { cursor: default; }
.row-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.row-t { font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-m { font-size: 12px; color: var(--text-3); line-height: 1.4; }
.row-c { font-size: 12px; color: var(--accent); line-height: 1.4; }
.row-n { flex: none; font-size: 15px; }
.row-d { flex: none; font-size: 12px; color: var(--text-3); align-self: flex-start; padding-top: 2px; }
.row-side { flex: none; display: flex; align-items: center; gap: 12px; }
.row-side .row-n { min-width: 30px; text-align: right; }
.paper .row-t { font-size: 15px; }

.tag { display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 999px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.03em; background: var(--pill); color: var(--text-2); vertical-align: 1px; }
.tag.rise { color: var(--accent); }
.tag.wake { color: var(--overdue-text); background: #f4e7dd; }
.tag.new { color: var(--accent); background: none; border: 1px solid var(--accent); }
.hero-line .tag { margin-left: 0; align-self: center; }

.seg { margin-bottom: 8px; }
.page section > .seg:first-child { margin-bottom: 4px; }

.bars { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.bars li { display: grid; grid-template-columns: minmax(0, 11em) 1fr 3.2em; align-items: center; gap: 12px; font-size: 14px; }
.bar-k { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar-n { text-align: right; font-size: 13px; color: var(--text-2); }

.chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip-s { padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 14px; }

.lanes { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.lanes li { display: grid; grid-template-columns: 138px 1fr; align-items: center; gap: 12px; }
.lane-n { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lanes svg { display: block; overflow: visible; }
.lanes text { font-family: var(--mono); font-size: 11px; fill: var(--text-3); }

.foot { flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.linkish.inline { min-height: 0; padding: 0; font-size: inherit; color: var(--accent); }
.linkish:disabled { opacity: 0.6; }

.sheet { max-height: 92vh; overflow-y: auto; gap: 10px; max-width: 520px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: -6px; }
.sheet-head .linkish { padding-right: 0; }
.sheet-title { margin: 0; font-size: 20px; line-height: 1.3; font-weight: 500; }
.sheet .hero-line { margin: 6px 0 2px; }
.sheet-sub { margin-top: 10px; }
.sheet .btn { margin-top: 6px; text-decoration: none; }
.milestones { margin-top: 12px; }

/* Letters, quotes, map */
.letter .letter-p { font-size: 16px; line-height: 1.6; margin-top: 10px; }
.letter .linkish { padding-left: 0; }
.letter-old { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
blockquote { margin: 8px 0 6px; padding-left: 14px; border-left: 3px solid var(--accent); font-size: 16px; line-height: 1.55; color: var(--text); }
.quote .row-c { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.sq { margin-top: 12px; }
.sq blockquote { font-size: 14px; border-left-color: var(--border); }
.chip-s.own { border-color: var(--accent); }
.map { margin-top: 12px; }
.map svg { display: block; }
.bar-track i.far { background: var(--overdue); opacity: 0.8; }
.quote .linkish.inline { text-align: left; font-size: 12px; line-height: 1.4; text-decoration: none; }
