[data-section='onboarding'] {
  background: var(--canvas);
}

.onboarding {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(100%, 480px);
  height: 100dvh;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
}

.onboarding-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 54px;
  padding: 5px 13px 0;
  color: var(--primary);
  font: 700 24px/30px var(--heading-font);
  text-align: center;
}

.step-circle {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: var(--primary);
}

.step-circle::before {
  position: absolute;
  inset: 3px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow);
  content: '';
}

.step-icon { position: relative; width: 22px; height: 22px; }
.step-chip {
  width: fit-content;
  min-width: 80px;
  margin: 1px auto 0;
  padding: 7px 14px;
  border-radius: 16px;
  background: var(--subtle);
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.onboarding main {
  min-width: 0;
  padding: 0 14px 12px;
  overflow-y: auto;
  scrollbar-width: none;
}

.step-intro {
  position: relative;
  min-width: 0;
  margin: 12px 8px;
}

.step-intro:has(.step-hero) > div { position: relative; z-index: 1; width: 67%; }
.step-intro h1 { font: 700 clamp(26px, 7.7vw, 30px)/1.13 var(--heading-font); }
.step-intro p { margin-top: 12px; color: var(--muted); font-size: 16px; line-height: 20px; }
.step-hero {
  position: absolute;
  inset: 4px 0 0 auto;
  width: min(47%, 168px);
  height: 100%;
  object-fit: contain;
}

.onboarding[data-step='topics'] .step-intro { min-height: 154px; margin-top: 17px; }
.onboarding[data-step='goal'] .step-intro { min-height: 151px; margin-top: 32px; }
.onboarding[data-step='goal'] .step-intro > div { width: 74%; }
.onboarding[data-step='time'] > .step-chip { margin-top: 20px; }
.onboarding[data-step='time'] .step-intro { min-height: 188px; margin-top: 25px; }
.onboarding[data-step='time'] .step-intro:has(.step-hero) > div { width: 86%; }
.onboarding[data-step='time'] .step-hero { width: 39%; object-position: center top; }
.onboarding[data-step='example'] .step-intro,
.onboarding[data-step='source'] .step-intro { margin-top: 29px; }
.onboarding[data-step='source'] .step-intro { margin-bottom: 17px; }
.onboarding[data-step='source'] .step-hero { width: 36%; inset-block-start: -12px; }

.step-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 8px;
}

.step-cards button, .step-rows button, .source-options button {
  position: relative;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.step-cards button {
  display: grid;
  justify-items: center;
  align-content: start;
  padding: 7px 4px;
  font: 700 18px/22px var(--heading-font);
}

.step-cards button img { width: 81px; height: 75px; object-fit: contain; }
.topic-options button { min-height: 132px; }
.topic-options strong { margin-top: 4px; }
.topic-options button[aria-pressed='true'], .source-options button[aria-pressed='true'] { background: var(--subtle); }
.selection-dot {
  display: grid;
  width: 22px;
  height: 22px;
  flex: none;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
}

.step-cards .selection-dot { position: absolute; inset: auto 8px 8px auto; }
.topic-options .selection-dot { inset: 7px 8px auto auto; }
.topic-options button[aria-pressed='false'] .selection-dot { visibility: hidden; }
.topic-options button[aria-pressed='true'] .selection-dot {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}
.topic-options button[aria-pressed='true'] .selection-dot::after { content: '✓'; font: 700 12px/1 Inter, sans-serif; }
.goal-options button { min-height: 174px; padding-top: 12px; font-size: clamp(18px, 5.65vw, 22px); }
.goal-options button img { width: 100px; height: 88px; }
.goal-options strong { margin-top: 10px; }
.goal-options button[aria-pressed='true'], .step-rows button[aria-pressed='true'] {
  background: var(--primary);
  color: var(--on-primary);
}
.goal-options button[aria-pressed='true'] .selection-dot { border-color: var(--on-primary); }
.goal-options button[aria-pressed='true'] .selection-dot::after,
.source-options button[aria-pressed='true'] .selection-dot::after,
.example-card button[aria-pressed='true'] .selection-dot::after {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  content: '';
}

.time-options { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.time-options button { min-height: 140px; padding-top: 14px; }
.time-options button[aria-pressed='true'] { border: 2px solid var(--primary); padding-top: 13px; }
.time-options button img { width: 46px; height: 46px; }
.time-options strong { margin-top: 14px; font-size: 28px; line-height: 32px; }
.time-options small { margin-top: 7px; font: 400 14px/20px Inter, sans-serif; color: var(--muted); }
.weekly {
  display: grid;
  grid-template-columns: 89px 1fr;
  align-items: center;
  gap: 18px;
  min-height: 105px;
  margin-top: 46px;
  padding: 12px 23px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font: 700 18px/24px var(--heading-font);
}
.weekly img { display: block; width: 72px; height: 72px; object-fit: contain; }

.example-chip { margin: 0 8px 12px; padding-inline: 28px; }
.example-card {
  min-height: 374px;
  padding: 18px 8px 16px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.example-prompt {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(38%, 128px);
  align-items: center;
  gap: 10px;
  min-height: 130px;
  padding: 6px 8px;
  font: 700 18px/22px var(--heading-font);
}
.example-prompt img { width: 100%; height: 108px; object-fit: contain; }
.example-card > button {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 44px;
  margin: 5px 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  text-align: start;
}
.example-card > button[aria-pressed='true'] { background: var(--subtle); font-weight: 700; }
.example-card > button[aria-pressed='true'] .selection-dot { border-color: currentColor; color: var(--primary); }
.example-card > button[data-value='efficient'][aria-pressed='true'] .selection-dot { color: var(--success, #226e53); }
.example-feedback {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 64px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--subtle);
  font: 700 18px/22px var(--heading-font);
}
.example-feedback img { width: 30px; height: 24px; }

.source-options, .step-rows { display: grid; gap: 8px; }
.onboarding[data-step='source'] main { display: flex; flex-direction: column; }
.onboarding[data-step='source'] .step-intro { flex: none; }
.source-options { overflow-y: auto; scrollbar-width: none; padding: 1px 0 9px; }
.source-options button {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 16px;
  min-height: 65px;
  padding: 6px 13px 6px 22px;
  text-align: start;
  font: 700 20px/24px var(--heading-font);
}
.source-options img { width: 26px; height: 26px; }
.source-options button[aria-pressed='true'] .selection-dot { color: var(--primary); border: 2px solid currentColor; }
.step-rows button {
  display: grid;
  grid-template-columns: 61px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  padding: 15px 16px 15px 12px;
  font: 700 18px/22px var(--heading-font);
  text-align: start;
}
.step-rows button img:not(.step-icon) { width: 58px; height: 58px; object-fit: contain; }
.step-rows .step-icon { width: 17px; height: 17px; transform: rotate(180deg); }
.step-rows button[aria-pressed='true'] .step-icon { filter: brightness(0) invert(1); }
.step-rows small, .example-feedback small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font: 400 14px/18px Inter, sans-serif;
}
.step-rows button[aria-pressed='true'] small { color: inherit; }
.center-hero { display: block; width: min(100%, 340px); height: 210px; margin: 0 auto; object-fit: contain; }
.onboarding[data-step='skip'] .step-intro,
.onboarding[data-step='diagnostic'] .step-intro { text-align: center; }
.onboarding[data-step='skip'] .step-intro h1,
.onboarding[data-step='diagnostic'] .step-intro h1 { font-size: 34px; line-height: 42px; }
.onboarding[data-step='skip'] .onboarding-header { font-style: italic; }
.onboarding[data-step='skip'] .step-intro { margin-top: 0; }
.onboarding[data-step='skip'] .center-hero { height: 229px; margin: 2px auto 12px; }
.onboarding[data-step='diagnostic'] .step-intro { margin-top: 12px; }
.onboarding[data-step='diagnostic'] .center-hero { height: 198px; }
.onboarding[data-step='skip'], .onboarding[data-step='diagnostic'] { grid-template-rows: auto minmax(0, 1fr) auto; }

.onboarding footer {
  display: grid;
  gap: 5px;
  padding: 12px 16px calc(34px + env(safe-area-inset-bottom));
  background: var(--canvas);
}
.onboarding footer .button { min-height: 48px; font-size: 18px; }
.onboarding footer p, .step-note {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
  margin-top: 20px;
}
.step-note { margin: 28px 0 8px; }
.footer-link {
  display: grid;
  min-height: 34px;
  padding: 3px;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}
.onboarding[data-step='diagnostic'] .footer-link { color: var(--primary); font-weight: 700; }
.source-sheet {
  position: fixed;
  inset: auto 0 0;
  width: min(100%, 480px);
  max-height: 90dvh;
  margin: 0 auto;
  padding: 10px 16px calc(40px + env(safe-area-inset-bottom));
  border: 1px solid var(--border);
  border-radius: 30px 30px 0 0;
  background: var(--surface);
  color: var(--ink);
}
.source-sheet::backdrop { background: rgb(0 0 0 / 19%); }
body:has(.source-sheet[open]) .onboarding-header > span {
  grid-column: 1 / -1;
  padding-left: 8px;
  text-align: start;
  font-style: italic;
}
body:has(.source-sheet[open]) .onboarding-header > a { display: none; }
.source-sheet form::before {
  display: block;
  width: 48px;
  height: 5px;
  margin: 0 auto 18px;
  border-radius: 4px;
  background: var(--subtle);
  content: '';
}
.source-sheet h2 { margin: 0 7px; font: 700 30px/38px var(--heading-font); }
.source-sheet p { margin: 3px 7px 20px; color: var(--muted); font-size: 14px; }
.source-sheet input { width: calc(100% - 10px); min-height: 49px; margin: 0 5px; padding: 0 15px; color: inherit; font: inherit; }
.source-actions { display: grid; grid-template-columns: .86fr 1fr; gap: 12px; margin-top: 20px; }
.source-actions .button { font-size: 16px; }
