:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  background: var(--page);
  color: var(--ink);
  --page: #f0f1f6;
  --ink: #25263a;
  --muted: #858fa4;
  --accent: #7839e5;
  --line: #e8e9f0;
  --surface: #fff;
  --surface-selected: #fcfaff;
  --secondary: #62677a;
  --quiet: #737d92;
  --slogan: #98a3b8;
  --shadow: rgb(37 38 58 / 6%);
  --option-shadow: rgb(37 38 58 / 4%);
  --indicator-border: #cbd0dd;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #20232c;
  --ink: #fafaff;
  --muted: #c4c9d5;
  --line: #414653;
  --surface: #2a2e38;
  --surface-selected: #332d41;
  --secondary: #d0d4de;
  --quiet: #adb5c4;
  --slogan: #c1c7d4;
  --shadow: rgb(0 0 0 / 22%);
  --option-shadow: rgb(0 0 0 / 16%);
  --indicator-border: #737b8b;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--page);
  transition: background-color 420ms ease;
}

button, a { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 460px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 20px max(12px, env(safe-area-inset-bottom));
}

.message-card {
  width: 100%;
  margin: auto 0;
  padding: clamp(26px, 7vw, 38px);
  border: 1px solid rgb(37 38 58 / 5%);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 14px 36px var(--shadow);
  transition: background-color 420ms ease, color 420ms ease, box-shadow 420ms ease;
}

.eyebrow {
  display: block;
  margin-bottom: 24px;
  color: #843be9;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .14em;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 8vw, 38px);
  line-height: 1.1;
  letter-spacing: -.045em;
  transition: color 420ms ease;
}

.message, .muted, .quiet { line-height: 1.55; }
.message { margin: 0; }
.muted { margin: 0 0 24px; color: var(--secondary); }
.error-message { white-space: pre-line; }
.quiet { margin: 22px 0 0; color: var(--quiet); font-size: 14px; }

.identity {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--surface-selected);
}

.identity + .identity { margin-top: 12px; }
.identity span { color: var(--quiet); font-size: 13px; }
.identity strong { font-size: 20px; font-variant-numeric: tabular-nums; }

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 14px 20px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(105deg, #2869f4 0%, #7838ef 55%, #d522df 100%);
  box-shadow: 0 8px 18px rgb(115 55 231 / 20%);
  color: #fff;
  font-size: 16px;
  font-weight: 750;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.primary-button:not(:disabled):active { transform: scale(.985); box-shadow: 0 4px 10px rgb(115 55 231 / 18%); }
.primary-button:disabled { opacity: .48; box-shadow: none; cursor: not-allowed; }
.primary-button svg { width: 42px; height: 42px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.primary-link { text-decoration: none; }
.primary-button:focus-visible, .back-button:focus-visible, .language-option:focus-visible, .level-option:focus-visible {
  outline: 3px solid #aa83f2;
  outline-offset: 3px;
}

.onboarding {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: calc(100dvh - max(18px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)));
}

.brand-header { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; align-items: center; padding: 0 2px 16px; }
.brand-side { display: grid; width: 38px; height: 38px; place-items: center; }
.brand-identity { display: flex; align-items: center; justify-self: center; gap: 5px; }
.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  overflow: visible;
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
:root[data-theme="dark"] .brand-mark img { filter: brightness(0) invert(1); }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { color: var(--ink); font-size: 15px; letter-spacing: .015em; transition: color 420ms ease; }
.brand-copy small { color: var(--slogan); font-size: 7px; font-weight: 750; letter-spacing: .08em; transition: color 420ms ease; }

.setup-shell { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.back-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 5px 14px var(--option-shadow);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 420ms ease, color 420ms ease, box-shadow 420ms ease;
}
.back-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 5px 14px var(--option-shadow);
  color: var(--ink);
  cursor: pointer;
  transition: background-color 420ms ease, color 420ms ease, box-shadow 420ms ease;
}
.theme-icon {
  display: block;
  width: 23px;
  height: 23px;
  background: currentColor;
  -webkit-mask: url('/assets/change-theme.svg') center / contain no-repeat;
  mask: url('/assets/change-theme.svg') center / contain no-repeat;
  transition: transform 700ms cubic-bezier(.2,.75,.25,1);
}
.theme-toggle:focus-visible { outline: 3px solid #aa83f2; outline-offset: 3px; }
.setup-stage { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 3px 2px 10px; scrollbar-width: none; }
.setup-stage::-webkit-scrollbar { display: none; }
.setup-heading { max-width: 100%; margin: 0 auto 22px; font-size: clamp(25px, 7vw, 32px); line-height: 1.16; letter-spacing: -.04em; text-align: center; }
.setup-heading-line { display: block; }
.setup-heading--native { display: flex; min-height: 2.32em; flex-direction: column; justify-content: center; align-items: center; }
.setup-options { display: grid; gap: 10px; }

.language-option, .level-option {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 14px;
  padding: 13px 15px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 7px 20px var(--option-shadow);
  text-align: left;
  cursor: pointer;
  transition: border-color 480ms cubic-bezier(.2,.75,.25,1), background-color 480ms cubic-bezier(.2,.75,.25,1), color 420ms ease, transform 480ms cubic-bezier(.2,.75,.25,1), box-shadow 480ms cubic-bezier(.2,.75,.25,1);
}
.language-option { min-height: 68px; }
.language-option:hover, .level-option:hover { transform: translateY(-1px); box-shadow: 0 9px 22px rgb(37 38 58 / 7%); }
.language-option[aria-pressed="true"], .level-option[aria-pressed="true"] {
  border-color: #9144eb;
  background: var(--surface-selected);
  box-shadow: 0 0 0 2px rgb(137 61 233 / 10%), 0 9px 22px rgb(37 38 58 / 5%);
}
.language-option img { display: block; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; object-fit: cover; }
.option-label { flex: 1; color: var(--ink); font-size: 15px; font-weight: 650; line-height: 1.3; transition: color 420ms ease; }
.option-indicator {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border: 1.5px solid var(--indicator-border);
  border-radius: 50%;
  color: #fff;
}
.option-indicator svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.65); transition: opacity 420ms ease, transform 480ms cubic-bezier(.2,.75,.25,1); }
.language-option[aria-pressed="true"] .option-indicator, .level-option[aria-pressed="true"] .option-indicator { border-color: #813be8; background: #813be8; }
.language-option[aria-pressed="true"] .option-indicator svg, .level-option[aria-pressed="true"] .option-indicator svg { opacity: 1; transform: scale(1); }

.language-options--compact { gap: 8px; }
.language-options--compact .language-option { min-height: 57px; padding: 9px 13px; border-radius: 16px; }
.language-options--compact .language-option img { width: 34px; height: 34px; }

.level-options { gap: 9px; }
.level-option { align-items: flex-start; min-height: 68px; padding: 12px 14px; gap: 12px; }
.level-copy { display: grid; flex: 1; gap: 3px; }
.level-title { color: var(--ink); font-size: 14px; font-weight: 750; line-height: 1.25; transition: color 420ms ease; }
.level-description { color: var(--quiet); font-size: 12px; line-height: 1.38; transition: color 420ms ease; }
.level-option .option-indicator { margin-top: 2px; }
.setup-footer { position: sticky; bottom: 0; z-index: 1; margin-top: auto; padding: 14px 2px 6px; background: linear-gradient(180deg, rgb(240 241 246 / 0%), var(--page) 16px); }
.setup-error { margin: 0 0 10px; color: #b42342; font-size: 13px; line-height: 1.4; }

.enter-forward { animation: enter-forward 650ms cubic-bezier(.2,.75,.25,1) both; }
.enter-backward { animation: enter-backward 650ms cubic-bezier(.2,.75,.25,1) both; }
@keyframes enter-forward { from { opacity: 0; transform: translateX(28px) scale(.985); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes enter-backward { from { opacity: 0; transform: translateX(-28px) scale(.985); } to { opacity: 1; transform: translateX(0) scale(1); } }

@media (max-height: 740px) {
  .brand-header { padding-bottom: 10px; }
  .setup-heading { margin-bottom: 16px; }
  .language-option { min-height: 61px; }
  .level-option { min-height: 62px; padding-block: 9px; }
  .setup-footer { padding-top: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
