:root {
  --bg: #faf9f7; --surface: #ffffff; --text: #1d1b19; --muted: #77716a; --line: #e8e4de;
  --accent: #c2410c; --chip: #f1ede7; --chip-on: #1d1b19; --chip-on-text: #faf9f7; --danger: #b91c1c;
  --ok: #15803d; --warn: #b45309; --empty: #eeeae4;
  --r1: #f4a7a0; --r2: #f6b69a; --r3: #f8c79a; --r4: #f9d79c; --r5: #f6e3a1;
  --r6: #e3e6a3; --r7: #c9e2a4; --r8: #addaa6; --r9: #93d0aa; --r10: #7cc5b0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514; --surface: #1f1d1b; --text: #ece8e3; --muted: #9a938b; --line: #2e2b28;
    --accent: #fb923c; --chip: #2a2725; --chip-on: #ece8e3; --chip-on-text: #161514; --danger: #f87171;
    --ok: #4ade80; --warn: #fbbf24; --empty: #262321;
    --r1: #9b4a43; --r2: #9c5a3f; --r3: #9a6a3e; --r4: #957a40; --r5: #8a8344;
    --r6: #737f45; --r7: #5d7a48; --r8: #4a744c; --r9: #3d6e55; --r10: #34685c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
main { max-width: 680px; margin: 0 auto; padding: 12px 16px 80px; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* Quiet progress feedback, with real elapsed time rather than a simulated percentage. */
.activity { display: flex; align-items: center; gap: 12px; padding: 16px; margin: 8px 0 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.activity strong { font-size: 14px; font-weight: 600; }
.activity-time { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.activity-spinner { flex: 0 0 18px; width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: activity-spin .9s linear infinite; }
.loading-card { border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 12px 0; background: var(--surface); }
.loading-card i { display: block; height: 10px; background: var(--empty); border-radius: 5px; margin: 10px 0; animation: activity-pulse 1.6s ease-in-out infinite; }
.loading-card i:first-child { width: 28%; height: 8px; }
.loading-card i:last-child { width: 65%; }
button:disabled { cursor: wait; opacity: .65; }
@keyframes activity-spin { to { transform: rotate(360deg); } }
@keyframes activity-pulse { 50% { opacity: .45; } }
@media (max-width: 420px) { .activity { flex-wrap: wrap; } .activity-time { margin-left: 30px; } }
@media (prefers-reduced-motion: reduce) { .activity-spinner, .loading-card i { animation: none; } }

/* top bar */
nav.top { display: flex; align-items: center; gap: 4px; padding: 6px 0 14px; position: sticky; top: 0; background: var(--bg); z-index: 3; }
nav.top a { text-decoration: none; font-size: 14.5px; padding: 6px 11px; border-radius: 999px; color: var(--muted); }
nav.top a.on { background: var(--chip); color: var(--text); font-weight: 600; }
nav.top .spacer { flex: 1; }

/* day header */
.dayhead { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; }
.dayhead h1 { font-size: 22px; margin: 0; flex: 1; letter-spacing: -.01em; }
.dayhead h1 .muted { font-weight: 400; font-size: 15px; margin-left: 6px; }
.arrow { width: 34px; height: 34px; border-radius: 10px; background: var(--chip); font-size: 18px; display: grid; place-items: center; text-decoration: none; }
.arrow[aria-disabled="true"] { opacity: .35; pointer-events: none; }

/* rating */
.rating { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.rating button {
  aspect-ratio: 1; border-radius: 12px; background: var(--chip); font-weight: 600; font-size: 15px;
  font-variant-numeric: tabular-nums; transition: transform .08s, background .15s;
}
.rating button:active { transform: scale(.92); }
.rating button.on { background: var(--c); box-shadow: inset 0 0 0 2px var(--text); }
.rating-label { font-size: 13px; color: var(--muted); margin: 6px 2px 16px; min-height: 18px; display: flex; justify-content: space-between; }

/* writing */
textarea.write, input.field, select.field {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; outline: none;
}
textarea.write { resize: none; overflow: hidden; display: block; font-size: 17px; line-height: 1.55; min-height: 180px; }
textarea.write:focus, input.field:focus, select.field:focus { border-color: var(--accent); }
input.field, select.field { padding: 9px 12px; border-radius: 10px; font-size: 15px; }
/* the formatted view of an entry; same box as the editor */
.md-view { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-height: 120px; cursor: text; font-size: 16.5px; line-height: 1.55; overflow-wrap: anywhere; }
.md-view:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.md-view > :first-child { margin-top: 0; } .md-view > :last-child { margin-bottom: 0; }
.md-view p { margin: 0 0 10px; }
.md-view h3, .md-view h4, .md-view h5 { margin: 16px 0 6px; line-height: 1.3; }
.md-view h3 { font-size: 19px; } .md-view h4 { font-size: 17px; } .md-view h5 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.md-view ul, .md-view ol { margin: 0 0 10px; padding-left: 22px; }
.md-view li { margin: 2px 0; } .md-view li > ul, .md-view li > ol { margin: 2px 0 4px; }
.md-view ul ul { list-style-type: circle; } .md-view ul ul ul { list-style-type: square; }
.md-view li.task { list-style: none; margin-left: -20px; }
.md-view li.task input { margin: 0 6px 0 0; vertical-align: -1px; accent-color: var(--accent); }
.md-view blockquote { margin: 0 0 10px; padding: 2px 0 2px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.md-view hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.md-view pre { padding: 10px 12px; margin: 0 0 10px; white-space: pre-wrap; }
.md-view a { color: var(--accent); }
.md-hint { font-size: 12px; color: var(--muted); margin: 5px 4px 0; display: none; }
.mdbox.editing .md-hint, .mdbox:has(textarea:not([hidden]):focus) .md-hint { display: block; }
.saved { font-size: 12.5px; color: var(--muted); margin: 6px 4px 0; min-height: 18px; text-align: right; }

.addnote { display: flex; gap: 8px; margin: 18px 0 6px; flex-wrap: wrap; }
.chip { font-size: 14px; padding: 6px 12px; border-radius: 999px; background: var(--chip); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.chip.on { background: var(--chip-on); color: var(--chip-on-text); }
.chip:hover { filter: brightness(.97); }

/* cards & lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 8px 0; display: block; text-decoration: none; }
.card .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.card .title { font-weight: 600; margin: 2px 0 0; }
.card .snip { color: var(--muted); font-size: 14.5px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.kind { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kind.practice { color: #2563eb; } .kind.thought { color: #7c3aed; } .kind.vent { color: var(--danger); } .kind.week { color: var(--ok); } .kind.day { color: var(--muted); }
@media (prefers-color-scheme: dark) { .kind.practice { color: #60a5fa; } .kind.thought { color: #a78bfa; } }
/* each kind has a color: the left edge of its cards and its Notes tab */
.card.k-practice, .tab.k-practice { --k: #2563eb; } .card.k-thought, .tab.k-thought { --k: #7c3aed; }
.card.k-vent, .tab.k-vent { --k: var(--danger); } .card.k-week, .tab.k-week { --k: var(--ok); }
@media (prefers-color-scheme: dark) { .card.k-practice, .tab.k-practice { --k: #60a5fa; } .card.k-thought, .tab.k-thought { --k: #a78bfa; } }
.card[class*="k-"]:not(.k-day) { border-left: 4px solid var(--k); }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 12px; }
.tab { text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; border-top: 4px solid var(--k); }
.tab .tab-name { font-weight: 600; font-size: 14.5px; }
.tab .tab-n { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tab.on { box-shadow: inset 0 0 0 2px var(--k); }
.dot { width: 22px; height: 22px; border-radius: 7px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--c, var(--empty)); color: var(--text); flex: none; }
.month { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 4px; }

h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 8px; font-weight: 600; }

/* strip of recent days */
.strip { display: flex; gap: 5px; margin-top: 6px; }
.strip a { flex: 1; text-align: center; text-decoration: none; font-size: 11.5px; color: var(--muted); }
.strip a .sq { height: 30px; border-radius: 8px; background: var(--c, var(--empty)); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--text); margin-bottom: 3px; }
.strip a.today .sq { box-shadow: inset 0 0 0 2px var(--text); }

.banner { display: flex; align-items: center; gap: 10px; background: var(--chip); border-radius: 14px; padding: 12px 14px; margin: 0 0 16px; text-decoration: none; }
.banner b { flex: 1; font-weight: 600; }

/* progress */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat .n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12.5px; color: var(--muted); }
.heat { overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.heat svg { display: block; }
.heat rect { rx: 2.5; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 10px; }
.legend { display: flex; gap: 3px; align-items: center; font-size: 11.5px; color: var(--muted); margin-top: 6px; justify-content: flex-end; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.toolbar input { flex: 1 1 100%; }

/* week */
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.weekdays a { text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 7px 4px; text-align: center; min-width: 0; }
.weekdays .wd { font-size: 11.5px; color: var(--muted); }
.weekdays .dot { margin: 4px auto 0; }
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; font-size: 15.5px; }
.summary p { margin: 0 0 8px; } .summary ul { margin: 0 0 8px; padding-left: 20px; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
button.primary { background: var(--chip-on); color: var(--chip-on-text); padding: 9px 16px; border-radius: 10px; font-weight: 600; }
button.primary:disabled { opacity: .5; }
button.ghost { background: var(--chip); padding: 8px 14px; border-radius: 10px; }
button.danger { color: var(--danger); }

/* keys */
.secret { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 8px 0; }
.secret .top { display: flex; align-items: center; gap: 8px; }
.secret .name { font-weight: 600; flex: 1; }
.status { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.status.ok { background: var(--ok); } .status.warn { background: var(--warn); } .status.broken { background: var(--danger); }
.when { font-size: 13px; font-variant-numeric: tabular-nums; }
.when.soon { color: var(--warn); font-weight: 600; } .when.late { color: var(--danger); font-weight: 600; }
.secret details { margin-top: 6px; font-size: 14px; }
.secret summary { color: var(--muted); cursor: pointer; font-size: 13px; }
.switch { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; flex: none; margin: 0; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: left .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { left: 18px; }
code, pre { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--chip); border-radius: 6px; }
code { padding: 1px 5px; } pre { padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }

.locked { text-align: center; padding: 40px 16px; }
.locked .big { font-size: 34px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--chip-on); color: var(--chip-on-text); padding: 9px 16px; border-radius: 999px; font-size: 14px; z-index: 9; }

/* sign-in */
.signin { max-width: 380px; margin: 14vh auto 0; padding: 0 16px; text-align: center; }
.signin h1 { font-size: 26px; margin: 10px 0 4px; }
.signin p { color: var(--muted); margin: 0 0 22px; }
.signin button.primary { width: 100%; padding: 14px; font-size: 17px; border-radius: 14px; }
.signin .err { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 12px; }
.signin form { display: grid; gap: 10px; margin-top: 18px; text-align: left; }
