/* /plan/ — the study planner. Tokens only, from core.css; works in both themes. */

/* 1200px, not the full frame: the form is three fields abreast and reads as one
   card; the plan's week items go two-up from 1100px (bottom of the Plan block). */
.plan-page { max-width: 1200px; margin: 0 auto; padding: var(--sp-6) 0 var(--sp-8); }

.plan-hero { margin-bottom: var(--sp-5); }
.plan-eyebrow {
  display: inline-block; margin: 0 0 var(--sp-2);
  padding: 0.2rem 0.7rem; border: 1px solid var(--border-accent); border-radius: var(--r-full);
  background: var(--accent-subtle); color: var(--accent);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.plan-hero h1 { margin: 0 0 var(--sp-2); font-size: var(--fs-3xl); line-height: 1.15; }
.plan-lede { margin: 0; color: var(--text-muted); font-size: var(--fs-md); line-height: 1.6; max-width: 62ch; }

.plan-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: var(--sp-5);
}

/* The page sits inside the layout's article, whose prose rules (heading
   underlines, list indents, li spacing, the details chevron) are for long-form
   content. Reset the ones this UI meets. */
.plan-page h2, .plan-page h3 { border: 0; padding: 0; }
.plan-page ol.plan-weeks { padding-left: 0; margin: 0; max-width: none; width: 100%; }
.plan-page p.plan-item-why { margin: var(--sp-1) 0 0; }
/* The article caps lists and paragraphs at a reading measure; this UI spans its card. */
.plan-page ul, .plan-page ol, .plan-page p, .plan-page .plan-item, .plan-page .plan-item-body > * { max-width: none; }
.plan-page li { margin: 0; }
/* ...except the hero lede, which the reset above stretched to the card. */
.plan-page p.plan-lede { max-width: 72ch; }
.plan-page .plan-week details { margin: 0; padding: 0; border: 0; background: none; overflow: visible; }
.plan-page .plan-week details summary { font-weight: inherit; font-size: inherit; color: inherit; background: none; border: 0; margin: 0; }
.plan-page .plan-week details[open] summary { border-bottom: 1px solid var(--border); margin: 0; }
.plan-page .plan-week details summary::before { content: none; display: none; }
.plan-page .plan-week details > ul.plan-items { margin: 0; padding: 0 var(--sp-5) var(--sp-4); }
.plan-page .plan-item:first-child { border-top: 0; }

/* ---- Form ---- */
.plan-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.plan-form[hidden] { display: none; }
.plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.plan-field { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; margin: 0; padding: 0; border: 0; }
.plan-field > label, .plan-field > legend { font-weight: 600; font-size: var(--fs-sm); color: var(--text); padding: 0; }
.plan-hint { font-weight: 400; color: var(--text-dim); margin-left: var(--sp-1); }

.plan-field select, .plan-field input[type="text"], .plan-field textarea {
  width: 100%; min-height: var(--target-min);
  padding: 0.55rem 0.75rem; font: inherit; font-size: var(--fs-sm);
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.plan-field textarea { resize: vertical; line-height: 1.5; }
/* Job description disclosure, top of the form. */
.plan-jd { margin: 0 0 var(--sp-4); border: 1px dashed var(--border-accent); border-radius: var(--r-md); background: var(--accent-subtle); }
/* flex-wrap, because content.css makes every `.content details summary` a flex
   row and this one carries two labels: the question and the "Paste it and the
   form fills itself" hint. As unwrapped flex items they needed ~400px and had
   298px on a 390px phone, so both shrank and both wrapped, giving four short
   ragged lines. Wrapping drops the hint onto its own line and keeps the
   question whole. */
.plan-jd > summary { cursor: pointer; padding: var(--sp-3) var(--sp-4); font-weight: 700; color: var(--text); list-style: none; flex-wrap: wrap; }
/* The hint's left margin only makes sense beside the question; once wrapped it
   is a stray indent, and the ::before box already reserves the gutter. */
.plan-jd > summary span { margin-left: 0; }
.plan-jd > summary::-webkit-details-marker { display: none; }
/* The +/- pair, and both halves have to out-specify content.css.
   `.content details summary::before` (0,1,2) sets `content: '▸'` and rotates
   it 90deg when open. The closed rule here was `.plan-jd > summary::before`
   at (0,1,1), so it LOST and the collapsed state showed content.css's
   triangle -- while the open rule, `.plan-jd[open] > summary::before` at
   (0,2,1), won. The control therefore toggled from a triangle to a minus:
   two different icon languages on one button, neither of which was the plus
   this file was written to draw.
   `.content` on the closed rule takes it to (0,2,2) and settles it. The
   rotation is cancelled because a plus does not rotate -- left on, it turned
   the minus on its side when open. */
.content .plan-jd > summary::before { content: "+"; display: inline-block; width: 1.1em; color: var(--accent); transform: none; }
.content .plan-jd[open] > summary::before { content: "−"; transform: none; }
.plan-jd > summary span { font-weight: 500; color: var(--text-muted); margin-left: var(--sp-1); }
.plan-jd > .plan-field { padding: 0 var(--sp-4) var(--sp-4); margin: 0; }
.plan-jd-row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-2); }
.plan-jd-out { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); flex: 1 1 220px; }
.plan-field select:focus-visible, .plan-field input:focus-visible, .plan-field textarea:focus-visible {
  outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); border-color: var(--accent);
}
.plan-field input[type="range"] { accent-color: var(--accent); min-height: var(--target-min); }
.plan-field output { color: var(--accent); font-variant-numeric: tabular-nums; }

.plan-companies {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.plan-companies:focus-within { border-color: var(--accent); }
.plan-combo { position: relative; flex: 1 1 180px; min-width: 0; }
.plan-companies .plan-combo input[type="text"] { width: 100%; border: 0; background: none; padding-inline: var(--sp-1); }
.plan-page .plan-combo-list {
  position: absolute; z-index: var(--z-overlay, 50); top: calc(100% + 6px); left: calc(-1 * var(--sp-2));
  width: min(320px, calc(100vw - 2 * var(--sp-5)));
  max-height: 280px; overflow-y: auto; margin: 0; padding: var(--sp-1); list-style: none;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}
.plan-page .plan-combo-list[hidden] { display: none; }
.plan-page .plan-combo-opt, .plan-page .plan-combo-empty {
  margin: 0; padding: 0.5rem 0.7rem; border-radius: var(--r-sm);
  font-size: var(--fs-sm); color: var(--text-muted); cursor: pointer;
}
.plan-combo-opt strong { color: var(--text); font-weight: 650; }
.plan-combo-opt[aria-selected="true"] { color: var(--text); background: var(--accent-subtle); }
.plan-combo-opt[aria-selected="true"] strong { color: var(--accent); }
.plan-page .plan-combo-empty { cursor: default; color: var(--text-dim); }

/* Native select chrome differs per OS; draw our own chevron so selects match the inputs. */
.plan-field select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.plan-field select option { background: var(--surface); color: var(--text); }
.plan-companies input[type="text"]:focus-visible { outline: none; }
.plan-chips { display: contents; list-style: none; margin: 0; padding: 0; }
.plan-chips li { margin: 0; }
.plan-chip {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0.15rem 0.6rem;
  font: inherit; font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
  color: var(--accent); background: var(--accent-subtle);
  border: 1px solid var(--border-accent); border-radius: var(--r-full);
}
.plan-chip:hover { background: var(--accent-subtle-hover); }
.plan-chip:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }

.plan-toggles { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.plan-toggles label {
  display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--target-min);
  padding: 0.35rem 0.8rem; cursor: pointer; font-size: var(--fs-sm); color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-full);
}
.plan-toggles input { accent-color: var(--accent); }
.plan-toggles label:has(input:checked) { color: var(--text); border-color: var(--border-accent); background: var(--accent-subtle); }
.plan-toggles label:has(input:focus-visible) { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }

.plan-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
/* Both build buttons are disabled together, so cover the one in the rendered
   plan (.plan-summary-actions #plan-regen) too, not just the form's. */
.plan-page .btn[disabled] { opacity: 0.6; cursor: progress; }
.plan-signin-note { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.plan-link-btn {
  padding: 0; font: inherit; color: var(--accent); background: none; border: 0;
  text-decoration: underline; cursor: pointer;
}

/* Building a plan is a round trip to the AI planner that takes 10 to 20
   seconds and is bounded at 45, so the button that was pressed has to say so.
   Dimming alone left the label reading "Build my plan" on a grayed button,
   which is indistinguishable from a click that never registered — so readers
   wait, then press it again. The pressed button keeps full opacity: the
   spinner is the signal, and dimming it fights that.
   Same recipe as the judge's .lc-btn.working (assets/css/judge.css), but the
   ring is currentColor so it needs no override per .btn variant, and the
   label is swapped rather than hidden — over a 20 second wait "Building your
   plan…" is worth more than a blank button. */
.plan-page .btn.is-building[disabled] { opacity: 1; }
.plan-page .btn.is-building::before {
  content: ''; flex: 0 0 auto; width: 1em; height: 1em;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: var(--r-full);
  animation: sc-spin 0.7s linear infinite;
}

/* Zero height when it has nothing to say, rather than a reserved 1.5em line.
   The reserved line was ~40px of unexplained gap between the hero and the
   plan on every visit with no message to show — which is every return visit,
   since the status is never restored from storage.
   It stays rendered rather than `display: none` when empty: this is the live
   region, and a region that appears with its text already in it is not
   reliably announced. Empty and rendered, it is in the accessibility tree
   before the message lands. */
.plan-status { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.plan-status:not(:empty) { margin: var(--sp-3) 0; }
.plan-status[data-kind="warn"] { color: var(--warning); }
/* No [data-kind="ok"]: the one success message this line carried was "Your
   plan is ready.", and it now flashes on the summary card as .plan-flash. A
   success worth a persistent sentence here would be a new case; green body
   text floating between two cards was not it. */
/* setStatus has passed 'busy' since this page shipped, with no rule to match.
   Accent, not a second spinner: the button is already animating and the
   reader is looking at it. */
.plan-status[data-kind="busy"] { color: var(--accent); }

/* ---- Building ------------------------------------------------------------
   The AI planner is a 10 to 20 second wait on the page's primary action, and a
   spinner alone leaves the reader staring at an empty page wondering whether
   anything is happening. This panel mirrors the shape of .plan-view that
   replaces it — summary card, then one card per week — so the wait previews
   the result instead of hiding it.

   Two patterns already in this repo rather than two new ones: the stage rows
   are the resume's staged scan (.rz-stage in resume.css, same
   is-wait/is-now/is-done states), and the week cards shimmer with the
   dsa-index.css treatment (.pat-skeleton). Both are namespaced plan-.
   -------------------------------------------------------------------------- */
.plan-building { display: flex; flex-direction: column; gap: var(--sp-4); }
.plan-building[hidden] { display: none; }

/* Indeterminate, not a percentage: the Worker reports no progress mid-call, so
   a bar claiming 60% would be invented. A sweep says "working" and nothing more. */
.plan-build-bar {
  height: 6px; margin-top: var(--sp-4);
  background: var(--surface-3); border-radius: var(--r-full); overflow: hidden;
}
.plan-build-bar::after {
  content: ''; display: block; height: 100%; width: 38%; border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: plan-sweep 1.6s var(--ease) infinite;
}
@keyframes plan-sweep { from { transform: translateX(-105%); } to { transform: translateX(370%); } }

.plan-stages { list-style: none; margin: var(--sp-2) 0 0; padding: 0; }
.plan-stage {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) 0; font-size: var(--fs-sm);
  border-top: 1px solid var(--border);
}
.plan-stage:first-child { border-top: 0; }
.plan-stage-mark { flex: 0 0 15px; height: 15px; display: inline-flex; align-items: center; justify-content: center; }
.plan-stage-label { margin-right: auto; color: var(--text-muted); }
/* The numbers these rows report are real, so give them room but never let a
   long topic name push the layout around. */
.plan-stage-detail {
  flex: 0 1 auto; min-width: 0; max-width: 45%;
  font-size: var(--fs-xs); color: var(--text-dim); text-align: right;
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.plan-stage.is-wait { opacity: 0.4; }
.plan-stage.is-wait .plan-stage-mark::before {
  content: ''; width: 7px; height: 7px;
  border: 1px solid var(--control-border); border-radius: var(--r-full);
}
.plan-stage.is-now .plan-stage-label { color: var(--text); font-weight: 600; }
.plan-stage.is-now .plan-stage-mark::before {
  content: ''; width: 13px; height: 13px;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: var(--r-full);
  animation: sc-spin 0.7s linear infinite;
}
.plan-stage.is-done .plan-stage-mark::before { content: '✓'; color: var(--success); font-size: 12px; font-weight: 700; line-height: 1; }

/* One card per week of the plan being built, so the page keeps the height and
   rhythm it will have when the real weeks land. Staggered, because four bars
   pulsing in lockstep looks like a loading bar and not like a list. */
.plan-skeleton { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.plan-skeleton li {
  display: flex; align-items: center; gap: var(--sp-4);
  min-height: 68px; padding: var(--sp-4) var(--sp-5);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
}
.plan-skel-num { flex: 0 0 auto; font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); opacity: 0.55; }
/* --border-accent for the highlight, not the --accent-subtle that
   dsa-index.css uses: subtle is 12% alpha in dark and 6% in light, which over
   --surface-3 is a lift of a shade or two — the bar reads as flat gray and the
   shimmer is invisible in light theme. --border-accent is 35% and 22%. */
.plan-skel-bar {
  flex: 1 1 auto; height: 11px; border-radius: var(--r-full);
  background: linear-gradient(100deg, var(--surface-3) 30%, var(--border-accent) 50%, var(--surface-3) 70%);
  background-size: 200% 100%;
  animation: sc-shimmer 1.4s linear infinite;
  animation-delay: calc(var(--i, 0) * 0.11s);
}
/* A second, shorter bar per card reads as a title over a meta line, which is
   what a real week card is. */
.plan-skel-bar.is-short { flex: 0 0 64px; }

/* ---- Plan ---- */
.plan-view { display: flex; flex-direction: column; gap: var(--sp-4); }
.plan-view[hidden] { display: none; }
.plan-summary-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.plan-summary-head h2 { margin: 0; font-size: var(--fs-xl); }
.plan-summary-head h2:focus { outline: none; }
.plan-source {
  padding: 0.2rem 0.65rem; font-size: var(--fs-xs); font-weight: 700; border-radius: var(--r-full);
  color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border);
}
.plan-source[data-source="ai"] { color: var(--accent); background: var(--accent-subtle); border-color: var(--border-accent); }
/* The "just built" confirmation, on the card it is confirming and beside the
   badge it qualifies — "Just built · AI-tuned" reads as one statement.
   It used to be `setStatus('Your plan is ready.', 'ok')`: a bare line of green
   body text in the gap between the hero and the plan, attached to nothing,
   which also never cleared, so it was still sitting there claiming readiness
   after the reader pressed Change goals and the form reopened under it.
   Mixed at the call site because core.css has no --success-subtle. The nav
   tiles used to mix the same four semantic tints the same way and no longer
   do -- see the comment on .nav-tile-icon in core.css -- so this is now the
   remaining caller, and the missing -subtle siblings are still a real gap in
   the token set. Here the green MEANS something: the plan is ready. */
.plan-head-tags { display: inline-flex; align-items: center; gap: var(--sp-2); }
.plan-flash {
  padding: 0.2rem 0.65rem; font-size: var(--fs-xs); font-weight: 700; border-radius: var(--r-full);
  color: var(--success);
  background: color-mix(in srgb, var(--success) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
  animation: plan-flash-in var(--dur) var(--ease);
}
/* Empty is the resting state — plan-page.js clears it a few seconds after a
   build, so it does not become permanent furniture on the card. */
.plan-flash:empty { display: none; }
@keyframes plan-flash-in { from { opacity: 0; transform: translateY(-2px); } }
.plan-summary-text { margin: var(--sp-3) 0; color: var(--text-muted); line-height: 1.6; }
.plan-progress { height: 8px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; }
.plan-progress span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width var(--dur) var(--ease); }
.plan-progress-text { margin: var(--sp-2) 0 var(--sp-4); font-size: var(--fs-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.plan-summary-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.plan-weeks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.plan-week { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.plan-week.is-current { border-color: var(--border-accent); box-shadow: var(--shadow-sm); }
.plan-week summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); cursor: pointer; list-style: none; min-height: var(--target-touch);
}
.plan-week summary::-webkit-details-marker { display: none; }
/* A drawn chevron rather than a glyph: '▾' rendered at a few pixels in the site font. */
.plan-week summary::after {
  content: ''; flex: 0 0 auto; width: 8px; height: 8px; margin: 0 var(--sp-1) var(--sp-1);
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg); transition: transform var(--dur) var(--ease);
}
.plan-week details[open] > summary::after { transform: rotate(-135deg); margin-bottom: -var(--sp-1); }
.plan-week summary:focus-visible { outline: var(--focus-ring); outline-offset: calc(-1 * var(--focus-ring-offset)); border-radius: var(--r-lg); }
.plan-week-title { display: flex; flex-direction: column; gap: var(--sp-0); min-width: 0; margin-right: auto; }
.plan-week-num { font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent); }
.plan-week-theme { font-weight: 650; color: var(--text); }
.plan-week-meta { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.plan-week.is-complete .plan-week-num { color: var(--success); }

.plan-items { list-style: none; margin: 0; padding: 0 var(--sp-5) var(--sp-4); display: flex; flex-direction: column; }
.plan-item { display: flex; gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--border); }
.plan-item-mark {
  flex: 0 0 22px; height: 22px; margin-top: 1px; display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: 700; border: 2px solid var(--border-strong); border-radius: var(--r-full);
}
.plan-item.is-done .plan-item-mark { color: var(--accent-contrast); background: var(--success); border-color: var(--success); }
.plan-item-body { min-width: 0; flex: 1; }
.plan-item-title { font-weight: 600; color: var(--text); text-decoration: none; }
.plan-item-title:hover { color: var(--accent); text-decoration: underline; }
.plan-item.is-done .plan-item-title { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--text-dim); }
.plan-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--text-muted); }
.plan-track { font-weight: 600; color: var(--text-muted); }
.plan-item-why { margin: var(--sp-1) 0 0; font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.5; }

/* A week's items two-up once the card is wide enough for two ~520px columns.
   Each item keeps its own top rule; the first two lose it so the row under the
   week header is clean, as `.plan-item:first-child` does for one column. */
@media (min-width: 1100px) {
  /* Two-up, and with no per-item rules at all. A top border drawn per item
     spans one grid column, so a week with an odd number of items drew a rule
     under the last left-hand item and nothing beside it: a notch across the
     middle of the card. The `:nth-child(2)` exemption below was the same
     problem at the top of the grid.
     Row gap separates the rows instead, and `.plan-item:hover` still tints
     the row under the pointer. */
  .plan-page .plan-week details > ul.plan-items {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: var(--sp-5); row-gap: var(--sp-2);
  }
  .plan-page .plan-week details > ul.plan-items > .plan-item { border-top: 0; }
}

/* ---- Off-site resources ---------------------------------------------------
   Topics the reader's note named that the site does not teach. It reuses
   .plan-item wholesale — same tick, same title, same meta row — because these
   are study items and should behave like one. What it does NOT reuse is the
   card treatment: no accent border, no gradient, a dashed rule instead, so the
   card reads as a pointer off the site rather than as more SystemCraft.
   -------------------------------------------------------------------------- */
.plan-gaps { border-style: dashed; }
.plan-gaps[hidden] { display: none; }
.plan-gaps h3 { margin: 0; font-size: var(--fs-md); }
.plan-gaps-count { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.plan-page p.plan-gaps-lede { margin: var(--sp-2) 0 var(--sp-3); font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.6; }
.plan-page ul.plan-gaps-list { list-style: none; margin: 0; padding: 0; }
.plan-page .plan-gap-item:first-child { border-top: 0; }
/* The host, so the reader can see where a link goes before they take it. */
.plan-gap-src { font-weight: 600; color: var(--text-muted); }
.plan-gap-tag {
  padding: 0.05rem 0.4rem; border-radius: var(--r-sm);
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-dim); border: 1px solid var(--border);
}
/* An outbound arrow on the title, so a new tab is not a surprise. */
.plan-gap-item .plan-item-title::after { content: " ↗"; font-weight: 400; color: var(--text-dim); }

.plan-tips h3 { margin: 0 0 var(--sp-2); font-size: var(--fs-md); }
.plan-tips ul { margin: 0; padding-left: 1.2rem; color: var(--text-muted); line-height: 1.6; }

@media (max-width: 720px) {
  .plan-page { padding-top: var(--sp-4); }
  .plan-hero h1 { font-size: var(--fs-2xl); }
  .plan-grid { grid-template-columns: 1fr; }
  .plan-card { padding: var(--sp-4); }
  .plan-week summary { padding: var(--sp-3) var(--sp-4); }
  .plan-page .plan-week details > ul.plan-items { padding: 0 var(--sp-4) var(--sp-3); }
  .plan-week-meta { white-space: normal; text-align: right; }
}

/* ---- Polish ---- */
.plan-hero {
  position: relative;
  padding: var(--sp-6);
  border: 1px solid var(--border-accent);
  border-radius: var(--r-xl);
  background:
    radial-gradient(ellipse 55% 90% at 100% 0%, var(--accent-subtle), transparent 70%),
    radial-gradient(ellipse 45% 70% at 0% 100%, var(--accent-subtle), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow-md);
}
.plan-form { box-shadow: var(--shadow-md); }

/* Once a plan is rendered the form is hidden, and the hero's lede — "Pick your
   role, target companies and how much time you have" — is instruction for a
   control that is not on the page. That was 240px of stale onboarding sitting
   above the thing a returning reader came back for, so the hero drops to a
   label and the plan moves up the page. plan-page.js adds .has-plan in
   render(); it is never removed, because the plan stays on screen even while
   Change goals reopens the form, and re-expanding the hero under a reader
   mid-edit would jump the layout. */
.plan-page.has-plan .plan-hero { padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-3); }
.plan-page.has-plan .plan-hero h1 { margin: 0; font-size: var(--fs-xl); }
.plan-page.has-plan .plan-eyebrow,
.plan-page.has-plan p.plan-lede { display: none; }

.plan-summary {
  background:
    radial-gradient(ellipse 50% 100% at 100% 0%, var(--accent-subtle), transparent 70%),
    var(--surface);
  border-color: var(--border-accent);
}
.plan-page ul.plan-kpis {
  list-style: none; margin: 0 0 var(--sp-4); padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-3);
}
.plan-kpi {
  display: flex; flex-direction: column; gap: var(--sp-0); padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2);
}
.plan-kpi strong { font-size: var(--fs-xl); line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.plan-kpi span { font-size: var(--fs-xs); color: var(--text-muted); }
.plan-progress { height: 10px; }
.plan-progress span { background: linear-gradient(90deg, var(--accent), var(--accent-hover)); }

/* Timeline: a rail down the left with a node per week. */
.plan-page ol.plan-weeks { position: relative; padding-left: var(--sp-6); }
.plan-page ol.plan-weeks::before {
  content: ""; position: absolute; left: 9px; top: var(--sp-5); bottom: var(--sp-5);
  width: 2px; background: var(--border); border-radius: 1px;
}
.plan-week { position: relative; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.plan-week::before {
  content: ""; position: absolute; left: calc(-1 * var(--sp-6) + 3px); top: 26px;
  width: 14px; height: 14px; border-radius: var(--r-full);
  background: var(--bg); border: 2px solid var(--border-strong); box-sizing: border-box;
}
.plan-week.is-current::before { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px var(--accent-subtle); }
.plan-week.is-complete::before { border-color: var(--success); background: var(--success); }
.plan-week:hover { border-color: var(--border-accent); }
.plan-week.is-current { box-shadow: var(--shadow-md); }
.plan-week-bar { height: 4px; margin: 0 var(--sp-5); border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.plan-week details:not([open]) .plan-week-bar { margin-bottom: var(--sp-4); }
.plan-week-bar span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width var(--dur) var(--ease); }
/* Nothing done yet draws no track. A 0% bar is a full-width gray slab, and on
   a freshly built plan there is one under the summary and one under every
   week — which reads as a row of loading bars that have stalled, not as "you
   have not started". The counts beside them already say that. */
.plan-progress.is-empty, .plan-week-bar.is-empty { background: transparent; }
.plan-week.is-complete .plan-week-bar span { background: var(--success); }
.plan-page .plan-week details[open] summary { border-bottom: 0; }
.plan-page .plan-week details > ul.plan-items { padding-top: var(--sp-2); }

.plan-item { border-radius: var(--r-sm); transition: background var(--dur-fast) var(--ease); }
.plan-item:hover { background: var(--surface-2); }
.plan-page .plan-item { padding-left: var(--sp-2); padding-right: var(--sp-2); }

.plan-tips { border-left: 3px solid var(--accent); }

@media (max-width: 720px) {
  .plan-hero { padding: var(--sp-5); }
  .plan-page ul.plan-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .plan-page ol.plan-weeks { padding-left: var(--sp-5); }
  .plan-page ol.plan-weeks::before { left: 5px; }
  .plan-week::before { left: calc(-1 * var(--sp-5) - 1px); }
  .plan-week-bar { margin: 0 var(--sp-4); }
}
@media (prefers-reduced-motion: reduce) {
  .plan-progress span, .plan-week-bar span, .plan-week { transition: none; }
  .plan-flash { animation: none; }
  /* Slowed, not stopped (the aicode.css convention). A halted spinner is a
     static broken ring, which says nothing about whether work is happening. */
  .plan-page .btn.is-building::before,
  .plan-stage.is-now .plan-stage-mark::before { animation-duration: 2s; }
  /* The sweep and the shimmer are the two that travel across the screen, so
     they stop outright and hold a flat tint. The spinners above still turn,
     which is what carries "working" once these are still. */
  .plan-build-bar::after { animation: none; width: 100%; background: var(--accent-subtle); }
  .plan-skel-bar { animation: none; background: var(--surface-3); }
}

/* Tickable plan items (all tracks except DSA, which ticks from the judge). */
.plan-item-tick {
  padding: 0; cursor: pointer; background: none; color: inherit; font: inherit; font-size: var(--fs-xs); font-weight: 700;
  /* 22px visual circle, 44px tap target via the outline-free hit area below. */
  position: relative;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.plan-item-tick::after { content: ""; position: absolute; inset: -11px; }
.plan-item-tick:hover { border-color: var(--accent); background: var(--accent-subtle); }
.plan-item-tick:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-ring-offset); }
.plan-item.is-done .plan-item-tick:hover { background: var(--success); opacity: .85; }
.plan-auto { font-style: italic; color: var(--text-dim); }
