/* Wide-screen layout system (bead mp-jxt.85). Loaded on every page after style.css.
   - One text-size control (--fs, 90 to 130%) scales the whole page with `zoom`, because the
     site's CSS is written in px. 1.1 is the built-in lift from the old 14 to 16px text to about 18px.
   - Darker grey text, a high-contrast switch, 44px minimum tap targets.
   - Fluid widths: the old 720/1040/1100/1120px caps are gone (see the overrides below). */
:root { --fs: 1; --tx-lift: 1.1; }
body {
  zoom: calc(var(--fs) * var(--tx-lift));
  font-size: 16px;
  line-height: 1.55;
  /* Grey text derived from text and background, so it is always readable on any theme
     (the theme's own --muted is often too faint). */
  --muted: color-mix(in srgb, var(--text) 74%, var(--bg));
}
html.hc body { --muted: var(--text); --border: var(--text); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Tap targets */
button, .btn, .hm-pill, .cp-btn, summary, select, input[type=checkbox] + label { min-height: 44px; }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password], input[type=time], select { min-height: 44px; }

/* Width caps removed */
.container, .nav-inner, .app-header-inner { max-width: none; }
.container-narrow { max-width: 760px; }
.hm-wrap, .hm-footer { max-width: none; }
.cp-main, .cp-wide { max-width: none; }

/* ── Text size and contrast control (bottom right, collapses to one button) ── */
.tx-tools { position: fixed; right: 12px; bottom: 12px; z-index: 40; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; zoom: 1; }
.tx-toggle { min-width: 44px; min-height: 44px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); color: var(--text); font: 600 15px/1 Georgia, serif; cursor: pointer; box-shadow: var(--shadow); }
.tx-panel { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); max-width: 260px; justify-content: flex-end; }
.tx-panel[hidden] { display: none; }
.tx-panel button { min-width: 44px; min-height: 44px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; background: transparent; color: var(--text); font: 600 14px Inter, system-ui, sans-serif; cursor: pointer; }
.tx-panel button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent, var(--bg)); }
.tx-toggle:focus-visible, .tx-panel button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ── Compass shell: a 230px left sidebar on wide screens, today's top nav on narrow ones ── */
@media (min-width: 901px) {
  .hm-wrap:has(> .cp-head) { display: grid; grid-template-columns: 230px minmax(0, 1fr); column-gap: 36px; row-gap: 0; align-items: start; }
  .hm-wrap:has(> .cp-head) > .cp-head { grid-column: 1; grid-row: 1 / span 30; position: sticky; top: 16px; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 10px; margin: 0; padding: 18px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
  .hm-wrap:has(> .cp-head) > :not(.cp-head) { grid-column: 2; min-width: 0; }
  .cp-head .back-home { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; color: var(--muted); }
  .cp-head .hm-brand { font-size: 26px; }
  .cp-head .cp-nav { flex-direction: column; align-items: stretch; gap: 4px; }
  .cp-head .cp-group { flex-direction: column; flex-wrap: nowrap; gap: 4px; }
  .cp-head .hm-pill { border-radius: 10px; border-color: transparent; background: transparent; padding: 0 12px; }
  .cp-head .hm-pill:hover { background: var(--accent-soft); }
  .cp-head .hm-pill.is-active { background: var(--accent-soft); border-color: transparent; }
  .cp-head .cp-sep { width: auto; height: 1px; margin: 6px 4px; opacity: .5; }
}

/* ── Compass content ── */
.cp-main > .hm-title { font-size: 2rem; }
/* Forms and prose keep a readable line length; grids and boards use the full width. */
.cp-new, .cp-main > p, .cp-main > form, .cp-main > details, .cp-section > p, .cp-section > form { max-width: 60rem; }
.cp-trend { max-width: 560px; }

/* Focus page: today's habits | in focus | detail panel */
.cp-cols { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(300px, 1.1fr) minmax(300px, .9fr); gap: 24px; align-items: start; }
.cp-cols > section { margin: 0; min-width: 0; }
.cp-cols .cp-card, .cp-detail { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; }
.cp-int-pick { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.cp-int[aria-current="true"] { border: 2px solid var(--accent); padding: 15px 17px; }
.cp-detail[hidden] { display: none; }
.cp-detail h3 { font-family: Georgia, 'Times New Roman', serif; font-size: 1.25rem; margin: 0 0 8px; }
@media (max-width: 1280px) {
  .cp-cols { grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr); }
  .cp-cols > .cp-detail-wrap { grid-column: 1 / -1; }
}
@media (max-width: 900px) { .cp-cols { grid-template-columns: minmax(0, 1fr); } }

/* Map: fills the window, never scrolls sideways */
.cp-map-scroll { overflow-x: visible; margin: 0; padding: 4px 0; }
.cp-map { width: 100%; height: auto; max-width: none; }

/* Goals board: columns grow with the window */
.cp-board { grid-template-columns: repeat(4, minmax(220px, 1fr)); }
@media (max-width: 1100px) { .cp-board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .cp-board { grid-template-columns: minmax(0, 1fr); } }

/* Home: card grid adds columns as space allows (replaces the fixed three) */
.hm-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.hm-wide { grid-column: auto; }
@media (min-width: 1500px) { .hm-wide { grid-column: span 2; } }
@media (max-width: 760px) { .hm-grid { grid-template-columns: minmax(0, 1fr); } }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* Anchor buttons: `.hm-page a { color: inherit }` was beating the button colours (dark text on green). */
.hm-page .cp-btn-main, .hm-page a.cp-btn-main { color: var(--on-accent, #fff); }
.hm-page .cp-btn-quiet { color: var(--muted); }

/* ── Value palette, global (tasks use it too) ── */
:root { --vc-teal:#3fb8ab; --vc-blue:#6ea8fe; --vc-amber:#f2b84b; --vc-rose:#f27a9b; --vc-violet:#a98bfb; --vc-green:#7fcf6a; --vc-orange:#f58f4a; --vc-slate:#9aa7b8; }
[data-theme="light"] { --vc-teal:#1f7a70; --vc-blue:#2b62c4; --vc-amber:#a8710a; --vc-rose:#b83a63; --vc-violet:#6a43c7; --vc-green:#3a7d2a; --vc-orange:#b85a14; --vc-slate:#566377; }
.vc-teal{--vc:var(--vc-teal)} .vc-blue{--vc:var(--vc-blue)} .vc-amber{--vc:var(--vc-amber)} .vc-rose{--vc:var(--vc-rose)}
.vc-violet{--vc:var(--vc-violet)} .vc-green{--vc:var(--vc-green)} .vc-orange{--vc:var(--vc-orange)} .vc-slate{--vc:var(--vc-slate)}

/* ── Tasks: Supports chip and the Priority / Supports popover ── */
.task-supports { display: inline-flex; align-items: center; max-width: 14rem; margin-left: 8px; padding: 1px 10px; border-radius: 99px; border: 1px solid var(--vc, var(--border)); background: color-mix(in srgb, var(--vc, var(--accent)) 16%, transparent); color: var(--text); font-size: .78rem; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
html.hc .task-supports { border-width: 2px; border-color: var(--text); }
.cat-btn.cat-btn-set { background: color-mix(in srgb, var(--vc, var(--accent)) 18%, transparent); border-color: var(--vc, var(--accent)); color: var(--text); }
.cat-btn .cat-btn-chosen { margin-left: 6px; padding-left: 6px; border-left: 1px solid var(--border); font-weight: 600; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-picker { width: min(360px, calc(100vw - 16px)); padding: 12px; }
.sp-label { font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 6px 0 6px; }
.sp-chips { display: flex; gap: 6px; margin-bottom: 8px; }
.sp-chip { flex: 1; min-height: 40px; padding: 0 8px; border: 1.5px solid var(--chip, var(--border)); border-radius: 99px; background: transparent; color: var(--text); font: 600 .85rem Inter, system-ui, sans-serif; cursor: pointer; }
.sp-chip.is-on { background: color-mix(in srgb, var(--chip, var(--accent)) 28%, var(--surface)); box-shadow: inset 0 0 0 1.5px var(--chip, var(--accent)); }
.sp-search { width: 100%; box-sizing: border-box; min-height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; font-size: .9rem; }
.sp-search:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.sp-list { max-height: min(46vh, 340px); overflow-y: auto; margin-top: 8px; }
.sp-grouptitle { font-size: .72rem; font-weight: 700; color: var(--muted); margin: 10px 4px 4px; text-transform: uppercase; letter-spacing: .04em; }
.sp-opt { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 4px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; font: inherit; font-size: .88rem; cursor: pointer; }
.sp-opt.is-indent { padding-left: 28px; }
.sp-opt.is-hi { background: var(--accent-soft); }
.sp-opt.is-selected .sp-name { font-weight: 700; }
.sp-opt.is-selected::after { content: "\2713"; margin-left: auto; }
.sp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-kind, .sp-parent { font-size: .72rem; color: var(--muted); flex: none; }
.sp-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--vc, transparent); flex: none; border: 1px solid color-mix(in srgb, var(--text) 40%, transparent); }
.sp-dot-none { background: transparent; border-style: dashed; }
.sp-all > summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; padding: 0 8px; color: var(--accent); font-size: .85rem; }
.sp-empty { padding: 10px 8px; color: var(--muted); font-size: .85rem; }

/* ══ Task pages (bead mp-jxt.88) ══ */
/* Hide completed also hides completed habit rows; Hide habits hides the habit rows of the day views. */
body.hide-done .wday-habit-done { display: none; }
body.hide-habits .wday-habits { display: none; }
.theme-toggle-btn.is-on { color: var(--accent); }

/* Habit rows take the colour of their intention (first value); default green */
.wday-habit { --hc: var(--habit-c, var(--cal-color-habit, var(--c-green))); background: color-mix(in srgb, var(--hc) 9%, transparent); border-color: var(--hc); }
.wday-habit:hover { background: color-mix(in srgb, var(--hc) 14%, transparent); }
.wday-habit-icon { color: var(--hc); }
.wday-habit-done { border-color: var(--border); }

/* A task that supports a goal or intention: a colour bar on each side (8px). The text is in the
   tooltip of the left bar (hover, focus, title and aria-label); the row itself shows no text. */
[data-has-supports] { position: relative; border-left: 8px solid var(--sup, var(--muted)); border-right: 8px solid var(--sup, var(--muted)); }
html.hc [data-has-supports] { border-left-width: 12px; border-right-width: 12px; }
.supports-bar { position: absolute; left: -8px; top: 0; bottom: 0; width: 8px; cursor: help; z-index: 3; }
html.hc .supports-bar { left: -12px; width: 12px; }
.supports-bar::after { content: attr(data-tip); position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: max-content; max-width: min(210px, 60vw); padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: .8rem; line-height: 1.35; white-space: normal; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 30; }
.supports-bar:hover::after, .supports-bar:focus-visible::after { opacity: 1; }
.supports-bar:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

/* Day columns: the same layout for every week, forward or back. Equal columns that always fill the
   width; no today weighting (today is marked in its header). */
.week-cal:not(.view-3day) .wday-today { flex: 1 1 0; }
.week-cal.view-3day .wday.wday-3day-visible, .week-cal.view-3day .wday.wday-today.wday-3day-visible { flex: 1 1 0; }
/* The day columns (3-day and 7-day) use about 80% of the width, centred */
.week-cal-wrap { width: 80%; margin-left: auto; margin-right: auto; }
@media (max-width: 900px) { .week-cal-wrap { width: 100%; } }
/* Column handles also in the 3-day view (the script shows them between visible days only) */
.week-cal.view-3day .col-resizer { display: block; }
.col-resizer { flex: 0 0 6px; width: 6px; }
.col-resizer:hover, .col-resizer.resizing { background: var(--accent); }
/* Same-height day headers: no task count, one row */
.wday-count { display: none; }
.wday-header { box-sizing: border-box; height: 3.6rem; display: flex; align-items: center; padding-top: 0; padding-bottom: 0; }
.wday-label { width: 100%; }
.wday-label-row, .wday-name-group { flex-wrap: nowrap; }
.wday-name-group { white-space: nowrap; }
/* The one-day view uses about 80% too */
@media (min-width: 901px) { .container.container-day { width: 80%; margin-left: auto; margin-right: auto; } }

/* Bigger day and date headings */
.wday-name-group { flex-direction: row; align-items: baseline; gap: .4rem; flex-wrap: nowrap; min-width: 0; }
.wday-name { font-size: 1.45rem; font-weight: 700; line-height: 1.1; color: var(--text); }
.wday-today .wday-name { font-size: 1.45rem; color: var(--purple-light); }
.wday-date { font-size: 1.1rem; font-weight: 500; color: var(--text-2); }
.wday-header { padding: .85rem .85rem .75rem; }
.date-bar-date { font-size: 1.7rem; font-weight: 700; line-height: 1.15; color: var(--text); }

/* One-day view: list picker on the left, the day, then the move-to-date target */
.container-day { max-width: none; }
.day-content-row { align-items: flex-start; }
.day-lists-panel { flex: 0 0 300px; min-width: 0; }
.day-lists-label { display: block; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin-bottom: 4px; }
.day-list-select { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; }
.day-lists-hint { font-size: .8rem; color: var(--text-2); margin: 6px 0 12px; }
/* The list panel keeps its own width and scrolls inside itself. A plain "1fr" grid track is
   minmax(auto, 1fr), so one long no-wrap task title stretched the card far past the 300px panel and it
   painted over the main column; minmax(0, 1fr) plus min-width: 0 stops that. The panel height is capped
   (the page is zoomed by the text-size control, so the cap is divided by that zoom) and it sticks while
   the day scrolls. */
.day-lists-panel { position: sticky; top: 12px; align-self: flex-start; max-height: calc((100vh - 24px) / (var(--fs, 1) * var(--tx-lift, 1))); overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; padding-right: 4px; }
.day-lists-panel .list-grid { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.day-lists-panel .list-card, .day-lists-panel .list-card-items, .day-lists-panel .list-card-item, .day-lists-panel .task-row-main { min-width: 0; max-width: 100%; }
.day-lists-panel .list-card-items { max-height: none; overflow: visible; }
.day-items-col { min-width: 0; }
.day-lists-panel select { max-width: 100%; }
/* Not enough room for three columns: stack the panel above the day, with its own height cap */
@media (max-width: 1100px) {
  .day-content-row { flex-direction: column; align-items: stretch; }
  .day-lists-panel { position: static; flex: 0 0 auto; width: 100%; max-height: calc(50vh / (var(--fs, 1) * var(--tx-lift, 1))); }
  .next-day-box { width: 100%; min-height: 64px; }
}
.next-day-box { width: 150px; min-height: 120px; border: 2px dashed var(--border); background: transparent; cursor: pointer; transition: border-color .15s, background .15s; }
.next-day-box:hover, .next-day-box:focus-visible { border-color: var(--accent); }
.next-day-box:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.next-day-box.needs-task .ndb-title::after { content: "Select a task first"; display: block; margin-top: 6px; font-weight: 500; font-size: .75rem; color: var(--text-2); }
.ndb-title { font-weight: 600; font-size: .9rem; color: var(--text-2); }

/* Move-to-date dialog */
.mv-backdrop { position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.mv-backdrop[hidden] { display: none; }
.mv-dialog { width: min(420px, 100%); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; padding: 22px 24px; box-shadow: var(--shadow-lg, 0 10px 40px rgba(0,0,0,.4)); }
.mv-title { font-family: Georgia, 'Times New Roman', serif; font-size: 1.3rem; margin: 0 0 4px; }
.mv-what { margin: 0 0 14px; color: var(--text-2); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.mv-q { min-height: 44px; padding: 0 14px; border: 1.5px solid var(--border); border-radius: 99px; background: transparent; color: var(--text); font: 600 .85rem Inter, system-ui, sans-serif; cursor: pointer; }
.mv-q span { font-weight: 500; color: var(--text-2); margin-left: 4px; }
.mv-q:hover, .mv-q.is-on { border-color: var(--accent); background: var(--accent-soft); }
.mv-label { display: block; font-size: .8rem; color: var(--text-2); margin-bottom: 4px; }
.mv-date { width: 100%; box-sizing: border-box; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; }
.mv-error { color: var(--c-red, #c0392b); font-size: .85rem; margin: 6px 0 0; }
.mv-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.mv-cancel, .mv-go { min-height: 44px; padding: 0 18px; border-radius: 99px; font: 600 .9rem Inter, system-ui, sans-serif; cursor: pointer; }
.mv-cancel { border: 1px solid var(--border); background: transparent; color: var(--text); }
.mv-go { border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent, #fff); }
.mv-go:disabled { opacity: .5; cursor: not-allowed; }
.mv-go:focus-visible, .mv-cancel:focus-visible, .mv-q:focus-visible, .mv-date:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (max-width: 720px) {
  .day-lists-panel { flex: 1 1 auto; width: 100%; }
  .next-day-box { width: 100%; }
}

/* The right bar shows the same tooltip, opening to the left */
.supports-bar-r { left: auto; right: -8px; }
html.hc .supports-bar-r { left: auto; right: -12px; }
.supports-bar-r::after { left: auto; right: 16px; }

/* Seven narrow columns: slightly smaller heading so the day, date and View all fit on one line */
.week-cal:not(.view-3day) .wday-name, .week-cal:not(.view-3day) .wday-today .wday-name { font-size: 1.25rem; }
.week-cal:not(.view-3day) .wday-date { font-size: .95rem; }
.week-cal:not(.view-3day) .wday-today-pill { display: none; }

/* ── Day header is a link to the one-day view ── */
.wday-title-link { color: inherit; text-decoration: none; border-radius: 8px; padding: 2px 6px; margin: -2px -6px; }
.wday-title-link:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.wday-title-link:hover .wday-name { text-decoration: underline; text-underline-offset: 3px; }
.wday-title-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ── App brand badge (one definition for every app; see the "brand" template) ──
   Font: the PlotMyBrain wordmark's own (system UI stack, bold, .2px spacing). The first word is white on
   dark themes and the theme's strong text colour on light ones (white would vanish there); "MyBrain" is
   the app's muted accent, brighter on dark and deeper on light, so it stays readable on both. In
   high-contrast mode both words use the text colour and "MyBrain" is underlined, so it is not
   colour alone that tells them apart. */
:root { --bb-first: #fff; --bb-tame: #8fa8ff; --bb-plan: #7fcf9a; --bb-fit: #f2a35e; --bb-plot: #e58aa8; }
[data-theme="light"] { --bb-first: var(--text); --bb-tame: #3a55c4; --bb-plan: #2f7d4d; --bb-fit: #a2500f; --bb-plot: #b0345f; }
.brand-badge { --bb-accent: var(--bb-tame); display: inline-flex; align-items: center; min-height: 44px; white-space: nowrap; text-decoration: none !important; font: 700 1.2rem/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; letter-spacing: .2px; }
.brand-badge[data-app="plan"] { --bb-accent: var(--bb-plan); }
.brand-badge[data-app="fit"] { --bb-accent: var(--bb-fit); }
.brand-badge[data-app="plot"] { --bb-accent: var(--bb-plot); }
.bb-logo { color: var(--bb-accent); margin-right: 6px; font-weight: 400; }
.bb-a { color: var(--bb-first) !important; }
.bb-b { color: var(--bb-accent) !important; }
.brand-badge:hover .bb-a, .brand-badge:hover .bb-b { text-decoration: underline; text-underline-offset: 3px; }
.brand-badge:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
html.hc .bb-a, html.hc .bb-b, html.hc .bb-logo { color: var(--text) !important; }
html.hc .bb-b { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.cp-head .brand-badge { font-size: 1.45rem; }
/* A habit block that supports an intention names it on hover and focus (mp-jxt.92). */
.wday-habit-sup { display: inline-flex; align-items: center; flex-shrink: 0; cursor: help; border-radius: 4px; padding: 2px; margin: -2px; }
.wday-habit-sup:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
