/* Study plan, placement check and test overview (plan/*.js). Ported from the IELTS app; the
   IELTS token names are mapped onto the TOEFL palette here, scoped to the plan screen. */
#planScreen {
  --accent: #5356cc; --accent-hover: #4346b4; --accent-ink: #33369a; --accent-lt: #ecebff; --accent-mid: #d9d8ff;
  --surface: #fff; --surface2: #f3f3fb; --text2: #4a4d6a; --text3: #8a8db0; --gold: #d97706; --danger: #c0392b;
  --radius: 10px; --radius-sm: 6px; --radius-lg: 16px; --font-b: inherit;
}

.plan-wrap { max-width: 760px; margin: 0 auto; padding: 24px 16px 64px; font-family: var(--font-b); color: var(--text); }
.plan-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; }
.plan-empty { text-align: center; }
.plan-h2 { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; color: var(--navy); margin: 4px 0 8px; line-height: 1.25; }
.plan-big { color: var(--accent); }
.plan-lead { color: var(--text2); font-size: 15px; line-height: 1.55; margin: 0 0 20px; }
.plan-note { color: var(--text2); font-size: 13px; line-height: 1.5; background: var(--surface2); border-radius: var(--radius); padding: 12px 14px; margin: 16px 0; }
.plan-note a { color: var(--accent); font-weight: 600; }
.plan-err { color: var(--danger); }
.plan-loading { color: var(--text3); padding: 32px 0; text-align: center; }
.pc-kicker { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: 0.4px; text-transform: uppercase; margin-bottom: 4px; }

/* Buttons */
.plan-btn { appearance: none; border: 0; border-radius: var(--radius); background: var(--accent); color: #fff; font: inherit; font-weight: 700; font-size: 15px; padding: 14px 22px; min-height: 48px; cursor: pointer; transition: background .15s ease, transform .12s ease; }
.plan-btn:hover { background: var(--accent-hover); }
.plan-btn:active { transform: scale(0.97); }
.plan-btn[disabled] { background: var(--text3); cursor: default; transform: none; }
.plan-btn.ghost { background: var(--surface); color: var(--text2); border: 1.5px solid var(--border); }
.plan-btn.ghost:hover { background: var(--surface2); }
.plan-link { appearance: none; background: none; border: 0; padding: 10px 0; color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.plan-row { display: flex; gap: 12px; margin-top: 20px; }
.plan-row .plan-btn { flex: 1; }

/* Setup form */
.plan-form { display: flex; flex-direction: column; gap: 18px; }
.plan-field { display: flex; flex-direction: column; gap: 8px; }
.plan-field > span { font-size: 13px; font-weight: 700; color: var(--text2); }
.plan-field input[type=date], .plan-field select { font: inherit; font-size: 16px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--text); min-height: 48px; }
.plan-field input:focus, .plan-field select:focus { outline: none; border-color: var(--accent); }
.plan-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.plan-chip input { position: absolute; opacity: 0; pointer-events: none; }
.plan-chip span { display: flex; flex-direction: column; justify-content: center; min-height: 44px; min-width: 48px; text-align: center; padding: 8px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); background: #fff; font-weight: 600; font-size: 14px; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.plan-chip span small { font-weight: 500; font-size: 11px; color: var(--text3); }
.plan-chip input:checked + span { border-color: var(--accent); background: var(--accent-lt); color: var(--accent-ink); }
.plan-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.plan-chip.dis span { opacity: .45; cursor: not-allowed; }
.plan-grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.plan-grid4 .plan-row { grid-column: 1 / -1; }

/* Placement check */
.pc-steps { display: flex; gap: 4px; margin-bottom: 16px; }
.pc-steps i { flex: 1; height: 5px; border-radius: 99px; background: var(--border); }
.pc-steps i.on { background: var(--accent); }
.pc-audio { width: 100%; margin: 4px 0 16px; }
.pc-notes { margin-bottom: 8px; }
.pc-notes .q-grp { margin-bottom: 16px; }
.pc-notes .iinput { font-size: 16px; } /* no iOS zoom on focus */
.pc-passage { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 8px 0 14px; line-height: 1.6; font-size: 15px; }
.pc-q { font-size: 17px; font-weight: 600; line-height: 1.45; margin: 4px 0 14px; }
.pc-opts { display: flex; flex-direction: column; gap: 10px; }
.pc-opt { appearance: none; text-align: left; font: inherit; font-size: 15px; padding: 14px 16px; min-height: 48px; border: 1.5px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--text); cursor: pointer; transition: border-color .15s ease, background .15s ease, transform .12s ease; }
.pc-opt:active { transform: scale(0.98); }
.pc-opt.sel { border-color: var(--accent); background: var(--accent-lt); }

/* Bands */
.plan-bands { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 4px; }
.plan-band { display: grid; grid-template-columns: 84px 36px 1fr; align-items: center; gap: 10px; font-size: 14px; }
.plan-band span { color: var(--text2); font-weight: 600; }
.plan-band b { font-variant-numeric: tabular-nums; }
.plan-band i { position: relative; height: 8px; border-radius: 99px; background: var(--surface2); }
.plan-band i::before { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--w); border-radius: 99px; background: var(--accent); }
.plan-band.gap i::before { background: var(--gold); }
.plan-band i::after { content: ''; position: absolute; top: -4px; bottom: -4px; left: var(--t); width: 2px; background: var(--navy); border-radius: 1px; }
.plan-bands.compact { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; margin: 0 0 16px; }

/* Plan view */
.plan-top { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.plan-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.plan-kpis div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.plan-kpis b { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--navy); }
.plan-kpis span { font-size: 12px; color: var(--text2); }

.plan-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 12px; }
.plan-day.today { border: 2px solid var(--accent); }
.plan-day.rest .plan-lead { margin: 6px 0 0; }
.plan-day-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.plan-day-h b { font-size: 15px; }
.plan-day.today .plan-day-h b { color: var(--accent); font-size: 17px; }
.plan-day-h span { font-size: 12px; color: var(--text3); font-variant-numeric: tabular-nums; }
.plan-day ul { list-style: none; margin: 0; padding: 0; }
.plan-s { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.plan-s:first-child { border-top: 0; }
.plan-s-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.plan-s-txt b { font-size: 14px; font-weight: 600; }
.plan-s-txt span { font-size: 12px; color: var(--text2); }
.plan-s.done .plan-s-txt b { color: var(--text3); text-decoration: line-through; }
.plan-tick { appearance: none; flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); background: #fff; cursor: pointer; position: relative; transition: background .15s ease, border-color .15s ease; }
.plan-tick::after { content: ''; position: absolute; inset: -9px; } /* 44px tap target */
.plan-s.done .plan-tick { background: var(--accent); border-color: var(--accent); }
.plan-s.done .plan-tick::before { content: ''; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.plan-start { appearance: none; flex: none; border: 0; border-radius: 50px; background: var(--accent-lt); color: var(--accent-ink); font: inherit; font-size: 13px; font-weight: 700; padding: 0 16px; min-height: 36px; cursor: pointer; transition: background .15s ease, transform .12s ease; }
.plan-start:hover { background: var(--accent-mid); }
a.plan-start { display: inline-flex; align-items: center; text-decoration: none; }
.plan-start:active { transform: scale(0.97); }
.plan-start.lock { background: var(--surface2); color: var(--text2); }
.plan-s[data-type="full"] .plan-s-txt b { color: #be185d; }

.plan-pace { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 16px; font-size: 13px; color: var(--text2); font-weight: 600; }
.plan-chip-btn { appearance: none; font: inherit; font-size: 13px; font-weight: 600; padding: 0 14px; min-height: 36px; border-radius: 50px; border: 1.5px solid var(--border); background: #fff; color: var(--text2); cursor: pointer; }
.plan-chip-btn.on { border-color: var(--accent); background: var(--accent-lt); color: var(--accent-ink); }
.plan-chip-btn[disabled] { opacity: .45; cursor: not-allowed; }

.plan-week { margin-bottom: 12px; }
.plan-week summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 700; font-size: 15px; padding: 12px 4px; list-style: none; }
.plan-week summary::-webkit-details-marker { display: none; }
.plan-week summary::before { content: '›'; display: inline-block; margin-right: 8px; color: var(--text3); transition: transform .15s ease; }
.plan-week[open] summary::before { transform: rotate(90deg); }
.plan-week summary span { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--text3); }
.plan-actions { display: flex; flex-direction: column; align-items: flex-start; margin-top: 8px; }

@media (min-width: 640px) {
  .plan-wrap { padding: 32px 24px 80px; }
  .plan-card { padding: 32px; }
  .plan-h2 { font-size: 28px; }
  .plan-top { flex-direction: row; justify-content: space-between; align-items: flex-end; }
  .plan-kpis { min-width: 320px; }
  .plan-grid4 { grid-template-columns: repeat(4, 1fr); }
  .plan-actions { flex-direction: row; gap: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .plan-btn, .plan-start, .pc-opt, .plan-tick, .plan-week summary::before { transition: none; }
}

/* Test overview (js/plan/overview.js) */
.ov { --l-bg: #e0f2fe; --l-ink: #075985; --r-bg: #dcfce7; --r-ink: #166534; --w-bg: #fee2e2; --w-ink: #991b1b; --s-bg: #ede9fe; --s-ink: #5b21b6; }
.ov-head { margin-bottom: 8px; }
.ov-head .plan-lead { max-width: 62ch; }
.ov-sec { margin-top: 36px; }
.ov-h { font-size: 19px; font-weight: 800; letter-spacing: -0.2px; color: var(--navy); margin: 0 0 14px; }
.ov-h4 { font-size: 15px; font-weight: 800; color: var(--navy); margin: 24px 0 8px; }
.ov-p { color: var(--text2); line-height: 1.65; margin: 0 0 16px; max-width: 65ch; }

/* The test to scale: a column on phones (height ∝ minutes), a row from 640px (width ∝ minutes).
   The first three parts sit in one bracketed group: they are one sitting. */
.ov-scale { display: flex; flex-direction: column; gap: 16px; height: 380px; }
.ov-group { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.ov-group-s { flex-grow: 0 !important; }
.ov-segs { flex: 1; display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.ov-cap { font-size: 12px; font-weight: 600; color: var(--text2); }
.ov-seg { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; padding: 0 14px; border-radius: 8px; font-size: 14px; }
.ov-seg b { font-weight: 800; }
.ov-seg span { font-variant-numeric: tabular-nums; font-weight: 600; }
.ov-listening.ov-seg { background: var(--l-bg); color: var(--l-ink); }
.ov-reading.ov-seg { background: var(--r-bg); color: var(--r-ink); }
.ov-writing.ov-seg { background: var(--w-bg); color: var(--w-ink); }
.ov-speaking.ov-seg { background: var(--s-bg); color: var(--s-ink); }
@keyframes ov-draw { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
.ov-scale { animation: ov-draw 700ms cubic-bezier(0.23, 1, 0.32, 1) both; }

/* Parts */
.ov-part { border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; }
.ov-part.ov-listening { background: var(--l-bg); --ink: var(--l-ink); }
.ov-part.ov-reading { background: var(--r-bg); --ink: var(--r-ink); }
.ov-part.ov-writing { background: var(--w-bg); --ink: var(--w-ink); }
.ov-part.ov-speaking { background: var(--s-bg); --ink: var(--s-ink); }
.ov-part-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; color: var(--ink); }
.ov-part-h b { font-size: 17px; font-weight: 800; }
.ov-part-h span { font-size: 13px; font-weight: 600; }
.ov-part dl { display: grid; grid-template-columns: 1fr; gap: 2px 14px; margin: 0; font-size: 14px; line-height: 1.55; }
.ov-part dt { font-weight: 700; color: var(--ink); margin-top: 6px; }
.ov-part dd { margin: 0; color: var(--text); }
.ov-note { margin: 12px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink); font-weight: 600; }

/* Score calculator */
.ov-calc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.ov-calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ov-step { display: flex; flex-direction: column; gap: 6px; }
.ov-step-name { font-size: 13px; font-weight: 700; color: var(--text2); }
.ov-step-ctl { display: flex; align-items: center; justify-content: space-between; border: 1.5px solid var(--border); border-radius: var(--radius); padding: 3px; }
.ov-step-ctl button { appearance: none; width: 40px; height: 40px; border: 0; border-radius: 8px; background: var(--surface2); color: var(--navy); font: inherit; font-size: 20px; font-weight: 700; cursor: pointer; transition: background .15s ease, transform .12s ease; }
.ov-step-ctl button:hover { background: var(--accent-lt); }
.ov-step-ctl button:active { transform: scale(0.94); }
.ov-step-ctl button[disabled] { opacity: .35; cursor: default; transform: none; }
.ov-step-ctl output { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--navy); }
.ov-result { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.ov-result > div { display: flex; flex-direction: column; }
.ov-result-l { font-size: 12px; font-weight: 700; color: var(--text2); }
.ov-result b { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text2); }
.ov-result b.ov-big { font-size: 34px; color: var(--navy); line-height: 1.1; }
.ov-result.met b.ov-big { color: var(--accent); }
.ov-arrow { width: 28px; height: 2px; background: var(--border); position: relative; }
.ov-arrow::after { content: ''; position: absolute; right: -1px; top: -4px; border: 5px solid transparent; border-left-color: var(--border); border-right: 0; }
.ov-verdict { flex-basis: 100%; margin: 0; font-size: 14px; font-weight: 600; color: var(--text2); }
.ov-result.met .ov-verdict { color: var(--accent-ink); }

.ov-facts { margin: 0; padding-left: 20px; line-height: 1.65; max-width: 65ch; }
.ov-facts li { margin-bottom: 8px; }
.ov-done { margin-top: 32px; width: 100%; }

@media (min-width: 640px) {
  .ov-scale { flex-direction: row; height: auto; }
  .ov-group { flex-basis: 0; }
  .ov-group-s { flex: 0 0 120px; }
  .ov-segs { flex-direction: row; height: 72px; flex: none; }
  .ov-cap { padding-top: 6px; border-top: 2px solid var(--border); }
  .ov-seg { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; padding: 0 12px; min-width: 0; flex-basis: 0; }
  @keyframes ov-draw { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
  .ov-part dl { grid-template-columns: 150px 1fr; }
  .ov-part dt { margin-top: 0; }
  .ov-calc-grid { grid-template-columns: repeat(4, 1fr); }
  .ov-done { width: auto; }
}
@media (prefers-reduced-motion: reduce) { .ov-scale { animation: none; } .ov-step-ctl button { transition: none; } }

/* Plan screen chrome + the home screen's plan banner (TOEFL tokens) */
#planScreen .plan-wrap { padding: 8px 0 40px; }
.plan-back { appearance: none; background: none; border: 1px solid var(--border); color: #555; padding: 8px 18px; border-radius: 50px; cursor: pointer; font: inherit; font-size: 13px; }
.plan-date { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: var(--accent-ink); }
.plan-rest { margin: 6px 0 0; }
.home-plan { appearance: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin: 0 0 20px; padding: 16px 20px; border: 1.5px solid #c9c8f5; border-radius: 14px; background: #f4f3ff; color: var(--navy); font: inherit; text-align: left; cursor: pointer; transition: background .15s ease, transform .12s ease; }
.home-plan:hover { background: #ecebff; }
.home-plan:active { transform: scale(0.99); }
.home-plan-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.home-plan-txt b { font-size: 1rem; font-weight: 800; }
.home-plan-txt span { font-size: 0.82rem; color: #4a4d6a; }
.home-plan-go { flex: none; font-size: 0.82rem; font-weight: 700; color: #33369a; }
