/* Life v2 — a quiet logbook. Grey on near-black, colour only for the three
   areas. 1px rules, 8px corners, no shadows or gradients. */

:root {
  --bg: #111214;
  --surface: #1A1B1E;
  --rule: #2A2B2F;
  --text: #E8E6E1;
  --muted: #8A8A86;
  --track: #232428;     /* empty bars and grid cells */
  --box: #4A4B50;       /* unchecked checkbox */
  --faint: #55565B;     /* empty note pencil, locked hints */
  --handle: #3A3B40;
  --scrim: rgba(0, 0, 0, 0.55);
  --swatch: #B8B6B0;    /* neutral legend swatch */
  --note: #C9C7C2;
  --social: #E2694F;
  --body: #5FA463;
  --mind: #6E8BF0;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #F7F5F0;
    --surface: #FFFFFF;
    --rule: #E4E1DA;
    --text: #1B1B1A;
    --muted: #76736D;
    --track: #ECE9E2;
    --box: #B9B5AC;
    --faint: #B5B1A9;
    --handle: #D5D1C8;
    --scrim: rgba(27, 27, 26, 0.3);
    --swatch: #8F8C85;
    --note: #3A3936;
    --social: #C9533A;
    --body: #3F8A45;
    --mind: #4B67D1;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 13px/1.4 var(--mono);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--muted); outline-offset: 2px; }

/* area colour as a custom property: style="--a: var(--social)" */
.a-social { --a: var(--social); }
.a-body   { --a: var(--body); }
.a-mind   { --a: var(--mind); }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; padding: 20px 16px 24px; display: flex; flex-direction: column; gap: 16px; }

.label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.h1 { font-size: 20px; font-weight: 500; }
.num { font-variant-numeric: tabular-nums; }
.dot { width: 6px; height: 6px; border-radius: 3px; background: var(--a, var(--muted)); flex: none; display: inline-block; }
.pts { font-weight: 500; color: var(--a); white-space: nowrap; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.page-head > div:first-child { display: flex; flex-direction: column; gap: 4px; }

.card {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
}
.card::before { content: ''; width: 4px; background: var(--a, var(--rule)); flex: none; }
.card-body { flex: 1; min-width: 0; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.card-plain::before { display: none; }

/* ---------- dock: Add Activity + bottom nav ---------- */
.dock { position: sticky; bottom: 0; background: var(--bg); z-index: 5; }
.add-btn {
  margin: 12px 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 56px; border-radius: 8px;
  background: var(--text); color: var(--bg);
  font-weight: 700; font-size: 15px;
  width: calc(100% - 32px);
}
.nav {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
  height: calc(56px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
}
.nav a { display: flex; align-items: center; justify-content: center; color: var(--muted); }
.nav a[aria-current="page"] { color: var(--text); font-weight: 700; }

/* ---------- Today ---------- */
.day-head { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.icon-btn {
  width: 44px; height: 44px; border: 1px solid var(--rule); border-radius: 8px;
  color: var(--muted); display: flex; align-items: center; justify-content: center;
}
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn.bare { border: none; }
.day-title { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.day-title b { font-size: 15px; font-weight: 500; }
.totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.total {
  position: relative;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 4px;
}
.total .v { font-size: 20px; font-weight: 500; color: var(--a); }
.lock-note { font-size: 11px; color: var(--muted); text-align: center; }

.daily { display: flex; flex-direction: column; }
.drow { display: flex; align-items: center; gap: 10px; min-height: 46px; border-bottom: 1px solid var(--rule); }
.drow .name { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; text-align: left; height: 44px; }
.drow .name span:last-child { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.check .box { width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--box); display: flex; align-items: center; justify-content: center; color: var(--bg); }
.check[aria-pressed="true"] .box { width: 22px; height: 22px; background: var(--a); border: none; }
.check.pop .box { animation: pop 180ms ease-out; }
@keyframes pop { 50% { transform: scale(1.25); } }
.stepper { display: flex; align-items: center; border: 1px solid var(--rule); border-radius: 8px; height: 36px; }
.stepper button { width: 36px; height: 36px; color: var(--muted); font-size: 15px; }
.stepper button:disabled { opacity: 0.3; cursor: default; }
.stepper .v { width: 40px; text-align: center; font-weight: 500; color: var(--a); }
.pencil { width: 36px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--faint); }
.pencil.has { color: var(--a); }
.pencil.has svg { fill: currentColor; }
.note-box { padding: 4px 0 10px 16px; display: flex; gap: 8px; align-items: flex-end; border-bottom: 1px solid var(--rule); }
.note-box textarea { flex: 1; }

.acts { display: flex; flex-direction: column; gap: 8px; }
.act { height: 50px; text-align: left; width: 100%; }
.act .card-body { flex-direction: row; align-items: center; gap: 8px; padding: 0 12px; }
.act .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { color: var(--muted); font-size: 11px; padding: 6px 0; }

/* ---------- inputs ---------- */
.input, textarea.input {
  width: 100%; height: 44px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
  font-size: 13px;
}
textarea.input {
  height: 88px; padding: 10px 12px; resize: none;
  font-family: var(--sans); font-size: 15px; line-height: 1.45;
}
textarea.input.short { height: 64px; }
.input::placeholder { color: var(--muted); opacity: 0.8; }
.field { display: flex; flex-direction: column; gap: 8px; }
.seg { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.seg button { height: 44px; color: var(--muted); font-size: 13px; padding: 0 10px; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-checked="true"] { background: var(--rule); color: var(--text); font-weight: 700; }
.chip {
  height: 34px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--rule); color: var(--muted);
  font-size: 12px; display: inline-flex; align-items: center; gap: 6px;
}
.chip .v { font-size: 11px; opacity: 0.7; }
.chip[aria-pressed="true"] {
  border-color: var(--a, var(--muted)); color: var(--a, var(--text));
  background: color-mix(in srgb, var(--a, var(--muted)) 14%, transparent);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dashed { height: 44px; border: 1px dashed var(--rule); border-radius: 8px; color: var(--muted); width: 100%; }
.btn {
  height: 44px; padding: 0 16px; border-radius: 8px;
  background: var(--text); color: var(--bg); font-weight: 700;
}
.btn.ghost { background: none; color: var(--muted); border: 1px solid var(--rule); font-weight: 400; }
.btn.small { height: 36px; padding: 0 12px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- sheets and forms ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 20; display: flex; justify-content: center; align-items: flex-end; }
.sheet {
  width: 100%; max-width: 480px; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-top: 1px solid var(--rule); border-radius: 16px 16px 0 0;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 18px;
}
.handle { width: 36px; height: 4px; border-radius: 2px; background: var(--handle); align-self: center; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 10px;
  min-height: 84px; padding: 12px; background: var(--bg); border: 1px solid var(--rule); border-radius: 8px; text-align: left;
}
.tile svg { stroke: var(--a); }
.tile span { display: flex; flex-direction: column; gap: 2px; }

.form-page { min-height: 100dvh; display: flex; flex-direction: column; }
.form-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.form-head .grow { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.form-head b { font-size: 15px; font-weight: 500; }
.date-pick { position: relative; font-size: 11px; color: var(--muted); align-self: flex-start; }
.date-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.date-pick span { text-decoration: underline dotted; text-underline-offset: 3px; }
.form-body { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 20px; }
.form-foot {
  position: sticky; bottom: 0; background: var(--bg);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px calc(20px + env(safe-area-inset-bottom)); border-top: 1px solid var(--rule);
}
.form-foot .grow { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.form-foot .big { font-size: 20px; font-weight: 700; color: var(--a); }
.form-foot .btn { height: 56px; width: 160px; font-size: 15px; }
.sec-head { display: flex; justify-content: space-between; align-items: center; }
.person, .gconvo { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.person-top { display: flex; align-items: center; gap: 8px; }
.person-top .input { flex: 1; min-width: 0; height: 36px; padding: 0 10px; background: var(--bg); }
.person-top .pts { width: 44px; text-align: right; }
.x { width: 32px; height: 36px; color: var(--muted); font-size: 16px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.defs { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); line-height: 1.5; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px; }
.defs b { color: var(--text); font-weight: 500; }
.help { width: 22px; height: 22px; border: 1px solid var(--rule); border-radius: 11px; font-size: 11px; color: var(--muted); }
.text-btn { display: inline-flex; align-items: center; color: var(--muted); font-size: 12px; height: 44px; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- scoreboard ---------- */
.big-score { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.big-score .n { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; }
.big-score .p { font-size: 15px; }
.prow { display: grid; grid-template-columns: 72px minmax(0, 1fr) 44px; align-items: center; gap: 10px; color: var(--muted); }
.prow.lead { color: var(--text); font-weight: 700; }
.prow .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow .v { text-align: right; }
.bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--a); opacity: 0.35; }
.prow.lead .bar i { opacity: 1; }
.lines { display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.lines > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--rule); }
.lines > div:last-child { border-bottom: none; }

/* ---------- charts ---------- */
.legend { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--swatch); }
.bars8 { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; height: 110px; align-items: end; border-bottom: 1px solid var(--rule); }
.bars8 > div { display: flex; gap: 2px; align-items: flex-end; justify-content: center; height: 110px; }
.bars8 i { flex: 0 1 13px; min-width: 3px; background: var(--a); border-radius: 2px 2px 0 0; }
.wks { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; font-size: 11px; color: var(--muted); text-align: center; }
.wks .now { color: var(--text); }
.cells { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 9px); grid-auto-columns: 9px; gap: 2px; }
.cells i { width: 9px; height: 9px; border-radius: 2px; background: var(--track); }
.cells i.on { background: var(--a); }
.cells i.future { background: transparent; }
.scale { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.scale i { width: 9px; height: 9px; border-radius: 2px; background: var(--swatch); }

/* ---------- centuries ---------- */
.ctile { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; min-width: 0; }
.ctile .top { display: flex; justify-content: space-between; align-items: center; gap: 4px; height: 16px; font-size: 11px; }
.ctile .top span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lap { font-size: 11px; padding: 0 4px; border-radius: 4px; background: var(--a); color: var(--bg); font-weight: 700; }
.dots { display: grid; grid-template-columns: repeat(10, 6px); grid-auto-rows: 6px; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--rule); }
.dots i.on { background: var(--a); }
.crow { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.crow .who { display: grid; grid-template-columns: 56px minmax(0, 1fr) 64px; gap: 8px; align-items: center; font-size: 11px; color: var(--muted); }
.crow .who.me { color: var(--text); }
.crow .bar { height: 6px; }
.crow .bar i { opacity: 1; }
.crow .who:not(.lead) .bar i { opacity: 0.35; }
.feed { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--rule); padding-top: 10px; }
.feed > div { display: flex; align-items: center; gap: 10px; min-height: 32px; font-size: 12px; }

/* ---------- history ---------- */
.week-row { display: flex; justify-content: space-between; align-items: center; min-height: 36px; margin-top: 8px; border-bottom: 1px solid var(--rule); }
.week-row span:last-child { color: var(--text); letter-spacing: 0; text-transform: none; }
.hday { display: flex; flex-direction: column; gap: 6px; padding: 12px 0 4px; }
.hday-top { display: flex; justify-content: space-between; align-items: baseline; }
.sbm { display: flex; gap: 10px; font-size: 11px; }
.hact .card-body { padding: 8px 12px; gap: 4px; }
.hact .top { display: flex; gap: 8px; align-items: baseline; }
.hact .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { font-size: 11px; color: var(--muted); line-height: 1.5; }
.note { font-family: var(--sans); font-size: 13px; line-height: 1.45; color: var(--note); white-space: pre-wrap; }
.private { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--faint); }

/* ---------- rules ---------- */
.rules-table { width: 100%; border-collapse: collapse; }
.rules-table td { padding: 8px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.rules-table td:first-child { padding-right: 12px; }
.rules-table td.v { text-align: right; white-space: nowrap; color: var(--a, var(--text)); font-weight: 500; padding-left: 12px; }
.rules-table .def { font-size: 11px; color: var(--muted); }
.prose { line-height: 1.6; color: var(--muted); }
.prose b { color: var(--text); font-weight: 500; }

/* ---------- sign in ---------- */
.signin { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 24px 16px; }
.signin .input { font-size: 20px; height: 56px; text-align: center; letter-spacing: 0.3em; }
.signin .btn { height: 56px; font-size: 15px; }
.err { color: var(--text); font-size: 12px; min-height: 18px; text-align: center; }

/* ---------- feedback ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(140px + env(safe-area-inset-bottom));
  width: calc(100% - 32px); max-width: 448px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 8px;
  padding: 0 4px 0 14px; min-height: 48px;
  display: flex; align-items: center; gap: 12px; z-index: 40;
}
.toast .msg { flex: 1; padding: 10px 0; }
.toast button { height: 44px; padding: 0 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; }
.float {
  position: absolute; pointer-events: none; z-index: 30;
  font-weight: 700; color: var(--a);
  animation: floatup 800ms ease-out forwards;
}
@keyframes floatup { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-26px); } }
.loading { color: var(--muted); font-size: 11px; padding: 24px 0; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .check.pop .box, .float { animation: none; }
  .float { display: none; }
}
