/* ============================================================
   AgendaAI — styles
   ============================================================ */

:root {
  /* ---- Surface ---- */
  --bg: #f2f2f7;              /* iOS gray page — this is what makes white cards separate */
  --card: #ffffff;            /* primary surface */
  --surface-inset: #ececf1;   /* inset surfaces (wheel bg, input bg, pill bg) */
  --separator: rgba(60, 60, 67, 0.12);   /* hairlines between grouped rows */

  /* Legacy aliases — kept so existing rules continue to resolve */
  --panel: var(--card);
  --panel-2: #f9f9fb;
  --panel-3: var(--surface-inset);
  --border: var(--separator);
  --border-strong: rgba(60, 60, 67, 0.2);

  /* ---- Ink ---- */
  --text-primary:   #1c1c1e;
  --text-secondary: rgba(60, 60, 67, 0.6);
  --text-tertiary:  rgba(60, 60, 67, 0.3);
  --text:        var(--text-primary);
  --text-strong: #000000;
  --muted:       var(--text-secondary);
  --muted-2:     var(--text-tertiary);

  /* ---- Accent (single — change this one variable to rebrand) ---- */
  --accent:      #0a84ff;     /* iOS blue */
  --accent-2:    #409cff;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --accent-dim:  var(--accent-soft);

  /* ---- Semantic ---- */
  --danger:     #ff3b30;
  --danger-dim: rgba(255, 59, 48, 0.12);
  --ok:         #34c759;
  --ok-dim:     rgba(52, 199, 89, 0.12);
  /* Focus session-type accent — purple for Reading. Must match the scatter's
     JS target FOCUS_SCATTER_READING = rgb(138,92,224). */
  --focus-reading: #8a5ce0;

  /* ---- Priority — DISTINCT from --accent so the amber bar won't clash if accent changes ---- */
  --prio-high:   #ff3b30;
  --prio-medium: #ff9f0a;
  --prio-normal: #c7c7cc;

  /* ---- Radii ---- */
  --r-card:  14px;
  --r-pill:  10px;
  --r-sheet: 20px;

  /* Legacy radius aliases */
  --radius-sm: 10px;
  --radius:    var(--r-card);
  --radius-lg: var(--r-card);
  --radius-xl: var(--r-sheet);

  /* ---- Elevation — soft and low ---- */
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow:      0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg:   0 12px 36px rgba(0, 0, 0, 0.14);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);

  /* ---- Typography ---- */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  /* Reading font for My Code content — Verdana for its large x-height and open
     apertures (maximal small-screen legibility). System font everywhere; no
     web-font dependency. */
  --font-reading: Verdana, Geneva, Tahoma, sans-serif;
  --num: "tnum";
}

/* ---------- Reset & base ---------- */

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
}
body {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }
::selection { background: var(--accent-dim); }

/* ---------- Layout shell ---------- */

.topbar {
  padding: env(safe-area-inset-top, 0) 20px 0;
  background: rgba(242, 242, 247, 0.78);
  border-bottom: 1px solid var(--separator);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.topbar-inner {
  display: flex; align-items: flex-end; justify-content: space-between;
  min-height: 72px; padding: 16px 0 12px;
  gap: 12px;
}
.topbar h1 {
  font-size: 11px; font-weight: 600; margin: 0 0 4px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}
.topbar .date {
  color: var(--text-primary); font-size: 30px; font-weight: 800;
  margin-top: 0; letter-spacing: -0.02em; line-height: 1.02;
  font-feature-settings: var(--num);
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }

main {
  flex: 1; overflow-y: auto;
  padding: 16px 18px calc(100px + env(safe-area-inset-bottom, 0));
  max-width: 720px; width: 100%; margin: 0 auto;
}

.tab-view { display: none; }
.tab-view.active { display: block; }

.botnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(242, 242, 247, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0));
  z-index: 5;
}
.botnav button {
  background: transparent; border: none;
  color: var(--text-tertiary); font-size: 11px;
  padding: 8px 4px; cursor: pointer; min-height: 44px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.15s;
}
.botnav button:hover { color: var(--text-secondary); }
.botnav button.active { color: var(--accent); }

/* ---------- Buttons ---------- */

.btn {
  border: none; border-radius: var(--r-pill);
  background: var(--surface-inset); color: var(--text-primary);
  padding: 10px 16px; font-size: 15px; font-weight: 600;
  cursor: pointer;
  min-height: 44px; min-width: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 0.15s, transform 0.05s, opacity 0.15s;
  letter-spacing: -0.005em;
}
.btn:hover  { background: #e0e0e6; }
.btn:active { transform: scale(0.98); opacity: 0.85; }
.btn-primary {
  background: var(--accent); color: white;
  box-shadow: 0 1px 2px rgba(10, 132, 255, 0.20);
}
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost  { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }

/* ---------- Banner ---------- */

.banner {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
  font-size: 13px; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.banner button {
  background: transparent; border: none; color: var(--accent);
  cursor: pointer; font-size: 13px; padding: 6px;
  font-weight: 500;
}

/* ---------- Timeline rows ---------- */

.empty {
  padding: 64px 24px; text-align: center;
  color: var(--muted); font-size: 14px; line-height: 1.6;
}

.item-row {
  background: var(--card);
  border: 1px solid var(--separator);
  border-left: 3px solid transparent;
  border-radius: var(--r-card);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer;
  min-height: 56px;
  transition: background 0.15s, transform 0.05s;
  box-shadow: var(--shadow-card);
}
.item-row:hover  { background: #fafafd; }
.item-row:active { transform: scale(0.997); }

/* Priority left bar — applied for items by JS; habits get a soft accent edge */
.item-row[data-kind="habit"] { border-left-color: var(--accent-soft); }
.item-row.prio-high   { border-left-color: var(--prio-high); }
.item-row.prio-medium { border-left-color: var(--prio-medium); }
.item-row.prio-normal { border-left-color: var(--prio-normal); }

.item-time {
  font-size: 13px; color: var(--text-secondary);
  min-width: 64px;
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
  font-weight: 500;
}
.item-body { flex: 1; min-width: 0; }
.item-title {
  font-size: 17px; font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.25;
}
.item-meta {
  font-size: 13px; color: var(--text-secondary); margin-top: 3px;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}

.item-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-inset); color: var(--text-secondary);
  letter-spacing: 0.04em; font-weight: 600;
  font-family: var(--font-mono); text-transform: lowercase;
}
.badge-kind { background: var(--accent-soft); color: var(--accent); }

/* Done / skipped states */
.item-row.done .item-title {
  text-decoration: line-through;
  color: var(--text-tertiary);
}
.item-row.done .item-time { opacity: 0.5; }
.item-row.done           { opacity: 0.6; }
.item-row.done .item-check {
  background: var(--accent); color: white;
  border-color: var(--accent);
}
.item-row.skipped .item-title { color: var(--text-tertiary); opacity: 0.8; }
.item-row.skipped { opacity: 0.7; }
.item-row.skipped .item-check {
  background: var(--surface-inset);
  color: var(--text-tertiary);
}
.item-check {
  font-size: 14px;
  width: 22px; height: 22px;
  text-align: center; line-height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--text-tertiary);
  color: transparent;
  flex-shrink: 0;
}

/* ---------- Modals (shared) ---------- */

.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.32);
  display: none; align-items: flex-end; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal.open { display: flex; }
.modal-panel {
  position: relative;
  background: rgba(255, 255, 255, 0.96);
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  width: 100%; max-width: 560px; max-height: 92vh;
  overflow-y: auto;
  padding: 28px 20px calc(20px + env(safe-area-inset-bottom, 0));
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--separator);
  border-bottom: none;
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
}
/* iOS-style grabber handle at the top of every bottom-sheet */
.modal-panel::before {
  content: '';
  position: absolute;
  top: 8px; left: 50%;
  width: 36px; height: 5px;
  transform: translateX(-50%);
  background: var(--text-tertiary);
  border-radius: 999px;
  opacity: 0.6;
  pointer-events: none;
}
.modal-panel h2 {
  margin: 0 0 16px; font-size: 20px; font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

/* ---------- Forms ---------- */

label {
  display: block; font-size: 11px;
  color: var(--text-tertiary); margin-bottom: 6px;
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
}
.field { margin-bottom: 16px; }

/* Add-item sheet: even vertical rhythm across every field group (Title, Someday,
   Date, All-day, Time, Duration, Priority, Notes) — uniform gap + label spacing. */
#form-modal .field { margin: 0 0 18px; }
#form-modal .field > label { margin-bottom: 8px; }
#form-modal .field > label.toggle-row { margin-bottom: 0; }
#form-modal #item-fields { margin-bottom: 0; }
#form-modal #item-fields > .field:last-child { margin-bottom: 18px; }
input[type="text"], input[type="time"], input[type="date"],
input[type="number"], textarea, select {
  width: 100%;
  background: var(--surface-inset); color: var(--text-primary);
  border: 1px solid transparent; border-radius: var(--r-pill);
  padding: 11px 12px; font-size: 15px;
  min-height: 44px;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  background: var(--card);
}
textarea { min-height: 80px; resize: vertical; line-height: 1.4; }

.type-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; margin-bottom: 16px;
  background: var(--surface-inset); padding: 3px;
  border-radius: var(--r-pill);
}
/* Add-item type selector holds exactly two tabs (To-do, Event) — no blank
   third slot left over from the removed Habit tab. Scoped so #vault-type-tabs
   (3) and #block-type-tabs (5, wrapping) keep the base 3-column layout. */
#type-tabs { grid-template-columns: repeat(2, 1fr); }
/* WHEN control (to-do only): two half-width options, reuses .type-tabs.
   minmax(0,1fr) keeps each option from overflowing on a 360px screen. */
.when-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.when-tabs button { min-height: 44px; white-space: nowrap; }
.type-tabs button {
  background: transparent; border: none;
  color: var(--text-secondary); padding: 8px;
  border-radius: 8px; font-size: 13px;
  cursor: pointer; min-height: 36px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.type-tabs button.active {
  background: var(--card); color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.days-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.day-btn {
  background: var(--surface-inset); border: 1px solid transparent;
  color: var(--text-secondary); padding: 10px 0;
  border-radius: var(--r-pill); font-size: 13px;
  cursor: pointer; min-height: 44px;
  text-align: center; font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.day-btn.active {
  background: var(--accent); color: white; border-color: var(--accent);
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.preset-row {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px;
}
.preset-btn {
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--muted); border-radius: var(--radius-sm);
  padding: 6px 11px; font-size: 12px;
  cursor: pointer; font-weight: 500;
}
.preset-btn:hover { color: var(--text); }

.form-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.form-actions .spacer { flex: 1; }

.error-msg {
  color: var(--danger); font-size: 13px;
  margin-top: 8px; padding: 9px 11px;
  background: var(--danger-dim);
  border: 1px solid rgba(239, 91, 107, 0.22);
  border-radius: var(--radius-sm);
}

/* ---------- Wheel time picker ---------- */

.wheel-picker {
  position: relative;
  display: flex;
  height: 180px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.wheel-col {
  flex: 1;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-mask-image: linear-gradient(to bottom,
    transparent 0%, black 28%, black 72%, transparent 100%);
  mask-image: linear-gradient(to bottom,
    transparent 0%, black 28%, black 72%, transparent 100%);
}
.wheel-col::-webkit-scrollbar { display: none; }
.wheel-col + .wheel-col { border-left: 1px solid var(--border); }
.wheel-item {
  height: 36px;
  display: flex; align-items: center; justify-content: center;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  font-size: 17px;
  color: var(--muted-2);
  font-feature-settings: var(--num);
  cursor: pointer;
  transition: color 0.15s;
}
.wheel-item.selected {
  color: var(--text); font-weight: 600;
  font-size: 19px;
}
.wheel-overlay {
  position: absolute;
  top: 50%; left: 8px; right: 8px;
  height: 36px;
  transform: translateY(-50%);
  pointer-events: none;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
}

/* ---------- Morning popup (blocking) ---------- */

.modal-blocking {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  align-items: center;
}
.modal-blocking .modal-panel {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  margin: 0 16px;
  max-height: 88vh;
}

.scale {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
}
.scale-btn {
  background: var(--surface-inset); border: 1px solid transparent;
  color: var(--text-secondary); padding: 12px 0;
  border-radius: var(--r-pill); font-size: 15px; font-weight: 600;
  cursor: pointer; min-height: 44px;
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
  transition: background 0.15s;
}
.scale-btn.active {
  background: var(--accent); color: white; border-color: var(--accent);
}
.scale-labels {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-tertiary); margin-top: 6px;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-family: var(--font-mono); font-weight: 600;
}

.flags-row {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.flag-chip {
  background: var(--surface-inset); border: 1px solid transparent;
  color: var(--text-secondary); padding: 8px 14px;
  border-radius: 999px; font-size: 13px;
  cursor: pointer; min-height: 36px;
  font-weight: 600;
}
.flag-chip.active {
  background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent);
}

.popup-meta {
  font-size: 13px; color: var(--muted);
  margin: -8px 0 16px;
}

/* ---------- Summary panels ---------- */

.summary-panel {
  background: var(--card); border: 1px solid var(--separator);
  border-radius: var(--r-card); padding: 18px; margin-top: 16px;
  box-shadow: var(--shadow-card);
}
.summary-panel h3 {
  margin: 0 0 14px; font-size: 11px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  font-family: var(--font-mono);
}
.summary-pct {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px;
}
.summary-pct .big {
  font-size: 36px; font-weight: 800; color: var(--text-primary);
  font-family: var(--font-mono);
  font-feature-settings: var(--num); letter-spacing: -0.03em;
  line-height: 1;
}
.summary-pct .label { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.pct-bar {
  height: 6px; background: var(--surface-inset); border-radius: 3px;
  overflow: hidden; margin-bottom: 16px;
}
.pct-bar .fill {
  height: 100%; background: var(--accent);
  transition: width 0.3s;
  border-radius: 3px;
}
.summary-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; font-size: 14px;
  border-top: 1px solid var(--separator);
}
.summary-row:first-of-type { border-top: none; padding-top: 4px; }
.summary-row .k { color: var(--text-secondary); }
.summary-row .v {
  color: var(--text-primary); text-align: right;
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
}
.summary-list {
  margin: 4px 0 0; padding-left: 18px;
  font-size: 13px; color: var(--text);
}
.summary-list li { padding: 2px 0; }
.streak-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; font-size: 14px;
}
.streak-row .count {
  background: var(--accent-soft); padding: 3px 10px;
  border-radius: 999px; font-weight: 600; color: var(--accent);
  font-family: var(--font-mono);
  font-feature-settings: var(--num); font-size: 12px;
}
.streak-row .count.broken { background: var(--danger-dim); color: var(--danger); }

/* ---------- Current-streak board (This Week card) ---------- */

.streak-board {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 2px;
}
.streak-chip {
  display: flex; flex-direction: column; align-items: center;
  min-width: 64px; padding: 10px 12px;
  background: var(--accent-soft); border-radius: var(--r-card);
}
.streak-num {
  font-size: 26px; font-weight: 800; color: var(--accent);
  font-family: var(--font-mono);
  font-feature-settings: var(--num); letter-spacing: -0.03em; line-height: 1;
}
.streak-name {
  margin-top: 4px; font-size: 11px; color: var(--text-secondary);
  text-align: center; max-width: 88px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.streak-empty {
  padding: 8px 0 2px; font-size: 13px; color: var(--text-secondary);
}

/* ---------- Off-track 7-day mini-trend (Focus card) ---------- */

.offtrack-mini {
  display: flex; gap: 6px; align-items: flex-end;
  padding: 6px 0 2px;
}
.offtrack-mini-col {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.offtrack-mini-track {
  width: 100%; height: 44px; display: flex; align-items: flex-end;
  background: var(--surface-inset); border-radius: 5px; overflow: hidden;
}
.offtrack-mini-fill {
  width: 100%; min-height: 2px; background: var(--accent);
  border-radius: 5px 5px 0 0; transition: height 0.3s;
}
.offtrack-mini-val {
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  font-family: var(--font-mono); font-feature-settings: var(--num);
}
.offtrack-mini-day {
  font-size: 10px; color: var(--text-tertiary); text-transform: uppercase;
}

/* ---------- All-time history (live, read-only, collapsed) ---------- */

.alltime-panel { padding: 0; overflow: hidden; }
.alltime-toggle {
  width: 100%; min-height: 48px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: transparent; border: none; padding: 16px 18px;
  cursor: pointer; text-align: left;
}
.alltime-toggle:hover { background: var(--surface-inset); }
.alltime-title {
  font-size: 11px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  font-family: var(--font-mono);
}
.alltime-chevron {
  color: var(--text-tertiary); font-size: 20px; line-height: 1;
  transition: transform 0.2s;
}
.alltime-panel.open .alltime-chevron { transform: rotate(90deg); }
.alltime-body { padding: 0 18px 16px; }
.alltime-caption {
  margin: 0 0 12px; font-size: 12px; color: var(--text-tertiary);
  line-height: 1.45;
}
.alltime-history-list { margin-top: 10px; }
.alltime-history-list .item-row:first-child { margin-top: 0; }

/* ---------- Sleep card (Today) + Sleep stats (Stats) ---------- */

.sleep-card {
  background: var(--card); border: 1px solid var(--separator);
  border-radius: var(--r-card); padding: 14px 16px 12px;
  margin-bottom: 12px; box-shadow: var(--shadow-card);
}
.sleep-label {
  font-size: 11px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  font-family: var(--font-mono); margin-bottom: 8px;
}
.sleep-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 44px;
}
.sleep-text { font-size: 15px; color: var(--text-secondary); }
.sleep-value { color: var(--text-primary); font-weight: 600; }
.sleep-bedtime-input { width: auto; max-width: 130px; min-width: 110px; min-height: 44px; }

.sleep-substrip-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--text-tertiary); font-family: var(--font-mono);
  margin: 12px 0 2px;
}
.sleep-week {
  display: flex; gap: 6px; padding: 6px 0 2px;
}
/* Morning-popup inline validation warning (blocks save; user re-picks). */
.mc-warn { margin-top: 8px; font-size: 12px; color: var(--danger); line-height: 1.35; }
.sleep-week-col {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.sleep-week-val {
  font-size: 11px; font-weight: 600; color: var(--text-primary);
  font-family: var(--font-mono); font-feature-settings: var(--num);
  text-align: center;
}
.sleep-week-val.unset { color: var(--text-tertiary); font-weight: 500; }
.sleep-week-val.impl { color: var(--danger); }   /* implausible (daytime) bedtime — shown but flagged */
.sleep-warn {
  margin-top: 8px; font-size: 12px; color: var(--danger);
  line-height: 1.35;
}
.sleep-week-day {
  font-size: 10px; color: var(--text-tertiary); text-transform: uppercase;
}

/* ---- Night-aligned sleep strip (horizontally scrollable) ---- */
.sleep-nights-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 10px 0 4px; padding-bottom: 4px;
  scrollbar-width: thin;
}
.sleep-nights-row { display: flex; gap: 8px; width: max-content; }
.sleep-night {
  flex: 0 0 auto; min-width: 88px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 12px 10px; background: var(--surface-inset);
  border-radius: var(--r-card); text-align: center;
}
.sleep-night.bad { opacity: 0.55; }
.sleep-night-day {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-tertiary); font-family: var(--font-mono);
  white-space: nowrap; margin-bottom: 3px;
}
.sleep-night-bed, .sleep-night-wake {
  font-size: 14px; color: var(--text-secondary);
  font-family: var(--font-mono); font-feature-settings: var(--num); white-space: nowrap;
}
.sleep-night-hours {
  font-size: 16px; font-weight: 800; color: var(--text-primary);
  font-family: var(--font-mono); font-feature-settings: var(--num); white-space: nowrap;
}
.sleep-night-bed.danger, .sleep-night-hours.danger { color: var(--danger); }
.sleep-night-caption {
  margin: 8px 0 0; font-size: 11px; color: var(--text-tertiary); line-height: 1.4;
}

/* ---------- Action sheet ---------- */

.action-panel {
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
}
.action-title {
  font-size: 17px; font-weight: 600;
  padding: 4px 0 14px; text-align: center;
  border-bottom: 1px solid var(--separator);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.action-btn {
  display: block; width: 100%;
  background: transparent; color: var(--accent);
  border: none; padding: 16px;
  font-size: 17px; cursor: pointer;
  border-radius: var(--r-card);
  text-align: center;
  font-weight: 500;
}
.action-btn:hover { background: var(--accent-soft); }
.action-btn.primary { color: var(--accent); font-weight: 600; }
.action-btn.danger  { color: var(--danger); }
.action-btn.danger:hover { background: var(--danger-dim); }
.action-btn.cancel {
  margin-top: 8px;
  background: var(--surface-inset);
  color: var(--text-primary);
  font-weight: 600;
}
.action-btn.cancel:hover { background: #e0e0e6; }

/* ---------- Settings ---------- */

.settings-section {
  background: var(--card); border: 1px solid var(--separator);
  border-radius: var(--r-card); padding: 4px 16px; margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}
.settings-section h3 {
  margin: 0 0 8px 4px; font-size: 11px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  font-family: var(--font-mono);
  /* iOS-style: caption sits OUTSIDE the card, above it */
  position: relative; top: -32px; height: 0;
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 0;
  border-top: 1px solid var(--separator);
  font-size: 15px;
}
.settings-row:first-of-type { border-top: none; }
.settings-row .meta {
  color: var(--text-secondary); font-size: 13px; margin-top: 2px;
}

/* ---------- Calendar ---------- */

.calendar-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; padding: 4px 0;
}
.calendar-header h2 {
  margin: 0; font-size: 20px; font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}
.calendar-nav-btn {
  background: var(--card); border: 1px solid var(--separator);
  color: var(--text-primary);
  width: 36px; height: 36px;
  border-radius: var(--r-pill);
  font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.calendar-nav-btn:hover { background: var(--surface-inset); }

.calendar-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px; margin-bottom: 8px;
}
.calendar-weekdays span {
  text-align: center; font-size: 11px;
  color: var(--text-tertiary); padding: 4px 0;
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
}

.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-day {
  position: relative;
  aspect-ratio: 1 / 1;
  background: transparent;
  border: none;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 16px; font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.calendar-day:hover { background: var(--surface-inset); }
.calendar-day.other-month {
  color: var(--text-tertiary);
}
.calendar-day.today {
  background: var(--accent);
  color: white;
  font-weight: 700;
}
.calendar-day.selected:not(.today) {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

/* Completion tint indicator as a small dot at the bottom of each cell */
.calendar-day.high::after,
.calendar-day.mid::after,
.calendar-day.low::after {
  content: ''; position: absolute;
  bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
}
.calendar-day.high::after { background: var(--ok); }
.calendar-day.mid::after  { background: var(--prio-medium); }
.calendar-day.low::after  { background: var(--prio-high); }
.calendar-day.today::after,
.calendar-day.selected:not(.today)::after { background: currentColor; opacity: 0.7; }

/* Stop the old "fill the cell" tint behavior */
.calendar-day.high,
.calendar-day.mid,
.calendar-day.low {
  background: transparent;
}
.calendar-day.today.high,
.calendar-day.today.mid,
.calendar-day.today.low { background: var(--accent); }
.calendar-day.selected:not(.today).high,
.calendar-day.selected:not(.today).mid,
.calendar-day.selected:not(.today).low { background: var(--accent-soft); }

.calendar-day .dot { display: none; }

.calendar-detail {
  margin-top: 24px;
}
.calendar-detail h3 {
  margin: 0 0 6px; font-size: 20px; font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.015em;
}
.calendar-detail .meta {
  font-size: 13px; color: var(--text-secondary); margin-bottom: 16px;
}
.cal-add-btn {
  width: 100%; margin-bottom: 14px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: calc(96px + env(safe-area-inset-bottom, 0));
  left: 50%; transform: translateX(-50%);
  background: rgba(28, 28, 30, 0.92);
  color: white;
  padding: 12px 18px; border-radius: var(--r-pill);
  font-size: 14px; z-index: 200;
  max-width: min(92vw, 420px); white-space: normal; text-align: center;   /* long toasts wrap inside the viewport, never clip at 320px */
  opacity: 0; transition: opacity 0.2s;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; }

/* ---------- Unified item form (v2 merge) ---------- */
.toggle-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--surface-inset);
  border-radius: var(--r-card);
  border: 1px solid transparent;
  font-size: 15px; color: var(--text-primary);
  text-transform: none; letter-spacing: 0;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  margin-bottom: 0;
}
.toggle-row input[type="checkbox"] {
  width: 20px; height: 20px;
  min-height: 20px;
  margin: 0; padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.priority-select {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--surface-inset); padding: 3px;
  border-radius: var(--r-pill);
}
.prio-btn {
  background: transparent; border: none;
  color: var(--text-secondary); padding: 8px;
  border-radius: 8px; font-size: 13px;
  cursor: pointer; min-height: 36px;
  font-weight: 600;
  font-family: var(--font-sans);
  transition: background 0.15s, color 0.15s;
}
.prio-btn.active {
  background: var(--card); color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.prio-btn[data-prio="high"].active   { color: var(--prio-high); }
.prio-btn[data-prio="medium"].active { color: var(--prio-medium); }

/* ---------- All-day band on timeline ---------- */
.allday-band {
  background: var(--card); border: 1px solid var(--separator);
  border-radius: var(--r-card); padding: 10px 14px 6px;
  margin-bottom: 12px; box-shadow: var(--shadow-card);
}
.allday-label {
  font-size: 10px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700; font-family: var(--font-mono);
  margin-bottom: 6px;
}
.allday-band .item-row {
  margin-bottom: 4px;
  padding: 8px 10px;
  min-height: 44px;
  box-shadow: none;
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  border-radius: 8px;
}
.allday-band .item-row:hover { background: var(--surface-inset); }
.allday-band .item-row:last-child { margin-bottom: 0; }
.allday-band .item-time { display: none; }

/* ---------- Account & Backup (Supabase sync) ---------- */
.account-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 4px; padding-bottom: 12px;
}
.sync-status-line {
  padding: 12px 0 0;
  border-top: 1px solid var(--separator);
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
#account-signed-in .settings-row { padding: 12px 0; border-top: none; }

.reminder-time-input { width: auto; max-width: 130px; min-width: 110px; }
#account-email-display { font-weight: 600; color: var(--text-primary); font-size: 15px; }

/* ---------- Upcoming tab ---------- */
.upcoming-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; padding: 4px 0 8px;
}
.upcoming-h {
  margin: 0; font-size: 30px; font-weight: 800;
  letter-spacing: -0.02em; color: var(--text-primary);
}

.upcoming-group { margin-bottom: 24px; }
.upcoming-group:last-child { margin-bottom: 0; }
.upcoming-group-header {
  font-size: 11px; color: var(--text-tertiary);
  font-weight: 600; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin: 0 0 10px 4px;
}

.upcoming-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--separator);
  border-left: 3px solid transparent;
  border-radius: var(--r-card);
  padding: 14px 16px;
  margin-bottom: 8px;
  min-height: 56px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: background 0.15s, transform 0.05s;
}
.upcoming-row:hover  { background: #fafafd; }
.upcoming-row:active { transform: scale(0.997); }

/* Priority left bar — reusable, applied here and on .item-row */
.prio-high   { border-left-color: var(--prio-high); }
.prio-medium { border-left-color: var(--prio-medium); }
.prio-normal { border-left-color: var(--prio-normal); }

.upcoming-check {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.75px solid var(--text-tertiary);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s, border-color 0.15s;
}
.upcoming-check:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upcoming-check-spacer { width: 24px; flex-shrink: 0; }

.upcoming-row-body { flex: 1; min-width: 0; }
.upcoming-title {
  font-size: 17px; font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.25;
}
.upcoming-meta {
  display: flex; gap: 10px;
  font-size: 13px; margin-top: 4px;
  align-items: center; flex-wrap: wrap;
}

.relative-label {
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
}
.rel-overdue { color: var(--prio-high);    font-weight: 600; }
.rel-soon    { color: var(--text-primary); font-weight: 600; }
.rel-later   { color: var(--text-secondary); }

.upcoming-time {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
}

.upcoming-row.is-event .upcoming-meta::after {
  content: 'event';
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: auto;
}

/* ---------- Intention card (Today tab) ---------- */
.intention-card {
  background: var(--card);
  border: 1px solid var(--separator);
  border-radius: var(--r-card);
  padding: 14px 16px 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}
.intention-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  font-family: var(--font-mono);
  margin-bottom: 8px;
}
.intention-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.intention-input {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 8px 0;
  min-height: 44px;
  border-radius: 0;
  transition: color 0.15s, opacity 0.15s;
}
.intention-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 500;
}
.intention-input:focus {
  outline: none;
  background: transparent;
  border-color: transparent;
}
.intention-card.done .intention-input {
  text-decoration: line-through;
  color: var(--text-tertiary);
  opacity: 0.7;
}
.intention-check {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  /* The actual circle is drawn by a 24x24 inner box (via background-image + border) on the button itself,
     centered by flex layout — content (the checkmark) sits on top of that background. */
  background-image: radial-gradient(circle at center, transparent 12px, transparent 12px);
  font-size: 14px;
  font-weight: 700;
  color: transparent;
  position: relative;
}
.intention-check .intention-check-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.75px solid var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: transparent;
  font-weight: 700;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.intention-check.checked .intention-check-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ---------- Focus card (Today tab) ---------- */
.focus-card {
  background: var(--card);
  border: 1px solid var(--separator);
  border-radius: var(--r-card);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.focus-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  font-family: var(--font-mono);
}
.focus-summary {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.focus-start-btn {
  width: 100%;
  min-height: 48px;
}

/* ---------- Focus overlay (full-screen) ---------- */
.modal.focus-overlay-mode {
  background: var(--bg);
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.focus-overlay-panel {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  padding:
    calc(24px + env(safe-area-inset-top, 0))
    18px
    calc(24px + env(safe-area-inset-bottom, 0));
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 720px;
  margin: 0 auto;
}
.focus-overlay-intention {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 4px 12px;
}
.focus-overlay-intention strong {
  color: var(--text-primary);
  font-weight: 700;
}
.focus-tap-zone {
  flex: 1;
  width: 100%;
  min-height: 320px;
  background: var(--accent-soft);
  border: 1.5px solid rgba(10, 132, 255, 0.18);
  border-radius: var(--r-sheet);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  padding: 24px;
  color: var(--accent);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, transform 0.05s;
}
.focus-tap-zone:active {
  transform: scale(0.998);
  background: rgba(10, 132, 255, 0.18);
}
.focus-tap-zone.pulse {
  animation: focus-tap-pulse 0.32s ease-out;
}
@keyframes focus-tap-pulse {
  0%   { background: rgba(10, 132, 255, 0.28); }
  100% { background: var(--accent-soft); }
}
.focus-count {
  font-size: 96px;
  line-height: 1;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
  letter-spacing: -0.04em;
}
.focus-count-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-bottom: 12px;
}
.focus-timer {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
  letter-spacing: -0.01em;
}
.focus-tap-hint {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 14px;
  text-align: center;
  max-width: 280px;
  line-height: 1.4;
  font-weight: 500;
}
.focus-controls {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 8px;
}
.focus-control-btn {
  min-height: 52px;
  font-size: 15px;
}

/* ---------- Focus stats (Stats tab) ---------- */
.focus-stats-panel { /* uses .summary-panel base */ }
.focus-session-row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
  border-top: 1px solid var(--separator);
}
.focus-session-row:first-of-type { border-top: none; }
.focus-session-time {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
  font-size: 13px;
}
.focus-session-dur {
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
}
.focus-session-lapses {
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
  text-align: right;
}
.focus-trend-row {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}
.focus-trend-day {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
}
.focus-trend-bar {
  background: var(--surface-inset);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}
.focus-trend-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}
.focus-trend-rate {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}
.focus-stats-note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  padding: 10px 12px;
  background: var(--surface-inset);
  border-radius: var(--r-pill);
}

/* ---------- Focus doorway — feedback (headline, tiles, scatter) ---------- */
.focus-headline { display: flex; align-items: baseline; gap: 10px; margin: 2px 0 4px; }
.focus-headline-num {
  font-size: 44px; font-weight: 800; line-height: 1; color: var(--text-primary);
  font-family: var(--font-mono); font-feature-settings: var(--num); letter-spacing: -0.03em;
}
.focus-headline-unit { font-size: 13px; color: var(--text-secondary); font-weight: 500; }
.focus-nudge { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; }
.focus-nudge.improving { color: var(--ok); }
.focus-nudge.worse { color: var(--text-secondary); }

.focus-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 6px; }
.focus-tile {
  background: var(--surface-inset); border-radius: var(--r-card);
  padding: 12px 8px; text-align: center;
}
.focus-tile-val {
  font-size: 20px; font-weight: 700; color: var(--text-primary); line-height: 1.1;
  font-family: var(--font-mono); font-feature-settings: var(--num);
}
.focus-tile-label { font-size: 11px; color: var(--text-secondary); margin-top: 4px; overflow-wrap: anywhere; }

.focus-scatter-head, .focus-log-head {
  margin: 18px 0 6px; font-size: 11px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; font-family: var(--font-mono);
}
.focus-scatter-svg { display: block; width: 100%; height: auto; margin: 2px 0; touch-action: none; }
.fs-zone { fill: var(--ok); opacity: 0.10; }
.fs-zone-label { font-size: 9px; fill: var(--ok); font-family: var(--font-mono); opacity: 0.9; }
.fs-axis-line { stroke: var(--separator); stroke-width: 1; }
.fs-axis { font-size: 9px; fill: var(--text-tertiary); font-family: var(--font-mono); }
.fs-dot { stroke: var(--card); stroke-width: 0.5; }
.fs-ring { fill: none; stroke: var(--accent); stroke-width: 1.5; opacity: 0.85; }
.focus-legend { font-size: 11px; color: var(--text-tertiary); margin: 6px 0 2px; line-height: 1.4; }
.focus-scatter-empty { padding: 20px 0; }

/* ---------- Focus: tappable session rows + per-session detail ---------- */
.focus-session-row-btn {
  width: 100%; min-height: 44px;
  background: none; border: none; border-top: 1px solid var(--separator);
  border-radius: 0; font: inherit; color: inherit; cursor: pointer;
  text-align: left; -webkit-appearance: none; appearance: none;
}
.focus-session-row-btn:first-of-type { border-top: none; }
.focus-session-row-btn:active { background: var(--surface-inset); }

.focus-detail-head { display: flex; align-items: center; gap: 10px; margin: -2px 0 12px; }
.focus-back {
  min-height: 44px; min-width: 44px; padding: 0 6px 0 0;
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; -webkit-appearance: none; appearance: none;
}
.focus-detail-title {
  margin: 0; font-size: 15px; font-weight: 700; color: var(--text-primary);
  text-transform: none; letter-spacing: 0; font-family: inherit;
}
.focus-timeline-svg { display: block; width: 100%; height: auto; margin: 2px 0; }
.focus-timeline-bar { fill: var(--danger); }
.focus-detail-note {
  margin: 10px 0 2px; font-size: 12px; line-height: 1.5;
  padding: 10px 12px; background: var(--surface-inset); border-radius: var(--r-pill);
}
.focus-detail-note.muted { color: var(--text-secondary); }
.focus-detail-note.clean { color: var(--ok); }
/* Quiet full-width destructive action — matches .action-btn.danger language. */
.focus-delete-btn {
  display: block; width: 100%; margin-top: 18px;
  min-height: 44px; padding: 12px;
  background: transparent; border: none; cursor: pointer;
  color: var(--danger); font-size: 15px; font-weight: 600;
  border-radius: var(--r-card);
  -webkit-appearance: none; appearance: none;
}
.focus-delete-btn:hover { background: var(--danger-dim); }

/* ---------- Focus session types (Work / Reading) ---------- */
/* Picker on the Focus card — two tabs, so override .type-tabs' 3-col grid. */
.focus-type-tabs { grid-template-columns: repeat(2, 1fr); margin: 4px 0 12px; }
/* Small colored dot before a typed session's date in the recent-sessions log. */
.focus-type-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: baseline;
}
.focus-type-work    { background: var(--accent); }
.focus-type-reading { background: var(--focus-reading); }
/* Muted type suffix on the detail page title (e.g. "· Reading"). */
.focus-detail-type { color: var(--text-secondary); font-weight: 500; font-size: 0.9em; }

/* ---------- Off-track chip (top bar) ---------- */
.off-track-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-inset);
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 11px;
  min-height: 44px;
  min-width: 44px;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.off-track-chip:active { transform: scale(0.96); }
.off-track-chip:hover  { background: #e0e0e6; }
.off-track-chip-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  line-height: 1;
}
.off-track-chip-count {
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.01em;
  min-width: 10px;
  text-align: center;
}
.off-track-chip.has-count {
  background: rgba(255, 159, 10, 0.14);
  border-color: rgba(255, 159, 10, 0.28);
}
.off-track-chip.has-count .off-track-chip-label { color: var(--prio-medium); }
.off-track-chip.has-count .off-track-chip-count { color: var(--prio-medium); }
.off-track-chip.has-count:hover { background: rgba(255, 159, 10, 0.2); }

.off-track-chip.pulse { animation: off-track-pulse 0.34s ease-out; }
@keyframes off-track-pulse {
  0%   { background: rgba(255, 159, 10, 0.32); transform: scale(1.06); }
  60%  { transform: scale(1.02); }
  100% { background: rgba(255, 159, 10, 0.14); transform: scale(1); }
}

/* ---------- Off-track in Stats Focus section ---------- */
.off-track-today-row .v {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.off-track-today-num {
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
  font-weight: 700;
  color: var(--prio-medium);
  font-size: 17px;
  letter-spacing: -0.01em;
}
.off-track-correct-btn {
  background: var(--surface-inset);
  color: var(--text-primary);
  border: none;
  border-radius: var(--r-pill);
  padding: 6px 12px;
  min-height: 32px;
  min-width: 44px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.off-track-correct-btn:hover:not([disabled]) { background: #e0e0e6; }
.off-track-correct-btn[disabled] { opacity: 0.4; cursor: default; }

.off-track-trend-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}
.off-track-trend-day {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12px;
}
.off-track-trend-count {
  color: var(--prio-medium);
  font-family: var(--font-mono);
  font-feature-settings: var(--num);
  font-size: 14px;
  font-weight: 700;
  text-align: right;
}

/* ============================================================================
   The Vault — personal finances
   ========================================================================== */

/* ---- Today entry card ---- */
.vault-entry-card {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--separator);
  border-radius: var(--r-card); padding: 16px;
  box-shadow: var(--shadow-card); cursor: pointer;
  margin-bottom: 12px; min-height: 64px;
  text-align: left;
}
.vault-entry-card:hover { background: var(--surface-inset); }
.vault-entry-icon {
  font-size: 26px; line-height: 1;
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); border-radius: var(--r-pill);
}
.vault-entry-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.vault-entry-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.vault-entry-sub { font-size: 13px; color: var(--text-secondary); }
.vault-entry-chev { color: var(--text-tertiary); font-size: 22px; line-height: 1; flex-shrink: 0; }

/* Two square Today cards (Vault + Franklin) side by side */
.today-squares { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.today-squares > div { min-width: 0; }

/* ---- Practising card (Today, first) — name, definition, slip count + stepper ---- */
.prac-card {
  background: var(--card); border: 0.5px solid var(--border);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
}
.prac-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; color: var(--text-tertiary); }
.prac-name { font-size: 19px; font-weight: 500; color: var(--text-primary); margin-top: 4px; overflow-wrap: break-word; }
.prac-def { font-size: 14px; color: var(--text-secondary); line-height: 1.5; margin-top: 4px; overflow-wrap: break-word; }
.prac-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-top: 0.5px solid var(--border); padding-top: 10px; margin-top: 12px;
}
.prac-count { font-size: 14px; color: var(--text-secondary); min-width: 0; overflow-wrap: break-word; }
.prac-steps { display: flex; gap: 8px; flex-shrink: 0; }
.prac-step {
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0.5px solid var(--border); border-radius: var(--radius);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.prac-step-minus { color: var(--text-secondary); }
.prac-step-plus  { color: var(--text-primary); }
.vault-entry-square {
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 7px; padding: 16px 12px;
  aspect-ratio: 1 / 1; margin-bottom: 0; min-height: 0;
}
.vault-entry-square .vault-entry-icon { font-size: 30px; width: 56px; height: 56px; }
.vault-entry-square .vault-entry-title { font-size: 15px; line-height: 1.2; }
.vault-entry-square .vault-entry-sub { font-size: 12px; line-height: 1.2; }

/* Three squares side by side — tighter to fit ~360-390px iPhone width.
   (Retained for compatibility; My Code is now a full-width card above.) */
.today-squares-3 { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.today-squares-3 .vault-entry-square { padding: 12px 6px; gap: 5px; }
.today-squares-3 .vault-entry-icon { font-size: 24px; width: 44px; height: 44px; }
.today-squares-3 .vault-entry-title { font-size: 12.5px; line-height: 1.15; }
.today-squares-3 .vault-entry-sub { font-size: 10px; line-height: 1.2; }
/* Four rooms -> 2x2 on every width; full-size squares (each ≥44px tap). */
.today-squares-4 { grid-template-columns: repeat(2, 1fr); gap: 12px; }

/* ---- Goals (direction layer) ---- */
.goals-empty { font-size: 13px; color: var(--text-tertiary); padding: 8px 0; line-height: 1.5; }
.goals-list { display: flex; flex-direction: column; }
.goals-row {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0; border-top: 1px solid var(--separator);
}
.goals-row:first-child { border-top: none; }
.goals-row-main { flex: 1; min-width: 0; cursor: pointer; }
.goals-row-name { font-size: 15px; font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.goals-row-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.goals-row-actions { display: inline-flex; align-items: center; flex-shrink: 0; }

.goals-detail-name { font-size: 20px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.01em; margin-bottom: 10px; overflow-wrap: anywhere; }
.goals-why-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 4px 0 6px; }
/* Reading-font treatment for the user's own writing (matches My Code). */
#goals-body .goals-why {
  font-family: var(--font-reading); font-size: 14px; line-height: 1.6;
  min-height: 72px; overflow: hidden; resize: none;   /* autogrows to content — no inner scrollbar */
}

.goals-habit-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--separator);
}
.goals-habit-row:first-of-type { border-top: none; }
.goals-habit-main { flex: 1; min-width: 0; }
.goals-habit-label { font-size: 14px; font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.goals-habit-space { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 1px; }
.goals-habit-consistency {
  flex-shrink: 0; font-size: 13px; color: var(--text-secondary);
  font-family: var(--font-mono); font-feature-settings: var(--num);
}
.goals-habit-nodue { font-family: inherit; font-style: italic; color: var(--text-tertiary); }

/* 14-day mini-strip on a linked-habit row. Same three-state palette as the
   Habits heatmap (own small-scale classes — the heatmap's rules are untouched).
   Can shrink + wrap its own cells on narrow screens without touching the ✕. */
/* ---- Goal linked-habit row: two lines at all widths ---- */
.goal-habit-row {
  padding: 10px 0; border-top: 1px solid var(--separator);
}
.goal-habit-row:first-of-type { border-top: none; }
.goal-habit-top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.goal-habit-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* Word-boundary wrapping only — long multi-word names wrap at spaces, never
   per-character (no break-all / overflow-wrap: anywhere). */
.goal-habit-label { font-size: 14px; font-weight: 600; color: var(--text-primary); overflow-wrap: break-word; }
.goal-habit-space { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 1px; }
.goal-habit-meta {
  flex-shrink: 0; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}

/* 14-day strip: its own full-width second line; cells flex to fill it, capped
   so they stay small on wide screens. Same three-state palette as the heatmap. */
.goal-strip {
  display: flex; align-items: center; gap: 3px; margin-top: 6px; width: 100%;
}
.goal-strip-cell { flex: 1 1 0; max-width: 14px; height: 11px; border-radius: 2px; }
.goal-strip-empty { margin-top: 6px; font-size: 13px; font-style: italic; color: var(--text-tertiary); }
.gs-done   { background: rgba(52, 199, 89, 0.30); }               /* heatmap quiet green */
.gs-missed { background: rgba(255, 59, 48, 0.90); }               /* danger tint, nudged for small-scale visibility */
.gs-off    { background: var(--card); border: 1px solid var(--separator); }  /* near-white empty */
.gs-pending{ background: var(--card); border: 1px solid var(--accent); }      /* today, open — accent outline, not failed */

/* ---- Weekly review ---- */
/* Today card — slim full-width row. */
.review-card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--card); border: 1px solid var(--separator);
  border-radius: var(--r-card); box-shadow: var(--shadow-card);
  padding: 14px 16px; margin-bottom: 12px; cursor: pointer; text-align: left;
}
.review-card-icon { font-size: 22px; flex-shrink: 0; }
.review-card-text { display: flex; flex-direction: column; min-width: 0; }
.review-card-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.review-card-sub { font-size: 12px; color: var(--text-secondary); margin-top: 1px; }

/* Composer */
.review-datehead { font-size: 13px; color: var(--text-tertiary); margin-bottom: 12px; }
.review-q { display: block; font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; line-height: 1.3; }
.review-note { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.review-reading { font-family: var(--font-reading); }
.review-empty { font-size: 13px; color: var(--text-tertiary); padding: 6px 0; }
.review-save { width: 100%; margin-top: 4px; }

/* Ranked-list rate number — the ONLY colored judgment; counts otherwise. */
.review-rate { font-family: var(--font-mono); font-feature-settings: var(--num); font-size: 13px; font-weight: 600; }
.review-rate-bad { color: var(--danger); }
.review-rate-mid { color: var(--text-secondary); }
.review-rate-ok  { color: var(--ok); }
.review-notdue { font-size: 12px; color: var(--text-tertiary); font-style: italic; white-space: nowrap; }

/* Tallies row — event counts in the window; +0 success, >0 danger. */
.review-tallies { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--separator); }
.review-tally { display: inline-flex; align-items: baseline; gap: 5px; background: var(--surface-inset); border-radius: var(--r-pill); padding: 4px 10px; }
.review-tally-label { font-size: 12px; color: var(--text-secondary); }
.review-tally-n { font-family: var(--font-mono); font-feature-settings: var(--num); font-size: 12px; font-weight: 700; }
.review-tally-zero { color: var(--ok); }
.review-tally-hit  { color: var(--danger); }

/* Sleep panel — one inline raw row, no delta/arrow. */
.review-sleep { margin-bottom: 12px; }

/* Sleep panel: 3 metric rows x (this week | prior), mean over range. */
.review-sleep-grid {
  display: grid; grid-template-columns: 55px 1fr 1fr;
  gap: 6px 8px; align-items: baseline; margin-bottom: 8px;
}
.rsg-head { font-size: 10px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em; }
.rsg-rlabel { font-size: 11px; color: var(--text-secondary); }
.rsg-cell { min-width: 0; }
.rsg-mean { font-family: var(--font-mono); font-feature-settings: var(--num); font-size: 14px; color: var(--text-primary); line-height: 1.2; }
.rsg-cell.rsg-prior .rsg-mean { color: var(--text-secondary); }   /* prior reads lighter — the only hierarchy */
.rsg-range { font-family: var(--font-mono); font-feature-settings: var(--num); font-size: 11px; color: var(--text-tertiary); white-space: nowrap; line-height: 1.3; }
.review-sleep-counts { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; }
.review-sleep-legend { font-size: 10px; color: var(--text-tertiary); margin-bottom: 10px; }

/* Today card — Q5 ("the one thing"): your own sentence, no status of any kind. */
.review-card-q5wrap { flex-direction: column; align-items: flex-start; gap: 4px; }
.review-card-q5label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); }
.review-card-q5 { font-family: var(--font-reading); font-size: 15px; line-height: 1.45; color: var(--text-primary); overflow-wrap: anywhere; }

/* ---- Compact review composer (scoped to #review-body; Goals rows untouched) ---- */
#review-body .vault-section { padding: 12px; margin-bottom: 10px; }
/* Textareas ~2 lines, autogrow to content — no fixed tall height, no scrollbar. */
#review-body .code-textarea { min-height: 52px; overflow: hidden; resize: none; }
/* Ranked rows tighter; schedule hint sits inline after the name (strip stays
   its own line). Wraps at a space on very narrow widths. */
#review-body .goal-habit-row { padding: 7px 0; }
#review-body .goal-habit-name { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 6px; }
#review-body .goal-habit-space { margin-top: 0; }
/* Q6 pair slightly shorter to match the compacted form. */
#review-body .review-q6 button { min-height: 38px; }

/* Q4 loop — last week's q5, reading font, accent block. */
.review-lastweek { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: var(--r-card); padding: 10px 12px; margin-bottom: 10px; }
.review-lastweek-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.review-lastweek-text { font-family: var(--font-reading); font-size: 14px; line-height: 1.55; color: var(--text-primary); white-space: pre-wrap; overflow-wrap: break-word; }

/* Q6 segmented pair — two half-width options. */
.review-q6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.review-q6 button { min-height: 44px; }

/* Archive cards (Stats Journal doorway) */
.review-arch { background: var(--card); border: 1px solid var(--separator); border-radius: var(--r-card); padding: 12px 14px; margin-bottom: 10px; }
.review-arch-date { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 6px; }
.review-arch-q5 { font-family: var(--font-reading); font-size: 14px; line-height: 1.55; color: var(--text-primary); white-space: pre-wrap; overflow-wrap: break-word; margin-bottom: 8px; }
.review-arch-block { margin-top: 8px; }
.review-arch-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); margin-bottom: 2px; }
.review-arch-text { font-size: 13px; line-height: 1.45; color: var(--text-primary); white-space: pre-wrap; overflow-wrap: break-word; }

.goals-ms-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 0; border-top: 1px solid var(--separator);
}
.goals-ms-row:first-of-type { border-top: none; }
.goals-ms-check {
  flex-shrink: 0; width: 24px; height: 24px; margin-top: 1px;
  border: 1.5px solid var(--separator); border-radius: 50%;
  background: transparent; color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.goals-ms-check.checked { background: var(--ok); border-color: var(--ok); }
.goals-ms-dot { font-size: 14px; line-height: 1; }
.goals-ms-text { flex: 1; min-width: 0; font-size: 14px; line-height: 1.4; color: var(--text-primary); overflow-wrap: anywhere; padding-top: 3px; }
.goals-ms-row.done .goals-ms-text { color: var(--text-secondary); }
.goals-ms-date { font-size: 12px; color: var(--ok); font-weight: 600; white-space: nowrap; }

/* Habit picker sheet */
.goals-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.goals-sheet-title { font-size: 17px; font-weight: 700; color: var(--text-primary); margin: 0; }
.goals-pick-space { font-size: 11px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; margin: 14px 0 4px; }
.goals-pick-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 12px; margin-bottom: 6px;
  background: var(--surface-inset); border: none; border-radius: var(--r-pill);
  cursor: pointer; text-align: left;
}
.goals-pick-label { font-size: 14px; color: var(--text-primary); overflow-wrap: anywhere; }
.goals-pick-state { font-size: 12px; font-weight: 600; color: var(--accent); flex-shrink: 0; }
.goals-pick-row.linked { opacity: 0.55; cursor: default; }
.goals-pick-row.linked .goals-pick-state { color: var(--text-tertiary); }

/* My Code — primary full-width card above the two squares. */
.code-entry-primary { min-height: 72px; padding: 18px 16px; }
.code-entry-primary .vault-entry-icon { font-size: 28px; width: 48px; height: 48px; }
.code-entry-primary .vault-entry-title { font-size: 17px; }

/* ---- My Code overlay ---- */
.code-header-actions { display: flex; gap: 8px; align-items: center; }
.code-journal-btn {
  min-width: 44px; min-height: 44px; padding: 8px 12px; font-size: 18px;
  background: var(--surface-inset);
}
.code-tabs { margin-bottom: 14px; }
.code-empty { font-size: 13px; color: var(--text-tertiary); padding: 8px 0; }

.code-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 0; border-top: 1px solid var(--separator);
}
.code-row:first-of-type { border-top: none; }
.code-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.code-row-text {
  font-size: 14px; line-height: 1.4; color: var(--text-primary);
  white-space: pre-wrap; word-break: break-word;
}
.code-virtue-tag {
  align-self: flex-start; font-size: 11px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft);
  padding: 2px 8px; border-radius: var(--r-pill);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Edit-mode badge is a tap target (opens the rule's virtue picker) — >=44px. */
.code-virtue-tag-edit {
  border: none; cursor: pointer; min-height: 44px;
  display: inline-flex; align-items: center; padding: 4px 12px;
}
/* Virtue multi-select in the rule sheet: scrolls itself, never the page. */
.code-rule-virtues { max-height: 45vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.code-rule-virtue-opt {
  display: flex; align-items: center; gap: 10px; min-height: 44px;
  padding: 6px 2px; cursor: pointer;
}
.code-rule-virtue-check { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.code-rule-virtue-opt input { width: 20px; height: 20px; flex-shrink: 0; }
.code-rule-virtue-check span { overflow-wrap: break-word; min-width: 0; }
/* Star to promote a checked virtue to core — separately tappable from the checkbox. */
.code-virtue-star {
  flex-shrink: 0; min-width: 44px; min-height: 44px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--text-tertiary);
}
.code-virtue-star.set { color: var(--accent); }
.code-rule-virtues-hint { font-size: 11px; color: var(--text-tertiary); margin-top: 6px; line-height: 1.4; }

/* Core vs also-serves on a rule row (virtue detail + recite card). The only
   emphasis: star + accent scope line + body weight 500 for core; indent + muted
   scope + secondary text for also-serves. No fills, no size step, weight caps 500. */
.code-core-star { flex-shrink: 0; width: 16px; text-align: center; color: var(--accent); font-size: 12px; line-height: 1.6; }
.code-core-star-empty { color: transparent; }   /* keeps also-serves body aligned under core body */
.code-scope-core { color: var(--accent); }
.code-scope-secondary { color: var(--text-tertiary); }
.code-body-core { font-weight: 500; color: var(--text-primary); }
.code-body-secondary { font-weight: 400; color: var(--text-secondary); }
/* recite pre-reveal core count fragment */
.code-recite-core { color: var(--accent); font-weight: 500; }
.code-row-actions { display: flex; gap: 2px; flex-shrink: 0; }

.code-virtue-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; min-height: 48px; padding: 12px 10px;
  background: transparent; border: none; border-top: 1px solid var(--separator);
  cursor: pointer; text-align: left;
}
.code-virtue-item:first-of-type { border-top: none; }
.code-virtue-item:hover { background: var(--surface-inset); }
.code-virtue-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.code-virtue-status { color: var(--text-tertiary); font-size: 16px; }

.code-back {
  background: transparent; border: none; cursor: pointer;
  color: var(--accent); font-size: 15px; font-weight: 600;
  padding: 8px 2px; margin-bottom: 4px; min-height: 44px;
}
.code-virtue-title { font-size: 22px; font-weight: 800; color: var(--accent); letter-spacing: -0.02em; }
.code-virtue-def { font-size: 13px; color: var(--text-secondary); line-height: 1.45; margin: 4px 0 12px; }
.code-field-label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary);
  margin: 12px 0 6px; text-transform: none; letter-spacing: 0; font-family: inherit;
}
.code-textarea {
  width: 100%; min-height: 88px; resize: vertical; line-height: 1.45;
  background: var(--surface-inset); color: var(--text-primary);
  border: 1px solid transparent; border-radius: var(--r-pill);
  padding: 11px 12px; font-size: 15px; font-family: inherit;
}
.code-textarea:focus { outline: none; border-color: var(--accent); background: var(--card); }
.code-linked-rule {
  font-size: 13px; color: var(--text-secondary); line-height: 1.4;
  padding: 8px 0; border-top: 1px solid var(--separator);
  white-space: pre-wrap; word-break: break-word;
}
.code-linked-rule:first-of-type { border-top: none; }

/* ---- Rules: numbered tight rows + responsive public/private ---- */
.code-rule-toggle { margin-bottom: 14px; }
.code-rule-cols { display: block; }
/* Narrow (default): show only the toggled scope's column. */
.code-rule-cols[data-active-scope="public"]  .code-rule-col-private { display: none; }
.code-rule-cols[data-active-scope="private"] .code-rule-col-public  { display: none; }
.code-rule-col + .code-rule-col { margin-top: 18px; }
/* Both header buttons (Edit/Done + Add) sit together on the right. */
.code-rule-head-actions { display: inline-flex; align-items: center; gap: 8px; }
.code-rule-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 0; border-top: 1px solid var(--separator);   /* reading air (was 9px) */
}
.code-rule-row:first-child { border-top: none; }
.code-rule-num {
  flex-shrink: 0; min-width: 1.5em; text-align: right; margin-right: 4px;  /* clean hanging column */
  font-family: var(--font-mono); font-feature-settings: var(--num);
  font-weight: 700; font-size: 13px; color: var(--accent); line-height: 1.55;
  padding-top: 1px;                                    /* top-align with first text line */
}
.code-rule-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.code-rule-text {
  font-size: 14px; line-height: 1.6; color: var(--text-primary);  /* Verdana reading size */
  white-space: pre-wrap; word-break: break-word;
}
.code-menu-btn { flex-shrink: 0; }

@media (min-width: 700px) {
  .code-rule-toggle { display: none; }                 /* both columns shown, no toggle */
  .code-rule-cols { display: grid; grid-template-columns: 1fr 1fr; column-gap: 40px; row-gap: 20px; align-items: start; }
  .code-rule-cols .code-rule-col { display: block !important; } /* override narrow hide */
  .code-rule-col + .code-rule-col { margin-top: 0; }
}
/* Read mode reclaims the ⋯ gutter fully: the button element isn't emitted at
   all, so rows run number → full-width text. This class marks the editing
   state (hook for any edit-only row spacing). */
.code-rules-editing .code-rule-row { gap: 8px; }

/* ---- My Code reads as a document: reading font (Verdana) for CONTENT only ----
   Scoped to the My Code page (#code-body) and the Stats journal archive
   (#journalstats-body). Chrome — section labels, buttons, rule numbers,
   virtue tags, rating chips, dates, stat tiles — is deliberately NOT selected
   and stays in the app sans/mono. System font stack; no new web font. */
#code-body .code-rule-text,
#code-body .code-linked-rule,
#code-body .code-virtue-name,
#code-body .code-virtue-def,
#code-body .code-vn-text,
#code-body .code-journal-past-text,
#code-body .code-textarea,
#journalstats-body .jd-entry-text,
#journalstats-body .jd-reading-text {
  font-family: var(--font-reading);
}
/* Body-size content at Verdana 14/1.6 — 14px is deliberate: Verdana's wide
   x-height reads like Inter at 15–16px without adding line wrap. Virtue NAMES
   are intentionally excluded here so they keep their larger heading sizes. */
#code-body .code-rule-text,
#code-body .code-linked-rule,
#code-body .code-virtue-def,
#code-body .code-vn-text,
#code-body .code-journal-past-text,
#code-body .code-textarea,
#journalstats-body .jd-entry-text,
#journalstats-body .jd-reading-text {
  font-size: 14px; line-height: 1.6;
}

/* ---- Virtues: all expanded inline ---- */
.code-virtue-card { }
.code-virtue-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.code-virtue-card-head .code-virtue-name { font-size: 18px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.01em; }
.code-virtue-card .code-virtue-def { font-style: italic; margin: 2px 0 12px; }
.code-vn-block { margin-top: 10px; }
.code-vn-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-tertiary); font-family: var(--font-mono); margin-bottom: 3px;
}
.code-vn-text {
  font-size: 14px; line-height: 1.5; color: var(--text-primary);
  white-space: pre-wrap; word-break: break-word;
}
.code-virtue-empty { font-size: 13px; color: var(--text-tertiary); margin-top: 8px; }
.code-vn-footer { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--separator); }

.code-rating { margin: 12px 0; }
.code-journal-save { width: 100%; min-height: 48px; font-weight: 600; }
.code-journal-past {
  padding: 10px 0; border-top: 1px solid var(--separator);
}
.code-journal-past:first-of-type { border-top: none; }
.code-journal-past-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px;
}
.code-journal-date { font-size: 12px; color: var(--text-tertiary); font-family: var(--font-mono); }
.code-journal-rating { font-size: 11px; font-weight: 700; color: var(--text-secondary); }
.code-journal-rating.rating-lived { color: var(--ok); }
.code-journal-rating.rating-held  { color: var(--accent); }
.code-journal-rating.rating-short { color: var(--danger); }
.code-journal-past-text {
  font-size: 14px; color: var(--text-primary); line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.code-journal-seeall { width: 100%; min-height: 44px; margin-top: 12px; font-weight: 600; }

/* ---- Journal doorway (read-only archive + rating trend) ---- */
.jd-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.jd-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface-inset); border-radius: var(--r-card); padding: 14px 8px;
}
.jd-tile-count {
  font-size: 28px; font-weight: 800; line-height: 1;
  font-family: var(--font-mono); font-feature-settings: var(--num);
}
.jd-tile-label { font-size: 12px; color: var(--text-secondary); text-align: center; overflow-wrap: anywhere; }
.jd-tile-lived .jd-tile-count { color: var(--ok); }
.jd-tile-held  .jd-tile-count { color: var(--accent); }
.jd-tile-short .jd-tile-count { color: var(--danger); }

.jd-section { margin-top: 20px; }
.jd-section-head {
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px;
}
.jd-trend {
  display: flex; align-items: flex-end; gap: 4px;
  height: 88px; padding: 8px 10px;
  background: var(--surface-inset); border-radius: var(--r-card);
}
.jd-bar { flex: 1 1 0; min-width: 5px; border-radius: 3px 3px 0 0; background: var(--text-tertiary); }
.jd-bar-lived { background: var(--ok); }
.jd-bar-held  { background: var(--accent); }
.jd-bar-short { background: var(--danger); }
.jd-bar-none  { background: var(--text-tertiary); }
.jd-trend-empty { margin: auto; font-size: 13px; color: var(--text-tertiary); }
.jd-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.jd-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.jd-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.jd-entry { padding: 12px 0; border-top: 1px solid var(--separator); }
.jd-entry:first-of-type { border-top: none; }
.jd-entry-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px;
}
.jd-entry-date { font-size: 12px; color: var(--text-tertiary); font-family: var(--font-mono); }
.jd-entry-rating { font-size: 11px; font-weight: 700; color: var(--text-secondary); }
.jd-entry-rating.rating-lived { color: var(--ok); }
.jd-entry-rating.rating-held  { color: var(--accent); }
.jd-entry-rating.rating-short { color: var(--danger); }
.jd-entry-text {
  font-size: 14px; color: var(--text-primary); line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}

/* ---- v49: Code-practice card, read-dots, reading sub-block ---- */
.jd-practice {
  display: flex; gap: 10px; margin-top: 12px;
  background: var(--surface-inset); border-radius: var(--r-card); padding: 14px 12px;
}
.jd-practice-stat { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.jd-practice-num {
  font-size: 28px; font-weight: 800; line-height: 1; color: var(--text-primary);
  font-family: var(--font-mono); font-feature-settings: var(--num);
}
.jd-practice-denom { font-size: 15px; font-weight: 600; color: var(--text-tertiary); }
.jd-practice-label { font-size: 12px; color: var(--text-secondary); text-align: center; overflow-wrap: anywhere; }
.jd-practice-empty { flex: 1; font-size: 13px; color: var(--text-tertiary); text-align: center; }

/* Read-dots row — mirrors .jd-trend's flex + gap + horizontal padding so each
   dot centers under its bar column. */
.jd-readdots { display: flex; gap: 4px; padding: 6px 10px 0; }
.jd-dot-cell { flex: 1 1 0; min-width: 5px; display: flex; justify-content: center; }
.jd-dot-read, .jd-dot-unread {
  width: 6px; height: 6px; border-radius: 50%; display: inline-block; box-sizing: border-box;
}
.jd-dot-read { background: var(--text-secondary); }
.jd-dot-unread { border: 1px solid var(--text-tertiary); background: transparent; }
.jd-legend .jd-dot-read { width: 8px; height: 8px; }
/* v51: cap trend bar + read-dot column width so one entry doesn't stretch
   wall-to-wall; bars and dots share the cap to stay column-aligned. Additive —
   the existing flex 1 1 0 still governs shrink at 10+ entries. */
.jd-bar { max-width: 38px; }
.jd-dot-cell { max-width: 38px; }

.jd-entry-read {
  font-size: 12px; color: var(--text-tertiary);
  font-family: var(--font-mono); margin-bottom: 5px;
}
.jd-reading {
  margin-top: 8px; padding: 4px 0 4px 10px;
  border-left: 2px solid var(--separator);
}
.jd-reading-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--text-tertiary); font-family: var(--font-mono); margin-bottom: 3px;
}
.jd-reading-text {
  font-size: 13px; color: var(--text-secondary); line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}

/* ---- v49: gated read-slice card in the journal composer ---- */
.code-readslice-virtue { margin-bottom: 4px; }
.code-readslice-vn { margin-top: 10px; }
.code-readslice-empty { font-size: 13px; color: var(--text-tertiary); margin-top: 8px; }
.code-readslice-rule { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--separator); }
/* Scope tag on a gate rule row — disambiguates the shared 1–7 numbering. */
.code-readslice-scope { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); margin-bottom: 2px; }
.code-readslice-done { margin-top: 16px; }
/* Recite mode — before-reveal recall prompt. */
.code-recite-count { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-top: 14px; }
.code-recite-prompt { font-size: 13px; color: var(--text-secondary); margin-top: 4px; margin-bottom: 14px; }
.code-recite-reveal { min-height: 44px; }
.code-summary-add { align-self: flex-start; margin: 2px 0 6px; padding-left: 0; }

/* ---- The Benjamin Franklin overlay body ---- */
.fr-tallies { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fr-tally {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--surface-inset); border-radius: var(--r-card); padding: 12px 8px;
}
.fr-tally-count {
  font-size: 28px; font-weight: 800; color: var(--text-primary);
  font-family: var(--font-mono); font-feature-settings: var(--num); line-height: 1;
}
.fr-tally-label {
  font-size: 12px; color: var(--text-secondary); text-align: center;
  overflow-wrap: anywhere;
}
.fr-ctrls { display: flex; gap: 6px; justify-content: center; }
.fr-ctrls-wide { margin-top: 12px; }
/* Rotation-length stepper row (edit mode): label left, ±1 buttons right. */
.fr-cycle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fr-cycle-label { font-size: 14px; color: var(--text-secondary); }
.fr-cycle-val { font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.fr-btn {
  min-width: 44px; min-height: 44px; padding: 8px 12px;
  border: none; border-radius: var(--r-pill); cursor: pointer;
  background: var(--surface-inset); color: var(--text-secondary);
  font-size: 15px; font-weight: 700; font-family: var(--font-mono);
}
.fr-btn:hover { background: var(--separator); }
.fr-btn:disabled { opacity: 0.35; cursor: default; }
.fr-btn-plus { background: var(--accent-soft); color: var(--accent); }
.fr-btn-plus:hover { background: var(--accent); color: #fff; }

/* ---- Franklin edit mode (tallies + virtues) ---- */
.franklin-edit-btn { min-height: 44px; padding: 8px 14px; font-weight: 600; }
.fr-empty { font-size: 13px; color: var(--text-tertiary); padding: 8px 0; }
.fr-cap-note { font-size: 12px; color: var(--text-tertiary); margin-top: 8px; }
.fr-edit-list { display: flex; flex-direction: column; }
.fr-edit-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-top: 1px solid var(--separator); min-height: 44px;
}
.fr-edit-row:first-child { border-top: none; }
.fr-edit-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fr-edit-name { font-size: 15px; font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
.fr-edit-def {
  font-size: 12px; color: var(--text-tertiary); line-height: 1.35;
  overflow-wrap: anywhere;
}
.fr-edit-actions { display: flex; gap: 2px; flex-shrink: 0; }

.fr-focus { border: 1px solid var(--accent); }
.fr-days { font-size: 12px; color: var(--text-secondary); font-family: var(--font-mono); }
.fr-focus-name {
  font-size: 26px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--accent); margin-bottom: 6px;
}
.fr-focus-def { font-size: 14px; color: var(--text-secondary); line-height: 1.45; }
.fr-focus-stats { display: flex; gap: 24px; margin-top: 14px; }
.fr-stat { display: flex; flex-direction: column; gap: 2px; }
.fr-stat-num {
  font-size: 24px; font-weight: 800; color: var(--text-primary);
  font-family: var(--font-mono); font-feature-settings: var(--num); line-height: 1;
}
.fr-stat-lab { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em; }
.fr-next { margin-top: 12px; font-size: 12px; color: var(--text-tertiary); font-family: var(--font-mono); }

.fr-list-toggle {
  width: 100%; min-height: 44px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: transparent; border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text-primary); text-align: left;
}
.fr-list-chev { color: var(--text-tertiary); font-size: 20px; transition: transform 0.2s; }
.fr-list-section.open .fr-list-chev { transform: rotate(90deg); }
.fr-list-body { margin-top: 8px; }
.fr-list-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: 10px 10px; border-radius: 9px; min-height: 40px;
}
.fr-list-row.current { background: var(--accent-soft); }
.fr-list-row.current .fr-list-name { color: var(--accent); font-weight: 700; }
.fr-list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fr-list-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.fr-list-def {
  font-size: 11.5px; color: var(--text-tertiary); line-height: 1.35;
  overflow-wrap: anywhere;
}
.fr-list-count {
  font-size: 13px; color: var(--text-secondary); flex-shrink: 0;
  font-family: var(--font-mono); font-feature-settings: var(--num);
}

/* ---- Tally line chart (Stats) ---- */
/* Three controls share the row proportionally: series widest (shows its label),
   range narrow, bucket medium. min-width:0 lets the selects shrink w/o collapsing. */
.tally-controls {
  display: grid; grid-template-columns: 2fr 1fr 1.2fr;
  gap: 8px; align-items: center; margin-bottom: 12px;
}
.tc-select { width: 100%; min-width: 0; min-height: 44px; }
.tc-range { width: 100%; min-width: 0; min-height: 44px; text-align: center; padding-left: 6px; padding-right: 6px; }
.tally-chart-svg { display: block; width: 100%; height: auto; margin: 4px 0 2px; }
.tc-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tc-dot { fill: var(--accent); }
.tc-grid { stroke: var(--separator); stroke-width: 1; opacity: 0.7; }   /* faint, behind the data line */
.tc-vgrid { opacity: 0.4; }
.tc-axis { font-size: 9px; fill: var(--text-tertiary); font-family: var(--font-mono); }
.tally-caption {
  font-size: 12px; color: var(--text-secondary);
  font-family: var(--font-mono); margin-top: 6px;
}

/* ---- Full-screen overlay (modelled on the Focus overlay) ---- */
.modal.vault-overlay-mode {
  background: var(--bg);
  align-items: stretch; justify-content: stretch;
  padding: 0;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.vault-overlay-panel {
  position: relative;
  width: 100%; height: 100vh; height: 100dvh;
  background: var(--bg);
  max-width: 720px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding:
    calc(16px + env(safe-area-inset-top, 0))
    16px
    calc(8px + env(safe-area-inset-bottom, 0));
}
.vault-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 4px 2px 12px;
  border-bottom: 1px solid var(--separator);
  flex-shrink: 0;
}
.vault-title { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; color: var(--text-primary); }
.vault-close-btn { min-height: 44px; padding: 8px 16px; font-weight: 600; }
.vault-body { flex: 1; overflow-y: auto; padding: 14px 2px calc(24px + env(safe-area-inset-bottom, 0)); }

/* ---- Sheet sits above the overlay ---- */
.modal.vault-sheet-mode { z-index: 120; }

.vault-add-btn { width: 100%; min-height: 50px; font-size: 16px; margin-bottom: 16px; }

/* ---- Sections ---- */
.vault-section {
  background: var(--card); border: 1px solid var(--separator);
  border-radius: var(--r-card); padding: 16px;
  box-shadow: var(--shadow-card); margin-bottom: 14px;
}
.vault-section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.vault-section-title {
  font-size: 11px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  font-family: var(--font-mono);
}
.vault-month { font-size: 12px; color: var(--text-secondary); font-family: var(--font-mono); }

/* ---- This month summary ---- */
.vault-net {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.vault-net-label {
  font-size: 12px; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.vault-net-val {
  font-size: 34px; font-weight: 800;
  font-family: var(--font-mono); font-feature-settings: var(--num);
  letter-spacing: -0.03em; line-height: 1;
}
.vault-net.pos .vault-net-val { color: var(--ok); }
.vault-net.neg .vault-net-val { color: var(--danger); }

.vault-io-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; font-size: 14px; margin-top: 8px;
}
.vault-io-k { color: var(--text-secondary); display: inline-flex; align-items: center; gap: 8px; }
.vault-io-v {
  color: var(--text-primary); font-family: var(--font-mono);
  font-feature-settings: var(--num); font-weight: 600;
}
.vault-io-bar {
  height: 6px; background: var(--surface-inset); border-radius: 3px;
  overflow: hidden; margin: 5px 0 2px;
}
.vault-io-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.vault-io-fill.in  { background: var(--ok); }
.vault-io-fill.out { background: var(--danger); }
.vault-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.vault-dot.in   { background: var(--ok); }
.vault-dot.out  { background: var(--danger); }
.vault-dot.save { background: var(--accent); }
.vault-saved-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; font-size: 14px; margin-top: 14px;
  padding-top: 12px; border-top: 1px solid var(--separator);
}
.vault-note-line { margin: 10px 0 0; font-size: 12px; color: var(--text-tertiary); line-height: 1.45; }

/* ---- Goals ---- */
.vault-mini-btn {
  background: var(--accent-soft); color: var(--accent);
  border: none; border-radius: var(--r-pill);
  padding: 8px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; min-height: 36px;
}
.vault-mini-btn:hover { background: var(--accent); color: #fff; }
.vault-total-saved {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.vault-total-saved span { font-size: 13px; color: var(--text-secondary); }
.vault-total-saved strong {
  font-size: 22px; font-weight: 800; color: var(--accent);
  font-family: var(--font-mono); font-feature-settings: var(--num);
  letter-spacing: -0.02em;
}
.vault-goal-card {
  background: var(--surface-inset); border-radius: var(--r-card);
  padding: 13px 14px; margin-top: 10px;
}
.vault-goal-top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 9px;
}
.vault-goal-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.vault-goal-amt {
  font-size: 13px; color: var(--text-secondary);
  font-family: var(--font-mono); font-feature-settings: var(--num);
  white-space: nowrap;
}
.vault-goal-bar {
  height: 8px; background: var(--card); border-radius: 4px;
  overflow: hidden; margin-bottom: 9px;
}
.vault-goal-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }
.vault-goal-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.vault-goal-pct { font-size: 12px; color: var(--text-secondary); font-family: var(--font-mono); }
.vault-goal-actions { display: flex; gap: 6px; }

/* ---- Transactions ---- */
.vault-txn {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 0; min-height: 44px;
  border-top: 1px solid var(--separator);
  cursor: pointer;
}
.vault-txn:first-of-type { border-top: none; }
.vault-txn-tag {
  flex-shrink: 0; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 4px 8px; border-radius: var(--r-pill);
  font-family: var(--font-mono); min-width: 48px; text-align: center;
}
.vault-txn-tag.in   { background: rgba(52, 199, 89, 0.14); color: var(--ok); }
.vault-txn-tag.out  { background: var(--danger-dim); color: var(--danger); }
.vault-txn-tag.save { background: var(--accent-soft); color: var(--accent); }
.vault-txn-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vault-txn-cat {
  font-size: 14px; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vault-txn-note { color: var(--text-tertiary); font-weight: 400; }
.vault-txn-note::before { content: '· '; }
.vault-txn-date { font-size: 12px; color: var(--text-tertiary); font-family: var(--font-mono); }
.vault-txn-amt {
  flex-shrink: 0; font-size: 15px; font-weight: 700;
  font-family: var(--font-mono); font-feature-settings: var(--num);
}
.vault-txn-amt.in   { color: var(--ok); }
.vault-txn-amt.out  { color: var(--danger); }
.vault-txn-amt.save { color: var(--accent); }
.vault-txn-del {
  flex-shrink: 0; width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-tertiary); font-size: 15px; border-radius: var(--r-pill);
}
.vault-txn-del:hover { background: var(--danger-dim); color: var(--danger); }
.vault-showall-btn {
  width: 100%; margin-top: 12px; min-height: 44px;
  background: var(--surface-inset); color: var(--accent);
  border: none; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.vault-showall-btn:hover { background: var(--accent-soft); }

/* ---- Export ---- */
.vault-export-row { display: flex; gap: 10px; }
.vault-export-btn { flex: 1; min-height: 46px; font-weight: 600; }

/* ---- Empty states ---- */
.vault-empty {
  padding: 14px 0; font-size: 13px; color: var(--text-secondary);
  line-height: 1.5; text-align: center;
}

/* ---- Sheet bits ---- */
.vault-type-tabs { margin-bottom: 16px; }
.vault-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.vault-chip {
  background: var(--surface-inset); border: 1px solid transparent;
  color: var(--text-secondary); border-radius: var(--r-pill);
  padding: 8px 13px; font-size: 13px; font-weight: 500;
  cursor: pointer; min-height: 38px;
}
.vault-chip:hover { color: var(--text-primary); border-color: var(--accent); }

/* ============================================================================
   Spaces — user-built platform (STEP 1: container + view + checkbox block)
   ========================================================================== */

/* ---- Today hub ---- */
/* ---- 3-day timeline (Today card, read-only) ---- */
.td-section { margin-bottom: 14px; }
.td-cols {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; align-items: start;
}
.td-col { min-width: 0; }                 /* let 1fr columns shrink, no overflow */
.td-head {
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.03em;
  text-align: center; padding-bottom: 6px; margin-bottom: 8px;
  border-bottom: 1px solid var(--separator);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.td-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.td-item { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.td-time {
  font-size: 10px; color: var(--accent);
  font-family: var(--font-mono); font-feature-settings: var(--num);
}
.td-title {
  font-size: 12px; line-height: 1.25; color: var(--text-primary);
  overflow-wrap: anywhere; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.td-empty {
  font-size: 12px; color: var(--text-tertiary); text-align: center;
}

/* ---- Next 3 days (vertical Today-tab section) ---- */
.next3-card {
  background: var(--card); border: 1px solid var(--separator);
  border-radius: var(--r-card); padding: 16px;
  box-shadow: var(--shadow-card); margin-bottom: 14px;
}
.next3-title {
  font-size: 11px; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  margin-bottom: 12px;
}
.next3-day {
  padding-top: 12px; margin-top: 12px;
  border-top: 1px solid var(--separator);
}
.next3-day:first-of-type { padding-top: 0; margin-top: 0; border-top: none; }
.next3-day-label {
  font-size: 12px; font-weight: 700; color: var(--text-secondary);
  margin-bottom: 8px;
}
.next3-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 5px 0; min-width: 0;
}
.next3-tappable { cursor: pointer; border-radius: var(--r-pill); }
.next3-tappable:active { background: var(--surface-inset); }
.next3-time {
  flex-shrink: 0; font-size: 11px; color: var(--accent);
  font-family: var(--font-mono); font-feature-settings: var(--num);
}
.next3-item-title {
  font-size: 14px; line-height: 1.3; color: var(--text-primary);
  overflow-wrap: anywhere; word-break: break-word; min-width: 0;
}
.next3-empty { font-size: 13px; color: var(--text-tertiary); }

/* Next 3 days — header link + footer stat chips */
.next3-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.next3-head .next3-title { margin-bottom: 0; }
.next3-seeall {
  background: transparent; border: none; cursor: pointer;
  color: var(--accent); font-size: 12px; font-weight: 600;
  padding: 4px 2px; white-space: nowrap;
}
.next3-footer {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--separator);
}
.next3-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 44px; padding: 8px 10px; border-radius: var(--r-card);
  cursor: pointer; border: 1px solid transparent; text-align: center;
}
.next3-chip-count { font-family: var(--font-mono); font-size: 18px; font-weight: 500; line-height: 1.1; }
.next3-chip-label { font-size: 12px; line-height: 1.15; }
/* Undated = the dateless bucket's only nag: accent tint + accent text. */
.next3-chip-undated { background: var(--accent-soft); }
.next3-chip-undated .next3-chip-count,
.next3-chip-undated .next3-chip-label { color: var(--accent); }
/* Nothing to nag about -> quiet neutral, not accent. */
.next3-chip-empty { background: var(--surface-inset); }
.next3-chip-empty .next3-chip-count { color: var(--text-secondary); }
.next3-chip-empty .next3-chip-label { color: var(--text-tertiary); }
/* Next-14-days = the pressure gauge: neutral card surface, hairline border. */
.next3-chip-next14 { background: var(--card); border-color: var(--separator); }
.next3-chip-next14 .next3-chip-count { color: var(--text-primary); }
.next3-chip-next14 .next3-chip-label { color: var(--text-secondary); }

/* Upcoming — Someday promoted to the top in a distinct accent block. */
.upcoming-someday-section {
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: var(--r-card); padding: 12px 14px;
}
.upcoming-someday-header { color: var(--accent); }

.spaces-hub { margin-bottom: 14px; }
.spaces-empty {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.5; margin-bottom: 12px;
}
.space-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.space-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; min-height: 92px; padding: 14px 8px;
  background: var(--surface-inset); border: 1px solid transparent;
  border-radius: var(--r-card); cursor: pointer; text-align: center;
}
.space-tile:hover { border-color: var(--accent); }
.space-tile-icon { font-size: 28px; line-height: 1; }
.space-tile-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.space-tile-new {
  background: transparent; border: 1px dashed var(--border-strong);
  color: var(--text-secondary);
}
.space-tile-new .space-tile-icon { color: var(--accent); font-weight: 700; }
.space-tile-new .space-tile-name { color: var(--text-secondary); }

/* ---- Spaces hub: vertical stacked rows ---- */
.space-list {
  display: flex; flex-direction: column;
  border: 1px solid var(--separator); border-radius: var(--r-card);
  overflow: hidden; background: var(--card);
}
.space-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 52px; padding: 12px 14px;
  background: var(--card); border: none;
  border-top: 1px solid var(--separator);
  cursor: pointer; text-align: left;
}
.space-row:first-child { border-top: none; }
.space-row:hover { background: var(--surface-inset); }
.space-row-icon { font-size: 22px; line-height: 1; flex-shrink: 0; }
.space-row-name {
  flex: 1; min-width: 0;
  font-size: 15px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.space-row-status {
  flex-shrink: 0; font-size: 13px; color: var(--text-secondary);
  font-family: var(--font-mono);
}
.space-row-status.done { color: var(--ok); font-weight: 600; }
.space-row-status.neutral { color: var(--text-tertiary); }
.space-row.complete { background: rgba(52, 199, 89, 0.10); }
.space-row.complete .space-row-name { color: var(--ok); }
.space-row-new .space-row-icon { color: var(--accent); font-weight: 700; }
.space-row-new .space-row-name { color: var(--text-secondary); font-weight: 600; }

/* ---- Full-screen Space view (mirrors the Vault overlay) ---- */
.modal.space-overlay-mode {
  background: var(--bg);
  align-items: stretch; justify-content: stretch;
  padding: 0;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.space-overlay-panel {
  position: relative;
  width: 100%; height: 100vh; height: 100dvh;
  background: var(--bg);
  max-width: 720px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding:
    calc(16px + env(safe-area-inset-top, 0))
    16px
    calc(8px + env(safe-area-inset-bottom, 0));
}
.space-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 4px 2px 12px;
  border-bottom: 1px solid var(--separator);
  flex-shrink: 0;
}
.space-title {
  margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--text-primary); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.space-title-icon { font-size: 22px; }
.space-header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.space-edit-btn, .space-close-btn { min-height: 44px; padding: 8px 14px; font-weight: 600; }

/* Eye toggle: "hiding" state (default) shows a slash over the eye. */
.space-eye-btn {
  min-width: 44px; min-height: 44px; padding: 8px 10px; font-size: 18px;
  background: var(--surface-inset); position: relative; line-height: 1;
}
.space-eye-btn.eye-off { opacity: 0.75; }
.space-eye-btn.eye-off::after {
  content: ''; position: absolute; left: 8px; right: 8px; top: 50%;
  height: 2px; background: var(--text-secondary);
  transform: rotate(-20deg); border-radius: 2px; pointer-events: none;
}

/* Muted hint shown when not-due items are hidden. */
.space-hidden-hint {
  display: block; width: 100%; min-height: 44px; margin-top: 10px;
  background: transparent; border: 1px dashed var(--separator);
  border-radius: var(--r-card); padding: 11px 12px;
  color: var(--text-tertiary); font-size: 13px; cursor: pointer; text-align: center;
}
.space-hidden-hint:hover { background: var(--surface-inset); color: var(--text-secondary); }
.space-body { flex: 1; overflow-y: auto; padding: 14px 2px calc(24px + env(safe-area-inset-bottom, 0)); }

/* Sheet sits above the overlay */
.modal.space-sheet-mode { z-index: 120; }

/* ---- Block rows ---- */
.space-block {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; min-height: 56px;
  border-top: 1px solid var(--separator);
}
.space-block:first-of-type { border-top: none; }
.space-tick {
  flex-shrink: 0; width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-inset); border: 2px solid var(--border-strong);
  border-radius: 50%; cursor: pointer;
  color: #fff; font-size: 20px; transition: background 0.15s, border-color 0.15s;
}
.space-tick.on { background: var(--accent); border-color: var(--accent); }
.space-tick-mark { line-height: 1; }
/* Edit-past-days sheet (checkbox correction tool). Reuses .space-tick visual. */
.past-days-sub { margin: -4px 0 14px; font-size: 13px; color: var(--text-tertiary); }
.past-days-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.past-days-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 4px; background: transparent; border: none; cursor: pointer; text-align: left;
}
.past-days-label { font-size: 15px; color: var(--text-primary); }
.past-days-empty { padding: 14px 4px; font-size: 14px; color: var(--text-tertiary); }
.space-block-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
/* Labels wrap freely (no truncation) now that the controls collapsed into ⋯. */
.space-block-label {
  font-size: 15px; line-height: 1.3; color: var(--text-primary);
  overflow-wrap: anywhere; word-break: break-word;
}
.space-block.checked .space-block-label { color: var(--text-tertiary); text-decoration: line-through; }
.space-block-sub {
  font-size: 12.5px; color: var(--text-tertiary);
  font-family: var(--font-mono); line-height: 1.35;
  overflow-wrap: anywhere;
}
.space-block-actions { display: flex; gap: 4px; flex-shrink: 0; }
.space-menu-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 22px; line-height: 1;
  border-radius: var(--r-pill);
}
.space-menu-btn:hover { background: var(--surface-inset); color: var(--text-primary); }

/* ⋯ action-menu popover + outside-tap backdrop */
.block-menu-backdrop { position: fixed; inset: 0; z-index: 200; background: transparent; }
.block-menu {
  position: fixed; z-index: 201;
  min-width: 184px; padding: 6px;
  background: var(--card); border: 1px solid var(--separator);
  border-radius: var(--r-card); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 2px;
}
/* The `hidden` attribute is the show/hide mechanism (closeBlockMenu sets
   hidden=true). Ensure it wins over the display:flex / position:fixed above so
   the menu and its full-screen backdrop fully disappear (no stray bar, no
   lingering tap-blocking overlay). */
.block-menu[hidden], .block-menu-backdrop[hidden] { display: none !important; }
.block-menu-item {
  min-height: 44px; padding: 10px 14px;
  background: transparent; border: none; cursor: pointer;
  text-align: left; font-size: 15px; color: var(--text-primary);
  border-radius: 9px;
}
.block-menu-item:hover { background: var(--surface-inset); }
.block-menu-item:disabled { opacity: 0.35; cursor: default; }
.block-menu-item.danger { color: var(--danger); }
.block-menu-item.danger:hover { background: var(--danger-dim); }
.space-arrow {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 14px; border-radius: var(--r-pill);
}
.space-arrow:hover { background: var(--surface-inset); color: var(--text-primary); }
.space-arrow:disabled { opacity: 0.25; cursor: default; }

/* ---- Space/block sheet bits ---- */
.space-icon-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.space-icon-chip {
  width: 48px; height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px; background: var(--surface-inset);
  border: 2px solid transparent; border-radius: var(--r-card); cursor: pointer;
}
.space-icon-chip.active { border-color: var(--accent); background: var(--accent-soft); }
.space-rec-tabs { margin-bottom: 0; }

/* ============================================================================
   Spaces STEP 2 — all-done visuals, counter + cycle blocks
   ========================================================================== */

/* ---- "All done" green: hub tiles + master signal + space header ---- */
.space-tile { position: relative; }
.space-tile.complete {
  background: rgba(52, 199, 89, 0.12);
  border-color: var(--ok);
}
.space-tile-done {
  position: absolute; top: 6px; right: 8px;
  color: var(--ok); font-size: 14px; font-weight: 800; line-height: 1;
}
.spaces-master {
  margin-bottom: 12px; padding: 10px 12px;
  border-radius: var(--r-pill); font-size: 13px; font-weight: 600;
  background: var(--surface-inset); color: var(--text-secondary);
  text-align: center;
}
.spaces-master.done { background: rgba(52, 199, 89, 0.14); color: var(--ok); }
.spaces-master.neutral { color: var(--text-tertiary); }

.space-header.complete { border-bottom-color: var(--ok); }
.space-header.complete .space-title { color: var(--ok); }
.space-done-banner {
  margin-bottom: 14px; padding: 12px;
  border-radius: var(--r-card); text-align: center;
  background: rgba(52, 199, 89, 0.14); color: var(--ok);
  font-weight: 700; font-size: 15px;
}

/* ---- Checkbox row: not-due today (still visible, de-emphasised) ---- */
.space-block.not-due .space-tick { opacity: 0.55; }
.space-block.not-due .space-block-label { color: var(--text-secondary); }

/* ---- Counter + cycle blocks ---- */
.space-block-counter, .space-block-cycle {
  flex-direction: column; align-items: stretch; gap: 10px;
}
.space-block-top {
  display: flex; align-items: center; gap: 10px; width: 100%;
}
.space-block-empty {
  font-size: 12px; color: var(--text-tertiary); padding: 4px 0;
}
.space-log-btn, .space-marker-add {
  min-height: 44px; padding: 8px 14px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent); flex-shrink: 0;
}
.space-log-btn:hover, .space-marker-add:hover { background: var(--accent); color: #fff; }
.space-counter-trend { width: 100%; }

/* Cycle */
/* Cycle running total — a distinct accent PILL (reads as accumulation, not a
   consistency streak/fire). */
.space-cycle-count {
  display: inline-block;
  margin-left: 4px;
  padding: 2px 9px;
  background: var(--accent); color: #fff;
  border-radius: var(--r-pill);
  font-family: var(--font-mono); font-feature-settings: var(--num);
  font-weight: 800; font-size: 13px; letter-spacing: -0.01em;
  vertical-align: middle;
}

/* Snapchat-style consecutive-completion streak badge on checkbox rows. */
.space-streak {
  display: inline-flex; align-items: center; gap: 2px;
  margin-left: 6px; vertical-align: middle;
  font-size: 12px; line-height: 1;
}
.space-streak-num {
  color: var(--prio-medium, var(--accent));
  font-family: var(--font-mono); font-feature-settings: var(--num);
  font-weight: 800; font-size: 12px;
}
.space-cycle-ticks { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.space-cycle-inc { min-width: 52px; min-height: 44px; font-size: 16px; font-weight: 800; }
.space-cycle-due {
  padding: 10px 12px; border-radius: var(--r-card);
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 14px;
}
.space-cycle-markers { display: flex; flex-direction: column; gap: 6px; }
.space-cycle-marker {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 40px; padding: 8px 10px;
  background: var(--surface-inset); border-radius: var(--r-pill);
  cursor: pointer; font-size: 13px; color: var(--text-primary);
}
.space-cycle-marker-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-cycle-marker-del {
  width: 40px; height: 40px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-tertiary); font-size: 13px; border-radius: var(--r-pill);
}
.space-cycle-marker-del:hover { background: var(--danger-dim); color: var(--danger); }

.space-hint { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* Type picker wraps once it holds 5 types */
.type-tabs-wrap { flex-wrap: wrap; }

/* ---- Goal block ---- */
.space-block-goal { flex-direction: column; align-items: stretch; gap: 10px; }
.space-goal-bar {
  width: 100%; height: 8px; background: var(--surface-inset);
  border-radius: 4px; overflow: hidden;
}
.space-goal-fill {
  height: 100%; background: var(--accent);
  border-radius: 4px; transition: width 0.3s;
}
.space-block-goal.goal-done .space-goal-fill { background: var(--ok); }
.space-goal-check {
  color: var(--ok); font-size: 12px; font-weight: 700;
  margin-left: 4px;
}
.space-goal-note {
  font-size: 13px; color: var(--text-secondary); line-height: 1.4;
}

/* ---- Notes block ---- */
.space-block-notes { flex-direction: column; align-items: stretch; gap: 8px; }
.space-notes-text {
  font-size: 14px; color: var(--text-primary); line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}

/* ===================== Stats hub — overview + doorways ===================== */

#stats-overview-tiles { margin-bottom: 12px; }

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-tile {
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 14px 8px;
  text-align: center;
  min-width: 0;
}
.stat-tile-val {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-tile-label {
  margin-top: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Doorway grid — six tappable cards */
#stats-doorways { margin: 6px 0 14px; }
.doorway-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.doorway-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-height: 72px;
  padding: 13px 14px;
  background: var(--card);
  border: none;
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.doorway-card:active { transform: scale(0.98); }
.doorway-icon { font-size: 22px; line-height: 1; }
.doorway-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.doorway-sub { font-size: 12px; color: var(--text-secondary); }

.doorway-note {
  margin: 16px 4px;
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
}
.doorway-empty, .habit-space-empty {
  padding: 16px;
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}

/* Habits doorway — back button in the overlay header */
.habits-back-btn { margin-right: auto; }
/* The `hidden` attribute must win over `.btn { display: inline-flex }`, otherwise
   the Back button shows (and dead-ends) on the Habits list root. */
.habits-back-btn[hidden] { display: none; }
/* Same fix for the Goals overlay's back button — renderGoals sets hidden=true on
   the list root, but `.btn`'s display overrode the bare [hidden] attribute so it
   stayed visible (and dead-ended). This makes the existing toggle actually hide it. */
.goals-back-btn[hidden] { display: none; }
/* Same [hidden]-wins-over-.btn fix for the People overlay's back button. */
.people-back-btn[hidden] { display: none; }

/* ---- People ---- */
.people-empty { font-size: 13px; color: var(--text-tertiary); padding: 8px 0; line-height: 1.5; }
.people-list { display: flex; flex-direction: column; }
.people-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 0; border-top: 1px solid var(--separator); cursor: pointer;
}
.people-row:first-child { border-top: none; }
.people-row-name { font-size: 15px; font-weight: 600; color: var(--text-primary); min-width: 0; overflow-wrap: anywhere; }
.people-row-threads { font-weight: 400; color: var(--text-tertiary); font-size: 13px; }
/* Days-since — plain neutral mono number. NEVER danger/red, whatever the value. */
.people-row-days { flex-shrink: 0; font-family: var(--font-mono); font-feature-settings: var(--num); font-size: 13px; color: var(--text-secondary); }

/* Detail header */
.people-head { display: flex; align-items: center; gap: 12px; }
.people-avatar {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
}
.people-head-text { flex: 1; min-width: 0; }
.people-head-name { font-size: 18px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.people-head-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.people-head-actions { display: inline-flex; flex-shrink: 0; }

/* Open-threads briefing — accent block, mirrors the read-slice/someday language. */
.people-threads { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: var(--r-card); padding: 12px 14px; margin-bottom: 12px; }
.people-threads-label { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.people-thread { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; }
.people-thread-check { flex-shrink: 0; width: 22px; height: 22px; margin-top: 1px; border: 1.5px solid var(--accent); border-radius: 50%; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.people-thread-dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.people-thread-text { flex: 1; min-width: 0; font-size: 14px; line-height: 1.4; color: var(--text-primary); overflow-wrap: anywhere; }
.people-thread-add { margin-top: 6px; background: transparent; border: none; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 0; min-height: 32px; }

/* List → card grid (2-up at 360px, more on desktop). */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.people-card {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--separator);
  border-radius: var(--r-card); padding: 12px; cursor: pointer; min-width: 0;
}
.people-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
.people-card-avatar { width: 34px; height: 34px; font-size: 15px; }
.people-card-days { font-family: var(--font-mono); font-feature-settings: var(--num); font-size: 12px; color: var(--text-secondary); }
.people-card-name { font-size: 14px; font-weight: 500; color: var(--text-primary); overflow-wrap: anywhere; }
.people-card-desc {
  font-size: 11px; line-height: 1.35; color: var(--text-secondary); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.people-card-desc-empty { font-style: italic; color: var(--text-tertiary); }
.people-card-tag { color: var(--text-secondary); font-weight: 600; }
.people-head-tag { font-size: 12px; color: var(--text-secondary); font-weight: 600; margin-top: 1px; }
.people-card-threads { font-size: 11px; color: var(--text-tertiary); }
.people-card-threads-open { color: var(--accent); font-weight: 600; }

/* Detail → profile-first: slim header band, then the three profile panels
   spread across the full width (single column on phones). */
.people-header-band {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px;
}
.people-header-band .people-head-actions { margin-left: auto; }
.people-header-band .people-head-name { margin-bottom: 1px; }
.people-profile-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px; margin-bottom: 12px;
}
.people-profile-panel { min-width: 0; margin-bottom: 0; }
.people-profile-panel .people-about-label { margin-bottom: 6px; }

/* About / Who they are */
.people-about-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
#people-body .people-about { font-family: var(--font-reading); font-size: 14px; line-height: 1.6; min-height: 72px; overflow: hidden; resize: none; }
.people-log-btn { width: 100%; margin-bottom: 14px; }

/* History */
.people-hist-row { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--separator); }
.people-hist-row:first-of-type { border-top: none; }
.people-hist-date { flex-shrink: 0; font-family: var(--font-mono); font-feature-settings: var(--num); font-size: 12px; color: var(--text-tertiary); min-width: 52px; }
.people-hist-note { font-size: 14px; line-height: 1.4; color: var(--text-primary); overflow-wrap: anywhere; white-space: pre-wrap; }
.people-hist-more { font-size: 12px; color: var(--text-tertiary); padding-top: 8px; }

/* Log sheet */
.people-sheet-head { margin-bottom: 12px; }
.people-sheet-title { font-size: 17px; font-weight: 700; color: var(--text-primary); margin: 0; }
.people-log-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 12px 0 6px; }
.people-log-hint { font-weight: 400; color: var(--accent); }
.people-log-date { width: 100%; padding: 11px 12px; border-radius: var(--r-pill); border: 1px solid transparent; background: var(--surface-inset); color: var(--text-primary); font-size: 15px; }
.people-log-threads { margin-top: 12px; }
.people-log-threads-label { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-tertiary); margin-bottom: 6px; }
.people-log-thread { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; font-size: 14px; color: var(--text-primary); }
.people-sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.people-sheet-actions .btn { flex: 1; }

/* Q6 contact line — muted data, no judgment. */
.review-contact-line { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
/* Q6 upgrade reminder-by-UI. */
.review-q6-wip { font-size: 11px; color: var(--text-tertiary); margin-top: 6px; font-style: italic; }

/* Space list rows */
.habit-space { margin-bottom: 8px; }
.habit-space-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  background: var(--card);
  border: none;
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.habit-space-icon { font-size: 20px; line-height: 1; }
.habit-space-name { font-size: 15px; font-weight: 600; color: var(--text-primary); flex: 1; text-align: left; }
.habit-space-count { font-size: 12px; color: var(--text-secondary); }
.habit-space-caret { font-size: 12px; color: var(--text-tertiary); width: 14px; text-align: center; }

.habit-space-empty { text-align: left; padding: 10px 16px; }

/* Habit rows (expanded under a Space) */
.habit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px 10px 24px;
  margin-top: 4px;
  background: var(--surface-inset);
  border: none;
  border-radius: var(--r-pill);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.habit-row-name { font-size: 14px; font-weight: 500; color: var(--text-primary); flex: 1; text-align: left; }
.habit-row-metrics { display: flex; align-items: center; gap: 12px; }
.habit-row-stat { font-family: var(--font-mono); font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

/* Heatmap detail */
.habit-detail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.hd-stat {
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  padding: 12px 6px;
  text-align: center;
}
.hd-val { font-family: var(--font-mono); font-size: 22px; font-weight: 600; color: var(--text-primary); line-height: 1.1; }
.hd-lbl { margin-top: 4px; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); }

.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  max-width: 340px;
  margin: 0 auto;
}
.heat-cell {
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  background: transparent;
}
.heat-done   { background: var(--ok); }
.heat-missed { background: transparent; border: 1px solid var(--separator); }
.heat-notdue { background: transparent; border: 1px dashed var(--text-tertiary); opacity: 0.5; }
.heat-future { background: transparent; }
.heat-pre    { background: transparent; }   /* days before the habit existed — blank */

/* Calendar-aligned habit heatmap — additive; nothing above is modified.
   .heatmap-grid is no longer emitted but its rule stays for safety. */
.heat-cal {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 340px;
  margin: 0;                 /* left-aligned — no floating clump */
}
.heat-cal-head,
.heat-cal-week {
  display: grid;
  grid-template-columns: 44px repeat(7, 1fr);   /* shared template = exact alignment */
  gap: 4px;
  align-items: center;
}
.heat-cal-wklbl {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  text-align: right;
  padding-right: 2px;
  white-space: nowrap;
}
.heat-cal-daylbl {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: center;
}
.heat-cal-week .heat-cell { width: 100%; aspect-ratio: 1 / 1; }   /* scoped — legend untouched */
.heat-blank { background: transparent; border: none; box-shadow: none; }
.heat-today { box-shadow: 0 0 0 2px var(--accent); }

/* Calendar colour language — THREE states, zero decoding. Scoped to the grid
   so the base .heat-* rules (and anything else using them) stay as they were.
   Green = done (quiet, the default texture). Red = missed (the rare state —
   this is the information, it must pop). White = everything else: not-due,
   pre-creation and future days are all one silent empty cell, so every row is
   a solid 7-cell rectangle. */
.heat-cal-week .heat-done {
  background: rgba(52, 199, 89, 0.30);              /* soft --ok tint, no border */
  border: none;
  opacity: 1;
}
.heat-cal-week .heat-missed {
  background: rgba(255, 59, 48, 0.85);              /* --danger tint — loud */
  border: none;
  opacity: 1;
}
.heat-cal-week .heat-notdue,
.heat-cal-week .heat-empty,
.heat-cal-week .heat-pending {                      /* today, still open — never red */
  background: var(--card);                          /* plain faint empty cell */
  border: 1px solid var(--separator);               /* hairline, no dash */
  opacity: 1;
}
/* Legend chips read the same green/red as the grid (the base .heat-missed is a
   pale outline, which would not read as "missed" here). */
.heat-legend-item .heat-done   { background: rgba(52, 199, 89, 0.30); border: none; opacity: 1; }
.heat-legend-item .heat-missed { background: rgba(255, 59, 48, 0.85); border: none; opacity: 1; }

/* ---- Franklin doorway: bad-habits list + virtue ranking + detail ---- */
.frank-section { margin-bottom: 22px; }
.frank-h {
  font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--text-secondary); margin: 0 0 10px 2px;
}

.frank-habit-list { display: flex; flex-direction: column; gap: 8px; }
.frank-habit-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 52px; padding: 10px 14px;
  background: var(--card); border: none; border-radius: var(--r-card);
  box-shadow: var(--shadow-card); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.frank-habit-row:active { transform: scale(0.99); }
.frank-habit-name { font-size: 15px; font-weight: 600; color: var(--text-primary); text-align: left; }
.frank-habit-metrics { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.frank-habit-stat { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.fh-num { font-family: var(--font-mono); font-weight: 600; color: var(--text-primary); }

.frank-focus { font-size: 13px; color: var(--text-secondary); margin: 0 0 12px 2px; }
.frank-focus strong { color: var(--accent); }

.frank-virtue-list { display: flex; flex-direction: column; gap: 12px; }
.frank-virtue-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.frank-virtue-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.frank-virtue-nums { display: flex; align-items: baseline; gap: 8px; font-family: var(--font-mono); }
.fv-total { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.fv-avg { font-size: 11px; color: var(--text-tertiary); }
.frank-virtue-bar-track {
  height: 8px; border-radius: 4px; background: var(--surface-inset); overflow: hidden;
}
.frank-virtue-bar { height: 100%; border-radius: 4px; background: var(--danger); min-width: 0; }

/* Detail page */
.frank-hero { text-align: center; padding: 8px 0 20px; }
.frank-hero-num {
  font-family: var(--font-mono); font-size: 56px; font-weight: 700; line-height: 1;
  color: var(--text-primary);
}
.frank-hero-lbl {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-secondary); margin-top: 6px;
}
.frank-hero-sub { font-size: 13px; color: var(--text-tertiary); margin-top: 10px; }

.tc-bar { fill: var(--danger); }

.heat-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
}
.heat-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.heat-legend-item .heat-cell { width: 12px; height: 12px; aspect-ratio: auto; }
