/* ob-plan-goals-detail.css (R7-T3): the goal detail, the habit loop and the dialogs. Tokens only (--ob3-*), no raw hex; Paper and Graphite
   come from the themed roles. Taps are at least 44 px; the Min/Full toggle is 44 px high; a pill is 104 x 44 and never grows. */

/* On a phone the detail is PUSHED: it replaces the list while a goal is selected (Back returns, scroll restored by the module). */
#obp-goals[data-obpg-layout="phone"][data-obpg-selected] .obpg-head,
#obp-goals[data-obpg-layout="phone"][data-obpg-selected] .obpg-banner,
#obp-goals[data-obpg-layout="phone"][data-obpg-selected] .obpg-list { display: none; }
/* ... and so does the shell's Plan header (the board's detail frame starts at the Back arrow). */
.obds-canvas-body:has(#obp-goals[data-obpg-layout="phone"][data-obpg-selected]) #obp-head,
.obds-canvas-body:has(#obp-goals[data-obpg-layout="phone"][data-obpg-selected]) #obp-banner { display: none; }
#obp-goals .obpgd { position: relative; color: var(--ob3-ink); min-width: 0; display: flex; flex-direction: column; gap: var(--ob3-space-3); }
#obp-goals .obpgd-head { position: relative; display: flex; align-items: flex-start; gap: var(--ob3-space-2); }
#obp-goals .obpgd-titlebox { flex: 1 1 auto; min-width: 0; padding-top: 2px; }
#obp-goals .obpgd-title { margin: 0; font-size: var(--ob3-text-title); line-height: var(--ob3-leading-title); font-weight: var(--ob3-weight-bold); letter-spacing: var(--ob3-tracking-title); overflow-wrap: anywhere; }
#obp-goals .obpgd-title:focus-visible { outline: var(--ob3-focus-ring); outline-offset: var(--ob3-focus-offset); }
#obp-goals .obpgd-sub { color: var(--ob3-muted); font-size: var(--ob3-text-meta); line-height: var(--ob3-leading-meta); }
#obp-goals .obpgd-icon {
  box-sizing: border-box; width: 44px; min-width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; flex: none;
  border: 0; background: transparent; color: var(--ob3-ink); border-radius: var(--ob3-radius-full); cursor: pointer; font: inherit;
}
#obp-goals .obpgd-icon:disabled { opacity: 0.4; cursor: not-allowed; }
#obp-goals .obpgd-icon:focus-visible,
#obp-goals .obpgd-tab:focus-visible,
#obp-goals .obpgd-link:focus-visible,
#obp-goals .obpgd-tick:focus-visible,
#obp-goals .obpgd-switch:focus-visible,
#obp-goals .obpgd-mf:focus-visible,
#obp-goals .obpgd-action:focus-visible,
#obp-goals .obpgd-pill:focus-visible,
#obp-goals .obpgd-menuitem:focus-visible,
#obpgd-portal .obpgd-dlgbtn:focus-visible,
#obp-goals .obpgd-input:focus-visible, #obpgd-portal .obpgd-input:focus-visible { outline: var(--ob3-focus-ring); outline-offset: var(--ob3-focus-offset); }
#obp-goals .obpgd-menu {
  position: absolute; right: 0; top: 46px; z-index: 5; min-width: 220px; max-width: calc(100vw - 32px); padding: var(--ob3-space-2);
  background: var(--ob3-surface); border: 1px solid var(--ob3-line); border-radius: var(--ob3-radius-card); box-shadow: var(--ob3-shadow);
}
#obp-goals .obpgd-menuitem {
  box-sizing: border-box; width: 100%; min-height: 44px; display: flex; align-items: center; padding: 0 var(--ob3-space-3); border: 0; background: transparent;
  color: var(--ob3-ink); font: inherit; font-size: var(--ob3-text-body-sm); text-align: left; border-radius: var(--ob3-radius-control); cursor: pointer;
}
#obp-goals .obpgd-menuitem:hover { background: var(--ob3-sunk); }
#obp-goals .obpgd-menuitem.is-danger { color: var(--ob3-alert); font-weight: var(--ob3-weight-semibold); }
#obp-goals .obpgd-tabs { display: flex; gap: var(--ob3-space-1); padding: var(--ob3-space-1); background: var(--ob3-sunk); border-radius: var(--ob3-radius-full); }
#obp-goals .obpgd-tab {
  box-sizing: border-box; flex: 1 1 0; min-height: 44px; border: 0; border-radius: var(--ob3-radius-full); background: transparent; color: var(--ob3-muted);
  font: inherit; font-size: var(--ob3-text-body-sm); font-weight: var(--ob3-weight-semibold); cursor: pointer;
}
#obp-goals .obpgd-tab[aria-selected="true"] { background: var(--ob3-surface); color: var(--ob3-ink); box-shadow: 0 0 0 1px var(--ob3-line); }
#obp-goals .obpgd-panel { display: flex; flex-direction: column; gap: var(--ob3-space-3); min-width: 0; }
#obp-goals .obpgd-hero { display: flex; align-items: center; gap: var(--ob3-space-3); }
#obp-goals .obpgd-herotxt { display: flex; flex-direction: column; gap: var(--ob3-space-1); min-width: 0; }
#obp-goals .obpgd-streak { display: inline-flex; align-items: center; gap: var(--ob3-space-2); font-size: var(--ob3-text-card-title); line-height: var(--ob3-leading-card-title); font-weight: var(--ob3-weight-bold); }
#obp-goals .obpgd-flame { color: var(--ob3-attention-vivid); display: inline-flex; }
#obp-goals .obpgd-ring { position: relative; width: 88px; height: 88px; flex: none; }
#obp-goals .obpgd-ring svg { display: block; }
#obp-goals .obpgd-ring-track { fill: none; stroke: var(--ob3-sunk-deep); stroke-width: 8; }
#obp-goals .obpgd-ring-arc { fill: none; stroke-width: 8; stroke-linecap: round; }
#obp-goals .obpgd-ring-good .obpgd-ring-arc { stroke: var(--ob3-good-vivid); }
#obp-goals .obpgd-ring-accent .obpgd-ring-arc { stroke: var(--ob3-accent); }
#obp-goals .obpgd-ring-txt { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#obp-goals .obpgd-ring-txt b { font-size: var(--ob3-text-card-title); font-weight: var(--ob3-weight-bold); }
#obp-goals .obpgd-ring-txt span { font-size: var(--ob3-text-meta); color: var(--ob3-muted); }
#obp-goals .obpgd-card { background: var(--ob3-surface); border: 1px solid var(--ob3-line); border-radius: var(--ob3-radius-card); padding: var(--ob3-space-3) var(--ob3-space-4); box-sizing: border-box; min-width: 0; }
#obp-goals .obpgd-rest { display: flex; align-items: center; justify-content: space-between; gap: var(--ob3-space-3); background: var(--ob3-sunk); border-color: transparent; }
#obp-goals .obpgd-resttxt { display: flex; flex-direction: column; min-width: 0; }
#obp-goals .obpgd-resttxt b { font-weight: var(--ob3-weight-bold); }
#obp-goals .obpgd-resttxt span { color: var(--ob3-muted); font-size: var(--ob3-text-meta); }
#obp-goals .obpgd-switch { position: relative; flex: none; box-sizing: border-box; width: 56px; height: 44px; padding: 0; border: 0; cursor: pointer; }
#obp-goals .obpgd-switch::before { content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 30px; border-radius: var(--ob3-radius-full); background: var(--ob3-sunk-deep); }
#obp-goals .obpgd-switch[aria-checked="true"]::before { background: var(--ob3-good-vivid); }
#obp-goals .obpgd-switch:disabled { opacity: 0.55; cursor: not-allowed; }
#obp-goals .obpgd-knob { position: absolute; top: 10px; left: 3px; width: 24px; height: 24px; border-radius: var(--ob3-radius-full); background: var(--ob3-surface); box-shadow: 0 1px 3px var(--ob3-line-strong); transition: transform var(--ob3-dur-short) var(--ob3-ease); }
#obp-goals .obpgd-switch[aria-checked="true"] .obpgd-knob { transform: translateX(26px); }
@media (prefers-reduced-motion: reduce) { #obp-goals .obpgd-knob { transition: none; } }
#obp-goals .obpgd-cardtitle { margin: 0; font-size: var(--ob3-text-body); font-weight: var(--ob3-weight-bold); }
#obp-goals .obpgd-sechead { display: flex; align-items: center; justify-content: space-between; gap: var(--ob3-space-2); flex-wrap: wrap; }
#obp-goals .obpgd-steady { color: var(--ob3-muted); font-size: var(--ob3-text-meta); }
#obp-goals .obpgd-grid { display: flex; justify-content: space-between; gap: 4px; margin: var(--ob3-space-3) 0; }
#obp-goals .obpgd-gcol { display: flex; flex-direction: column; gap: 4px; flex: 1 1 0; align-items: center; }
#obp-goals .obpgd-cell { width: 14px; height: 14px; border-radius: 4px; box-sizing: border-box; background: var(--ob3-sunk-deep); display: inline-block; flex: none; }
#obp-goals .obpgd-cell.is-done { background: var(--ob3-good-vivid); }
#obp-goals .obpgd-cell.is-rest { background: transparent; border: 2px solid var(--ob3-good-vivid); }
#obp-goals .obpgd-cell.is-today { background: transparent; border: 2px dashed var(--ob3-good-vivid); }
#obp-goals .obpgd-cell.is-missed { background: var(--ob3-sunk-deep); }
#obp-goals .obpgd-cell.is-none { background: var(--ob3-sunk); }
#obp-goals .obpgd-mirror { display: flex; flex-direction: column; gap: var(--ob3-space-2); background: var(--ob3-saarthi-tint); border-color: transparent; }
#obp-goals .obpgd-mirrortxt { margin: 0; }
#obp-goals .obpgd-mirroracts { display: flex; flex-wrap: wrap; gap: var(--ob3-space-2); }
#obp-goals .obpgd-label { margin: var(--ob3-space-2) 0 var(--ob3-space-1); color: var(--ob3-muted); font-size: var(--ob3-text-label); line-height: var(--ob3-leading-label); letter-spacing: var(--ob3-tracking-label); text-transform: uppercase; font-weight: var(--ob3-weight-semibold); }
#obp-goals .obpgd-section { display: flex; flex-direction: column; gap: var(--ob3-space-1); min-width: 0; }
#obp-goals .obpgd-link { box-sizing: border-box; min-height: 44px; padding: 0 var(--ob3-space-2); border: 0; background: transparent; color: var(--ob3-accent-text); font: inherit; font-size: var(--ob3-text-body-sm); font-weight: var(--ob3-weight-semibold); cursor: pointer; }
#obp-goals .obpgd-steps { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ob3-line); }
#obp-goals .obpgd-step { display: flex; align-items: center; gap: var(--ob3-space-3); min-height: 56px; padding: var(--ob3-space-1) 0; border-bottom: 1px solid var(--ob3-line); flex-wrap: wrap; }
#obp-goals .obpgd-steptxt { flex: 1 1 140px; min-width: 0; }
#obp-goals .obpgd-steptitle { display: flex; align-items: center; gap: var(--ob3-space-2); font-weight: var(--ob3-weight-semibold); }
#obp-goals .obpgd-steplabel { overflow-wrap: anywhere; }
#obp-goals .obpgd-step.is-done .obpgd-steplabel { text-decoration: line-through; color: var(--ob3-muted); }
#obp-goals .obpgd-stepsub { color: var(--ob3-muted); font-size: var(--ob3-text-meta); line-height: var(--ob3-leading-meta); }
#obp-goals .obpgd-tick {
  box-sizing: border-box; width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center; padding: 0; background: transparent; border: 0; cursor: pointer; color: var(--ob3-on-accent); position: relative;
}
#obp-goals .obpgd-tick::before { content: ""; position: absolute; width: 24px; height: 24px; border-radius: var(--ob3-radius-full); border: 2px solid var(--ob3-line-strong); box-sizing: border-box; }
#obp-goals .obpgd-tick.is-on::before { background: var(--ob3-good-vivid); border-color: var(--ob3-good-vivid); }
#obp-goals .obpgd-tick svg { position: relative; }
#obp-goals .obpgd-tick.is-queued::before { border-style: dashed; }
#obp-goals .obpgd-tick:disabled { opacity: 0.6; cursor: progress; }
#obp-goals .obpgd-queued { box-sizing: border-box; padding: 2px var(--ob3-space-2); border-radius: var(--ob3-radius-full); background: var(--ob3-sunk); color: var(--ob3-muted); font-size: var(--ob3-text-meta); }
#obp-goals .obpgd-badge { padding: 0 var(--ob3-space-2); border-radius: var(--ob3-radius-full); background: var(--ob3-saarthi-tint); color: var(--ob3-saarthi); font-size: var(--ob3-text-meta); font-weight: var(--ob3-weight-semibold); }
#obp-goals .obpgd-minfull { display: inline-flex; flex: none; border: 1px solid var(--ob3-line); border-radius: var(--ob3-radius-full); overflow: hidden; }
#obp-goals .obpgd-mf { box-sizing: border-box; min-width: 52px; height: 44px; padding: 0 var(--ob3-space-3); border: 0; background: transparent; color: var(--ob3-muted); font: inherit; font-size: var(--ob3-text-body-sm); cursor: pointer; }
#obp-goals .obpgd-mf[aria-pressed="true"] { background: var(--ob3-accent-tint); color: var(--ob3-on-accent-tint); font-weight: var(--ob3-weight-semibold); }
#obp-goals .obpgd-reorder { display: inline-flex; flex: none; }
#obp-goals .obpgd-chips { display: flex; flex-wrap: wrap; gap: var(--ob3-space-2); }
#obp-goals .obpgd-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 var(--ob3-space-3); border-radius: var(--ob3-radius-full); background: var(--ob3-sunk); color: var(--ob3-ink); font-size: var(--ob3-text-meta); font-weight: var(--ob3-weight-semibold); }
#obp-goals .obpgd-chip-cat { background: var(--ob3-accent-tint); color: var(--ob3-on-accent-tint); }
#obp-goals .obpgd-chip-alert { background: var(--ob3-alert-tint); color: var(--ob3-alert); }
#obp-goals .obpgd-mem { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 var(--ob3-space-2); border-radius: var(--ob3-radius-full); background: var(--ob3-sunk); color: var(--ob3-muted); font-size: var(--ob3-text-meta); }
#obp-goals .obpgd-serves { display: flex; align-items: center; gap: var(--ob3-space-3); background: var(--ob3-sunk); border-color: transparent; }
#obp-goals .obpgd-serves div { display: flex; flex-direction: column; }
#obp-goals .obpgd-addrow { display: flex; align-items: center; gap: var(--ob3-space-2); flex-wrap: wrap; padding-top: var(--ob3-space-2); }
#obp-goals .obpgd-addactions { display: flex; flex-wrap: wrap; gap: var(--ob3-space-2); padding-top: var(--ob3-space-2); }
#obp-goals .obpgd-input, #obpgd-portal .obpgd-input { box-sizing: border-box; flex: 1 1 160px; min-height: 44px; padding: 0 var(--ob3-space-3); border: 1px solid var(--ob3-line-strong); border-radius: var(--ob3-radius-control); background: var(--ob3-surface); color: var(--ob3-ink); font: inherit; min-width: 0; width: 100%; }
#obp-goals .obpgd-addrow .obpgd-input { width: auto; }
#obp-goals .obpgd-pill {
  box-sizing: border-box; width: 104px; min-width: 104px; max-width: 104px; height: 44px; padding: 0 var(--ob3-space-2); display: inline-flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  border: 1px solid var(--ob3-line); border-radius: var(--ob3-radius-full); background: var(--ob3-surface); color: var(--ob3-ink); font: inherit; font-size: var(--ob3-text-body-sm); font-weight: var(--ob3-weight-semibold); cursor: pointer;
}
#obp-goals .obpgd-pill-primary { background: var(--ob3-accent); border-color: var(--ob3-accent); color: var(--ob3-on-accent); }
#obp-goals .obpgd-pill:disabled,
#obp-goals .obpgd-action:disabled { opacity: 0.55; cursor: not-allowed; }
#obp-goals .obpgd-action {
  box-sizing: border-box; min-height: 44px; padding: 0 var(--ob3-space-4); display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--ob3-line); border-radius: var(--ob3-radius-full);
  background: var(--ob3-surface); color: var(--ob3-ink); font: inherit; font-size: var(--ob3-text-body-sm); font-weight: var(--ob3-weight-semibold); cursor: pointer;
}
#obp-goals .obpgd-note { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--ob3-space-2) var(--ob3-space-3); min-height: 44px; padding: var(--ob3-space-2) var(--ob3-space-3); border-radius: var(--ob3-radius-card); background: var(--ob3-inverse-surface); color: var(--ob3-on-inverse); font-size: var(--ob3-text-body-sm); }
#obp-goals .obpgd-note .obpgd-pill { background: transparent; border-color: transparent; color: var(--ob3-on-inverse); text-decoration: underline; }
#obp-goals .obpgd-muted { margin: 0; color: var(--ob3-muted); font-size: var(--ob3-text-meta); line-height: var(--ob3-leading-meta); }
#obp-goals .obpgd-tail { margin: 0 0 var(--ob3-space-2); }
#obp-goals .obpgd-err, #obpgd-portal .obpgd-err { margin: var(--ob3-space-1) 0 0; color: var(--ob3-alert); font-size: var(--ob3-text-body-sm); }
#obp-goals .obpgd-sr, #obpgd-portal .obpgd-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#obp-goals .obpgd-last7 { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--ob3-space-3); flex-wrap: wrap; }
#obp-goals .obpgd-l7 { display: flex; flex-direction: column; align-items: center; gap: var(--ob3-space-1); font-size: var(--ob3-text-meta); color: var(--ob3-muted); }

/* Dialogs (Let go confirm, Pick date, Make recurring): a centred overlay inside #obp-goals, so the poll pauses while it is open. */
#obpgd-portal { position: fixed; inset: 0; z-index: 1900; display: flex; align-items: center; justify-content: center; padding: var(--ob3-space-4); background: var(--ob3-scrim); }
#obpgd-portal .obpgd-dialog { box-sizing: border-box; width: 100%; max-width: 420px; max-height: calc(100vh - 32px); overflow: auto; padding: var(--ob3-space-4); border-radius: var(--ob3-radius-sheet); border: 1px solid var(--ob3-line); background: var(--ob3-surface); color: var(--ob3-ink); box-shadow: var(--ob3-shadow); }
#obpgd-portal .obpgd-dialog:focus-visible { outline: none; }
#obpgd-portal .obpgd-dlgtitle { margin: 0 0 var(--ob3-space-2); font-size: var(--ob3-text-card-title); line-height: var(--ob3-leading-card-title); font-weight: var(--ob3-weight-bold); }
#obpgd-portal .obpgd-dlgtxt { margin: 0 0 var(--ob3-space-3); color: var(--ob3-ink); font-size: var(--ob3-text-body-sm); overflow-wrap: anywhere; }
#obpgd-portal .obpgd-dlgacts { display: flex; gap: var(--ob3-space-3); margin-top: var(--ob3-space-3); }
#obpgd-portal .obpgd-dlgacts.obpgd-col { flex-direction: column; }
#obpgd-portal .obpgd-dlgbtn { box-sizing: border-box; flex: 1 1 0; min-height: 44px; padding: 0 var(--ob3-space-3); border: 1px solid var(--ob3-line-strong); border-radius: var(--ob3-radius-full); background: var(--ob3-surface); color: var(--ob3-ink); font: inherit; font-weight: var(--ob3-weight-semibold); cursor: pointer; }
#obpgd-portal .obpgd-dlgbtn.obpgd-danger { background: var(--ob3-alert); border-color: var(--ob3-alert); color: var(--ob3-on-accent); }
#obpgd-portal .obpgd-dlgbtn.obpgd-primary { background: var(--ob3-accent); border-color: var(--ob3-accent); color: var(--ob3-on-accent); }
#obpgd-portal .obpgd-dlgbtn:disabled { opacity: 0.6; cursor: progress; }

/* theme.css forces `:root[data-theme] button { background, color, border-color !important }` (and the same for inputs) on every control;
   these rules outrank it (higher specificity, also !important) for the detail's own controls. Tokens only. */
:root[data-theme] #obp-goals .obpgd-icon { background: transparent !important; color: var(--ob3-ink) !important; border-color: transparent !important; }
:root[data-theme] #obp-goals .obpgd-menuitem { background: transparent !important; color: var(--ob3-ink) !important; border-color: transparent !important; }
:root[data-theme] #obp-goals .obpgd-menuitem.is-danger { color: var(--ob3-alert) !important; }
:root[data-theme] #obp-goals .obpgd-tab { background: transparent !important; color: var(--ob3-muted) !important; border-color: transparent !important; }
:root[data-theme] #obp-goals .obpgd-tab[aria-selected="true"] { background: var(--ob3-surface) !important; color: var(--ob3-ink) !important; border-color: var(--ob3-line) !important; }
:root[data-theme] #obp-goals .obpgd-link { background: transparent !important; color: var(--ob3-accent-text) !important; border-color: transparent !important; }
:root[data-theme] #obp-goals .obpgd-tick { background: transparent !important; color: var(--ob3-on-accent) !important; border-color: transparent !important; }
:root[data-theme] #obp-goals .obpgd-switch { background: transparent !important; border-color: transparent !important; color: var(--ob3-ink) !important; }
:root[data-theme] #obp-goals .obpgd-mf { background: transparent !important; color: var(--ob3-muted) !important; border-color: transparent !important; }
:root[data-theme] #obp-goals .obpgd-mf[aria-pressed="true"] { background: var(--ob3-accent-tint) !important; color: var(--ob3-on-accent-tint) !important; }
:root[data-theme] #obp-goals .obpgd-pill, :root[data-theme] #obp-goals .obpgd-action { background: var(--ob3-surface) !important; color: var(--ob3-ink) !important; border-color: var(--ob3-line) !important; }
:root[data-theme] #obp-goals .obpgd-pill-primary { background: var(--ob3-accent) !important; color: var(--ob3-on-accent) !important; border-color: var(--ob3-accent) !important; }
:root[data-theme] #obp-goals .obpgd-note .obpgd-pill { background: transparent !important; color: var(--ob3-on-inverse) !important; border-color: transparent !important; }
:root[data-theme] #obpgd-portal .obpgd-dlgbtn { background: var(--ob3-surface) !important; color: var(--ob3-ink) !important; border-color: var(--ob3-line-strong) !important; }
:root[data-theme] #obpgd-portal .obpgd-dlgbtn.obpgd-danger { background: var(--ob3-alert) !important; color: var(--ob3-on-accent) !important; border-color: var(--ob3-alert) !important; }
:root[data-theme] #obpgd-portal .obpgd-dlgbtn.obpgd-primary { background: var(--ob3-accent) !important; color: var(--ob3-on-accent) !important; border-color: var(--ob3-accent) !important; }
:root[data-theme] #obp-goals .obpgd-input, :root[data-theme] #obpgd-portal .obpgd-input { background: var(--ob3-surface) !important; color: var(--ob3-ink) !important; border-color: var(--ob3-line-strong) !important; }

/* Section actions are 184 x 44 and never grow; a programmatic focus on the title shows no ring (it is not a control). */
#obp-goals .obpgd-section-action { box-sizing: border-box; width: 184px; min-width: 184px; max-width: 184px; height: 44px; padding: 0 var(--ob3-space-3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#obp-goals .obpgd-title:focus, #obp-goals .obpgd-title:focus-visible { outline: none; }
#obp-goals .obpgd-suglist { margin: var(--ob3-space-2) 0; padding-left: var(--ob3-space-4); }
