/* Fit by 40 — paper journal */
:root {
  --paper: #f4efe6;
  --paper-2: #ece6da;
  --ink: #2a2622;
  --mid: #5a544c;
  --muted: #7a736a;
  --rust: #c9622f;
  --rule: rgba(42, 38, 34, 0.25);
  --rule-soft: rgba(42, 38, 34, 0.12);
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { background: var(--paper); }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
a { color: var(--ink); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
input, select, textarea { font: inherit; color: inherit; }
.serif { font-family: var(--serif); font-variant-numeric: tabular-nums; }
.caps { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.rust { color: var(--rust); }
[hidden] { display: none !important; }

.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* Header */
.hdr { padding: 22px 22px 0 22px; }
.hdr-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hdr-date { font-size: 30px; font-style: italic; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-clock { font-size: 15px; font-weight: 500; white-space: nowrap; }
.hdr-left { display: flex; align-items: baseline; gap: 10px; }
.hdr-right { display: flex; align-items: center; gap: 8px; }
.avatar { width: 40px; height: 40px; border-radius: 999px; border: 1.5px solid var(--ink); display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 500; font-style: italic; line-height: 1; padding-bottom: 2px; }
.avatar.on { background: var(--ink); color: var(--paper); }
.avatar:active { background: var(--paper-2); }
.avatar.on:active { background: var(--mid); }
.hdr-sub { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; padding-bottom: 10px; border-bottom: 1.5px solid var(--ink); }
.count { display: flex; align-items: baseline; gap: 5px; }
.count-n { font-size: 18px; font-weight: 600; color: var(--rust); }

/* View */
.view { flex: 1; padding: 0 22px 24px 22px; }
.loading { padding: 40px 0; text-align: center; color: var(--muted); font-style: italic; font-family: var(--serif); font-size: 18px; }
.section { margin-top: 18px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; }
.h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; }

/* Cards */
.card { margin-top: 16px; padding: 14px; border: 1.5px solid var(--ink); border-radius: 6px; }
.card.dashed { border-style: dashed; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.row-l { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.bigv { font-family: var(--serif); font-size: 19px; font-weight: 500; font-variant-numeric: tabular-nums; }
.bigv .d { color: var(--muted); font-weight: 400; }
.bar { height: 8px; margin-top: 8px; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ink); transition: width .4s ease; }
.bar.rust > i { background: var(--rust); }
.macros { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.macros b { font-family: var(--serif); font-weight: 400; font-size: 14px; color: var(--ink); }
.divider { height: 12px; }

/* Pills & buttons */
.pill { display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 12px; border: 1.5px solid var(--ink); border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.big { height: 44px; padding: 0 16px; font-size: 13px; }
.pill.solid { background: var(--ink); color: var(--paper); }
.pill.soft { border-color: var(--rule); color: var(--muted); }
.pill:active { background: var(--paper-2); }
.pill.solid:active { background: var(--mid); }
.btn-wide { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 50px; border: 1.5px solid var(--ink); border-radius: 999px; font-size: 15px; font-weight: 500; margin-top: 18px; }
.btn-wide.solid { background: var(--ink); color: var(--paper); }
.btn-wide:active { background: var(--paper-2); }
.btn-wide.solid:active { background: var(--mid); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 34px; padding: 0 13px; border: 1.5px solid var(--rule); border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--muted); }
.chip.on { border-color: var(--ink); background: var(--ink); color: var(--paper); }

/* Habits */
.habit { display: flex; align-items: center; gap: 12px; min-height: 48px; border-bottom: 1px solid var(--rule); }
.habit .box { flex: none; width: 44px; height: 44px; margin-left: -13px; display: flex; align-items: center; justify-content: center; }
.habit .box i { width: 18px; height: 18px; border: 1.5px solid var(--ink); display: block; }
.habit.done .box i { background: var(--ink); }
.habit .name { flex: 1; font-size: 15px; text-align: left; min-height: 44px; display: flex; align-items: center; }
.habit.done .name { text-decoration: line-through; color: var(--muted); }
.habit .meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.habit .meta.rem { font-family: var(--serif); font-style: italic; font-size: 14px; color: var(--rust); }

/* Tonight */
.tonight-t { font-family: var(--serif); font-size: 17px; font-style: italic; }
.tonight-b { font-size: 13px; line-height: 1.4; color: var(--mid); margin-top: 3px; }

/* Weight */
.weight { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding-bottom: 12px; border-bottom: 1.5px solid var(--ink); width: 100%; text-align: left; }
.weight-n { font-family: var(--serif); font-size: 28px; font-weight: 500; line-height: 1; }
.weight-s { font-size: 12px; color: var(--muted); }

/* Tabs */
.tabs { position: sticky; bottom: 0; display: flex; justify-content: space-around; align-items: center; padding: 8px 24px calc(10px + var(--safe-b)) 24px; background: var(--paper); border-top: 1px solid var(--rule-soft); }
.tab { height: 44px; font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); border-bottom: 1.5px solid transparent; }
.tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

/* Sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(42,38,34,0.35); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { width: 100%; max-width: 480px; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--paper); border-top: 1.5px solid var(--ink); border-radius: 14px 14px 0 0; padding: 14px 22px calc(22px + var(--safe-b)) 22px; }
.sheet-bar { display: flex; justify-content: space-between; align-items: center; padding-bottom: 10px; border-bottom: 1.5px solid var(--ink); }
.sheet-title { font-size: 26px; font-style: italic; }
.sheet-close { height: 44px; padding: 0 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.sheet-body { padding-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field label { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.field input, .field textarea, .field select { width: 100%; padding: 10px 12px; border: 1.5px solid var(--ink); border-radius: 6px; background: transparent; font-size: 16px; }
.field textarea { min-height: 88px; resize: vertical; font-family: var(--serif); font-size: 18px; line-height: 1.4; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--rust); outline-offset: 1px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; font-style: italic; font-family: var(--serif); font-size: 15px; }
.list-row { display: flex; align-items: center; gap: 10px; min-height: 48px; border-bottom: 1px solid var(--rule); }
.list-row .grow { flex: 1; }
.list-row .sub { font-size: 12px; color: var(--muted); }
.del { height: 44px; padding: 0 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.sev { display: flex; gap: 8px; }
.sev button { flex: 1; height: 44px; border: 1.5px solid var(--rule); border-radius: 6px; font-family: var(--serif); font-size: 18px; color: var(--muted); }
.sev button.on { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.sev button.on.hot { background: var(--rust); border-color: var(--rust); }

/* Regulars dropdown + portion stepper */
.m-select { width: 100%; padding: 10px 12px; border: 1.5px solid var(--ink); border-radius: 6px; background: transparent; font-size: 15px; appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }
.stepper { display: flex; align-items: center; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.stepper button { width: 38px; height: 38px; font-size: 20px; line-height: 1; }
.stepper button:active { background: var(--paper-2); }
.stepper input { width: 52px; height: 38px; border: 0; border-left: 1.5px solid var(--ink); border-right: 1.5px solid var(--ink); background: transparent; text-align: center; font-family: var(--serif); font-size: 16px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Meal reading */
.ib { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1.5px solid var(--ink); border-radius: 6px; cursor: pointer; }
.ib:active { background: var(--paper-2); }
.ib.live { background: var(--rust); border-color: var(--rust); color: var(--paper); }
.thumb { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.thumb img { height: 96px; width: 96px; object-fit: cover; border-radius: 6px; border: 1.5px solid var(--ink); }
.item { border-bottom: 1px solid var(--rule); }
.item-main { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 8px 0; text-align: left; }
.item-main .grow { flex: 1; font-size: 15px; }
.item-main .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item-edit { padding-bottom: 12px; }
.item-edit .field { margin-top: 8px; }
.item-edit .del { margin-top: 6px; padding-left: 0; }
#scan { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; border: 1.5px solid var(--ink); background: #000; }
button:disabled { opacity: 0.55; }

/* Journal & past days */
.daybar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 10px 12px; border: 1.5px solid var(--ink); border-radius: 6px; background: var(--paper-2); }
.daybar .t { font-family: var(--serif); font-style: italic; font-size: 16px; }
.jrow { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.jrow .d { display: flex; justify-content: space-between; align-items: baseline; }
.jrow .d b { font-family: var(--serif); font-weight: 600; font-size: 18px; }
.jrow .d span { font-size: 12px; color: var(--muted); }
.jrow .s { font-size: 12px; color: var(--muted); }
.jrow .x { font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--mid); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.jrow .x.none { color: var(--muted); opacity: 0.7; }
.journal-ta { width: 100%; min-height: 110px; padding: 12px; border: 1.5px solid var(--ink); border-radius: 6px; background: transparent; font-family: var(--serif); font-size: 17px; line-height: 1.45; resize: vertical; }
.journal-ta:focus { outline: 2px solid var(--rust); outline-offset: 1px; }

/* Coach view (wider layout, works on a laptop and a phone) */
.coach { max-width: 900px; margin: 0 auto; padding: 22px 22px 60px 22px; }
.c-hdr { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding-bottom: 12px; border-bottom: 1.5px solid var(--ink); flex-wrap: wrap; }
.c-title { font-size: 30px; font-style: italic; line-height: 1.1; }
.c-actions { display: flex; gap: 8px; align-items: center; }
.c-actions a { text-decoration: none; }
.c-filters { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; padding: 12px 14px; border: 1.5px solid var(--ink); border-radius: 6px; }
.c-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.c-dates { display: flex; gap: 10px; align-items: center; }
.c-dates label { display: flex; align-items: center; gap: 6px; }
.c-dates input { padding: 6px 8px; border: 1.5px solid var(--ink); border-radius: 6px; background: transparent; font-size: 14px; }
.c-search { flex: 1; min-width: 200px; padding: 9px 12px; border: 1.5px solid var(--ink); border-radius: 6px; background: transparent; font-size: 15px; }
.c-search:focus { outline: 2px solid var(--rust); outline-offset: 1px; }
.c-check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.c-check input { width: 18px; height: 18px; accent-color: var(--ink); }
.c-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 14px; }
.c-stat { padding: 10px 12px; border: 1.5px solid var(--rule); border-radius: 6px; }
.c-stat-n { font-size: 26px; font-weight: 500; line-height: 1.1; }
.c-day { margin-top: 22px; }
.c-week { margin-top: 26px; padding-top: 14px; border-top: 1.5px solid var(--ink); }
.c-week-head { margin-bottom: 4px; }
.c-day-head { padding-bottom: 8px; border-bottom: 1.5px solid var(--ink); }
.c-week .c-day-head { border-bottom: 1px solid var(--rule); }
.c-day-title { font-size: 22px; font-weight: 600; }
.c-day-stats { font-size: 13px; color: var(--muted); margin-top: 4px; }
.c-day-stats b { font-family: var(--serif); font-weight: 500; font-size: 15px; color: var(--ink); }
.c-meal { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.c-photo { flex: none; width: 96px; height: 96px; border-radius: 6px; overflow: hidden; border: 1.5px solid var(--ink); padding: 0; background: var(--paper-2); }
.c-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.c-photo.none { border: 1.5px dashed var(--rule); }
.c-meal-body { flex: 1; min-width: 0; }
.c-meal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 15px; }
.c-items { margin-top: 6px; }
.c-item { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 3px 0; }
.c-item .muted { font-size: 12px; }
.c-meal-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.c-raw { margin-top: 6px; font-family: var(--serif); font-style: italic; font-size: 14px; color: var(--mid); }
.c-lightbox { position: fixed; inset: 0; background: rgba(42,38,34,0.85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; z-index: 40; padding: 20px; }
.c-lightbox img { max-width: 100%; max-height: 80vh; border-radius: 6px; }
@media (max-width: 600px) { .c-photo { width: 72px; height: 72px; } .c-title { font-size: 26px; } }

/* Interval timer */
.t-body { transition: background .3s ease; }
.t-body.t-dark { background: var(--ink); color: var(--paper); }
.t-app { max-width: 480px; margin: 0 auto; padding: 18px 22px 40px 22px; }
.t-hdr { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1.5px solid var(--ink); }
.t-title { font-size: 26px; font-style: italic; }
.t-summary { margin-top: 14px; padding: 12px 14px; border: 1.5px dashed var(--ink); border-radius: 6px; font-size: 13px; color: var(--mid); }
.t-summary b { font-size: 20px; font-weight: 500; color: var(--ink); margin-right: 4px; }
.t-run { min-height: 100dvh; display: flex; flex-direction: column; padding: 18px 22px calc(24px + var(--safe-b)) 22px; max-width: 520px; margin: 0 auto; }
.t-dark .t-run { color: var(--paper); }
.t-top { display: flex; justify-content: space-between; }
.t-dark .caps { color: rgba(244,239,230,0.7); }
.t-mid { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; }
.t-phase { font-size: 13px; }
.t-clock { font-size: 128px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.t-exercise { font-size: 34px; font-weight: 600; line-height: 1.15; margin-top: 8px; text-wrap: balance; }
.t-next { font-size: 15px; color: var(--muted); margin-top: 6px; }
.t-dark .t-next { color: rgba(244,239,230,0.7); }
.t-bar { height: 8px; border: 1.5px solid currentColor; border-radius: 999px; overflow: hidden; margin: 12px 0 16px 0; }
.t-bar i { display: block; height: 100%; background: currentColor; transition: width .25s linear; }
.t-controls { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 10px; }
.t-btn { height: 64px; border: 1.5px solid currentColor; border-radius: 14px; font-size: 16px; font-weight: 600; }
.t-btn:active { opacity: .7; }
.t-btn-main { background: var(--ink); color: var(--paper); border-color: var(--ink); font-size: 18px; }
.t-dark .t-btn-main { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.t-end { margin-top: 12px; height: 44px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.t-dark .t-end { color: rgba(244,239,230,0.6); }
@media (max-height: 700px) { .t-clock { font-size: 96px; } .t-exercise { font-size: 28px; } }

/* Trends: each section is a button that opens the numbers behind it */
.t-raw { display: block; width: 100%; text-align: left; font: inherit; color: inherit; }
.t-raw:active { background: var(--paper-2); }
.raw-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.raw-table th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 6px 0; border-bottom: 1.5px solid var(--ink); }
.raw-table th.n, .raw-table td.n { text-align: right; font-family: var(--serif); font-variant-numeric: tabular-nums; }
.raw-table td.n { font-size: 16px; }
.raw-table td { padding: 9px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.raw-table tr[data-day] { cursor: pointer; }
.raw-table .sub { font-size: 12px; color: var(--muted); }

/* Trends */
.chart { width: 100%; height: auto; display: block; margin-top: 8px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 5px; background: var(--ink); }
.legend i.rust { background: var(--rust); }
.grid-days { display: grid; gap: 3px; margin-top: 8px; }
.grid-days .cell { aspect-ratio: 1; border: 1px solid var(--rule); border-radius: 2px; }
.grid-days .cell.on { background: var(--ink); border-color: var(--ink); }
.grid-days .lbl { font-size: 11px; color: var(--muted); align-self: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 80px; margin-top: 8px; border-bottom: 1px solid var(--rule); }
.bars i { flex: 1; display: block; background: var(--ink); border-radius: 2px 2px 0 0; min-height: 1px; }
.bars i.rust { background: var(--rust); }
.bars i.over { background: var(--rust); }
.stat { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; font-size: 12px; color: var(--muted); }

/* Symptoms */
.sym-day { margin-top: 14px; }
.sym-day .caps { padding-bottom: 4px; border-bottom: 1px solid var(--rule); }
.sym { display: flex; align-items: center; gap: 10px; min-height: 44px; border-bottom: 1px solid var(--rule-soft); }
.sym .sv { font-family: var(--serif); font-size: 18px; width: 22px; text-align: center; }
.sym .sv.hot { color: var(--rust); }
.sym .t { flex: 1; }
.sym .n { font-size: 12px; color: var(--muted); font-style: italic; font-family: var(--serif); font-size: 14px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%); max-width: 90vw; padding: 10px 16px; background: var(--ink); color: var(--paper); border-radius: 999px; font-size: 13px; font-weight: 500; z-index: 30; box-shadow: 0 6px 20px rgba(42,38,34,0.25); }

/* Empty */
.empty { font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--muted); padding: 14px 0; }

@media (prefers-reduced-motion: reduce) { .bar > i { transition: none; } }
