/* Linked goals: shared Winter Arc surfaces for night, snow and aurora. */
html[data-theme="night"] { --flow-hero: linear-gradient(135deg, #20292d, #14191d 70%); }
html[data-theme="snow"] { --flow-hero: linear-gradient(135deg, #dff1f1, #f7fbfc 76%); }
html[data-theme="aurora"] { --flow-hero: linear-gradient(135deg, #28525a, #192d3b 76%); }

.goal-flow-page,
.goals-page,
.plan-page,
#dialog {
  --flow-card: var(--ui-card, #17191c);
  --flow-soft: var(--ui-card-soft, #222529);
  --flow-ink: var(--ui-ink, #f5f7f7);
  --flow-muted: var(--ui-muted, #aeb7ba);
  --flow-border: var(--ui-border, #353b3f);
  --flow-accent: var(--ui-accent, #d7f8e9);
  --flow-accent-ink: var(--ui-accent-ink, #12372f);
  --flow-track: var(--ui-track, #384247);
  --flow-shadow: var(--ui-shadow, #0002);
}

.goal-flow-page {
  color: var(--flow-ink);
  padding-bottom: calc(38px + env(safe-area-inset-bottom));
}
.goal-flow-page .back-line { margin-bottom: 20px; }
.goal-flow-page .eyebrow { color: var(--flow-muted); font-size: 9px; font-weight: 800; }
.goal-flow-page .editor-title { margin: 8px 0 7px; line-height: 1.14; }
.goal-flow-page .editor-sub { max-width: 39ch; margin-bottom: 20px; color: var(--flow-muted); line-height: 1.55; }
.goal-flow-page .field { min-width: 0; }
.goal-flow-page .field-grid > * { min-width: 0; }
.goal-flow-page .input,
.goal-flow-page .select { min-width: 0; }
.goal-flow-page input:disabled { opacity: .62; }

/* Entry point and linked plan cards on the goals screen. */
.goal-flow-intro {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 15px 0 11px;
  padding: 14px;
  border: 1px solid var(--flow-border);
  border-radius: 19px;
  background: var(--flow-card);
  color: var(--flow-ink);
}
.goal-flow-intro > span {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--flow-soft);
  color: var(--flow-accent);
}
.goal-flow-intro > div { min-width: 0; }
.goal-flow-intro strong { display: block; font-size: 13px; line-height: 1.35; }
.goal-flow-intro small { display: block; margin-top: 4px; color: var(--flow-muted); font-size: 10px; line-height: 1.45; }
.goal-flow-new { margin: 0 0 22px !important; }
.goal-flow-hint { color: var(--flow-muted); font-size: 10px; line-height: 1.5; }
.linked-list-head { margin-top: 3px; }
.linked-plan-list { display: grid; gap: 9px; margin: 0 0 23px; }
.linked-plan-card {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 15px;
  text-align: left;
  border: 1px solid var(--flow-border);
  border-radius: 20px;
  background: var(--flow-card);
  color: var(--flow-ink);
  box-shadow: 0 6px 19px var(--flow-shadow);
}
.linked-plan-card:active { transform: scale(.99); }
.linked-plan-top { display: flex; align-items: center; gap: 10px; }
.linked-plan-top > svg { color: var(--flow-muted); }
.linked-plan-emblem {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: var(--flow-soft);
  color: var(--flow-accent);
}
.linked-plan-title { display: block; flex: 1; min-width: 0; }
.linked-plan-title strong { display: block; overflow-wrap: anywhere; font-size: 13px; line-height: 1.35; }
.linked-plan-title small { display: block; margin-top: 4px; color: var(--flow-muted); font-size: 10px; line-height: 1.45; }
.linked-plan-progress,
.linked-plan-bottom { display: flex; justify-content: space-between; gap: 10px; }
.linked-plan-progress { margin: 15px 0 7px; color: var(--flow-muted); font-size: 10px; font-weight: 700; }
.linked-plan-progress b { color: var(--flow-ink); }
.linked-plan-track { display: block; width: 100%; height: 6px; overflow: hidden; border-radius: 99px; background: var(--flow-track); }
.linked-plan-track > i { display: block; height: 100%; border-radius: inherit; background: var(--flow-accent); transition: width .3s ease; }
.linked-plan-bottom { margin-top: 10px; color: var(--flow-muted); font-size: 9px; line-height: 1.4; }
.linked-plan-bottom > span:first-child { color: var(--flow-ink); font-weight: 700; }
.linked-plan-bottom > span:last-child { text-align: right; }

/* Plan editor and future-plan revision. */
.plan-template-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.plan-template-row button,
.plan-add-habit,
.plan-add-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid var(--flow-border);
  border-radius: 13px;
  background: var(--flow-soft);
  color: var(--flow-ink);
  font-size: 11px;
  font-weight: 800;
}
.plan-template-row button:first-child { border-color: var(--flow-accent); color: var(--flow-accent); }
.plan-template-row button:disabled,
.plan-add-habit:disabled,
.plan-add-step:disabled { opacity: .46; cursor: default; }
.plan-goal-editor,
.plan-habit-editor {
  min-width: 0;
  padding: 17px 15px;
  border: 1px solid var(--flow-border);
  border-radius: 21px;
  background: var(--flow-card);
  box-shadow: 0 5px 18px var(--flow-shadow);
}
.plan-goal-editor > .field:last-of-type { margin-bottom: 0; }
.plan-editor-index { display: block; margin: 0 0 15px; color: var(--flow-accent); font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.plan-metric-fields { margin: -2px 0 17px; padding: 13px; border: 1px solid var(--flow-border); border-radius: 15px; background: var(--flow-soft); }
.plan-metric-fields .field { margin-bottom: 7px; }
.plan-metric-fields small { display: block; color: var(--flow-muted); font-size: 10px; line-height: 1.5; }
.plan-strict-check { display: flex; align-items: flex-start; gap: 11px; margin-top: 3px; padding: 13px; border: 1px solid var(--flow-border); border-radius: 15px; background: var(--flow-soft); cursor: pointer; }
.plan-strict-check input { flex: none; width: 19px; height: 19px; margin: 1px 0 0; accent-color: var(--flow-accent); }
.plan-strict-check span { min-width: 0; }
.plan-strict-check strong { display: block; font-size: 11px; line-height: 1.4; }
.plan-strict-check small { display: block; margin-top: 3px; color: var(--flow-muted); font-size: 10px; line-height: 1.5; }
.plan-editor-title { margin: 26px 1px 13px; }
.plan-editor-title .plan-editor-index { margin-bottom: 6px; }
.plan-editor-title h2 { margin: 0; font-size: 18px; line-height: 1.3; letter-spacing: -.35px; }
.plan-editor-title p { margin: 5px 0 0; color: var(--flow-muted); font-size: 11px; line-height: 1.55; }
.plan-habit-editor { margin-bottom: 11px; }
.plan-habit-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.plan-habit-heading > span { display: grid; place-items: center; flex: none; width: 31px; height: 31px; border-radius: 10px; background: var(--flow-accent); color: var(--flow-accent-ink); font-size: 11px; font-weight: 800; }
.plan-habit-heading strong { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.plan-habit-heading button { flex: none; border: 0; background: transparent; color: var(--flow-muted); font-size: 10px; font-weight: 800; padding: 7px 0 7px 7px; }
.plan-weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.plan-weekdays button { min-width: 0; min-height: 39px; padding: 0; border: 1px solid var(--flow-border); border-radius: 11px; background: var(--flow-soft); color: var(--flow-muted); font-size: 10px; font-weight: 800; }
.plan-weekdays button.active { border-color: var(--flow-accent); background: var(--flow-accent); color: var(--flow-accent-ink); }
.plan-steps-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 9px; margin: 4px 0 10px; }
.plan-steps-heading strong { font-size: 11px; }
.plan-steps-heading small { color: var(--flow-muted); font-size: 9px; line-height: 1.35; text-align: right; }
.plan-step-entry { margin-bottom: 8px; padding: 10px; border: 1px solid var(--flow-border); border-radius: 14px; background: var(--flow-soft); }
.plan-step-line { display: flex; align-items: center; gap: 6px; }
.plan-step-line .input { flex: 1; min-width: 0; }
.plan-step-line button { display: grid; place-items: center; flex: none; width: 39px; height: 39px; padding: 0; border: 1px solid var(--flow-border); border-radius: 11px; background: var(--flow-card); color: var(--flow-muted); font-size: 21px; }
.plan-step-options { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 7px; margin-top: 7px; }
.plan-add-step { min-height: 36px; margin-top: 2px; font-size: 10px; }
.plan-add-habit { width: 100%; min-height: 47px; border-style: dashed; margin: 3px 0 18px; }
.plan-next { margin-top: 4px; }

/* Confirmation screen. */
.plan-preview-hero,
.plan-detail-hero { overflow: hidden; padding: 19px; border: 1px solid var(--flow-border); border-radius: 23px; background: var(--flow-hero, var(--flow-card)); color: var(--flow-ink); }
.plan-preview-hero > span { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: var(--flow-card); color: var(--flow-accent); }
.plan-preview-hero h2,
.plan-detail-hero h1 { margin: 13px 0 7px; overflow-wrap: anywhere; font-size: 22px; line-height: 1.25; letter-spacing: -.5px; }
.plan-preview-hero p,
.plan-detail-hero p { margin: 0 0 9px; color: var(--flow-muted); font-size: 11px; line-height: 1.45; }
.plan-preview-hero small,
.plan-detail-hero small { color: var(--flow-muted); font-size: 10px; line-height: 1.5; }
.plan-preview-list { display: grid; gap: 8px; margin-top: 13px; }
.plan-preview-list > div { display: flex; align-items: flex-start; gap: 11px; min-width: 0; padding: 13px; border: 1px solid var(--flow-border); border-radius: 16px; background: var(--flow-card); }
.plan-preview-list > div > span:last-child { min-width: 0; }
.plan-preview-number { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 9px; background: var(--flow-soft); color: var(--flow-accent); font-size: 11px; font-weight: 800; }
.plan-preview-list strong { display: block; overflow-wrap: anywhere; font-size: 12px; line-height: 1.4; }
.plan-preview-list small,
.plan-preview-list em { display: block; margin-top: 3px; color: var(--flow-muted); font-size: 10px; font-style: normal; line-height: 1.45; }
.plan-preview-note,
.plan-detail-meaning { margin: 13px 0 0; padding: 12px 13px; border-left: 3px solid var(--flow-accent); border-radius: 0 12px 12px 0; background: var(--flow-soft); color: var(--flow-muted); font-size: 10px; line-height: 1.55; }
.goal-flow-page .editor-actions { padding-top: 17px; }
.goal-flow-page .editor-actions .secondary-button { width: 100%; margin-top: 9px; }

/* One day's linked habits and supporting tasks. */
.linked-day-loading { padding: 20px 13px; color: var(--flow-muted); font-size: 11px; text-align: center; }
.linked-day-group { overflow: hidden; margin: 14px 0; border: 1px solid var(--flow-border); border-radius: 20px; background: var(--flow-card); }
.linked-day-head { display: flex; justify-content: space-between; align-items: center; gap: 7px; padding: 12px 13px; background: var(--flow-soft); }
.linked-day-head button { display: flex; flex: 1; min-width: 0; align-items: center; justify-content: space-between; gap: 6px; padding: 0; border: 0; background: transparent; color: var(--flow-ink); text-align: left; font-size: 11px; font-weight: 800; }
.linked-day-head button span { display: flex; align-items: center; gap: 7px; min-width: 0; overflow-wrap: anywhere; }
.linked-day-head button svg { flex: none; }
.linked-day-head small { flex: none; color: var(--flow-muted); font-size: 9px; }
.linked-occurrence { min-width: 0; padding: 12px 13px; color: var(--flow-ink); }
.linked-day-group .linked-occurrence + .linked-occurrence { border-top: 1px solid var(--flow-border); }
.linked-occurrence-main { display: flex; align-items: center; gap: 9px; }
.linked-occurrence-symbol { display: grid; place-items: center; flex: none; width: 37px; height: 37px; border-radius: 12px; background: var(--flow-soft); color: var(--flow-accent); }
.linked-occurrence-copy { min-width: 0; flex: 1; }
.linked-occurrence-copy strong { display: block; overflow-wrap: anywhere; font-size: 11px; line-height: 1.4; }
.linked-occurrence-copy small { display: block; margin-top: 3px; color: var(--flow-muted); font-size: 9px; line-height: 1.4; }
.linked-occurrence.is-done .linked-occurrence-copy small { color: var(--flow-accent); }
.linked-occurrence-check { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 2px solid var(--flow-muted); border-radius: 50%; background: var(--flow-card); color: var(--flow-accent-ink); }
.linked-occurrence-check.done { border-color: var(--flow-accent); background: var(--flow-accent); }
.linked-occurrence-check:disabled,
.linked-occurrence-more:disabled { opacity: .4; cursor: default; }
.linked-support-list { display: grid; gap: 5px; margin: 10px 0 0 46px; }
.linked-support-list > span { margin-bottom: 2px; color: var(--flow-muted); font-size: 9px; line-height: 1.4; }
.linked-support { display: flex; align-items: center; gap: 7px; width: 100%; min-height: 32px; padding: 6px 9px; border: 1px solid var(--flow-border); border-radius: 10px; background: var(--flow-soft); color: var(--flow-ink); text-align: left; font-size: 10px; line-height: 1.3; }
.linked-support > span:first-child { display: grid; place-items: center; flex: none; width: 18px; height: 18px; border: 1px solid var(--flow-muted); border-radius: 6px; }
.linked-support > span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.linked-support small { flex: none; color: var(--flow-muted); font-size: 9px; }
.linked-support.done > span:first-child { border-color: var(--flow-accent); background: var(--flow-accent); color: var(--flow-accent-ink); }
.linked-occurrence-more { display: inline-flex; align-items: center; gap: 3px; margin: 10px 0 0 46px; padding: 3px 0; border: 0; background: transparent; color: var(--flow-muted); font-size: 9px; font-weight: 800; }
.plan-status-choices { display: grid; gap: 7px; margin: 13px 0 3px; }
.plan-status-choices button { min-height: 43px; padding: 8px 12px; border: 1px solid var(--flow-border); border-radius: 12px; background: var(--flow-soft); color: var(--flow-ink); text-align: left; font-size: 11px; font-weight: 750; }

/* Goal progress and habit analysis. */
.plan-detail-hero { margin-bottom: 10px; }
.plan-detail-hero .eyebrow { color: var(--flow-accent); }
.plan-detail-hero h1 { margin-top: 8px; }
.plan-detail-progress { display: flex; justify-content: space-between; gap: 10px; margin: 16px 0 7px; font-size: 11px; font-weight: 700; }
.plan-detail-progress b { color: var(--flow-accent); }
.plan-detail-hero > .linked-plan-track { margin-bottom: 9px; }
.plan-metric-summary { display: flex; align-items: center; gap: 9px; margin: 0 0 10px; padding: 13px; border: 1px solid var(--flow-border); border-radius: 16px; background: var(--flow-card); }
.plan-metric-summary > div { flex: 1; min-width: 0; }
.plan-metric-summary strong { display: block; font-size: 11px; }
.plan-metric-summary small { display: block; margin-top: 3px; color: var(--flow-muted); font-size: 9px; line-height: 1.4; }
.plan-metric-summary button,
.plan-detail-section > button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: none; min-height: 34px; padding: 7px 10px; border: 1px solid var(--flow-border); border-radius: 10px; background: var(--flow-soft); color: var(--flow-ink); font-size: 10px; font-weight: 800; }
.plan-detail-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.plan-detail-metrics > div { min-width: 0; padding: 12px 9px; border: 1px solid var(--flow-border); border-radius: 15px; background: var(--flow-card); }
.plan-detail-metrics strong { display: block; font-size: 19px; line-height: 1.2; }
.plan-detail-metrics small { display: block; margin-top: 4px; color: var(--flow-muted); font-size: 9px; line-height: 1.35; overflow-wrap: anywhere; }
.plan-detail-section { display: flex; align-items: end; justify-content: space-between; gap: 9px; margin: 23px 0 10px; }
.plan-detail-section h2 { margin: 3px 0 0; font-size: 17px; line-height: 1.25; }
.plan-detail-dates { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-bottom: 11px; }
.plan-detail-dates .date-chip { min-width: 0; padding: 0 2px; }
.plan-detail-occurrences { display: grid; gap: 8px; }
.plan-detail-occurrences .linked-occurrence { border: 1px solid var(--flow-border); border-radius: 17px; background: var(--flow-card); }
.plan-detail-habits { display: grid; gap: 8px; }
.plan-detail-habits article { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--flow-border); border-radius: 16px; background: var(--flow-card); }
.plan-habit-symbol { display: grid; place-items: center; flex: none; width: 35px; height: 35px; border-radius: 11px; background: var(--flow-soft); color: var(--flow-accent); }
.plan-detail-habits article > div { flex: 1; min-width: 0; }
.plan-detail-habits strong { display: block; overflow-wrap: anywhere; font-size: 11px; line-height: 1.4; }
.plan-detail-habits small,
.plan-detail-habits p { display: block; margin: 3px 0 0; color: var(--flow-muted); font-size: 9px; line-height: 1.45; }
.plan-habit-meta { display: flex; flex-wrap: wrap; gap: 5px 12px; margin-top: 8px; color: var(--flow-ink); font-size: 9px; font-weight: 700; }
.plan-habit-meta span { display: inline-flex; align-items: center; gap: 3px; }
.plan-revise-link { width: 100%; margin-top: 16px; }
.plan-delete-link { margin-top: 9px; }

@media (max-width: 370px) {
  .goal-flow-page .plan-goal-editor > .field-grid,
  .goal-flow-page .plan-metric-fields .field-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .linked-plan-bottom { flex-direction: column; gap: 2px; }
  .linked-plan-bottom > span:last-child { text-align: left; }
  .plan-steps-heading { display: block; }
  .plan-steps-heading small { display: block; text-align: left; margin-top: 3px; }
  .plan-habit-editor,
  .plan-goal-editor { padding: 14px 12px; }
  .plan-weekdays { gap: 3px; }
  .plan-weekdays button { min-height: 37px; border-radius: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .linked-plan-card,
  .linked-plan-track > i { transition: none; }
}
