/* ==========================================================================
   Cornerstone Quest — design system
   Warm paper surface, teal for structure, gold reserved for what matters most.
   ========================================================================== */

:root {
  /* Surfaces — page sits darker than cards so cards read as objects */
  --bg: #f2ece0;
  --surface: #fffdf8;
  --surface-sunken: #eae2d3;
  --surface-inset: rgba(26, 23, 20, 0.035);

  /* Ink — three levels, no more */
  --ink: #1a1714;
  --ink-2: #574f46;
  --ink-3: #8b8277;

  /* Lines — hairlines, not outlines */
  --line: rgba(26, 23, 20, 0.11);
  --line-strong: rgba(26, 23, 20, 0.2);

  /* Accents */
  --teal: #1d5a57;
  --teal-deep: #164643;
  --teal-tint: rgba(29, 90, 87, 0.08);
  --gold: #b9872e;
  --gold-bright: #f2bf2f;
  --gold-tint: rgba(242, 191, 47, 0.16);
  --gold-tint-strong: rgba(242, 191, 47, 0.3);
  --red: #9f3d32;
  --red-tint: rgba(159, 61, 50, 0.09);

  /* Tab groups: gold = the priority, teal = the category tabs,
     slate = the map, plum = off the main track */
  --gold-deep: #9c7126;
  --slate: #4a5a68;
  --slate-deep: #3c4a56;
  --plum: #6b4666;
  --plum-deep: #593a55;

  /* Status */
  --green: #1d5a57;
  --yellow: #b9872e;

  /* Elevation — two levels only */
  --shadow-sm: 0 1px 2px rgba(26, 23, 20, 0.04), 0 2px 6px rgba(26, 23, 20, 0.04);
  --shadow-md: 0 1px 2px rgba(26, 23, 20, 0.05), 0 10px 26px rgba(26, 23, 20, 0.08);

  /* Radii */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Type scale */
  --t-label: 0.6875rem;
  --t-xs: 0.75rem;
  --t-sm: 0.8125rem;
  --t-body: 0.9375rem;
  --t-lg: 1.0625rem;
  --t-h2: 1.375rem;
  --t-h1: 1.5rem;

  /* Space */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--t-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: var(--t-h1);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--teal);
}

h2 {
  font-size: var(--t-h2);
  font-weight: 750;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

h3 {
  font-size: var(--t-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* --------------------------------------------------------------------------
   Controls
   -------------------------------------------------------------------------- */

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  min-height: 36px;
  border-radius: var(--r-sm);
  padding: 0 14px;
  font-size: var(--t-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
}

button:hover {
  background: var(--surface-sunken);
  border-color: var(--line-strong);
}

button:active {
  transform: translateY(1px);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  font-size: var(--t-sm);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-tint);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

input[type="checkbox"] {
  width: auto;
  accent-color: var(--teal);
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* Primary actions — the one place a filled button is earned */
#saveAnchorRitual,
#addAnchor,
[data-save-area-ritual],
[data-add-track-task],
[data-save-task],
#saveOverride,
.sidequest-form button[type="submit"],
.investing-journal-form button[type="submit"] {
  border-color: var(--teal);
  background: var(--teal);
  color: #fffdf8;
}

#saveAnchorRitual:hover,
#addAnchor:hover,
[data-save-area-ritual]:hover,
[data-add-track-task]:hover,
[data-save-task]:hover,
#saveOverride:hover,
.sidequest-form button[type="submit"]:hover,
.investing-journal-form button[type="submit"]:hover {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.app-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: var(--s-4) 0 var(--s-6);
  overflow-x: clip;
}

.hidden {
  display: none !important;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* Shared card primitive */
.anchor-card,
.track-card,
.tomorrow-panel,
.sidequest-list,
.sidequest-form,
.goal-path-card,
.investing-journal,
.review-panel,
.score-card,
.streak-card,
.summary-card,
.weekly-goals {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.eyebrow {
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: var(--s-2);
}

/* --------------------------------------------------------------------------
   Topbar — compact, so the action cards sit above the fold
   -------------------------------------------------------------------------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-4);
  margin-bottom: var(--s-3);
}

.title-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.title-date-controls {
  display: flex;
  gap: 2px;
}

.date-arrow {
  display: grid;
  width: 26px;
  min-height: 26px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--teal);
  font-size: 1.05rem;
  line-height: 1;
}

.date-arrow:hover {
  background: var(--teal-tint);
  border-color: var(--teal-tint);
}

.header-stats {
  display: flex;
  gap: var(--s-2);
}

.day-pill {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-pill);
  padding: 6px 14px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

.day-pill span {
  color: var(--ink-3);
  font-size: var(--t-xs);
  font-weight: 600;
}

.day-pill strong {
  font-size: var(--t-sm);
  font-weight: 700;
}

.week-pill strong {
  color: var(--teal);
}

/* Sync status sits with the header pills and stays quiet unless it needs you */
.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-3);
  font-size: var(--t-xs);
  font-weight: 650;
  white-space: nowrap;
}

.sync-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: currentColor;
}

.sync-chip[data-tone="ok"] {
  color: var(--teal);
}

.sync-chip[data-tone="working"] {
  color: var(--gold);
}

.sync-chip[data-tone="error"] {
  color: var(--red);
  border-color: rgba(159, 61, 50, 0.35);
  background: var(--red-tint);
}

.sync-form {
  display: grid;
  gap: var(--s-3);
}

.sync-form label {
  display: grid;
  gap: var(--s-1);
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sync-note {
  color: var(--ink-2);
  font-size: var(--t-sm);
  line-height: 1.5;
}

.sync-error {
  color: var(--red);
  font-size: var(--t-sm);
  font-weight: 650;
}

.sync-backup {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2);
  border-top: 1px solid var(--line);
  padding-top: var(--s-3);
}

.sync-backup span {
  margin-right: auto;
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#syncConnect,
#syncTakeTheirs {
  border-color: var(--teal);
  background: var(--teal);
  color: #fffdf8;
}

#syncConnect:hover,
#syncTakeTheirs:hover {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
}

/* --------------------------------------------------------------------------
   Tabs — one row, teal for the active section
   -------------------------------------------------------------------------- */

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: var(--s-1);
  padding: var(--s-2) 0 var(--s-3);
  margin-bottom: var(--s-1);
  background: linear-gradient(var(--bg) 78%, rgba(242, 236, 224, 0));
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 650;
  white-space: nowrap;
}

/* Grouping by position rather than by marks: Top 3 stands alone, the six
   category tabs cluster, and the two reference tabs sit off to the right.
   The auto margin collapses to zero once the bar overflows, so narrow
   screens just scroll as one row. */
.tab[data-view="top3"] {
  margin-right: var(--s-3);
}

.tab[data-view="goals"] {
  margin-left: auto;
}

.tab:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}

.tab.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fffdf8;
  font-weight: 700;
}

.tab.active:hover {
  background: var(--teal-deep);
}

/* Gold takes dark ink: white on gold is only 3.2:1 at this size */
.tab[data-view="top3"].active {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--ink);
}

.tab[data-view="top3"].active:hover {
  background: var(--gold-deep);
  border-color: var(--gold-deep);
}

.tab[data-view="goals"].active {
  border-color: var(--slate);
  background: var(--slate);
}

.tab[data-view="goals"].active:hover {
  background: var(--slate-deep);
  border-color: var(--slate-deep);
}

.tab[data-view="sidequests"].active {
  border-color: var(--plum);
  background: var(--plum);
}

.tab[data-view="sidequests"].active:hover {
  background: var(--plum-deep);
  border-color: var(--plum-deep);
}

/* --------------------------------------------------------------------------
   Alignment panel — slim when closed, full ritual when open
   -------------------------------------------------------------------------- */

.signal-panel {
  display: grid;
  gap: var(--s-3);
}

.anchor-card {
  overflow: hidden;
}

.anchor-panel-summary,
.area-ritual > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px var(--s-4);
  color: var(--teal);
  cursor: pointer;
  font-size: var(--t-xs);
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  list-style: none;
}

.anchor-panel-summary:hover,
.area-ritual > summary:hover {
  background: var(--teal-tint);
}

.anchor-panel-summary::-webkit-details-marker,
.area-ritual > summary::-webkit-details-marker {
  display: none;
}

.anchor-card[open] .anchor-panel-summary,
.area-ritual[open] > summary {
  border-bottom: 1px solid var(--line);
}

.anchor-card[open] .anchor-panel-summary .add-task-arrow,
.area-ritual[open] .add-task-arrow {
  transform: rotate(90deg);
}

.anchor-panel-body {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-4);
}

.anchor-compact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}

.anchor-block {
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  display: grid;
  gap: var(--s-2);
  align-content: start;
  border-left: 3px solid transparent;
}

.purpose-block {
  background: var(--teal-tint);
  border-left-color: var(--teal);
}

.today-anchor-block {
  background: var(--gold-tint);
  border-left-color: var(--gold-bright);
}

.anchor-block .eyebrow {
  margin-bottom: 0;
  color: var(--ink-3);
  font-size: var(--t-label);
}

.anchor-card h2 {
  font-size: var(--t-lg);
  line-height: 1.3;
  font-weight: 700;
}

.purpose-block h2 {
  color: var(--teal);
}

.anchor-ritual {
  border-top: 1px solid var(--line);
  padding-top: var(--s-3);
}

.anchor-ritual > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  width: fit-content;
  color: var(--teal);
  cursor: pointer;
  font-size: var(--t-sm);
  font-weight: 650;
  list-style: none;
}

.anchor-ritual > summary::-webkit-details-marker {
  display: none;
}

.anchor-ritual[open] .add-task-arrow {
  transform: rotate(90deg);
}

.anchor-ritual-body {
  display: grid;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.anchor-section-label {
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-top: var(--s-2);
}

.anchor-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-2);
}

.anchor-choice {
  min-height: 64px;
  padding: 10px 12px;
  border-color: var(--line);
  background: var(--surface-inset);
  color: var(--ink-2);
  border-radius: var(--r-md);
  text-align: left;
  font-size: var(--t-sm);
  font-weight: 500;
  line-height: 1.35;
}

.anchor-choice.selected {
  border-color: var(--gold);
  background: var(--gold-tint);
  color: var(--ink);
  font-weight: 650;
  box-shadow: inset 3px 0 0 var(--gold);
}

.anchor-action-input {
  display: grid;
  gap: var(--s-1);
  margin-top: var(--s-2);
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.anchor-nav {
  min-height: 24px;
  width: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: var(--r-pill);
  color: var(--ink-3);
  font-size: 1.1rem;
  line-height: 1;
}

.anchor-nav:hover {
  background: var(--gold-tint);
  color: var(--ink);
}

.anchor-controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 26px;
}

.anchor-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.anchor-dot {
  width: 6px;
  height: 6px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--line-strong);
}

.anchor-dot.active {
  background: var(--gold);
}

#saveAnchorRitual {
  width: fit-content;
  min-width: 150px;
  justify-self: start;
  margin-top: var(--s-1);
}

.anchor-controls {
  margin-top: var(--s-2);
}

.anchor-controls summary {
  width: fit-content;
  margin: 0 auto;
  color: var(--ink-3);
  cursor: pointer;
  font-size: var(--t-sm);
  font-weight: 600;
}

.anchor-controls summary:hover {
  color: var(--teal);
}

.anchor-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

/* Tiny action pinned onto the focused win */
.anchor-action-pin {
  display: block;
  width: fit-content;
  margin-top: var(--s-2);
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--teal-tint);
  color: var(--teal);
  font-size: var(--t-xs);
  font-weight: 650;
}

/* --------------------------------------------------------------------------
   Strips — drift alert, food flag, side-quest reminder
   -------------------------------------------------------------------------- */

.alert,
.food-flag,
.sidequest-reminder {
  margin: var(--s-3) 0;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}

.alert {
  border-color: rgba(159, 61, 50, 0.25);
  background: var(--red-tint);
  padding: 0;
}

.alert summary {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 38px;
  padding: 0 var(--s-3);
  color: var(--red);
  cursor: pointer;
  font-size: var(--t-sm);
  list-style: none;
}

.alert summary::-webkit-details-marker {
  display: none;
}

.alert summary span {
  border-radius: var(--r-pill);
  padding: 2px 9px;
  background: rgba(159, 61, 50, 0.12);
  color: var(--red);
  font-size: var(--t-xs);
  font-weight: 650;
}

.alert.urgent {
  border-color: rgba(159, 61, 50, 0.5);
  background: rgba(159, 61, 50, 0.13);
}

.drift-alert-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-3) var(--s-3);
}

.alert p {
  color: var(--ink-2);
  font-size: var(--t-sm);
}

.alert-actions {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  flex-wrap: wrap;
}

/* Food flag reads as one quiet line, not a block */
.food-flag {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding: 8px var(--s-3);
  border-color: rgba(185, 135, 46, 0.3);
  background: var(--gold-tint);
  font-size: var(--t-sm);
}

.food-flag strong {
  color: var(--gold);
  font-size: var(--t-xs);
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.food-flag span {
  color: var(--ink-2);
}

.sidequest-reminder {
  padding: var(--s-3);
  border-color: rgba(29, 90, 87, 0.28);
  background: var(--teal-tint);
  font-size: var(--t-sm);
}

.sidequest-reminder strong {
  color: var(--teal);
  font-size: var(--t-xs);
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidequest-reminder ul {
  margin: var(--s-2) 0 0;
  padding-left: var(--s-4);
  color: var(--ink-2);
}

/* --------------------------------------------------------------------------
   Support tracks — sunken checklists, deliberately quiet
   -------------------------------------------------------------------------- */

.track-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-3);
}

.support-track {
  border: 1px solid var(--line);
  background: var(--surface-inset);
  border-radius: var(--r-md);
  padding: 9px var(--s-3) 10px;
  min-width: 0;
}

.support-track-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  margin-bottom: 7px;
  position: relative;
}

.support-track-head .eyebrow {
  margin-bottom: 0;
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.support-progress {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  border-radius: var(--r-pill);
  padding: 2px 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-3);
  font-size: var(--t-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.support-action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: var(--s-5);
  row-gap: var(--s-2);
}

.support-task {
  flex: 0 0 auto;
  padding: 1px 0;
}

.support-task.done {
  opacity: 0.5;
}

.support-task-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: var(--t-xs);
  line-height: 1.2;
  white-space: nowrap;
}

.support-task-title strong {
  font-weight: 550;
}

.support-quest .support-task {
  flex: 1 1 220px;
  max-width: 320px;
}

.support-quest .support-task-title {
  justify-content: center;
  text-align: center;
  white-space: normal;
}

.support-task-title > input[type="checkbox"],
.support-step-checks input {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  margin: 0;
}

.support-step-checks {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}

/* --------------------------------------------------------------------------
   Track cards — the three action cards, the centre of gravity
   -------------------------------------------------------------------------- */

.main-track-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
  min-width: 0;
}

.track-card {
  padding: var(--s-4);
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.track-head {
  margin-bottom: var(--s-3);
}

.track-head .eyebrow {
  color: var(--ink);
  font-size: var(--t-sm);
  font-weight: 750;
  letter-spacing: 0;
  text-transform: none;
  margin-bottom: 6px;
}

.track-progress-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
}

.track-head h2 {
  font-size: 1.5rem;
  font-weight: 750;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.bonus-count {
  color: var(--ink-3);
  font-size: var(--t-xs);
  white-space: nowrap;
}

/* Gold marker-pen underline on the track name. Painted as a background on an
   inline span with box-decoration-break, so a title that wraps gets a marker
   per line sized to that line's text. A single absolutely positioned bar left
   a long gold tail hanging past a short last line. */
.track-title-highlight {
  display: inline;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  background-image: linear-gradient(90deg, rgba(242, 191, 47, 0), var(--gold-tint-strong) 9%, var(--gold-tint-strong) 91%, rgba(242, 191, 47, 0));
  background-repeat: no-repeat;
  background-size: 100% 0.42em;
  background-position: 0 86%;
  padding: 0 3px;
  margin: 0 -3px;
}

/* Progress meter */
.meter {
  height: 5px;
  background: var(--surface-sunken);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: 10px;
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: var(--r-pill);
  background: var(--ink-3);
  transition: width 0.3s ease;
}

.meter.green span {
  background: var(--green);
}

.meter.yellow span {
  background: var(--yellow);
}

.meter.red span {
  background: var(--red);
}

/* Accumulating toward a target is progress, not a pass/fail score - so the
   clean cash bar stays neutral rather than reading red while it fills. */
.meter.cash span {
  background: var(--teal);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  border-radius: var(--r-pill);
  color: #fffdf8;
  font-size: var(--t-xs);
  font-weight: 700;
}

.status.green {
  background: var(--green);
}

.status.yellow {
  background: var(--yellow);
}

.status.red {
  background: var(--red);
}

/* Goals — a quiet inset, not another box */
.track-goal {
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  padding: 8px 10px;
  margin: 0 0 var(--s-3);
}

.track-goal summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  column-gap: var(--s-2);
  cursor: pointer;
  list-style: none;
}

.track-goal summary::-webkit-details-marker {
  display: none;
}

.track-goal > summary > span {
  display: block;
  padding-top: 1px;
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.track-goal strong {
  color: var(--teal);
  font-size: var(--t-xs);
  font-weight: 650;
  line-height: 1.3;
}

.track-goal-summary-lines {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.track-goal p {
  color: var(--ink-2);
  font-size: var(--t-xs);
  line-height: 1.45;
  margin-top: 6px;
}

.track-goal-detail small {
  display: block;
  margin-top: 10px;
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.track-footer {
  margin-top: auto;
}

/* --------------------------------------------------------------------------
   Top 3 — countdown strip and the clean cash figures
   -------------------------------------------------------------------------- */

/* The strip is the progress track: the fill grows as the deadline approaches
   and the days-left chip rides its leading edge toward the fixed date. */
.top3-countdown {
  position: relative;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
  overflow: hidden;
}

.top3-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: var(--r-pill);
  background: var(--teal);
  transition: width 0.3s ease, background 0.3s ease;
}

.top3-days {
  position: absolute;
  top: 50%;
  /* clamped so it parks before the date chip instead of colliding with it */
  left: min(calc(var(--p, 0%) + 8px), calc(100% - 232px));
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 4px 11px;
  background: var(--surface);
  color: var(--teal);
  font-size: var(--t-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: left 0.3s ease, color 0.3s ease;
}

.top3-date {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-2);
  font-size: var(--t-xs);
  font-weight: 650;
  white-space: nowrap;
}

.top3-countdown.urgent-soon .top3-fill {
  background: var(--gold);
}

.top3-countdown.urgent-soon .top3-days {
  color: var(--gold);
}

.top3-countdown.urgent-now .top3-fill,
.top3-countdown.past .top3-fill {
  background: var(--red);
}

.top3-countdown.urgent-now .top3-days,
.top3-countdown.past .top3-days {
  color: var(--red);
}

.cash-figures {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.cash-figures h2 {
  font-size: 1.5rem;
  font-weight: 750;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.cash-target {
  color: var(--ink-3);
  font-size: var(--t-sm);
  font-variant-numeric: tabular-nums;
}

.cash-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  margin-top: 6px;
  color: var(--ink-3);
  font-size: var(--t-xs);
}

.cash-edit {
  margin-top: var(--s-2);
}

.cash-edit summary {
  width: fit-content;
  cursor: pointer;
  color: var(--ink-3);
  font-size: var(--t-xs);
  font-weight: 650;
  list-style: none;
}

.cash-edit summary::-webkit-details-marker {
  display: none;
}

.cash-edit summary:hover {
  color: var(--teal);
}

.cash-edit-grid {
  display: grid;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

.cash-edit-grid label {
  display: grid;
  gap: var(--s-1);
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

[data-clean-cash-save] {
  border-color: var(--teal);
  background: var(--teal);
  color: #fffdf8;
  justify-self: start;
}

[data-clean-cash-save]:hover {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
}

/* --------------------------------------------------------------------------
   Tasks
   -------------------------------------------------------------------------- */

.task-list {
  display: grid;
  gap: var(--s-2);
}

.task {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--s-3);
  min-width: 0;
  font-size: var(--t-sm);
  overflow-wrap: anywhere;
}

.task strong {
  font-size: var(--t-body);
  font-weight: 650;
  line-height: 1.3;
}

.task input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-top: 1px;
}

.task.has-steps {
  grid-template-columns: 1fr;
}

/* The #1 win — the single loudest thing on the page */
.task.top-win {
  border-color: rgba(185, 135, 46, 0.4);
  background: linear-gradient(180deg, var(--gold-tint), rgba(255, 253, 248, 0.5));
  border-left: 3px solid var(--gold-bright);
}

.task.top-win.focused-win {
  border-color: var(--gold-bright);
  border-left-width: 3px;
  background: linear-gradient(180deg, var(--gold-tint-strong), var(--gold-tint));
  box-shadow: 0 0 0 3px rgba(242, 191, 47, 0.18);
  cursor: pointer;
}

.task.top-win > input[type="checkbox"] {
  margin-top: 3px;
}

.win-label-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.win-heading {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--gold);
  color: #fffdf8;
  font-size: var(--t-label);
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Debt reads red, not gold - it is not today's chosen priority */
.carry-chip {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: rgba(159, 61, 50, 0.12);
  color: var(--red);
  font-size: var(--t-label);
  font-weight: 700;
  white-space: nowrap;
}

.win-cycle {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin-left: auto;
}

.win-count {
  min-width: 26px;
  text-align: center;
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.carried-drawer > summary .drawer-label {
  color: var(--red);
}

.win-rotate {
  display: grid;
  width: 22px;
  min-height: 22px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--teal);
  font-size: 0.95rem;
  line-height: 1;
}

.win-rotate:hover {
  background: rgba(29, 90, 87, 0.14);
}

.implementation {
  display: block;
  margin-top: 5px;
  color: var(--ink-2);
  font-size: var(--t-sm);
  line-height: 1.45;
}

.task.done {
  opacity: 0.55;
}

.task.no-action-state {
  display: block;
  border-style: dashed;
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink-2);
}

.task.no-action-state strong {
  color: var(--ink);
}

.task.no-action-state button {
  margin-top: 10px;
}

.step-checks {
  display: flex;
  gap: 6px;
  align-items: center;
  padding-top: var(--s-2);
  flex-wrap: wrap;
}

.step-checks input {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
}

.step-progress {
  color: var(--ink-3);
  font-size: var(--t-xs);
  font-variant-numeric: tabular-nums;
  margin-left: 3px;
}

/* Bonus-action drawer */
.task-drawer {
  margin-top: var(--s-2);
}

.task-drawer summary {
  display: flex;
  align-items: center;
  min-height: 26px;
  cursor: pointer;
  list-style: none;
}

.task-drawer summary::-webkit-details-marker {
  display: none;
}

.drawer-label {
  color: var(--teal);
  font-size: var(--t-xs);
  font-weight: 650;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-label strong {
  color: var(--ink-3);
  font-weight: 550;
}

.drawer-open {
  display: none;
}

.task-drawer[open] .drawer-open {
  display: inline;
}

.task-drawer[open] .drawer-closed {
  display: none;
}

.task-drawer-list {
  margin-top: var(--s-2);
}

/* Inline edit + add panels */
.task-edit {
  margin-top: var(--s-2);
}

.task-edit summary {
  width: fit-content;
  cursor: pointer;
  color: var(--ink-3);
  font-size: var(--t-xs);
  font-weight: 650;
  list-style: none;
}

.task-edit summary::-webkit-details-marker {
  display: none;
}

.task-edit summary:hover {
  color: var(--teal);
}

.task-edit-grid,
.add-task-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(88px, 0.25fr);
  gap: var(--s-2);
  margin-top: var(--s-2);
}

.task-edit-grid label,
.add-task-grid label,
.sidequest-form label,
.area-ritual-body label,
.investing-journal-form label,
.review-panel label {
  display: grid;
  gap: var(--s-1);
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.task-edit-grid .wide {
  grid-column: 1 / -1;
}

.task-edit-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.add-task-panel {
  border-top: 1px solid var(--line);
  margin-top: var(--s-2);
  padding-top: var(--s-2);
}

.add-task-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  color: var(--ink-3);
  cursor: pointer;
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.07em;
  list-style: none;
  text-transform: uppercase;
}

.add-task-summary::-webkit-details-marker {
  display: none;
}

.add-task-summary:hover {
  color: var(--teal);
}

.add-task-arrow {
  color: var(--gold);
  font-size: 1rem;
  line-height: 1;
  transition: transform 0.16s ease;
}

.add-task-panel[open] .add-task-arrow {
  transform: rotate(90deg);
}

.add-task-grid {
  grid-template-columns: minmax(80px, 1fr) minmax(80px, 1fr) auto auto;
  align-items: end;
}

.add-task-grid [data-new-label],
.add-task-grid [data-new-intent] {
  grid-column: 1 / -1;
}

/* Track cards are a third of the width — stack their forms rather than squeeze */
.track-card .task-edit-grid,
.track-card .add-task-grid {
  grid-template-columns: 1fr;
}

.inline-check {
  align-items: center;
  grid-template-columns: auto max-content;
  min-height: 36px;
}

.inline-check input {
  width: 16px;
  height: 16px;
}

/* --------------------------------------------------------------------------
   Section headers
   -------------------------------------------------------------------------- */

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  margin: var(--s-5) 0 var(--s-3);
}

.section-head .eyebrow {
  margin-bottom: 3px;
}

/* --------------------------------------------------------------------------
   Tomorrow panel
   -------------------------------------------------------------------------- */

.tomorrow-panel {
  margin-top: var(--s-4);
  padding: var(--s-4);
}

.tomorrow-panel .section-head {
  margin: 0 0 var(--s-3);
}

.tomorrow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-3);
}

.tomorrow-card,
.goal-card {
  border: 1px solid var(--line);
  background: var(--surface-inset);
  border-radius: var(--r-md);
  padding: var(--s-3);
}

.tomorrow-card .eyebrow,
.goal-card .eyebrow {
  font-size: var(--t-label);
  margin-bottom: 6px;
}

.tomorrow-card ul,
.goal-card ul {
  margin: 0;
  padding-left: var(--s-4);
  color: var(--ink-2);
  font-size: var(--t-sm);
}

.tomorrow-card li,
.goal-card li {
  margin-bottom: 3px;
}

/* --------------------------------------------------------------------------
   Goal overview
   -------------------------------------------------------------------------- */

.goal-overview,
.area-action-view {
  display: grid;
  gap: var(--s-3);
}

.goal-path-card {
  display: grid;
  gap: var(--s-4);
  padding: var(--s-5);
}

.goal-path-card > .eyebrow {
  font-size: var(--t-sm);
  font-weight: 750;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  margin-bottom: 0;
}

.goal-path-section {
  display: grid;
  gap: var(--s-2);
}

.goal-path-label {
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.goal-path-section p {
  max-width: 78ch;
  color: var(--ink-2);
  font-size: var(--t-sm);
  line-height: 1.6;
}

.goal-milestones {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: var(--s-5);
  font-size: var(--t-sm);
  color: var(--ink-2);
}

.goal-milestones .current-milestone {
  color: var(--teal);
  font-weight: 700;
}

.current-goal-actions > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-2);
}

.goal-action {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 10px var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  font-size: var(--t-sm);
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.goal-action:hover {
  background: var(--teal-tint);
  border-color: rgba(29, 90, 87, 0.25);
}

.goal-action input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

/* --------------------------------------------------------------------------
   Area views — ritual + investing journal
   -------------------------------------------------------------------------- */

.area-ritual {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.area-ritual-body {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  align-items: end;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4) var(--s-4);
}

.investing-journal {
  display: grid;
  gap: var(--s-4);
  padding: var(--s-4);
}

.investing-journal-form {
  display: grid;
  grid-template-columns: minmax(160px, 210px) minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--s-2);
}

.investing-journal-form textarea {
  min-height: 84px;
}

.investing-journal-list {
  display: grid;
}

.investing-journal-entry {
  display: grid;
  grid-template-columns: minmax(120px, 150px) minmax(0, 1fr);
  gap: var(--s-4);
  padding: var(--s-3) 0;
  border-top: 1px solid var(--line);
}

.investing-journal-entry time {
  color: var(--teal);
  font-size: var(--t-xs);
  font-weight: 700;
}

.journal-daily-check {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
  padding: 8px 12px;
  border: 1px solid rgba(185, 135, 46, 0.35);
  border-radius: var(--r-md);
  background: var(--gold-tint);
  color: var(--ink);
  font-size: var(--t-sm);
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
}

.journal-daily-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 1px;
  accent-color: var(--gold);
}

.journal-daily-check.done {
  border-color: var(--line);
  background: var(--surface-inset);
  color: var(--ink-3);
  text-decoration: line-through;
}

.journal-entry-body {
  display: grid;
  gap: var(--s-2);
  min-width: 0;
}

.journal-edit {
  margin-top: var(--s-1);
}

.journal-edit > summary {
  width: fit-content;
  cursor: pointer;
  color: var(--ink-3);
  font-size: var(--t-xs);
  font-weight: 650;
  list-style: none;
}

.journal-edit > summary::-webkit-details-marker {
  display: none;
}

.journal-edit > summary:hover {
  color: var(--teal);
}

.journal-edit-grid {
  display: grid;
  grid-template-columns: minmax(140px, 200px) minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

.journal-edit-grid label {
  display: grid;
  gap: var(--s-1);
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.journal-edit-grid textarea {
  min-height: 76px;
}

[data-journal-save] {
  border-color: var(--teal);
  background: var(--teal);
  color: #fffdf8;
}

[data-journal-save]:hover {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
}

/* Marker-pen wash, same motif as the track titles */
.journal-mark {
  border-radius: 3px;
  background: var(--gold-tint-strong);
  box-shadow: 0 0 0 2px var(--gold-tint-strong);
  color: inherit;
  cursor: pointer;
}

.journal-mark:hover {
  background: rgba(159, 61, 50, 0.22);
  box-shadow: 0 0 0 2px rgba(159, 61, 50, 0.22);
}

/* Floats by the selection; position is set in JS against the viewport */
.journal-highlight-btn {
  position: fixed;
  z-index: 40;
  transform: translate(-50%, -125%);
  min-height: 28px;
  padding: 0 12px;
  border-color: var(--gold);
  border-radius: var(--r-pill);
  background: var(--gold);
  color: var(--ink);
  font-size: var(--t-xs);
  font-weight: 700;
  box-shadow: var(--shadow-md);
}

.journal-highlight-btn:hover {
  background: var(--gold-deep);
  border-color: var(--gold-deep);
  color: #fffdf8;
}

/* button:active nudges with translateY, which would replace the positioning
   transform and shift this button out from under the cursor mid-press - the
   mouseup then lands elsewhere and no click event is ever produced. */
.journal-highlight-btn:active {
  transform: translate(-50%, -125%);
}

.journal-archive {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-inset);
}

.journal-archive > summary {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 10px var(--s-3);
  cursor: pointer;
  list-style: none;
}

.journal-archive > summary::-webkit-details-marker {
  display: none;
}

.journal-archive[open] > summary {
  border-bottom: 1px solid var(--line);
}

.journal-archive[open] .add-task-arrow {
  transform: rotate(90deg);
}

.journal-archive-label {
  color: var(--ink-2);
  font-size: var(--t-xs);
  font-weight: 700;
}

.journal-archive-range {
  color: var(--ink-3);
  font-size: var(--t-xs);
  margin-left: auto;
}

.journal-archive .investing-journal-list {
  padding: 0 var(--s-3) var(--s-2);
}

.investing-journal-entry p,
.empty-journal {
  color: var(--ink-2);
  font-size: var(--t-sm);
  line-height: 1.55;
  white-space: pre-wrap;
}

/* --------------------------------------------------------------------------
   Side-quests
   -------------------------------------------------------------------------- */

.sidequest-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.3fr) auto auto;
  align-items: end;
  gap: var(--s-3);
  padding: var(--s-4);
  margin-bottom: var(--s-3);
}

.sidequest-no-deadline {
  align-self: end;
  min-height: 36px;
}

.sidequest-list {
  display: grid;
  gap: var(--s-4);
  padding: var(--s-4);
}

.sidequest-group {
  display: grid;
  gap: var(--s-2);
}

.sidequest-group h3 {
  border-bottom: 1px solid var(--line);
  padding-bottom: var(--s-2);
  font-size: var(--t-sm);
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.sidequest-item {
  display: grid;
  grid-template-columns: 22px minmax(200px, 1fr) minmax(140px, 0.35fr) minmax(140px, 0.35fr) auto auto auto auto;
  gap: var(--s-2);
  align-items: end;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--s-3);
}

.sidequest-item.important {
  border-color: var(--gold-bright);
  border-left: 3px solid var(--gold-bright);
  background: linear-gradient(180deg, var(--gold-tint), rgba(255, 253, 248, 0.5));
}

.sidequest-item > input[type="checkbox"] {
  width: 17px;
  height: 17px;
  align-self: center;
}

.sidequest-important-toggle {
  border-color: rgba(185, 135, 46, 0.4);
  background: var(--gold-tint);
  color: var(--gold);
  white-space: nowrap;
}

.sidequest-item.important .sidequest-important-toggle {
  background: var(--gold);
  border-color: var(--gold);
  color: #fffdf8;
}

.sidequest-main,
.sidequest-field {
  display: grid;
  gap: var(--s-1);
}

.sidequest-field {
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidequest-text,
.sidequest-item .sidequest-date {
  width: 100%;
  height: auto;
}

.sidequest-item.done .sidequest-text {
  color: var(--ink-3);
  text-decoration: line-through;
}

.sidequest-date-only,
.sidequest-clear-deadline {
  padding: 0 10px;
  white-space: nowrap;
}

.sidequest-meta {
  display: block;
  margin-top: var(--s-1);
  color: var(--ink-3);
  font-size: var(--t-xs);
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   Dialog
   -------------------------------------------------------------------------- */

dialog {
  width: min(440px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  padding: var(--s-5);
  box-shadow: var(--shadow-md);
}

dialog::backdrop {
  background: rgba(26, 23, 20, 0.45);
  backdrop-filter: blur(2px);
}

dialog form {
  display: grid;
  gap: var(--s-3);
}

dialog p {
  color: var(--ink-2);
  font-size: var(--t-sm);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
}

/* --------------------------------------------------------------------------
   Score / streak / review components (rendered by legacy views)
   -------------------------------------------------------------------------- */

.score-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-2);
}

.score-card,
.streak-card,
.summary-card {
  padding: var(--s-4);
}

.score-row,
.streak-row,
.task-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
}

.score-value {
  font-size: 1.35rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.streak-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-2);
  margin-top: var(--s-3);
}

.streak-mini {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--s-3);
}

.streak-mini span,
.task-meta,
.hint {
  color: var(--ink-3);
  font-size: var(--t-xs);
}

.streak-mini strong {
  display: block;
  font-size: 1.2rem;
  margin-top: var(--s-1);
}

.review-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
}

.review-panel {
  margin-top: var(--s-3);
  padding: var(--s-4);
  display: grid;
  gap: var(--s-3);
}

.streak-board {
  display: grid;
  gap: var(--s-3);
}

.weekly-goals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
  padding: var(--s-4);
  margin-bottom: var(--s-3);
}

.summary-card strong {
  display: block;
  font-size: 1.75rem;
  margin-top: var(--s-2);
}

.date-nav {
  display: grid;
  grid-template-columns: auto minmax(190px, 260px) auto auto;
  align-items: end;
  gap: var(--s-2);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: var(--s-3);
  margin-bottom: var(--s-3);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1100px) {
  .tomorrow-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 920px) {
  .app-shell {
    width: min(1240px, calc(100% - 28px));
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-3);
  }

  .header-stats {
    width: 100%;
    flex-wrap: wrap;
  }

  .drift-alert-body {
    flex-direction: column;
    align-items: flex-start;
  }

  .food-flag {
    flex-direction: column;
    gap: var(--s-1);
  }

  .main-track-grid,
  .review-grid,
  .summary-grid,
  .score-strip,
  .weekly-goals {
    grid-template-columns: 1fr;
  }

  .streak-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .add-task-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .area-ritual-body,
  .current-goal-actions > div,
  .investing-journal-form,
  .investing-journal-entry,
  .journal-edit-grid,
  .date-nav {
    grid-template-columns: 1fr;
  }

  .sidequest-form {
    grid-template-columns: 1fr;
  }

  .sidequest-item {
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: start;
  }

  .sidequest-main,
  .sidequest-field,
  .sidequest-date,
  .sidequest-item button {
    grid-column: 2;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1240px);
    padding-top: var(--s-3);
  }

  .anchor-compact,
  .anchor-choice-grid,
  .anchor-add-row,
  .add-task-grid,
  .task-edit-grid,
  .tomorrow-grid,
  .streak-rail {
    grid-template-columns: 1fr;
  }

  .goal-path-card {
    padding: var(--s-4);
  }

  .support-action-row {
    column-gap: var(--s-4);
  }

  /* Too little track to ride on a phone — pin the chip left so the two
     labels sit at opposite ends and never overlap. */
  .top3-days {
    left: 6px;
    padding: 3px 9px;
  }

  .top3-date {
    right: 10px;
  }

  /* Stack the progress badge instead of letting it sit on top of the label */
  .support-track-head {
    flex-direction: column;
    gap: var(--s-1);
  }

  .support-progress {
    position: static;
    transform: none;
  }

  .support-track-head .eyebrow {
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
