/* First-visit setup. Independent from the settings pop-up; follows the active theme. */
.onboarding {
  width: min(1060px, calc(100% - 32px));
  height: min(720px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--modal-bg);
  box-shadow: var(--shadow-strong);
}
.onboarding::backdrop { background: var(--bg); }
.onboarding[open] { animation: ob-enter 560ms cubic-bezier(.2, .9, .25, 1) both; }
.onboarding.is-closing { animation: none; }

.ob-shell { position: relative; isolation: isolate; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
.ob-ambient { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.ob-ambient span { position: absolute; width: 420px; height: 420px; border-radius: 50%; background: var(--accent); filter: blur(110px); opacity: .13; animation: ob-drift 18s ease-in-out infinite alternate; }
.ob-ambient span:nth-child(1) { top: -180px; left: -120px; }
.ob-ambient span:nth-child(2) { right: -160px; bottom: -200px; opacity: .1; animation-duration: 22s; animation-delay: -6s; }
.ob-ambient span:nth-child(3) { top: 30%; left: 45%; width: 260px; height: 260px; opacity: .06; animation-duration: 15s; animation-delay: -3s; }

.ob-top { display: flex; align-items: center; gap: 24px; padding: 22px 28px 0; }
.ob-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; font-weight: 800; }
.ob-logo { display: grid; place-items: center; width: 34px; height: 34px; color: var(--on-accent); border-radius: 11px; background: var(--accent); font-size: 13px; font-weight: 900; letter-spacing: -.02em; }
.ob-progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: min(300px, 40%); margin-left: auto; transition: opacity 300ms ease; }
.onboarding[data-step="welcome"] .ob-progress { opacity: 0; }
.ob-progress i { position: relative; height: 6px; overflow: hidden; border-radius: 3px; background: var(--line); }
.ob-progress i::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform 520ms cubic-bezier(.3, .8, .2, 1); }
.ob-progress i.active::after { transform: scaleX(.5); }
.ob-progress i.done::after { transform: scaleX(1); }
.ob-close { display: grid; place-items: center; flex: 0 0 auto; font-size: 20px; }
.ob-close[hidden] { display: none; }
.onboarding[data-step="welcome"] .ob-close:not([hidden]) { margin-left: auto; }

.ob-body { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(300px, .88fr); gap: 28px; min-height: 0; padding: 18px 28px 0 56px; }
.ob-main { min-width: 0; min-height: 0; overflow-y: auto; padding: 6px 8px 20px 0; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.ob-step:focus-visible, .ob-step h2:focus { outline: none; }
.ob-kicker { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px; color: var(--accent-ink); font-size: 13px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.ob-kicker i { font-size: 20px; transform-origin: 70% 80%; animation: ob-wave 1.6s ease-in-out 400ms 2; }
.ob-step h2 { margin: 0; font-size: clamp(30px, 3.3vw, 44px); line-height: 1.08; letter-spacing: -.04em; }
.onboarding[data-step="welcome"] .ob-step h2 { font-size: clamp(38px, 4.6vw, 60px); }
.ob-step h2 span { color: var(--accent-ink); }
.ob-copy { max-width: 520px; margin: 14px 0 26px; color: var(--muted); font-size: 16px; line-height: 1.55; }

.ob-features { display: grid; gap: 10px; margin: 0 0 22px; padding: 0; list-style: none; }
.ob-features li { display: flex; align-items: center; gap: 14px; padding: 13px 16px 13px 13px; border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb, var(--surface-2) 80%, transparent); animation: ob-rise 520ms cubic-bezier(.2, .8, .25, 1) both; animation-delay: calc(200ms + var(--i) * 90ms); }
.ob-features li > i { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; color: var(--accent-ink); border-radius: 13px; background: var(--accent-soft); font-size: 21px; }
.ob-features span { display: grid; gap: 2px; }
.ob-features strong { font-size: 15px; }
.ob-features small { color: var(--muted); font-size: 13px; line-height: 1.4; }
.ob-note { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--faint); font-size: 13px; }
.ob-note i { color: var(--accent-ink); font-size: 17px; }

.ob-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.ob-field + .ob-field { margin-top: 24px; }
.ob-field legend { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 0; color: var(--text-2); font-size: 13px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.ob-field legend i { color: var(--accent-ink); font-size: 17px; }
.ob-field.invalid legend, .ob-course.invalid .ob-course-label { color: var(--danger-text); }
.ob-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ob-tile { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 12px 14px; color: var(--text); text-align: left; border: 1.5px solid var(--line-strong); border-radius: 16px; background: var(--surface-2); cursor: pointer; transition: border-color 160ms ease, background-color 160ms ease, transform 140ms ease, box-shadow 200ms ease; }
.ob-tile:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.ob-tile:active { transform: scale(.98); }
.ob-tile:focus-visible, .ob-segmented button:focus-visible, .ob-switch:focus-visible, .ob-next:focus-visible, .ob-back:focus-visible, .ob-close:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
.ob-tile[aria-checked="true"] { border-color: var(--accent); background: var(--accent-surface); box-shadow: 0 0 0 4px var(--accent-soft); animation: ob-pop 340ms cubic-bezier(.2, 1.3, .3, 1); }
.ob-field.invalid .ob-tile { border-color: color-mix(in srgb, var(--danger) 70%, transparent); }
.ob-radio { position: relative; flex: 0 0 auto; width: 22px; height: 22px; border: 2px solid var(--line-strong); border-radius: 50%; transition: border-color 160ms ease; }
.ob-radio::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); transform: scale(0); transition: transform 260ms cubic-bezier(.2, 1.5, .3, 1); }
.ob-tile[aria-checked="true"] .ob-radio { border-color: var(--accent); }
.ob-tile[aria-checked="true"] .ob-radio::after { transform: scale(1); }
.ob-tile-copy { display: grid; gap: 2px; min-width: 0; }
.ob-tile-copy strong { font-size: 15px; line-height: 1.2; }
.ob-tile-copy small { color: var(--muted); font-size: 12px; font-weight: 600; }

.ob-courses { display: grid; gap: 10px; }
.ob-course { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 10px 10px 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-2); }
.ob-course.invalid { border-color: color-mix(in srgb, var(--danger) 70%, transparent); }
.ob-course-label { display: inline-flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800; }
.ob-course-label i { color: var(--accent-ink); font-size: 22px; }
.ob-segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.ob-segmented button { min-width: 100px; min-height: 44px; padding: 0 14px; color: var(--muted); border: 0; border-radius: 11px; background: transparent; cursor: pointer; font-size: 14px; font-weight: 800; transition: color 160ms ease, background-color 200ms ease, transform 120ms ease, box-shadow 200ms ease; }
.ob-segmented button:hover { color: var(--text-strong); }
.ob-segmented button:active { transform: scale(.96); }
.ob-segmented button[aria-checked="true"] { color: var(--on-accent); background: var(--accent); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 32%, transparent); animation: ob-pop 320ms cubic-bezier(.2, 1.3, .3, 1); }

.ob-switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 16px 18px; color: var(--text); text-align: left; border: 1.5px solid var(--line-strong); border-radius: 16px; background: var(--surface-2); cursor: pointer; transition: border-color 160ms ease, background-color 160ms ease; }
.ob-switch[aria-checked="true"] { border-color: var(--accent); background: var(--accent-surface); }
.ob-switch > span:first-child { display: grid; gap: 3px; }
.ob-switch strong { font-size: 15px; }
.ob-switch small { color: var(--muted); font-size: 13px; }
.ob-switch .switch-track { flex: 0 0 auto; }
.ob-switch[aria-checked="true"] .switch-track { background: var(--accent); }
.ob-switch[aria-checked="true"] .switch-thumb { transform: translateX(20px); }

/* The plan on the right fills in step by step. */
.ob-preview { display: grid; align-content: center; min-width: 0; padding-bottom: 24px; }
.ob-card { display: grid; gap: 12px; padding: 20px; border: 1px solid var(--line); border-radius: 26px; background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: var(--shadow); backdrop-filter: blur(12px); transform: rotate(1.2deg); animation: ob-card-in 700ms cubic-bezier(.2, .9, .25, 1.05) 150ms both; }
.ob-card-head { display: flex; align-items: baseline; justify-content: space-between; }
.ob-card-head span { color: var(--accent-ink); font-size: 11px; font-weight: 850; letter-spacing: .1em; }
.ob-card-head strong { font-size: 18px; letter-spacing: -.02em; }
.ob-days { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; color: var(--faint); font-size: 10px; letter-spacing: .06em; text-align: center; }
.ob-week { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.ob-week i { height: 30px; border: 1.5px dashed var(--line-strong); border-radius: 8px; transition: border-color 200ms ease; }
.ob-week i.on { border: 0; border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 18%, var(--surface-high)); animation: ob-lesson 460ms cubic-bezier(.2, 1.3, .3, 1) var(--d) both; }
.ob-summary { display: grid; gap: 2px; margin: 4px 0 0; padding: 10px 0 0; list-style: none; border-top: 1px solid var(--line); }
.ob-summary li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 30px; color: var(--muted); font-size: 13px; }
.ob-summary li i { color: var(--faint); font-size: 16px; }
.ob-summary li strong { max-width: 170px; overflow: hidden; color: var(--fainter); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.ob-summary li.filled i { color: var(--accent-ink); }
.ob-summary li.filled strong { color: var(--text-strong); animation: ob-value 360ms cubic-bezier(.2, 1.3, .3, 1); }

.ob-done { display: grid; justify-items: center; align-content: center; min-height: 100%; padding-top: 40px; text-align: center; }
.ob-done .ob-copy { margin-bottom: 0; }
.ob-done-mark { width: 104px; height: 104px; margin-bottom: 22px; }
.ob-done-mark circle { fill: var(--accent); transform-origin: center; animation: ob-pop-in 520ms cubic-bezier(.2, 1.4, .3, 1) both; }
.ob-done-mark path { fill: none; stroke: var(--on-accent); stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: ob-draw 420ms ease-out 380ms forwards; }
.onboarding[data-step="done"] .ob-actions { visibility: hidden; }

.ob-actions { display: grid; gap: 8px; padding: 14px 28px 24px 56px; }
.ob-error { min-height: 18px; margin: 0; color: var(--danger-text); font-size: 13px; font-weight: 750; }
.ob-buttons { display: flex; align-items: center; gap: 12px; max-width: calc(56% + 10px); }
.ob-back, .ob-next { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 56px; border: 0; border-radius: 16px; cursor: pointer; font-size: 16px; font-weight: 850; }
.ob-back { padding: 0 18px; color: var(--muted); background: transparent; transition: color 160ms ease, background-color 160ms ease; }
.ob-back:hover { color: var(--text-strong); background: var(--control); }
.ob-back[hidden] { display: none; }
.ob-next { flex: 1; padding: 0 22px; color: var(--on-accent); background: var(--accent); box-shadow: 0 5px 0 var(--accent-press), 0 14px 30px color-mix(in srgb, var(--accent) 22%, transparent); transition: background-color 160ms ease, transform 140ms ease, box-shadow 140ms ease; }
.ob-next:hover { background: var(--accent-hover); transform: translateY(-1px); }
.ob-next:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--accent-press); }
.ob-next i { font-size: 20px; transition: transform 200ms ease; }
.ob-next:hover i { transform: translateX(4px); }

@keyframes ob-enter { from { opacity: 0; transform: translateY(24px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes ob-drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(60px, 40px) scale(1.15); } }
@keyframes ob-wave { 0%, 100% { transform: rotate(0); } 20%, 60% { transform: rotate(16deg); } 40%, 80% { transform: rotate(-8deg); } }
@keyframes ob-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes ob-pop { 0% { transform: scale(.96); } 60% { transform: scale(1.03); } 100% { transform: none; } }
@keyframes ob-card-in { from { opacity: 0; transform: translateY(24px) rotate(4deg) scale(.95); } to { opacity: 1; transform: rotate(1.2deg); } }
@keyframes ob-lesson { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes ob-value { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
@keyframes ob-pop-in { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes ob-draw { to { stroke-dashoffset: 0; } }

@media (max-width: 900px) {
  .ob-body { grid-template-columns: minmax(0, 1fr); padding-left: 32px; padding-right: 32px; }
  .ob-preview { display: none; }
  .ob-actions { padding-left: 32px; padding-right: 32px; }
  .ob-buttons { max-width: none; }
}
@media (max-width: 760px) {
  .onboarding { inset: 0; width: 100vw; height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .ob-top { gap: 14px; padding: max(16px, env(safe-area-inset-top)) 20px 0; }
  .ob-brand span:last-child { display: none; }
  .ob-progress { width: auto; flex: 1; }
  .ob-body { padding: 8px 20px 0; }
  .ob-main { padding: 14px 2px 20px 0; overscroll-behavior: contain; }
  .ob-step h2 { font-size: clamp(27px, 7.4vw, 34px); }
  .onboarding[data-step="welcome"] .ob-step h2 { font-size: clamp(34px, 10vw, 44px); }
  .ob-copy { margin: 10px 0 20px; font-size: 15px; }
  .ob-tiles { grid-template-columns: 1fr; gap: 8px; }
  .ob-tile { min-height: 54px; }
  .ob-course { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px; }
  .ob-segmented button { min-width: 0; }
  .ob-features li { padding: 11px 13px 11px 11px; }
  .ob-actions { padding: 10px 20px max(16px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--modal-bg) 92%, transparent); backdrop-filter: blur(12px); }
  .ob-error:empty { display: none; }
  .ob-back, .ob-next { min-height: 54px; }
  .ob-back span { display: none; }
  .ob-next { box-shadow: 0 4px 0 var(--accent-press); }
}
@media (prefers-reduced-motion: reduce) {
  .onboarding[open], .ob-ambient span, .ob-features li, .ob-card, .ob-week i.on, .ob-kicker i, .ob-done-mark circle { animation: none; }
  .ob-done-mark path { animation: none; stroke-dashoffset: 0; }
}
[data-motion="off"] .ob-done-mark path { stroke-dashoffset: 0; }
