/* ============================================================
   LEDGER — the rules and values indexes
   Both pages list items with a month of history beside each one, and share this one
   look, built from the home page's pieces: cards on --surface-card with its sheen and
   lit top edge, the area's accent as the left stripe and its wash behind the card,
   system type on the cool neutral text tokens. History is a single strip of days
   rather than a month grid, so a row stays about 52px tall.
   ============================================================ */
.ledger-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 24px 72px;
  box-sizing: border-box;
  color: var(--text-1);
}

/* Rules | Values (shared/_ledger_head): one page's two views, as a switch. */
.ledger-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  letter-spacing: -0.005em;
}
/* Over the shared .ledger-title's heading size, which is set further down. */
.ledger-title.ledger-switch { font-size: var(--fs-15); font-weight: 600; }
.ledger-switch > a,
.ledger-switch > .is-current { padding: 5px 16px; border-radius: 999px; line-height: 1.2; }
.ledger-switch > a { color: var(--text-2); }
.ledger-switch > a:hover { color: var(--text-1); background: rgba(255, 255, 255, 0.04); }
.ledger-switch > .is-current { background: var(--surface-3, #2a2a30); color: var(--text-1); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }

/* The Overall strip's key (shared/_ledger_summary). */
.ledger-key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 10px 0 0; color: var(--text-3); font-size: var(--fs-11); }
.ledger-key span { display: inline-flex; align-items: center; gap: 6px; }
.ledger-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--key); }
.ledger-key i.is-blank { background: rgba(255, 255, 255, 0.08); }
.ledger-key i.is-scale { width: 64px; background: linear-gradient(90deg, rgba(167, 139, 250, 0.16), rgba(167, 139, 250, 1)); }
.ledger-key .ledger-key-gap { margin-left: 8px; }

/* An empty ranking's line saying what it's for (rules/index). */
/* One slim line until something's ranked, rather than a tall dashed box above the rules. */
.ledger-dropzone-hint { display: flex; align-items: center; gap: 8px; margin: 4px 12px 8px; padding: 7px 12px; border: 1px dashed var(--border); border-radius: var(--radius-sm); color: var(--text-3); font-size: var(--fs-12); list-style: none; }
.ledger-dropzone-hint[hidden] { display: none; }
/* A picker's faint stand-in icon when none is chosen (icon_picker_controller). */
.icon-picker-preview.is-placeholder { color: var(--text-3); opacity: 0.6; }
/* Nothing ranked yet: the card is just its drop line, a quiet dashed strip above the
   unranked list, rather than a whole card with a header counting 0. It comes back in full
   once a rule lands in it (rule-columns hides the hint). */
.ledger-card:has(> .ledger-list > .ledger-dropzone-hint:not([hidden])) { border-color: transparent; background: none; box-shadow: none; }
.ledger-card:has(> .ledger-list > .ledger-dropzone-hint:not([hidden])) > .ledger-card-head { display: none; }
.ledger-card:has(> .ledger-list > .ledger-dropzone-hint:not([hidden])) .ledger-dropzone-hint { margin: 0; }
/* An unranked row has no number, so it doesn't keep the number's column: its icon and name
   sit at the card's edge like the header's. */
.ledger-tray .ledger-row { grid-template-columns: 16px minmax(0, 1fr) auto 22px; }
.ledger-tray .ledger-row > .ledger-rank { display: none; }

/* Header: page switch and New on the left, month on the right. */
.ledger-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 18px;
}
.ledger-head-left { display: flex; align-items: center; gap: 14px; }
.ledger-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-size: var(--fs-22);
  font-weight: 600;
  letter-spacing: -0.015em;
}
.ledger-title a { color: var(--text-3); text-decoration: none; transition: color var(--dur-fast) ease; }
.ledger-title a:hover { color: var(--text-2); }
.ledger-title .is-current { color: var(--text-1); }
.ledger-title-sep { color: var(--border-strong); font-weight: 400; }
.ledger-new {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--fs-12);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dur-fast) ease, border-color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}
.ledger-new:hover { color: var(--text-1); border-color: var(--border-strong); background-color: var(--surface-2); }
.ledger-new i { font-size: var(--fs-10); }
/* Rules, Values, Journals and Library are the indexes whose New button repeats the
   sidebar's create link exactly — the sidebar link carries the same context the page
   button does, down to the area a values page is filtered to and the subject a Library
   page is showing. Only Things and Routines are left out, having no sidebar create
   link at all. At full width the sidebar row is right there, so the page button is
   noise. Below 1181px the sidebar is a 72px rail, and on a phone it's behind the ☰ menu;
   in both the create links are two taps deep, so the page button earns its place back.
   Breakpoint matches the rail's own, above. (Rules and Values show theirs at every width,
   quietly: .is-quiet.) */
.ledger-new.is-rail-only { display: none; }
@media (max-width: 1180px) {
  .ledger-new.is-rail-only { display: inline-flex; }
}
.ledger-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: -6px 0 14px;
  color: var(--text-3);
  font-size: var(--fs-12);
  text-decoration: none;
}
.ledger-back:hover { color: var(--text-1); }

.ledger-month { display: flex; align-items: center; gap: 4px; }
/* Clear of the Filters button in the page's top-right corner, which sat over the › — as
   the calendar and inspirations headers keep clear of it. A phone has no corner button. */
@media (min-width: 820px) {
  .ledger-head .ledger-month { margin-right: 46px; }
}
/* A phone: the switch and New on one line, the month on its own under them, spread across. */
@media (max-width: 640px) {
  .ledger-head .ledger-month { order: 3; width: 100%; justify-content: space-between; }
}
.ledger-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: var(--fs-11);
  cursor: pointer;
  transition: color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}
.ledger-nav-btn:hover { color: var(--text-1); border-color: var(--border-strong); }
.ledger-nav-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.ledger-month-picker { position: relative; }
.ledger-month-label {
  min-width: 136px;
  height: 28px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-1);
  font: inherit;
  font-size: var(--fs-14);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast) ease;
}
.ledger-month-label:hover { background-color: var(--surface-2); }
.ledger-month-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 170px;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px 0;
  background: var(--surface-pop);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}
.ledger-month-menu.open { display: block; }
.ledger-month-year {
  padding: 8px 14px 4px;
  color: var(--text-3);
  font-size: var(--fs-10);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ledger-month-item {
  display: block;
  width: 100%;
  padding: 6px 14px 6px 22px;
  border: none;
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-13);
  text-align: left;
  cursor: pointer;
}
@media (hover: hover) { .ledger-month-item:hover { background: var(--surface-3); color: var(--text-1); } }
.ledger-month-item.current { color: var(--accent-bright); font-weight: 600; }
/* A month with nothing in it is still worth opening, so it dims rather than disappears. */
.ledger-month-item.is-empty { opacity: 0.4; }
.ledger-month-item.is-empty:hover { opacity: 1; }

/* Cards. --ledger-accent and --ledger-surface come from the area (or category) the card
   holds; a card with neither is the plain day-panel surface with a neutral stripe. */
.ledger-card {
  position: relative;
  margin-bottom: 14px;
  background-color: var(--ledger-surface, var(--surface-card));
  background-image: var(--sheen);
  border: 1px solid var(--border-panel);
  border-left: 3px solid var(--ledger-accent, var(--border-strong));
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045), 0 1px 2px rgba(0, 0, 0, 0.4);
}
.ledger-card[hidden] { display: none; }
.ledger-card-head,
.ledger-tray-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 11px;
  border-bottom: 1px solid color-mix(in srgb, var(--ledger-accent, #ffffff) 12%, transparent);
}
.ledger-card-icon { width: 16px; color: var(--ledger-accent, var(--text-3)); font-size: var(--fs-13); text-align: center; }
.ledger-card-title { color: var(--text-1); font-size: var(--fs-14); font-weight: 600; }
.ledger-card-count { color: var(--text-3); font-size: var(--fs-12); font-variant-numeric: tabular-nums; }
.ledger-card-score {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--text-2);
  font-size: var(--fs-12);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.ledger-card-score::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--fill, transparent); }
.ledger-card-score.is-empty { color: var(--text-3); font-weight: 400; }
.ledger-card-score.is-empty::before { display: none; }
.ledger-card-score[hidden] { display: none; }

.ledger-tray-head {
  width: 100%;
  border-top: none;
  border-right: none;
  border-left: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ledger-tray-chevron { width: 16px; color: var(--text-3); font-size: var(--fs-10); text-align: center; transition: transform var(--dur-base) ease; }
.ledger-tray.is-collapsed .ledger-tray-chevron { transform: rotate(-90deg); }
.ledger-tray.is-collapsed .ledger-tray-head { border-bottom-color: transparent; }
.ledger-tray.is-collapsed .ledger-list { display: none; }

.ledger-summary { padding: 14px 16px 16px; }
.ledger-summary-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.ledger-eyebrow { color: var(--text-3); font-size: var(--fs-10); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.ledger-summary-stats { color: var(--text-2); font-size: var(--fs-13); font-variant-numeric: tabular-nums; }
.ledger-summary-stats strong { color: var(--text-1); font-weight: 600; }

.ledger-empty { padding: 40px 16px; color: var(--text-3); font-size: var(--fs-13); text-align: center; }
.ledger-empty a { color: var(--text-1); }

/* Rows: rank · icon · name and details · strip · hover action. */
.ledger-list { margin: 0; padding: 4px 0; list-style: none; }
.ledger-list.is-ranked { min-height: 44px; }
.ledger-row {
  display: grid;
  grid-template-columns: 22px 16px minmax(0, 1fr) auto 22px;
  align-items: center;
  column-gap: 12px;
  padding: 9px 10px 9px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.035);
  transition: background-color var(--dur-fast) ease;
}
.ledger-row:first-child { border-top-color: transparent; }
@media (hover: hover) { .ledger-row:hover { background-color: rgba(255, 255, 255, 0.025); } }
.ledger-list.is-draggable .ledger-row { cursor: grab; }
.ledger-list.is-draggable .ledger-row:active { cursor: grabbing; }
.ledger-row.is-someday,
.ledger-row.is-archived { opacity: 0.5; }
.ledger-ghost { opacity: 0.4; background: var(--surface-3) !important; }
.ledger-rank { color: var(--text-3); font-size: var(--fs-11); text-align: right; font-variant-numeric: tabular-nums; }
.ledger-icon { color: var(--ledger-accent, var(--text-3)); font-size: var(--fs-12); text-align: center; }
.ledger-body { min-width: 0; }
.ledger-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--text-1);
  font-size: var(--fs-14);
  font-weight: 500;
  line-height: 1.35;
  text-decoration: none;
  text-wrap: pretty;
}
.ledger-name:hover { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.ledger-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 4px; }
.ledger-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-2);
  font-size: var(--fs-11);
  line-height: 1;
  white-space: nowrap;
}
.ledger-tag.is-plain { padding: 0 2px; background: none; color: var(--text-3); }
.ledger-tag.is-muted { color: var(--text-3); }
.ledger-tag i { color: var(--text-3); font-size: var(--fs-10); }
a.ledger-tag { text-decoration: none; }
a.ledger-tag:hover, a.ledger-tag:hover i { color: var(--text-2); }
.ledger-desc {
  margin-top: 4px;
  overflow: hidden;
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ledger-track { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.ledger-actions { display: flex; justify-content: center; }
.ledger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--text-3);
  font-size: var(--fs-11);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-fast) ease, color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}
.ledger-row:hover .ledger-action,
.ledger-action:focus-visible { opacity: 1; }
/* The ↑ that ranks a row stays faintly in view, so the empty Prioritized card's "press ↑"
   points at something. */
.ledger-action.ledger-add { opacity: 0.4; }
.ledger-add:hover { background: var(--surface-3); color: var(--text-1); }
.ledger-remove:hover { background: rgba(239, 68, 68, 0.12); color: var(--danger-bright); }

/* The strip. Every week carries the same 2px padding in every mode, so strips line up
   down a card however each row is reviewed. */
.ledger-strip { display: flex; align-items: stretch; gap: 3px; }
.ledger-week { display: flex; gap: 2px; padding: 2px; border-radius: 5px; }
.ledger-day {
  position: relative;
  width: 7px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: box-shadow var(--dur-fast) ease;
}
.ledger-day:hover { box-shadow: 0 0 0 1px var(--text-3); }
.ledger-day.is-rated { background: var(--fill); }
/* Values: a day gone by with no rating is an outline, not a fill. Filled grey, it was all
   but the colour of the lowest rating's dark violet, so a bad day and a skipped one looked
   alike. (Rules' kept / partly / missed are green, orange and red, far enough from it.) */
[data-controller~="values-date-nav"] .ledger-day:not(.is-rated):not(.is-future) { background: transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); }
[data-controller~="values-date-nav"] .ledger-key i.is-blank { background: transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22); }
.ledger-day.is-future { background: rgba(255, 255, 255, 0.03); cursor: default; pointer-events: none; }
.ledger-day.is-marked { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6); }
.ledger-day.is-selected { box-shadow: 0 0 0 1.5px var(--text-1); }
.ledger-day.is-today::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 3px;
  height: 3px;
  margin-left: -1.5px;
  border-radius: 50%;
  background: var(--text-1);
}

/* Reviewed weekly: each week is outlined and clicked as one. Reviewed monthly: the
   whole strip is. A reading for that period fills it; the days stay faintly visible. */
.ledger-strip.is-weekly .ledger-week,
.ledger-strip.is-month { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); }
.ledger-strip.is-month { border-radius: 6px; }
.ledger-strip.is-weekly .ledger-day,
.ledger-strip.is-month .ledger-day { pointer-events: none; }
.ledger-week.is-clickable,
.ledger-strip.is-month.is-clickable { cursor: pointer; }
.ledger-week.is-clickable:hover,
.ledger-strip.is-month.is-clickable:hover { box-shadow: inset 0 0 0 1px var(--text-3); }
.ledger-week.is-selected,
.ledger-strip.is-month.is-selected { box-shadow: inset 0 0 0 1.5px var(--text-1); }
.ledger-week.is-filled,
.ledger-strip.is-filled { background: var(--fill); }
.ledger-week.is-filled .ledger-day,
.ledger-strip.is-filled .ledger-day { background: rgba(0, 0, 0, 0.14); }
.ledger-week.is-filled .ledger-day.is-future,
.ledger-strip.is-filled .ledger-day.is-future { background: rgba(0, 0, 0, 0.42); }

/* The Overall strip spans the card, with day numbers. */
.ledger-strip.is-summary { width: 100%; gap: 6px; }
.ledger-strip.is-summary .ledger-week { flex: var(--days) 1 0; padding: 0; }
.ledger-strip.is-summary .ledger-day {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 28px;
  border-radius: 4px;
  color: var(--text-3);
  font-size: var(--fs-10);
  font-weight: 600;
  cursor: default;
}
.ledger-strip.is-summary .ledger-day:hover { box-shadow: none; }
.ledger-strip.is-summary .ledger-day.is-rated { color: rgba(0, 0, 0, 0.72); }
.ledger-strip.is-summary .ledger-day.is-today { box-shadow: inset 0 0 0 1.5px var(--text-1); }
.ledger-strip.is-summary .ledger-day.is-today::after { display: none; }

/* Dials open under the strip. */
.ledger-dials { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.ledger-dials:empty { display: none; }
.ledger-dials-when { color: var(--text-3); font-size: var(--fs-11); }
.ledger-dials-row { display: flex; align-items: center; gap: 6px; }
/* Which class a rating came from (TaskRatedValue), ahead of its dials. */
.ledger-dials-task { flex: 0 1 9em; min-width: 0; color: var(--text-2); font-size: var(--fs-12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Clear a reading, back to untracked: the schedule column's x, left of the dials. Its
   space is held by a spacer when there's nothing to clear so the dials never shift. */
.ledger-untrack,
.ledger-untrack-spacer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.ledger-untrack {
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}
.ledger-untrack:hover { color: var(--rate-bad); background-color: color-mix(in srgb, var(--rate-bad) 14%, transparent); }
.ledger-untrack:focus-visible { outline: 2px solid var(--text-1); outline-offset: 1px; }

@media (max-width: 720px) {
  .ledger-page { padding: 18px 12px 56px; }
  .ledger-row { grid-template-columns: 22px 16px minmax(0, 1fr) 22px; row-gap: 10px; }
  .ledger-row > .ledger-rank { grid-column: 1; grid-row: 1; }
  .ledger-row > .ledger-icon { grid-column: 2; grid-row: 1; }
  .ledger-row > .ledger-body { grid-column: 3; grid-row: 1; }
  .ledger-row > .ledger-actions { grid-column: 4; grid-row: 1; }
  .ledger-row > .ledger-track { grid-column: 3 / 5; grid-row: 2; align-items: stretch; min-width: 0; }
  /* A month of fixed 7px days is wider than a phone's row, so here the strip stretches
     to the row instead and its days share the width. */
  .ledger-track .ledger-strip { width: 100%; }
  .ledger-track .ledger-week { flex: var(--days) 1 0; min-width: 0; }
  .ledger-track .ledger-day { flex: 1 1 0; width: auto; min-width: 0; }
  .ledger-track .ledger-dials { align-items: flex-start; }
  .ledger-strip.is-summary { gap: 3px; }
  .ledger-strip.is-summary .ledger-day { height: 22px; font-size: 0; }
}

/* ============================================================
   LEDGER SCORED — what the rules and values indexes (.ledger-page.is-scored) add to the
   LEDGER look, and the three-month history at the top of their edit forms
   (shared/_ledger_history). The other LEDGER pages are left as they are.
   Colours come from ledger_strip.js: kept rules a soft green and broken ones full red,
   values one violet from faint (−2) to full (+2).
   ============================================================ */
/* Last month left with gaps: a quiet orange banner over the Overall card, with a way back
   to finish it and an x to let it be. */
/* A month left unfinished: a reminder in blue, not a warning, and amber stays Premium's. */
.ledger-gaps {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 9px 10px 9px 14px;
  border: 1px solid color-mix(in srgb, var(--blue) 28%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--blue) 7%, transparent);
  color: var(--text-2);
  font-size: var(--fs-13);
}
.ledger-gaps[hidden] { display: none; }
.ledger-gaps-icon { color: var(--blue); font-size: var(--fs-13); }
.ledger-gaps-text { flex: 1; min-width: 0; }
.ledger-gaps-go {
  flex-shrink: 0;
  padding: 0.3rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--blue) 45%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  color: var(--blue);
  font: inherit;
  font-size: var(--fs-12);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast);
}
.ledger-gaps-go:hover { background: color-mix(in srgb, var(--blue) 22%, transparent); }
.ledger-gaps-close {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-3);
  cursor: pointer;
}
.ledger-gaps-close:hover { background: var(--hairline); color: var(--text-1); }
/* On a phone the words and the x share the first line, the button goes beneath. */
@media (max-width: 720px) {
  .ledger-gaps { flex-wrap: wrap; }
  .ledger-gaps-text { flex-basis: calc(100% - 72px); }
  .ledger-gaps-close { order: 3; }
  .ledger-gaps-go { order: 4; margin-left: 24px; }
}

/* A row's month beside its strip. */
.ledger-track-line { display: flex; align-items: center; gap: 10px; }
.ledger-row-score {
  min-width: 34px;
  color: var(--text-2);
  font-size: var(--fs-12);
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ledger-row-score:empty::before { content: '—'; color: var(--text-3); font-weight: 400; }
.ledger-row-score.is-low { color: var(--danger-bright); }

/* Outside the cards that already are its category (or area), a row's own thin edge. */
.ledger-row.has-accent { box-shadow: inset 2px 0 0 var(--row-accent); }

/* Dials open centred under the strip they answer for — the score column (34px and its
   10px gap) is left out of the centring, so they sit under the bar's middle. */
.is-scored .ledger-track { align-items: stretch; }
.is-scored .ledger-dials { align-items: center; padding-right: 44px; }
/* The eraser (or its spacer) sits left of the dials and the close x right of them, the
   same width, so the dials themselves sit in the middle the date above is centred on. A
   row without the x (a value's second and later rows) keeps its space. */
.is-scored .ledger-dials-row:not(:has(.ledger-dials-close))::after { content: ''; width: 16px; flex-shrink: 0; }
.ledger-dials-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: color var(--dur-fast) ease, background-color var(--dur-fast) ease;
}
.ledger-dials-close:hover { color: var(--text-1); background-color: var(--hairline); }
.ledger-dials-close:focus-visible { outline: 2px solid var(--text-1); outline-offset: 1px; }
@media (max-width: 720px) {
  .is-scored .ledger-track .ledger-dials { align-items: center; }
}

/* A meta line with nothing left in it once "Daily" goes unsaid. */
.is-scored .ledger-meta:not(:has(*)) { display: none; }

/* The Overall line: last month's score, and how this one compares. */
.ledger-summary-prev {
  padding: 0;
  border: none;
  background: none;
  color: var(--text-2);
  font: inherit;
  text-decoration: underline dotted var(--border-strong);
  text-underline-offset: 3px;
  cursor: pointer;
}
.ledger-summary-prev:hover { color: var(--text-1); }
.ledger-summary-trend { color: var(--text-3); }
.ledger-summary-trend.is-up { color: var(--accent-bright); }
.ledger-summary-trend.is-down { color: var(--danger-bright); }

/* The Overall strip's filled days are soft now, so their numbers go light. */
:is(.is-scored, .things-page) .ledger-strip.is-summary .ledger-day.is-rated { color: var(--text-1); }

/* Today, ringed — and the week or month that holds it, when that's the unit. */
:is(.is-scored, .ledger-history, .things-page) .ledger-day.is-today { box-shadow: 0 0 0 1.5px var(--text-2); }
:is(.is-scored, .ledger-history, .things-page) .ledger-day.is-today::after { display: none; }
:is(.is-scored, .things-page) .ledger-day.is-selected { box-shadow: 0 0 0 1.5px var(--text-1); }
:is(.is-scored, .things-page) .ledger-strip.is-summary .ledger-day.is-today { box-shadow: inset 0 0 0 1.5px var(--text-1); }

/* Reviewed weekly or monthly: solid cells, one per week or one for the month, rather
   than a month of empty days that reads like a daily rule left undone. */
:is(.is-scored, .ledger-history, .things-page) .ledger-strip:is(.is-weekly, .is-month) .ledger-day { visibility: hidden; }
:is(.is-scored, .ledger-history, .things-page) .ledger-strip.is-weekly .ledger-week { background: rgba(255, 255, 255, 0.08); box-shadow: none; }
:is(.is-scored, .ledger-history, .things-page) .ledger-strip.is-weekly .ledger-week.is-future { background: rgba(255, 255, 255, 0.03); }
:is(.is-scored, .ledger-history, .things-page) .ledger-strip.is-weekly .ledger-week.is-filled,
:is(.is-scored, .ledger-history, .things-page) .ledger-strip.is-month.is-filled { background: var(--fill); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fill) 75%, transparent); }
:is(.is-scored, .ledger-history, .things-page) .ledger-strip.is-month:not(.is-filled) { background: rgba(255, 255, 255, 0.08); }
:is(.is-scored, .ledger-history, .things-page) .ledger-strip.is-month { box-shadow: none; }
/* A week's or a month's one reading covers many days' width, so at full strength it was
   the loudest thing on the page for a single check-in. Its colour as a soft wash with the
   colour as an edge instead: the same reading at the weight of a day's. */
:is(.is-scored, .ledger-history, .things-page) .ledger-strip.is-weekly .ledger-week.is-filled,
:is(.is-scored, .ledger-history, .things-page) .ledger-strip.is-month.is-filled {
  background: color-mix(in srgb, var(--fill) 38%, transparent);
}
:is(.is-scored, .ledger-history, .things-page) .ledger-strip .ledger-week.is-current,
:is(.is-scored, .ledger-history, .things-page) .ledger-strip.is-month.is-current { box-shadow: inset 0 0 0 1.5px var(--text-2); }
:is(.is-scored, .things-page) .ledger-strip .ledger-week.is-clickable:hover,
:is(.is-scored, .things-page) .ledger-strip.is-month.is-clickable:hover { box-shadow: inset 0 0 0 1.5px var(--text-3); }
:is(.is-scored, .things-page) .ledger-strip .ledger-week.is-selected,
:is(.is-scored, .things-page) .ledger-strip.is-month.is-selected { box-shadow: inset 0 0 0 1.5px var(--text-1); }

/* Values' names in the same type as Rules' (one page, two tabs), what they mean as a
   quiet italic line beneath. */
.ledger-page.is-values .ledger-desc {
  color: var(--text-3);
  font-size: var(--fs-12);
  font-style: italic;
}
/* A value's figure in its score's colour (ledger_strip scoreTextColor, set as --fill). */
.ledger-page.is-values .ledger-row-score { color: var(--fill, #c4b5fd); }

/* On a phone the rank number goes, and the strip takes the row's full width. */
@media (max-width: 720px) {
  .is-scored .ledger-row { grid-template-columns: 16px minmax(0, 1fr) 22px; }
  .is-scored .ledger-row > .ledger-rank { display: none; }
  .is-scored .ledger-row > .ledger-icon { grid-column: 1; }
  .is-scored .ledger-row > .ledger-body { grid-column: 2; }
  .is-scored .ledger-row > .ledger-actions { grid-column: 3; }
  .is-scored .ledger-row > .ledger-track { grid-column: 1 / 4; }
  .is-scored .ledger-track-line { width: 100%; }
  .is-scored .ledger-track-line .ledger-strip { flex: 1 1 auto; width: auto; min-width: 0; }
}

/* The edit form's last three months: a strip and a score for each. */
.ledger-history {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
}
.ledger-history-months { display: flex; flex-direction: column; gap: 7px; margin: 0; padding: 0; list-style: none; }
.ledger-history-month { display: grid; grid-template-columns: 30px minmax(0, 1fr) 38px; align-items: center; gap: 10px; }
.ledger-history-label { color: var(--text-3); font-size: var(--fs-10); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.ledger-history-score { color: var(--text-2); font-size: var(--fs-12); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.ledger-history.is-values .ledger-history-score { color: #c4b5fd; }
.ledger-history-score.is-empty { color: var(--text-3); font-weight: 400; }
.ledger-history .ledger-strip { width: 100%; gap: 3px; }
.ledger-history .ledger-week { flex: var(--days) 1 0; min-width: 0; padding: 1px; }
.ledger-history .ledger-day { flex: 1 1 0; width: auto; min-width: 0; height: 12px; cursor: default; }
.ledger-history .ledger-day:hover { box-shadow: none; }
.ledger-history .ledger-day.is-today:hover { box-shadow: 0 0 0 1.5px var(--text-2); }
.ledger-history-none { display: none; margin: 0; color: var(--text-3); font-size: var(--fs-12); }
.ledger-history.is-empty .ledger-history-months { display: none; }
.ledger-history.is-empty .ledger-history-none { display: block; }

.rule-form-hint strong, .val-form-hint strong { color: var(--text-2); font-weight: 600; }

/* "Surprise me" and other buttons at a gallery heading's right (shared/_gallery head_link). */
.find-surprise {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-2);
  font-size: var(--fs-12);
  font-weight: 600;
  text-decoration: none;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
.find-surprise:hover { border-color: var(--border-strong); color: var(--text-1); }

/* ---- Values: before a value began; the rating dials; Rate today ---- */
/* A day before a value (or, Overall, any value) began: hatched, not an empty "not rated". */
.ledger-day.is-before-start {
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0 3px, transparent 3px 6px) !important;
  box-shadow: none !important; opacity: 0.55; cursor: default;
}
/* The dials say which end is which, and wear their tone faintly before one's picked. */
.ledger-dials-row .rate-end { color: var(--text-3); font-size: var(--fs-10); letter-spacing: 0.04em; width: 3.6em; }
.is-values .ledger-dials-row .rate-dial:not(.is-on) { border-color: color-mix(in srgb, var(--dial) 55%, transparent); }
/* Rate today, beside New value. */
.values-rate-today { color: #c4b5fd; border-color: rgba(167, 139, 250, 0.4); }
.values-rate-today:hover { background: rgba(167, 139, 250, 0.1); }
.values-rate-today[hidden] { display: none; }
.ledger-also { color: var(--text-3); font-size: var(--fs-11); font-style: italic; }
/* The value form's footer cards name themselves (Archive, Someday), as the other forms' do. */
.val-footer-card { gap: 7px; padding-inline: 11px !important; }
.val-footer-label { color: var(--text-3); font-size: var(--fs-12); }
.val-footer-card.active .val-footer-label { color: var(--text-1); }

/* ---- Rules: as Values — the circles' tones at rest, Mark today, labelled footer cards ---- */
[data-controller~="rules-month-nav"] .ledger-dials-row .rate-dial:not(.is-on) { border-color: color-mix(in srgb, var(--dial) 55%, transparent); }
.rules-mark-today { color: #86efac; border-color: rgba(34, 197, 94, 0.4); }
.rules-mark-today:hover { background: rgba(34, 197, 94, 0.1); }
.rules-mark-today[hidden] { display: none; }
.rule-footer-card { width: auto !important; gap: 7px; padding-inline: 11px !important; }
.rule-footer-label { color: var(--text-3); font-size: var(--fs-12); }
.rule-footer-card.active .rule-footer-label { color: var(--text-1); }
/* The end labels the same width either side ("Missed" and "Kept" aren't), so the circles
   stay centred under the strip, the way they open. */
.ledger-dials-row .rate-end { display: inline-block; }
.ledger-dials-row .rate-end:first-of-type { text-align: right; }

/* Values: days to come all but gone, so a month's first week isn't a row of empty boxes. */
:is([data-controller~="values-date-nav"], [data-controller~="rules-month-nav"]) .ledger-strip:not(.is-summary) .ledger-day.is-future { background: rgba(255, 255, 255, 0.015); }

/* Rate today's and Mark today's short forms, for a phone (values_date_nav and
   rules_month_nav controllers). */
.ledger-head .rt-short { display: none; }
@media (max-width: 640px) {
  .ledger-head .rt-long { display: none; }
  .ledger-head .rt-short { display: inline; }
  /* New value / New rule as its icon alone: its label wrapped onto two lines. */
  :is([data-controller~="values-date-nav"], [data-controller~="rules-month-nav"]) .ledger-head .ledger-new-label { display: none; }
}

/* A rule's dials as labelled buttons (rules_month_nav controller, .is-labelled): each says
   Missed, Partly or Kept in its colour, and is a proper target. */
.ledger-dials-row.is-labelled { gap: 6px; }
.ledger-dials-row.is-labelled .rate-dial {
  width: auto; height: 28px; padding: 0 12px;
  border-width: 1.5px; border-radius: 999px;
  color: var(--text-1); font: inherit; font-size: var(--fs-12); font-weight: 600; line-height: 1;
}
.ledger-dials-row.is-labelled .rate-dial::before { border-radius: 999px; }
.ledger-dials-row.is-labelled .rate-dial.is-on { color: #0a0a0c; }

/* A rule's figure in its score's colour, as a value's is (rules_month_nav, scoreTextColor). */
[data-controller~="rules-month-nav"] .ledger-row-score { color: var(--fill, var(--text-2)); }

/* ---- Values: Rate today is the page's one solid button ---- */
.ledger-head .ledger-new.values-rate-today { border-color: transparent; background: #7c3aed; color: #fff; font-weight: 600; opacity: 1; }
.ledger-head .ledger-new.values-rate-today:hover { background: #8b5cf6; color: #fff; }
.ledger-head .ledger-new.values-rate-today i { color: #fff; }

/* ---- A weekly or monthly value's period still to rate says so, in its own box ---- */
.ledger-page.is-values .ledger-strip.is-weekly .ledger-week.is-current:not(.is-filled),
.ledger-page.is-values .ledger-strip.is-month.is-current:not(.is-filled) { position: relative; box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.55); }
.ledger-page.is-values .ledger-strip.is-weekly .ledger-week.is-current:not(.is-filled)::after,
.ledger-page.is-values .ledger-strip.is-month.is-current:not(.is-filled)::after {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  color: #c4b5fd; font-size: var(--fs-10); font-weight: 600; letter-spacing: 0.04em; white-space: nowrap;
}
.ledger-page.is-values .ledger-strip.is-weekly .ledger-week.is-current:not(.is-filled)::after { content: 'Rate this week'; }
.ledger-page.is-values .ledger-strip.is-month.is-current:not(.is-filled)::after { content: 'Rate this month'; }

/* ---- A phone: the month switcher beside the Rules / Values switch, not a row of its own ---- */
@media (max-width: 640px) {
  .ledger-page.is-values .ledger-head { flex-wrap: wrap; row-gap: 8px; }
  .ledger-page.is-values .ledger-head .ledger-month { order: 0; width: auto; margin-left: auto; justify-content: flex-end; }
  .ledger-page.is-values .ledger-head .ledger-month-label { min-width: 0; padding: 0 6px; font-size: var(--fs-13); }
  .ledger-page.is-values .ledger-head .ledger-nav-btn { width: 24px; height: 24px; border-color: transparent; }
}
@media (max-width: 640px) {
  .ledger-page.is-values .ledger-strip.is-weekly .ledger-week.is-current:not(.is-filled)::after { content: 'Rate'; }
}

/* ---- Rules: Mark today is the page's one solid button ---- */
.ledger-head .ledger-new.rules-mark-today { border-color: transparent; background: var(--accent); color: #04130a; font-weight: 600; opacity: 1; }
.ledger-head .ledger-new.rules-mark-today:hover { background: var(--accent-bright); color: #04130a; }
.ledger-head .ledger-new.rules-mark-today i { color: #04130a; }

/* ---- A weekly or monthly rule's period still to mark says so ---- */
.ledger-page.is-rules .ledger-strip.is-weekly .ledger-week.is-current:not(.is-filled),
.ledger-page.is-rules .ledger-strip.is-month.is-current:not(.is-filled) { position: relative; box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.5); }
.ledger-page.is-rules .ledger-strip.is-weekly .ledger-week.is-current:not(.is-filled)::after,
.ledger-page.is-rules .ledger-strip.is-month.is-current:not(.is-filled)::after {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  color: #86efac; font-size: var(--fs-10); font-weight: 600; letter-spacing: 0.04em; white-space: nowrap;
}
/* "Mark", not "Mark this week": a week's cell is narrower than that, and the words ran
   over its edge into the next week's. The month's cell is the whole strip, so it keeps its. */
.ledger-page.is-rules .ledger-strip.is-weekly .ledger-week.is-current:not(.is-filled)::after { content: 'Mark'; }
.ledger-page.is-rules .ledger-strip.is-month.is-current:not(.is-filled)::after { content: 'Mark this month'; }

/* ---- An unranked rule's ↑ (Add to priority) comes up under the pointer ---- */
.ledger-page.is-rules .ledger-row:hover .ledger-add { color: var(--text-1); }
.ledger-page.is-rules .ledger-add:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

@media (max-width: 640px) {
  /* The month switcher smaller and to the right, as on Values. */
  .ledger-page.is-rules .ledger-head { flex-wrap: wrap; row-gap: 8px; }
  .ledger-page.is-rules .ledger-head .ledger-month { order: 0; width: auto; margin-left: auto; justify-content: flex-end; }
  .ledger-page.is-rules .ledger-head .ledger-month-label { min-width: 0; padding: 0 6px; font-size: var(--fs-13); }
  .ledger-page.is-rules .ledger-head .ledger-nav-btn { width: 24px; height: 24px; border-color: transparent; }
}

/* ---- Values: the rating dials in the strips' violet ----
   The picker's circles ran red to green while every rating on the page shows violet
   (ledger_strip.js valueFill: alpha 0.16 → 1.0 from −2 to +2), so a "Poor" tapped red read
   dark violet a moment later. Each dial now fills with the exact shade its rating gets in
   the strip; its ring is a little stronger at the faint end, to stay visible. Only here:
   the same dials elsewhere (tasks, things, rules) keep their tones. */
.is-values .ledger-dials-row .rate-dial[data-scale="value"][data-rate="-2"] { --dial: rgba(167, 139, 250, 0.16); --dial-ring: rgba(167, 139, 250, 0.38); }
.is-values .ledger-dials-row .rate-dial[data-scale="value"][data-rate="-1"] { --dial: rgba(167, 139, 250, 0.37); --dial-ring: rgba(167, 139, 250, 0.5); }
.is-values .ledger-dials-row .rate-dial[data-scale="value"][data-rate="0"]  { --dial: rgba(167, 139, 250, 0.58); --dial-ring: rgba(167, 139, 250, 0.62); }
.is-values .ledger-dials-row .rate-dial[data-scale="value"][data-rate="1"]  { --dial: rgba(167, 139, 250, 0.79); --dial-ring: rgba(167, 139, 250, 0.79); }
.is-values .ledger-dials-row .rate-dial[data-scale="value"][data-rate="2"]  { --dial: rgba(167, 139, 250, 1);    --dial-ring: rgba(167, 139, 250, 1); }
.is-values .ledger-dials-row .rate-dial[data-scale="value"]:not(.is-on) { border-color: var(--dial-ring); }
.is-values .ledger-dials-row .rate-dial[data-scale="value"].is-on { border-color: var(--dial-ring); }

/* A rule's name with its journal link beside it, when that's all its meta line would hold
   (rules/_index_item_row). The name still truncates; the link stays whole. */
.ledger-name-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ledger-name-line .ledger-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-name-line .rule-journal-tag { flex: none; }

/* The empty ranked list's hint: one quiet line, not a dashed box taking a row, until a
   rule is picked up, when it becomes the box to drop into. */
.ledger-dropzone-hint { border-color: transparent; padding: 2px 0; margin: 0 0 6px; background: none; }
[data-controller~="rule-columns"].is-dragging .ledger-dropzone-hint { border-color: var(--border-strong); padding: 10px 12px; background: var(--surface-1); }

/* Phone: the unfinished-month banner on one line — its sentence cut to what fits, then
   Finish and the close — rather than four lines with the button on a row of its own. */
@media (max-width: 720px) {
  .ledger-gaps { flex-wrap: nowrap; gap: 8px; padding: 7px 8px 7px 12px; }
  .ledger-gaps-text { flex: 1 1 auto; flex-basis: auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ledger-gaps-go { order: 0; margin-left: 0; padding: 0.25rem 0.6rem; }
  .ledger-gaps-close { order: 0; }
}
