/* The Clearing: one authored place for the first choice and urgent support. */
@font-face {
  font-family: "Manrope";
  src: url("/fonts/Manrope-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --phone-night: #181734;
  --phone-deep: #211d46;
  --phone-mid: #332b60;
  --phone-plane: #4b4179;
  --phone-lilac: #d7c4ee;
  --phone-lilac-light: #f1e5ff;
  --phone-text: #faf7ff;
  --phone-soft: #e5def1;
  --phone-muted: #c5b8dc;
  --phone-seam: rgba(223, 204, 250, .22);
  --phone-press: cubic-bezier(.23, 1, .32, 1);
}

html { background: var(--phone-night); scrollbar-color: #796a9e var(--phone-night); }
body {
  background: linear-gradient(165deg, var(--phone-deep), var(--phone-night) 67%);
}
::selection { color: #241d3e; background: #e8d5fb; }
input, textarea { caret-color: #9d70cc; }

/* These new structures also remain composed in a wide preview window. */
.home-view { width: min(100%, 680px); margin-inline: auto; }
.home-scene {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto;
  min-height: 630px;
  overflow: hidden;
  border-radius: 30px;
  background-color: #211d43;
  background-image:
    linear-gradient(180deg, rgba(22, 18, 49, .27), transparent 38%, rgba(20, 16, 47, .06) 66%, rgba(20, 16, 47, .27)),
    url("/art/clearing-loop.png"),
    linear-gradient(172deg, #23204a, #211d43);
  background-position: center, center, center;
  background-size: cover;
  background-repeat: no-repeat;
}
.home-invitation { z-index: 2; grid-row: 1; padding: 44px 44px 0; }
.home-invitation h1 { max-width: 12ch; margin-bottom: 14px; font-weight: 540; letter-spacing: -.035em; }
.home-invitation p { max-width: 30ch; color: var(--phone-soft); font-size: 1rem; line-height: 1.48; }
.home-landscape { grid-row: 2 / 4; grid-column: 1; pointer-events: none; }
.home-landscape > * { display: none; }
.home-action {
  z-index: 2;
  grid-row: 3;
  grid-column: 1;
  display: grid;
  gap: 12px;
  align-self: end;
  padding: 0 44px 34px;
  text-align: center;
}
.home-action #startSupportButton {
  width: 100%;
  min-height: 62px;
  border-radius: 18px;
  color: #2a2249;
  background: var(--phone-lilac-light);
  box-shadow: 0 10px 26px rgba(24, 17, 49, .17);
  font-size: 1.04rem;
  font-weight: 670;
}
.home-action p { max-width: 37ch; margin: 0 auto; color: #f3ebfa; font-size: .94rem; line-height: 1.42; text-shadow: 0 1px 6px rgba(21, 17, 45, .7); }
.home-tracking {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  margin-top: 14px;
}
#homeTrackingButton {
  display: grid;
  min-width: 0;
  min-height: 76px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-content: center;
  padding: 12px 17px;
  border: 0;
  border-radius: 17px;
  color: var(--phone-text);
  background: #473b70;
  cursor: pointer;
  text-align: left;
}
#homeTrackingButton > span { display: grid; min-width: 0; grid-column: 1; grid-row: 1 / 3; align-content: center; }
#homeTrackingLabel { color: var(--phone-soft); font-size: .82rem; line-height: 1.25; }
#homeTrackingValue { overflow-wrap: anywhere; margin-top: 2px; font-size: 1rem; font-weight: 620; line-height: 1.2; font-variant-numeric: tabular-nums; }
#homeTrackingButton svg { grid-column: 2; grid-row: 1 / 3; width: 18px; height: 18px; align-self: center; color: var(--phone-lilac); }
.home-tracking #logOccurrenceButton {
  min-width: 108px;
  max-width: 124px;
  min-height: 76px;
  padding: 10px 12px;
  border: 1px solid var(--phone-seam);
  border-radius: 17px;
  color: var(--phone-soft);
  background: #2b254f;
  font-size: .85rem;
  font-weight: 590;
  line-height: 1.23;
  white-space: normal;
}
.home-tracking #logOccurrenceButton:disabled { border-color: rgba(223, 204, 250, .12); color: #b2a6c8; background: #2a2549; }

/* Progress is a record surface: one reading, then history and analysis. */
.period-summary { margin-bottom: 22px; }
.period-summary .card-heading-row { align-items: center; }
.period-summary .timer-label { margin: 20px 0 7px; }
.period-summary .timer-display { font-weight: 540; letter-spacing: -.04em; }
.tracking-controls, .record-analysis, .plan-editor { min-width: 0; }
.tracking-controls summary, .record-analysis summary, .plan-editor summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  color: var(--phone-soft);
  cursor: pointer;
  font-size: .94rem;
  font-weight: 590;
  list-style: none;
}
.tracking-controls summary::-webkit-details-marker,
.record-analysis summary::-webkit-details-marker,
.plan-editor summary::-webkit-details-marker { display: none; }
.tracking-controls summary::after, .record-analysis summary::after, .plan-editor summary::after {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  margin-right: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  transform: rotate(45deg);
  transition: transform 160ms var(--phone-press);
}
.tracking-controls[open] summary::after, .record-analysis[open] summary::after, .plan-editor[open] summary::after { transform: rotate(225deg); }
.tracking-controls summary:focus-visible, .record-analysis summary:focus-visible, .plan-editor summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 8px; }

.plan-readout {
  padding: 27px;
  border-radius: 19px;
  color: #30264e;
  background: #d9c8ec;
}
.plan-readout h2, .plan-readout .card-copy, .plan-readout .compact-list li { color: #30264e; }
.plan-readout .card-copy { font-size: 1.04rem; line-height: 1.5; }
.plan-readout .compact-list li strong, .plan-readout .compact-list li span { display: block; }
.plan-readout .compact-list li strong { color: #30264e; font-weight: 660; }
.plan-readout .compact-list li span { margin-top: 2px; color: #4f3e69; font-size: .87rem; }
.plan-readout #editPlanButton { color: #3b2d5d; text-decoration: underline; text-underline-offset: 3px; }
.plan-editor { margin-top: 18px; }

/* The recent week reads like a small record, with counts in aligned columns. */
.week-overview { min-width: 0; container-type: inline-size; }
.ledger-label { display: none; }
.week-overview h2 { margin: 0; }
.week-ledger { width: 100%; margin: 0; border-collapse: collapse; table-layout: fixed; color: var(--phone-text); font-variant-numeric: tabular-nums; }
.week-ledger th, .week-ledger td { min-width: 0; padding: 8px 6px; overflow-wrap: anywhere; vertical-align: middle; line-height: 1.25; }
.week-ledger th:first-child { width: 28%; padding-left: 0; text-align: left; }
.week-ledger th:nth-child(2) { width: 40%; text-align: right; }
.week-ledger th:nth-child(3) { width: 32%; text-align: right; }
.week-ledger th:last-child, .week-ledger td:last-child { padding-right: 0; }
.week-ledger thead { border-bottom: 1px solid rgba(236, 220, 250, .43); }
.week-ledger thead th { color: var(--phone-soft); font-size: .81rem; font-weight: 570; }
.week-ledger tbody tr { height: 42px; border-bottom: 1px solid rgba(236, 220, 250, .15); }
.week-ledger tbody tr:last-child { border-bottom: 0; }
.week-ledger tbody th { color: #eee4f8; font-size: .89rem; font-weight: 540; }
.week-ledger tbody td { font-size: .94rem; font-weight: 620; text-align: right; }
.week-ledger tbody tr.is-current th { color: #fff; font-weight: 680; }
.entry-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 12px 0; font-size: .82rem; color: var(--phone-soft); }
.entry-legend span, .week-count { display: inline-flex; align-items: center; gap: 5px; }
.entry-mark { display: inline-block; width: 6px; height: 6px; flex: 0 0 6px; border: 1px solid currentColor; border-radius: 50%; }
.entry-mark.occurrence { background: currentColor; }
.week-count { font-size: .9rem; }
.days-chart.record-calendar { grid-template-columns: repeat(auto-fit, minmax(max(2.15rem, calc((100% - 24px) / 7)), 1fr)); gap: 4px; }
.days-chart.record-calendar { display: grid; margin: 16px 0; align-items: stretch; }
.days-chart.record-calendar .day-cell { display: grid; min-height: 88px; min-width: 0; align-content: center; justify-items: center; gap: 7px; border: 1px solid transparent; border-radius: 10px; color: #f5edfd; background: #544675; }
.days-chart.record-calendar .day-cell.is-untracked { border: 1px dashed #c5b8dc; background: #302951; }
.days-chart.record-calendar .day-cell.is-partial, .days-chart.record-calendar .day-cell.is-current { border: 1px solid #dac2ee; }
.days-chart.record-calendar .day-cell.has-entries { color: #2d2347; background: #dcc9ef; }
.days-chart.record-calendar .day-cell.has-entries.is-partial, .days-chart.record-calendar .day-cell.has-entries.is-current { border: 2px solid #5c427a; }
.days-chart.record-calendar .day-cell.has-entries.is-untracked { border: 2px dashed #5c427a; }
.calendar-details > summary { min-height: 48px; padding: 13px 0; color: var(--phone-soft); font-size: .9rem; cursor: pointer; }
.recent-records { min-width: 0; }
.history-details { border-top: 1px solid var(--phone-seam); }
.history-details summary { display: flex; min-height: 55px; align-items: center; justify-content: space-between; gap: 12px; color: var(--phone-soft); cursor: pointer; font-size: .98rem; font-weight: 590; list-style: none; }
.history-details summary::-webkit-details-marker { display: none; }
.history-details summary::after { width: 9px; height: 9px; flex: 0 0 9px; margin-right: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); content: ""; }
.history-details[open] summary::after { transform: rotate(225deg); }
.history-details summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 8px; }

@media (max-width: 760px) {
  :root {
    font-family: "Manrope", "Segoe UI", system-ui, sans-serif;
    --ink: var(--phone-text);
    --ink-soft: var(--phone-soft);
    --muted: var(--phone-muted);
    --line: var(--phone-seam);
    --line-strong: rgba(229, 210, 251, .4);
    --surface: #312b59;
    --surface-blue: #4a3e70;
    --primary-bg: var(--phone-lilac-light);
    --primary-text: #2a2249;
    --radius-control: 14px;
    --radius-surface: 17px;
    --radius-dialog: 20px;
  }
  body { font-size: 16px; line-height: 1.48; }
  body:has(#appRoot:not([hidden])) { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
  .page-shell { width: min(calc(100% - 32px), 620px); padding-bottom: 0; }
  .site-header {
    min-height: calc(58px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
    border-bottom: 0;
  }
  .brand { min-height: 44px; gap: 6px; font-size: .94rem; font-weight: 580; }
  .brand-mark { width: 31px; height: 31px; color: #d9c8ef; background: transparent; }
  .brand-mark .ui-icon { width: 28px; height: 28px; }
  .header-actions { gap: 1px; }
  .header-button { border-radius: 13px; color: var(--phone-soft); font-weight: 560; }
  .header-support { min-width: 0; border: 1px solid var(--phone-seam); border-radius: 999px; background: #3a3264; font-size: .81rem; }
  .app-shell { padding-top: 0; }
  .view-panel { padding-top: 13px; }
  h1 { font-size: clamp(2rem, 8.3vw, 2.125rem); font-weight: 550; letter-spacing: -.035em; line-height: 1.1; }
  h2 { font-size: 1.19rem; font-weight: 600; letter-spacing: -.025em; }
  .hero-copy { font-size: .97rem; line-height: 1.48; }
  .section-heading { margin-bottom: 24px; }
  .section-heading h1 { margin-bottom: 10px; }
  .button { font-weight: 610; transition: transform 140ms var(--phone-press), background-color 140ms var(--phone-press), border-color 140ms var(--phone-press); }
  .button-primary { background: var(--phone-lilac-light); }
  .button-secondary { border-color: rgba(226, 205, 248, .34); background: #493d72; }
  .text-button, .button-quiet { font-weight: 570; }
  .card-copy, .field-hint, .metric-note, .privacy-note { color: var(--phone-soft); }
  .count-pill, .quiet-badge { color: var(--phone-soft); background: #504475; font-weight: 570; }
  .toast { bottom: calc(93px + env(safe-area-inset-bottom)); border-radius: 15px; background: #514375; }

  /* Today fills the space between the compact header and floating dock. */
  #todayView.home-view {
    display: flex;
    min-height: calc(100dvh - 58px - env(safe-area-inset-top) - 102px - env(safe-area-inset-bottom));
    flex-direction: column;
    padding-top: 0;
  }
  .home-scene {
    flex: 1 0 auto;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 390px;
    margin-inline: -16px;
    border-radius: 0 0 29px 29px;
    background-position: center, center 50%, center;
  }
  .home-invitation { position: relative; isolation: isolate; padding: 17px 28px 0; }
  .home-invitation::before {
    position: absolute;
    z-index: -1;
    inset: 0 0 -40px;
    background: linear-gradient(90deg, rgba(17, 14, 42, .91), rgba(17, 14, 42, .81) 76%, rgba(17, 14, 42, .62));
    -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 40px), transparent 100%);
    mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 40px), transparent 100%);
    content: "";
    pointer-events: none;
  }
  .home-invitation h1 { max-width: 11ch; margin-bottom: 11px; font-size: clamp(2.3rem, 10.2vw, 2.65rem); font-weight: 540; line-height: 1.07; }
  .home-invitation p { max-width: 26ch; margin-bottom: 0; font-size: .95rem; }
  .home-landscape { margin: 0; }
  .home-action { gap: 9px; padding: 0 28px 20px; }
  .home-action #startSupportButton { min-height: 59px; }
  .home-action p { max-width: 32ch; font-size: .94rem; }
  .home-tracking { flex: 0 0 auto; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.45rem), 1fr)); margin-top: 10px; }
  #homeTrackingButton { min-height: 74px; }
  .home-tracking #logOccurrenceButton { width: 100%; min-width: 0; max-width: none; min-height: 74px; }

  /* The dock floats over the field, with a quiet active indication. */
  .mobile-bottom-nav {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(7px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    padding: 5px;
    border: 1px solid rgba(226, 209, 248, .22);
    border-radius: 22px;
    background: #2a244e;
    box-shadow: 0 12px 30px rgba(8, 5, 26, .3);
  }
  .mobile-bottom-nav button { position: relative; min-height: 59px; gap: 2px; border-radius: 16px; color: #cfc4e1; font-size: .81rem; font-weight: 560; }
  .mobile-bottom-nav .ui-icon { width: 21px; height: 21px; }
  .mobile-bottom-nav button[aria-current="page"] { color: #f7edff; background: rgba(191, 167, 226, .14); }
  .mobile-bottom-nav button[aria-current="page"]::before { position: absolute; top: 3px; width: 20px; height: 2px; border-radius: 99px; background: #ddc5f5; content: ""; }

  /* Progress has a single spacious record plane before the detailed list. */
  #progressView .section-heading { margin: 6px 0 17px; }
  #progressView .section-heading h1 { max-width: none; }
  .week-overview { margin: 0 -16px 24px; padding: 23px 24px 18px; border-radius: 24px; background: #3b3264; }
  .week-overview h2 { font-size: 1.25rem; font-weight: 600; }
  .week-overview #weekRange { margin: 3px 0 14px; color: #d8cce8; font-size: .82rem; }
  .week-overview > p:last-child { margin: 14px 0 0; color: #e5dced; font-size: .82rem; line-height: 1.37; }
  .recent-records { margin-bottom: 21px; }
  .recent-records h2 { margin-bottom: 12px; font-size: 1.21rem; font-weight: 600; }
  .recent-records .record-item { padding: 13px 0; border-top-color: var(--phone-seam); }
  .recent-records .record-title { font-weight: 590; }
  .recent-records .record-detail, .recent-records .record-time { color: #d1c6e1; }
  .record-dot.is-checkin { width: 9px; height: 9px; margin-top: 6px; border: 2px solid #c8afe6; background: transparent; }
  .history-details { margin: 0 0 5px; }
  .history-details .history-card { padding-top: 13px !important; }
  .record-analysis { margin-top: 3px; }
  .record-analysis > summary { min-height: 61px; }
  .record-analysis .period-summary { margin: 9px 0 20px; padding: 20px; border-radius: 17px; background: #3b3265; }
  .record-analysis .period-summary::before { display: none; }
  .record-analysis .period-summary .timer-label { margin-top: 16px; }
  .record-analysis .period-summary .timer-display { font-size: clamp(2rem, 9vw, 2.8rem); }
  .record-analysis .period-summary .timer-display.is-quiet { font-size: 1.4rem; }
  .period-summary {
    position: relative;
    overflow: hidden;
    margin: 0 -16px 19px;
    padding: 26px 28px 21px;
    border: 0;
    border-radius: 25px;
    background: linear-gradient(160deg, #544779, #3d346c 69%, #342d60);
  }
  .period-summary > * { position: relative; }
  .period-summary .card-heading-row h2 { max-width: 19ch; font-size: 1.02rem; font-weight: 570; }
  .period-summary .card-icon { color: #f0e4fd; background: rgba(246, 225, 255, .11); }
  .period-summary .timer-label { margin-top: 23px; color: #e7d9f4; font-size: .84rem; }
  .period-summary .timer-display { margin: 0 0 14px; font-size: clamp(2.4rem, 12vw, 3.9rem); font-weight: 480; line-height: 1.02; }
  .period-summary .timer-display.is-quiet { font-size: 1.5rem; font-weight: 510; line-height: 1.17; }
  .period-summary .card-copy { max-width: 37ch; margin-bottom: 13px; font-size: .88rem; line-height: 1.43; }
  .period-summary .tracking-controls { padding-top: 10px; border-top: 1px solid rgba(230, 207, 255, .22); }
  .period-summary .tracking-controls .button-row { margin-top: 10px; }
  .period-summary .tracking-controls .button-row .button { flex: 1 1 100%; }
  .period-summary .secondary-actions { margin-top: 7px; }
  #progressView .history-card { margin-bottom: 0; padding: 22px 0 23px; border-top: 1px solid var(--phone-seam); border-radius: 0; background: transparent; }
  #progressView .history-card .card-heading-row { margin-bottom: 10px; }
  #progressView .history-card h2 { font-size: 1.18rem; }
  #progressView .record-list { gap: 0; }
  #progressView .record-item { padding: 15px 0; }
  #progressView .record-title { font-weight: 590; }
  #progressView .record-detail, #progressView .record-time { color: #d4c8e5; }
  .record-analysis { margin-top: 7px; border-top: 1px solid var(--phone-seam); }
  .record-analysis > summary { min-height: 64px; color: var(--phone-text); font-size: 1rem; }
  .record-analysis .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 7px 0 24px; }
  .record-analysis .stat-card { min-height: 93px; justify-content: flex-start; padding: 15px; border: 0; border-radius: 15px; background: #39315f; }
  .record-analysis .stat-value { font-size: clamp(1.28rem, 6vw, 1.65rem); font-weight: 550; }
  .record-analysis .stat-label { margin-top: 7px; }
  .record-analysis .progress-card { margin: 0 0 12px; padding: 18px 0 24px; border-top: 1px solid var(--phone-seam); border-radius: 0; background: transparent; }
  .record-analysis .eyebrow { display: none; }
  .record-analysis .days-chart { gap: 6px; margin-top: 21px; }
  .record-analysis .day-bar-fill { width: 70%; background: #d5b7ef; }
  .record-analysis .day-bar-fill.is-empty { background: #786f9b; }
  .record-analysis .day-bar.is-partial .day-bar-fill, .record-analysis .day-bar.is-current .day-bar-fill { background: #a697c7; }
  .record-analysis .day-bar.is-untracked .day-bar-fill { border-color: #a99cc6; }
  .record-analysis .chart-legend { color: #d5cbe5; }
  .record-analysis .legend-mark { background: #d5b7ef; }
  .record-analysis .legend-mark.is-empty { background: #786f9b; }
  .record-analysis .legend-mark.is-partial { background: #a697c7; }
  .record-analysis .legend-mark.is-untracked { border-color: #a99cc6; background: transparent; }
  .record-analysis .days-accessible-list { color: var(--phone-soft); }
  .range-toggle { margin-top: 16px; border: 1px solid var(--phone-seam); border-radius: 14px; background: #302956; }
  .range-button { font-weight: 570; }
  .range-button.is-active { background: #d9c9ee; }

  /* Plan reads as a personal note. Editing is deliberate and separate. */
  #planView .section-heading { margin: 6px 0 24px; }
  #planView .section-heading h1 { max-width: 14ch; }
  .plan-readout {
    position: relative;
    overflow: hidden;
    margin: 0 -16px;
    padding: 30px 28px 33px;
    border: 0;
    border-radius: 25px;
    background: #d9c8ed;
  }
  .plan-readout > * { position: relative; z-index: 1; }
  .plan-readout .card-heading-row { align-items: start; }
  .plan-readout h2 { max-width: 15ch; font-size: 1.42rem; font-weight: 590; line-height: 1.16; }
  .plan-readout #editPlanButton { flex: 0 0 auto; min-height: 44px; margin: -7px -7px 0 0; font-size: .83rem; }
  .plan-readout .card-copy { margin: 26px 0 13px; font-size: 1.04rem; }
  .plan-readout .compact-list { gap: 0; margin-top: 18px; }
  .plan-readout .compact-list li { display: block; min-height: 0; padding: 15px 0; border-top: 1px solid rgba(73, 52, 105, .2); font-size: .94rem; line-height: 1.42; }
  .plan-readout .compact-list li:last-child { padding-bottom: 0; }
  .plan-readout .compact-list li::before { display: none; content: none; }
  .plan-readout .compact-list li strong { font-size: 1.04rem; line-height: 1.35; }
  .plan-readout .compact-list li span { margin-top: 4px; font-size: .87rem; line-height: 1.42; }
  .plan-readout .compact-list li.plan-reminder { color: #46345f; }
  .plan-readout .compact-list li.plan-reminder span { margin-top: 0; }
  .plan-readout .compact-list li.plan-reminder strong { margin-top: 5px; font-size: .96rem; }
  #planReasonReadout { margin: 23px 0 0; padding: 17px 0 0; border-top: 1px solid rgba(77, 52, 109, .25); color: #4f3e69; font-size: .9rem; font-weight: 480; line-height: 1.48; }
  #planReasonReadout .plan-note-label { display: block; margin-bottom: 5px; color: #6a567f; font-size: .78rem; font-weight: 650; letter-spacing: .01em; }
  #planReasonReadout p { margin: 0; color: inherit; font: inherit; }
  .plan-editor { margin-top: 21px; border-top: 1px solid var(--phone-seam); }
  .plan-editor > summary { min-height: 65px; color: var(--phone-text); font-size: 1rem; }
  .plan-editor .plan-form { gap: 0; padding: 5px 0 26px; }
  .plan-editor .form-card { margin: 0; padding: 22px 0 25px; border-top: 1px solid var(--phone-seam); border-radius: 0; background: transparent; }
  .plan-editor .form-card:first-child { border-top: 0; padding-top: 8px; }
  .plan-editor .field-label, .plan-editor legend { font-size: 1rem; font-weight: 590; }
  .plan-editor textarea { min-height: 133px; resize: vertical; background: #eee4fa; }
  .plan-editor .check-grid { gap: 9px; }
  .plan-editor .check-card { min-height: 68px; align-items: center; border: 1px solid transparent; border-radius: 15px; background: #3b3266; }
  .plan-editor .check-card:has(input:checked) { border-color: #d9bdf5; background: #625184; }
  .plan-editor .check-card strong { font-weight: 600; }
  .plan-editor .check-card small { color: #d7cbe8; }
  .plan-editor .form-actions { gap: 10px; padding-top: 12px; }
  .plan-editor .form-actions .button { min-width: 140px; }

  /* Focused support scene; the low horizon stays behind real choices. */
  .support-dialog { overflow: clip; background: var(--phone-night); }
  .support-dialog-card {
    --support-gutter: 24px;
    --support-top: max(20px, env(safe-area-inset-top));
    position: relative;
    isolation: isolate;
    overflow-x: hidden;
    padding: var(--support-top) var(--support-gutter) max(22px, env(safe-area-inset-bottom));
    background: linear-gradient(169deg, #25204d 0%, #29234f 57%, #1f1a42 100%);
  }
  .support-dialog-card:has(#supportStartStep:not([hidden])),
  .support-dialog-card:has(#supportActiveStep:not([hidden]):not(.is-timed)) {
    background-image:
      linear-gradient(90deg, rgba(22, 18, 48, .84), rgba(22, 18, 48, .70) 58%, rgba(22, 18, 48, .46)),
      linear-gradient(180deg, rgba(22, 18, 48, .55), rgba(22, 18, 48, .08) 45%, rgba(22, 18, 48, .52)),
      url("/art/clearing-loop.png"),
      linear-gradient(169deg, #25204d, #1f1a42);
    background-position: center, center, 68% 51%, center;
    background-size: cover, cover, auto 122%, cover;
    background-repeat: no-repeat;
  }
  .support-dialog .dialog-topline {
    position: sticky;
    z-index: 20;
    top: calc(-1 * var(--support-top));
    min-height: calc(44px + var(--support-top));
    align-items: center;
    margin: calc(-1 * var(--support-top)) calc(-1 * var(--support-gutter)) 0;
    padding: var(--support-top) var(--support-gutter) 7px;
    background: #241f49;
  }
  .support-dialog .quiet-badge { margin: 0; color: #dacde8; font-size: .8rem; }
  .support-dialog .header-button { border: 1px solid var(--phone-seam); border-radius: 999px; background: rgba(85, 69, 126, .32); }
  .support-dialog .icon-button { border-radius: 50%; background: #493c72; }
  .support-step { position: relative; z-index: 1; min-height: 0; padding-top: clamp(27px, 5dvh, 47px); }
  #supportStartStep, #supportActiveStep { padding-top: 12px; }
  #supportStartStep > .support-focal,
  #supportActiveStep:not(.is-timed) > .support-focal { flex: 0 0 auto; margin-block: auto; }
  .support-focal { min-width: 0; }
  .support-focal > :last-child { margin-bottom: 0; }
  .support-focal h2 { max-width: 14ch; }
  .support-focal .dialog-copy { margin-top: 15px; }
  #supportStartStep > .support-actions,
  #supportActiveStep > .support-actions { margin-top: 0; padding-top: 18px; }
  #supportActiveStep.is-timed > .support-focal { margin: 8px 0 0; }
  #supportActiveStep.is-timed > .urge-timer-block { margin-block: auto; }
  #supportActiveStep > .danger-button { margin-top: 12px; }
  #supportChoicesStep, #supportCheckinStep { padding-top: 27px; }
  .support-step h2 { max-width: 15ch; margin-bottom: 0; font-size: clamp(2.28rem, 10vw, 2.65rem); font-weight: 540; letter-spacing: -.036em; line-height: 1.07; }
  .support-step-number { margin-bottom: 13px; color: #d9c5ec; font-size: .82rem; font-weight: 590; }
  .support-step .dialog-copy { max-width: 33ch; margin-top: 16px; font-size: .98rem; }
  .support-step > .support-actions { margin-top: auto; padding-top: 25px; }
  #supportStartStep > .support-actions { margin-bottom: 0; }
  #supportActiveStep > .danger-button { margin-bottom: 0; }
  .support-actions { gap: 9px; }
  .support-actions .button { min-height: 54px; border-radius: 15px; }
  .support-actions .button-primary { min-height: 59px; color: #2a2249; background: var(--phone-lilac-light); }
  .support-actions .button-secondary { background: #534576; }
  .support-actions .button-quiet { color: #e8def3; }
  .support-actions .button:disabled { color: #bfb2d0; background: #3c3355; border-color: #675778; cursor: not-allowed; }
  .option-stack { gap: 10px; margin-top: 14px; }
  .option-button { min-height: 73px; border: 1px solid rgba(226, 208, 250, .21); border-radius: 15px; background: #493e71; }
  .option-button:first-child { border-color: transparent; color: #302448; background: #deceef; }
  .option-button:first-child strong, .option-button:first-child small, .option-button:first-child .option-arrow { color: #302448; }
  .option-button:first-child .option-icon { color: #f3eaff; background: #695487; }
  .option-icon { background: #deccf0; }
  .option-button strong { font-weight: 600; }
  .option-button small { color: #e4d9f1; }
  .urge-timer-block { width: 100%; min-height: 144px; align-content: center; margin: auto 0 11px; padding: 20px 24px; border: 1px solid rgba(240, 219, 255, .2); border-radius: 24px; background: rgba(123, 100, 168, .22); text-align: center; }
  .urge-timer-block .timer-label { margin: 0; color: #e2d5ef; }
  .urge-timer-block strong { font-size: clamp(3.2rem, 15vw, 5rem); font-weight: 450; letter-spacing: -.03em; }
  .feeling-grid { gap: 8px; }
  .feeling-button { min-height: 51px; border-radius: 14px; background: #493d72; font-weight: 570; }
  .feeling-button.is-selected { color: #30244c; background: #e6d5f4; }
  .checkin-details { margin-top: 19px; border-top: 1px solid var(--phone-seam); }
  .checkin-details summary { display: flex; min-height: 49px; align-items: center; justify-content: space-between; gap: 12px; color: #e6d9f0; cursor: pointer; font-size: .92rem; font-weight: 560; list-style: none; }
  .checkin-details summary::-webkit-details-marker { display: none; }
  .checkin-details summary::after { width: 9px; height: 9px; flex: 0 0 9px; margin-right: 5px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); content: ""; }
  .checkin-details[open] summary::after { transform: rotate(225deg); }
  .checkin-details summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 8px; }
  #checkinContact { margin-top: 20px; border: 0; }
  #checkinContact summary { min-height: 52px; padding: 10px 15px; border: 1px solid rgba(227, 211, 248, .53); border-radius: 14px; color: #f6ecff; background: #4b4073; font-weight: 610; }
  #checkinContact[open] summary { background: #5a4a80; }
  .check-stack { gap: 13px; margin-top: 2px; padding: 5px 0 12px; }
  .check-line { min-height: 50px; font-size: .93rem; }
  #supportCheckinStep > .support-actions { margin-top: 15px; }
  .temporary-note { color: #d7cde6; }

  /* First-use and utility layers share the same place without sacrificing legibility. */
  .age-gate {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    align-items: center;
    padding: max(25px, env(safe-area-inset-top)) 24px max(25px, env(safe-area-inset-bottom));
    background: linear-gradient(167deg, #25204c 0%, #231e46 66%, #1b1839);
  }
  .age-gate::before {
    position: absolute;
    z-index: -1;
    inset: auto 0 0;
    width: 100%;
    height: 43%;
    background: url("/art/clearing-loop.png") center 68% / cover no-repeat;
    opacity: .32;
    mask-image: linear-gradient(to bottom, transparent, black 45%);
    content: "";
  }
  .age-gate-card { position: relative; width: min(100%, 430px); padding: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .age-gate-card > .brand-mark { width: 45px; height: 45px; margin-bottom: 36px; color: #dec9f0; }
  .age-gate h1 { max-width: 13ch; margin-bottom: 18px; font-size: clamp(2.3rem, 10vw, 3.1rem); font-weight: 540; }
  .age-gate-copy { max-width: 38ch; margin-bottom: 0; font-size: .99rem; line-height: 1.52; }
  .age-gate-actions { gap: 10px; margin-top: 34px; }
  .age-gate-actions .button { min-height: 54px; border-radius: 16px; }
  .age-gate-actions .button-secondary { background: #3f3465; }
  .age-gate-actions .button:disabled { opacity: .6; cursor: default; }
  .age-gate-message { color: var(--phone-soft); }
  .privacy-cover { background: #1c193c; }
  .privacy-cover-card { border-radius: 21px; background: #3d3266; }
  .app-dialog:not(.support-dialog) { border-radius: 20px; }
  .app-dialog:not(.support-dialog) .dialog-card { border-radius: 20px; background: #3a3163; }
  .dialog-topline h2 { font-weight: 600; }
  .dialog-actions { gap: 9px; }
  .dialog-actions .button { min-height: 51px; }
  .radio-card { border-radius: 14px; background: #493d72; }
  .settings-group summary { font-weight: 590; }
  .settings-device, .settings-note { background: #4a3e70; }
  .site-footer { display: none; }
}

@media (max-width: 430px) {
  .home-invitation { padding-inline: 25px; }
  .home-action { padding-inline: 25px; }
  .home-tracking { gap: 8px; }
  #homeTrackingButton { padding-inline: 13px; }
  #homeTrackingValue { font-size: .94rem; }
  .home-tracking #logOccurrenceButton { padding-inline: 8px; font-size: .79rem; }
  .period-summary { padding-inline: 25px; }
  .plan-readout { padding-inline: 25px; }
  .support-dialog-card { --support-gutter: 21px; }
  .support-dialog .dialog-topline .quiet-badge { font-size: .76rem; }
}

@media (max-width: 360px) {
  .week-overview { margin-bottom: 14px; padding-top: 16px; padding-bottom: 12px; }
  .week-overview #weekRange { margin-bottom: 8px; }
  .week-overview > p:last-child { margin-top: 8px; }
  .week-ledger tbody tr { height: 38px; }
  .recent-records h2 { margin-bottom: 8px; }
  .recent-records .record-item { padding-block: 10px; }
  .home-invitation h1 { font-size: 2.32rem; }
  .home-invitation p { font-size: .95rem; }
  .home-action #startSupportButton { min-height: 56px; }
  .home-action p { font-size: .94rem; }
  .support-dialog .dialog-topline { gap: 4px; }
  .support-dialog .header-button { font-size: .76rem; }
}

/* Container queries use the selected root text size: keep full labels when
   enlarged text no longer fits the ordinary three-column ledger. */
@container (max-width: 15rem) {
  .week-ledger, .week-ledger tbody { display: block; width: 100%; }
  .week-ledger thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
  .week-ledger tbody tr { display: grid; height: auto; gap: 6px; padding: 14px 0; }
  .week-ledger tbody th:first-child { width: auto; padding: 0 0 4px; }
  .week-ledger tbody td { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 0; }
  .week-ledger .ledger-label { display: block; text-align: left; font-size: .81rem; font-weight: 500; color: var(--phone-soft); }
}

@media (max-height: 700px) and (max-width: 760px) {
  .home-scene { min-height: 385px; }
  .support-step { padding-top: 24px; }
  .support-step > .support-actions { padding-top: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .tracking-controls summary::after, .record-analysis summary::after, .plan-editor summary::after { transition: none; }
}
/* Keep personal-data controls available when membership entry is closed. */
.billing-data-only #appRoot .page-shell > :not(dialog) { display: none !important; }
.cancellation-card { display: flex; flex-direction: column; gap: 16px; }
.cancellation-card .button { width: 100%; }
#billingGate .option-stack { margin-block: 20px; }
#billingGate .button { margin-block: 8px; }
