/*
 * ---------- Planner (My Day Planner 01 / A-hybrid mock flow) ----------
 * Own stylesheet rather than folding ~200 lines into components.css —
 * this is a whole application state (Home replacement), not a small
 * addition to an existing section. Reuses existing tokens throughout
 * (--accent, --detail, --line, --radius-control, --surface) — no new
 * global tokens introduced; the graphite/warm-light theme system and
 * citron-accent discipline established elsewhere are unchanged here.
 *
 * Exception, deliberate: Planner Top Zone / Astra Variant 2 "Soft
 * tiles" introduces the small set of --tile-, --nav-ghost-fill,
 * --nav-icon, --month-text custom properties below. The approved
 * reference gave exact hex values
 * for the week-strip's dark palette that don't coincide with any
 * existing token (Today's fill/text are the one exception — those
 * match var(--accent)/var(--ink) exactly and reuse them directly, no
 * new variable). These are declared once here, dark-default on bare
 * :root (mirroring tokens.css's own dark-is-the-default convention),
 * with a light-theme block that substitutes the existing light tokens
 * instead of inventing unreviewed light-mode hex values — the approved
 * reference is a dark-mode screenshot only.
 */
:root {
  --tile-fill: #1e2121;
  --tile-weekday: #8e9892;
  --tile-date: #dce1d8;
  --tile-selected-fill: #3a3e35;
  --tile-selected-weekday: #b6bcad;
  --tile-selected-date: #e8ebdf;
  --tile-today-weekday: #44522d;
  --tile-marker: #929e85;
  --nav-ghost-fill: #1e2121;
  --nav-icon: #a7b0a9;
  --month-text: #b8bfba;
}
:root[data-theme="light"] {
  --tile-fill: var(--surface);
  --tile-weekday: var(--muted);
  --tile-date: var(--text);
  --tile-selected-fill: color-mix(in srgb, var(--accent) 16%, var(--surface));
  --tile-selected-weekday: var(--muted);
  --tile-selected-date: var(--text);
  --tile-today-weekday: var(--ink);
  --tile-marker: var(--detail);
  --nav-ghost-fill: var(--surface);
  --nav-icon: var(--muted);
  --month-text: var(--muted);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --tile-fill: var(--surface);
    --tile-weekday: var(--muted);
    --tile-date: var(--text);
    --tile-selected-fill: color-mix(in srgb, var(--accent) 16%, var(--surface));
    --tile-selected-weekday: var(--muted);
    --tile-selected-date: var(--text);
    --tile-today-weekday: var(--ink);
    --tile-marker: var(--detail);
    --nav-ghost-fill: var(--surface);
    --nav-icon: var(--muted);
    --month-text: var(--muted);
  }
}

.planner { margin-top: 4px; }

/* ---------- Top nav: dedicated Planner state, not Home's header ----------
 * Home's wordmark/status header is hidden entirely while Planner is open
 * (see planner-surface.js) and this restrained bar takes its place: a
 * quiet back control on the left, a quiet "Today" shortcut on the right.
 * Neither is a primary-action fill — both read as text-level navigation. */
.planner-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
}
.planner-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
}
.planner-back svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.planner-today {
  min-height: 44px;
  /* Stage B13P: right padding matches --rail-inset so this text glyph
   * lands on the same visual edge as the boxed circular controls below
   * (week-nav, group-chevron) instead of overhanging past them. */
  padding: 0 var(--rail-inset) 0 8px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 550;
}
.planner-heading { font-size: 20px; font-weight: 600; margin: 12px 0 10px; }
/* To Do Navigation 01: "Lists" sits beside "Today" - same quiet text control. */
.planner-top-actions { display: flex; align-items: center; gap: 4px; }
.planner-top-actions .planner-lists { padding-right: 8px; }
.list-rows { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 var(--rail-inset) 0 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 16px;
  text-align: left;
}
.list-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-note { color: var(--muted); font-size: 12px; }
.list-row-count { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
/* Navigation 02: the parent-list label - same quiet uppercase label as
   before (not an underlined button), a small chevron says "opens"; the
   tap area extends invisibly to 44px without moving the layout. */
.task-detail-list-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  min-height: 0;
  padding: 0;
  background: none;
  text-align: left;
}
.task-detail-list-link::after { content: ""; position: absolute; inset: -12px -10px; }
.task-detail-list-name { min-width: 0; overflow-wrap: anywhere; }
.task-detail-list-chevron {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lists-top-action { margin-left: auto; }
/* List Organization 01: MEM groups on the Lists overview - same quiet
   disclosure language as Planner's groups; a group header is a 44px
   summary with name, open-task total and the round chevron; its lists sit
   under it with a small inset so group and list read differently. */
.list-group { margin-bottom: 6px; }
.list-group-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  list-style: none;
  cursor: pointer;
}
.list-group-summary::-webkit-details-marker { display: none; }
.list-group-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list-group-total { font-variant-numeric: tabular-nums; font-weight: 500; }
.list-group[open] > .list-group-summary .group-chevron { transform: rotate(180deg); }
.list-group-body { padding-left: 12px; }
.list-group-empty { margin: 10px 0; color: var(--muted); font-size: 14px; }
/* List Organization 03: direct drag on the overview - a quiet handle at the
   start of group headers and list rows; the row itself still opens. */
.list-row-wrap { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.list-row-wrap .list-row { flex: 1; min-width: 0; border-bottom: 0; }
.drag-handle.is-quiet { width: 26px; margin-left: -6px; opacity: .45; font-size: 17px; }
.drag-handle.is-quiet:hover, .drag-handle.is-quiet:active { opacity: .9; }
.list-group-summary .drag-handle.is-quiet { margin-right: -4px; }
.list-group-empty[data-drop] { padding: 10px 0; border: 1px dashed var(--line); border-radius: 10px; text-align: center; font-size: 13px; }
.lists-toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 8px 8px 8px 16px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  box-shadow: 0 6px 20px #0006;
}
.lists-toast.is-error { border-color: var(--danger); }
.lists-toast span { min-width: 0; overflow-wrap: anywhere; }
.lists-toast-undo { min-height: 36px; padding: 0 12px; border-radius: 10px; color: var(--accent); font-weight: 600; }
.organize-menu { display: flex; flex-direction: column; }
.organize-menu-row {
  display: flex;
  align-items: center;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 16px;
  text-align: left;
  text-decoration: none;
}
.organize-rows { display: flex; flex-direction: column; }
.organize-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
}
.organize-row-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 44px; text-align: left; color: var(--text); }
.organize-row-open { padding: 0; }
.organize-row-name { flex: 1; min-width: 0; font-size: 15px; overflow-wrap: anywhere; }
.organize-row-text { display: flex; flex-direction: column; flex: 1; min-width: 6em; }
.organize-row-text .organize-row-name { overflow-wrap: break-word; }
.organize-row-meta { display: flex; gap: 8px; color: var(--muted); font-size: 12px; }
.organize-row-meta:empty { display: none; }
.organize-check { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--accent); }
.organize-unassigned { display: none; color: var(--warning); font-size: 12px; }
.organize-row.is-unassigned .organize-unassigned { display: inline; }
.organize-select {
  flex-shrink: 0;
  max-width: 40%;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.organize-batch { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.organize-batch-label { color: var(--muted); font-size: 13px; }
.organize-batch .organize-select { max-width: none; flex: 1; }
.organize-new-group { display: flex; gap: 8px; align-items: center; }
.organize-new-group .sheet-input { flex: 1; min-width: 0; }
.organize-subhead { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.organize-icon-button {
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 18px;
}
.organize-back { align-self: flex-start; min-height: 44px; color: var(--muted); font-size: 14px; }
.organize-save-bar { position: sticky; bottom: 0; padding: 8px 0 0; background: var(--bg); }
.list-manage-status { margin: 0; min-height: 1em; color: var(--accent); font-size: 14px; }
/* List Organization 02 - hierarchical Arrange with drag handles. */
.arr-tree { display: flex; flex-direction: column; }
.arr-section { border-bottom: 1px solid var(--line); }
.arr-head { display: flex; align-items: center; gap: 4px; min-height: 44px; }
.arr-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  text-align: left;
}
.arr-toggle[aria-expanded="true"] .group-chevron { transform: rotate(180deg); }
.arr-body { padding-left: 20px; }
.arr-row { min-height: 44px; }
.arr-row:last-child { border-bottom: 0; }
.arr-empty { margin: 0; padding: 12px 0; color: var(--muted); font-size: 13px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; margin-bottom: 8px; }
.drag-handle, .drag-handle-space {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  min-height: 44px;
  color: var(--muted);
  font-size: 20px;
}
.drag-handle {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.is-dragging, .is-dragging * { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.is-drag-source { opacity: .35; }
.drag-ghost {
  position: fixed;
  z-index: 1000;
  margin: 0;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 8px 24px #0008;
  opacity: .95;
}
.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.drop-into { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 10px; }
.arr-save-bar { display: flex; flex-direction: column; gap: 6px; }
.arr-save-bar .sheet-actions { margin-top: 0; }
.arr-save-buttons { display: flex; gap: 8px; }
.arr-save-buttons .primary { flex: 1; }
.list-manage-status.is-error { color: var(--danger); }
.list-form { display: flex; flex-direction: column; gap: 12px; }
.sheet-input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
}
.sheet-input:focus-visible { outline: none; border-color: var(--accent); }
.list-manage-note { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.list-manage-error { margin: 0; color: var(--danger); font-size: 14px; }
.danger-action { border-color: var(--danger); color: var(--danger); }
.danger-action:active { background: var(--danger); color: var(--ink); }

/* ---------- Month/year context row ----------
 * Planner Top Zone / Astra Variant 2: month label + its dedicated
 * chevron button form one left-side group; both week-arrow buttons
 * form a separate right-side group — "one group above the week; the
 * month is no longer framed by arrows" per the approved reference. No
 * border, no filled box on the month label itself — it stays plain
 * text-level navigation, quieter than the soft-tile week strip below. */
.planner-month-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.planner-month-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.planner-month {
  display: inline-flex;
  align-items: center;
  height: 32px;
  line-height: 1;
  padding: 0;
  color: var(--month-text);
  font-size: 14px;
  font-weight: 450;
}
/* Astra Variant 2: the month chevron and the two week-nav arrows share
 * one "soft ghost button" treatment — a 44x44 touch target around a
 * smaller 28px visible surface (same invisible-hit-area pattern
 * .completion-control and .group-chevron already use elsewhere), fill
 * var(--nav-ghost-fill) (the same dark tone as a normal day tile, so
 * these read as a matched family), no shared pill, no divider between
 * them. Equal hit areas; visually lighter than the day tiles below
 * (smaller surface, thinner 1.4px icon stroke, muted --nav-icon color
 * vs the tiles' filled/bright states). */
.month-chevron,
.week-nav {
  position: relative;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--nav-ghost-fill);
  color: var(--nav-icon);
}
.month-chevron::before,
.week-nav::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}
.month-chevron svg,
.week-nav svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.week-nav-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---------- Week strip ----------
 * Planner Top Zone / Astra Variant 2 "Soft tiles" — replaces the
 * Visual Pass 01-03 one-line outlined-cell design (never deployed;
 * rejected in favor of this reference) with a vertical weekday-over-
 * date tile. Every cell still carries the exact same box in every
 * state (fixed height, no border ever) — only `background`/text color
 * change between Normal/Selected/Today, so geometry can never shift.
 * ~45x54px / 10px radius per the approved reference; width stays
 * flex-computed (not a hardcoded 45px) since MEM's real card padding
 * differs slightly from the reference mockup's assumed width — the
 * resulting real width lands within ~1px of 45 at 375px, preserving
 * the intended proportions without hardcoding a value that could
 * misfit a different container width. */
.week-strip { display: flex; gap: 3px; margin-bottom: 18px; }
.day-cell {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 10px;
  border: none;
  background: var(--tile-fill);
}
/* Weekday/date sizes are identical across every state (Normal/
 * Selected/Today) — the approved reference differentiates states by
 * fill/text color only, never by font-size or font-weight. */
.day-cell-weekday {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--tile-weekday);
}
.day-cell-number {
  font-size: 19px;
  font-weight: 500;
  color: var(--tile-date);
}

/* Task marker — a thin bottom segment, absolutely positioned so its
 * presence/absence never affects the weekday/date position or the
 * tile's height (the same defect the pre-Visual-Pass-01 dot marker
 * had). On a Normal/Selected tile it uses --tile-marker (sage, legible
 * against the dark fill); on a Today tile (bright lime fill) it
 * switches to var(--ink) at reduced opacity instead, so it stays
 * legible against the fill exactly the way Today's own weekday/date
 * text does — the same "dark mark on the lime tile" treatment the
 * pre-Visual-Pass-01 dot already used for this exact problem. */
.day-cell::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 16px;
  height: 1px;
  transform: translateX(-50%);
  background: var(--tile-marker);
  opacity: 0;
}
.day-cell.has-marker::after { opacity: 1; }
.day-cell[data-today="true"].has-marker::after {
  background: var(--ink);
  opacity: .55;
}
/* CALENDAR STATE + MARKER CORRECTION: an active overdue task's marker
 * reads as the existing MEM overdue amber (--warning) — the same token
 * .due-date.is-overdue already uses — and stays amber regardless of the
 * tile's own state. Today's ink-marker treatment and the Selected fill
 * both exist to communicate TILE state; they must not swallow this
 * TASK-level overdue signal, so these rules are ordered after the two
 * above to win for any cell matching both. Only the marker segment is
 * colored — the date numeral/title is never tinted amber. */
.day-cell.is-overdue-marker::after { background: var(--warning); }
.day-cell[data-today="true"].is-overdue-marker::after {
  background: var(--warning);
  opacity: .85;
}

/* Planner Top Zone / Astra Variant 2 state model:
 *   Normal:            --tile-fill, muted weekday, readable date
 *   Selected, !today:  --tile-selected-fill (a muted graphite/olive,
 *                       clearly selected but much quieter than Today),
 *                       higher-contrast weekday/date text
 *   Today:              solid var(--accent) fill, dark on-accent text
 *                       (var(--ink) for the date, a muted-dark olive
 *                       for the weekday) — the strongest state
 * Today+Selected together: the selected rule is scoped with
 * :not([data-today="true"]), so a cell that is both never receives the
 * selected-only declarations — Today's own treatment alone carries
 * through ("Today treatment only" per the approved reference), not a
 * separate merged rule. No permanent border/outline in any state. */
.day-cell[aria-pressed="true"]:not([data-today="true"]) {
  background: var(--tile-selected-fill);
}
.day-cell[aria-pressed="true"]:not([data-today="true"]) .day-cell-weekday {
  color: var(--tile-selected-weekday);
}
.day-cell[aria-pressed="true"]:not([data-today="true"]) .day-cell-number {
  color: var(--tile-selected-date);
}

.day-cell[data-today="true"] {
  background: var(--accent);
}
.day-cell[data-today="true"] .day-cell-weekday {
  color: var(--tile-today-weekday);
}
.day-cell[data-today="true"] .day-cell-number {
  color: var(--ink);
}

/* ---------- Primary (selected-day) section ----------
 * Stage B13: this is the primary section now, leading directly under
 * the week strip. Today's heading gets the same citron accent as the
 * top-right Today control and the week-strip's own Today cell — the
 * strongest, most persistent temporal color, matching that identity
 * everywhere it appears. A non-today selected date gets NO accent
 * class at all: it falls back to the plain --text heading color
 * already used everywhere else, which is exactly the "subdued,
 * secondary to Today" treatment — there's no separate "selected" color
 * token to invent, quiet IS the absence of Today's own accent. */
.planner-day-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 14px;
}
.planner-day-heading h3 { font-size: 16px; font-weight: 600; }
.planner-day-heading.is-today h3 { color: var(--accent); }
.planner-due-count { font-size: 13px; color: var(--muted); white-space: nowrap; }

.day-task-list { display: flex; flex-direction: column; }
/* Tasks/Planner Visual Pass 02: slightly denser row rhythm (12px->10px
 * padding, 12px->10px control-to-title gap) — still comfortable tap
 * targets (the completion-control's own 44px invisible hit-area is
 * unaffected by this) but less loose between rows. margin-top on the
 * control is nudged to re-center it against the title's own line-box
 * at the new spacing, verified visually (see task report). */
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.task-row:last-child { border-bottom: 0; }
/* Task Detail UI v1: .task-main is a real <button> whenever a row is
   opened with onOpenDetail (day-task-list.js) — these overrides put it
   back to plain block flow (base.css's generic button{min-height:44px}
   and default inline layout would otherwise both change this row's
   existing rhythm), and left-align text like the plain div it replaces. */
.task-main {
  flex: 1;
  min-width: 0;
  display: block;
  width: 100%;
  min-height: 0;
  text-align: left;
}
.task-title { display: block; font-size: 16px; line-height: 1.4; color: var(--text); overflow-wrap: anywhere; }
.task-row.is-completed .task-title { color: var(--muted); text-decoration: line-through; }
.due-metadata { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 3px; font-size: 13px; color: var(--muted); }
.due-time { font-variant-numeric: tabular-nums; }
.due-source { color: var(--detail); }
/* Stage B10: due-date badge on Earlier/Next 7 days/Later rows — the
 * plain selected-day list never sets task.dueDateLabel, so this class
 * simply never appears there. Future dates (Next 7 days/Later) stay
 * exactly --muted — same as .due-time/.due-source, i.e. genuinely
 * neutral, not just "less red".
 *
 * Tasks/Planner Visual Pass 02: overdue metadata is deliberately the
 * QUIETEST of the three overdue signals (amber completion-circle ->
 * "N overdue" count label -> this) — no longer semi-bold (was
 * font-weight:600), just the warning color at normal weight, so four
 * places never all shout the same thing at equal strength. */
.due-date.is-overdue { color: var(--warning); }
.recurrence-mark {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin-top: 3px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* base.css's button{min-height:44px} would otherwise stretch this into
 * an oval (22px wide, 44px tall) — overridden here so the visible ring
 * stays a true circle. The >=44x44 touch target is restored separately,
 * as an invisible ::before hit-area centered on the ring, so tapping
 * near it still works without visually enlarging the ring itself. */
/* Stage B16D visual state model — the circle itself is the primary
 * status indicator:
 *   A. normal:    thin neutral stroke, no fill
 *   B. overdue:   amber stroke, no fill (title stays neutral — see
 *                 .task-title, never colored by overdue)
 *   C. pending:   base stroke (normal or amber) unchanged, plus a
 *                 separate lime pulse ring overlay — no fill, no check
 *   D. confirmed: no fill (never the old solid citron/olive fill),
 *                 accent-colored ring, real SVG checkmark — supersedes
 *                 overdue (day-task-list.js never applies is-overdue
 *                 alongside is-confirmed; see that module's own note)
 */
.completion-control {
  position: relative;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  min-height: 0;
  margin-top: 2px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  transition: border-color 150ms ease;
}
.completion-control::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}
/* A disabled completion-control (pending/confirmed) must not be dimmed
 * by base.css's generic button:disabled{opacity:.55} — the control's
 * own border/ring/check already communicates its state, and Stage
 * B16D specifically asks for a "bright full" confirmed check. */
.completion-control:disabled { opacity: 1; }

/* State B: active, overdue (superseded by .is-confirmed — see
 * day-task-list.js's completionControl, which decides precedence in
 * JS rather than relying on CSS source order). */
.completion-control.is-overdue {
  border-color: var(--warning);
}

/* State C: pending — a subtle lime ring pulses around whatever base
 * stroke is already showing (normal or overdue), so overdue semantics
 * stay visible underneath it. No fill, no checkmark. */
.completion-control.is-pending::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: completion-pending-pulse 900ms ease-in-out infinite;
}
@keyframes completion-pending-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 0.15; }
}
@media (prefers-reduced-motion: reduce) {
  .completion-control.is-pending::after { animation: none; opacity: 0.45; }
}

/* State D: confirmed. No fill — the control stays dark/neutral, only
 * the ring and the checkmark itself go lime. */
.completion-control.is-confirmed {
  border-color: var(--accent);
  background: transparent;
}
.completion-check {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The readOnly branch (day-task-list.js) is untouched since Stage
 * B16B — it still legitimately uses aria-pressed to show either real
 * completion state, just never lets the user change it, and keeps its
 * own pre-existing filled-circle look rather than the writable
 * control's new confirmed treatment above. */
.completion-control[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
}
.completion-control[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 5px;
  height: 9px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: rotate(40deg);
}

.empty-day {
  color: var(--muted);
  font-size: 14px;
  padding: 28px 0;
  text-align: center;
}
/* Stage B13P: the primary day's own zero-task message reuses
 * .empty-day's quiet look but needs far less vertical space — the
 * loading/error/connect states above still want the full 28px (they
 * fill the body alone, with nothing certain below them), but here the
 * temporal groups render directly underneath, so the same padding just
 * pushed them down with no content in between. Scoped to the day list
 * mount only (min-block-size, not a fixed height, so it never clips
 * translated text or larger accessibility font sizes) — every other
 * .empty-day usage is untouched. */
.day-task-list-mount .empty-day {
  padding: 4px 0 14px;
}
/* Stage B02: reuses .empty-day's quiet centered treatment for load
 * failures (unauthenticated/reauth/rate-limited/upstream) — only the
 * color shifts to --danger, no new layout. */
.empty-day.is-error { color: var(--danger); }

/* Stage B06: Connect/Reconnect — stacks the existing .empty-day message,
 * the real action button (.primary, already established elsewhere), and
 * an optional failure line. The container owns the vertical rhythm, so
 * the nested .empty-day paragraphs drop their own standalone padding. */
.connect-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 14px 0 28px;
}
.connect-action .empty-day { padding: 0; }
.connect-action .primary { max-width: 320px; }

/* ---------- Group disclosure (Earlier / Next 7 days / Later) ----------
 * Stage B10 generalizes the original overdue-only disclosure into the
 * shared shape all three time groups use. Visual Alignment: a quiet
 * row, not a bordered/backgrounded card — deliberately its own classes
 * (not shared with .settings-panel) so this slice never touches
 * already-accepted Settings CSS.
 *
 * Disclosure-affordance fix: the chevron previously read as a bare
 * small glyph — .group-chevron now gets its own visible circular
 * hit-area (border + background), so the control reads as clickable on
 * sight, not just by hovering over the whole row. The whole header
 * (<summary>) stays clickable; this only strengthens the chevron's own
 * visibility, per the task's explicit "no hidden-only affordance" rule. */
/* Tasks/Planner Visual Pass 02: quieter than the primary selected-day
 * heading (16px/600) by construction — smaller text, lighter weight,
 * and a smaller/thinner chevron chip (below) than Visual Pass 01's
 * 28px/1.5px, since a 44px-tall bordered-chevron row next to the far
 * simpler primary heading read as more visually assertive than a
 * secondary/opt-in overview section should. min-height trimmed to
 * 40px — still a full-width, comfortably tappable <summary>, not a
 * touch-target regression (only the chevron chip itself is a fixed
 * small circle either way). */
.group-disclosure { margin-bottom: 8px; }
.group-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  padding: 0;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  list-style: none;
  border-bottom: 1px solid var(--line);
}
/* Stage B13 temporal color system: each group's heading text AND its
 * chevron (icon color + hit-area ring) share the same semantic color —
 * Earlier keeps the existing amber/warning treatment; Next 7 days
 * introduces --upcoming (an alias of the already-established --detail
 * cool blue, not a new color); Later introduces --distant, a
 * deliberately deeper/quieter blue than --upcoming. Task rows inside
 * every group stay exactly --text/--muted (see .task-row/.due-date) —
 * color is confined to the heading and chevron, never the rows. */
.group-summary.is-earlier { color: var(--warning); }
.group-summary.is-earlier .group-chevron { color: var(--warning); border-color: var(--warning); }
.group-summary.is-next7 { color: var(--upcoming); }
.group-summary.is-next7 .group-chevron { color: var(--upcoming); border-color: var(--upcoming); }
.group-summary.is-later { color: var(--distant); }
.group-summary.is-later .group-chevron { color: var(--distant); border-color: var(--distant); }
.group-summary::-webkit-details-marker { display: none; }
.group-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--muted);
  transition: transform .15s ease;
}
.group-chevron svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.group-disclosure[open] .group-chevron { transform: rotate(180deg); }
.group-body { padding: 0; }
.group-body .task-row:first-child { padding-top: 12px; }

/* ---------- Month picker (rendered inside the shared #sheet dialog) ---------- */
.month-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 14px;
}
.month-picker-label { font-size: 15px; font-weight: 550; }
.month-nav {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border-radius: var(--radius-control);
}
.month-nav svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.month-picker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.month-picker-weekdays span {
  text-align: center;
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.month-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.month-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  color: var(--text);
  font-size: 13px;
}
.month-cell.is-outside { color: var(--muted); opacity: .5; }
/* CALENDAR STATE + MARKER CORRECTION: the dot must never participate in
 * .month-cell's own centering — with flex-direction:column plus a
 * toggled-hidden dot, the numeral shifted vertically every time a day's
 * marker appeared/disappeared, since removing the dot's box changed how
 * much content justify-content:center had to center. The dot is now
 * absolutely positioned below the numeral instead (the same "geometry
 * must never depend on the marker" rule week-strip's .day-cell::after
 * already follows), so hiding/showing it can never move the number, and
 * every numeral in the grid sits on one shared baseline. */
.month-cell-dot {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--detail);
}
.month-cell[data-today="true"] { color: var(--accent); font-weight: 650; }
.month-cell[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--text);
}
.month-picker-today { margin-top: 18px; }

/* ---------- Task Detail (Task Detail UI v1 — Astra Variant 2 "Soft
   sections") ----------
 * A dedicated app state exactly like Planner's own relationship to
 * Home — no special height/positioning trick needed beyond being a
 * normal sibling section inside .app's own min-height:100dvh container
 * (see base.css), so it naturally reads as a full-height, page-like
 * mobile surface. Reuses the established "soft card" recipe already
 * used throughout MEM (var(--surface) fill + 1px var(--line) border +
 * 13px radius — see .ask-entry/.today-entry in components.css) for
 * every section below — no gradients, no glass/blur, no new visual
 * language. Text never gets a fixed-height/overflow:hidden container
 * anywhere here, and .task-detail-title never truncates — both
 * deliberate, for long titles and larger accessibility text sizes. */
.task-detail { margin-top: 4px; }
.task-detail-top { display: flex; align-items: center; min-height: 44px; }
.task-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
}
.task-detail-back svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.task-detail-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0 18px;
  min-width: 0;
}
/* Navigation 02: control + title on their own row; the 22px circle is
   centred on the title's first 26px line (20px x 1.3). */
.task-detail-title-row { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
/* The header reuses .completion-control verbatim (day-task-list.js's
   own exported function) — sized/positioned identically to a task-row
   circle, just with a touch more top margin to optically align with
   the larger title text next to it rather than the 16px row title. */
.task-detail-header .completion-control { margin-top: 2px; }
.task-detail-title-group { flex: 1; min-width: 0; }
.task-detail-context {
  margin: 0 0 0 34px; /* under the title, past the 22px control + 12px gap */
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.task-detail-title {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  /* No white-space:nowrap, no text-overflow:ellipsis, no max-height —
     a long title simply wraps onto as many lines as it needs (Navigation
     02: unbroken strings and URLs included). */
}

.task-detail-section {
  min-width: 0;
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}
.task-detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}
.task-detail-steps-count { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---- Schedule ---- */
.task-detail-schedule-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.task-detail-schedule-row svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.task-detail-schedule-label { color: var(--muted); font-size: 13px; flex-shrink: 0; }
.task-detail-schedule-value {
  margin-left: auto;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
  text-align: right;
}
/* Task Rescheduling 01: Due / Reminder rows open a compact editor */
button.task-detail-schedule-row {
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  min-height: 44px;
}
.task-detail-schedule-value.is-overdue { color: var(--danger); }
/* a value that is not saved yet: visibly provisional until To Do confirms it */
.task-detail-schedule-value.is-pending { color: var(--muted); font-style: italic; }
.schedule-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 8px 28px; }
.schedule-quick .appearance-option { min-height: 40px; font-size: 14px; }
.schedule-quick .appearance-option:disabled, .schedule-chip:disabled { opacity: .45; }
.task-detail-schedule-edit { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.schedule-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 0 10px 28px;
}
.schedule-input, .schedule-select {
  font: inherit;
  font-size: 16px; /* iOS: no zoom on focus */
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
}
.schedule-input { width: 100%; box-sizing: border-box; }
.schedule-reminder-fields { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.schedule-reminder-fields .schedule-input { flex: 1 1 150px; width: auto; }
.schedule-time { display: flex; align-items: center; gap: 4px; }
.schedule-chips, .schedule-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.schedule-chip { font-size: 14px; }
.schedule-actions .primary { flex: 1 1 auto; max-width: 200px; }
.schedule-actions button:disabled { opacity: .5; }
.schedule-note:empty { display: none; }

/* ---- Steps ----
 * Task Steps Completion 01: the step icon sits inside a <button>
 * (.task-detail-step-toggle) in the same fixed 22px box as
 * .completion-control, with the same 44px invisible hit area and the
 * same pending pulse; the row itself is unchanged. */
.task-detail-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.task-detail-step:last-child { border-bottom: 0; }
.task-detail-step-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--muted);
}
.task-detail-step-icon.is-done { color: var(--accent); }
.task-detail-step-toggle {
  position: relative;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  min-height: 0;
  margin-top: 1px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.task-detail-step-toggle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
}
.task-detail-step-toggle .task-detail-step-icon { display: block; margin-top: 0; }
.task-detail-step-toggle:disabled { opacity: 1; cursor: default; }
.task-detail-step-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.task-detail-step-toggle.is-pending .task-detail-step-icon { opacity: 0.6; }
.task-detail-step-toggle.is-pending::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: completion-pending-pulse 900ms ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .task-detail-step-toggle.is-pending::after { animation: none; opacity: 0.45; }
}
.task-detail-step-text { flex: 1; min-width: 0; color: var(--text); font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.task-detail-step.is-done .task-detail-step-text { color: var(--muted); text-decoration: line-through; }

/* ---- Notes ----
 * Comfortable reading line-height, never a textarea/form look — plain
 * flowing text/HTML, matching the rest of MEM's typography. */
.task-detail-body-text, .task-detail-body-html {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.task-detail-body-html * { max-width: 100%; }
.task-detail-body-html p { margin: 0 0 10px; }
.task-detail-body-html p:last-child { margin-bottom: 0; }
.task-detail-body-html ul, .task-detail-body-html ol { margin: 0 0 10px; padding-left: 20px; }
.task-detail-link { color: var(--detail); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }

/* ---- Attachments (Navigation 02, read-only) ---- */
.attachment-list { display: flex; flex-direction: column; }
.attachment-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.attachment-row:last-child { border-bottom: 0; }
.attachment-row .task-detail-list-chevron { color: var(--muted); }
.attachment-texts { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.attachment-name { color: var(--text); font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.attachment-meta { margin: 0; color: var(--muted); font-size: 13px; }
.attachment-row.is-unsupported .attachment-name { color: var(--muted); }
.attachment-note { margin: 0; color: var(--muted); font-size: 14px; }
.attachment-viewer-title { overflow-wrap: anywhere; }
.attachment-stage { margin-top: 14px; }
.attachment-image { display: block; max-width: 100%; max-height: 60dvh; margin: 0 auto; border-radius: 13px; }
.attachment-frame { display: block; width: 100%; height: 60dvh; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.attachment-text {
  max-height: 50dvh;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---- Loading / error ---- */
.task-detail-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 14px 0 28px;
}
.task-detail-error .primary { max-width: 320px; }
