/* ==========================================================================
   The app around the practice loop (shell.js): the bar between the four
   places, the 3D labs gallery, the welcome, dialogs and forms, the league
   and the Me screen. Tokens from ../design/tokens.css, shared pieces from
   app.css. Layout per DESIGN.md: a bar along the bottom on a phone, a rail
   down the left from 1024px.
   ========================================================================== */

/* ── The shell and its bar ───────────────────────────────────────────── */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.shell-main { flex: 1; min-width: 0; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: var(--line) solid var(--border);
  padding: 0 var(--sp-xs) env(safe-area-inset-bottom);
  box-shadow: 0 -6px 20px rgba(20, 26, 36, .06);
}
.nav-brand, .nav-account { display: none; }
.nav-item {
  min-height: 64px; display: grid; justify-items: center; align-content: center; gap: var(--sp-2xs);
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 12px; line-height: 16px; font-weight: 800;
  transition: color var(--dur-micro) var(--ease-standard);
}
a.nav-item { text-decoration: none; }
.nav-item .ico { width: 26px; height: 26px; padding: 2px 12px; box-sizing: content-box; border-radius: var(--r-full); transition: background var(--dur-short) var(--ease-standard); }
.nav-item:hover { color: var(--text); }
.nav-item[aria-current="page"] { color: var(--teal-dark); }
.nav-item[aria-current="page"] .ico { background: var(--teal-soft); }
:root[data-theme="dark"] .nav-item[aria-current="page"] { color: var(--teal-bright); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nav-item[aria-current="page"] { color: var(--teal-bright); } }
.nav-item:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: -3px; border-radius: var(--r-md); }

.topbar { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--sp-lg); }
.topbar .chips { margin-left: auto; }
.chip { border: 0; background: none; cursor: pointer; font-family: var(--font-display); }
.account-btn {
  min-height: var(--tap-min); padding: 0 var(--sp-lg);
  display: inline-flex; align-items: center; gap: var(--sp-sm);
  border: var(--line) solid var(--border); border-radius: var(--r-full);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 800; font-size: 15px; cursor: pointer; white-space: nowrap;
}
.account-btn:hover { border-color: var(--teal-bright); }
.account-btn:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.account-btn.signed { padding: 0 var(--sp-md) 0 var(--sp-xs); }
.account-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 520px) { .account-btn.signed .account-name { display: none; } .account-btn.signed { padding: 0 var(--sp-xs); } }
/* A phone's top bar holds the mark, the two numbers and three buttons, and
   no more: at 375px the name pushed the account button off the screen. The
   name goes first, then (on the narrowest phones) the theme switch, which
   Me also has. */
@media (max-width: 480px) { .top-brand .brand-name { display: none; } .topbar { gap: var(--sp-sm); padding: 0 var(--sp-md); } }
@media (max-width: 350px) { .topbar #theme-btn { display: none; } }

.view.page {
  max-width: var(--content-max); margin: 0 auto;
  padding: 0 var(--sp-lg) var(--sp-4xl);
  display: flex; flex-direction: column; gap: var(--sp-xl);
}
.page-head { display: grid; gap: var(--sp-xs); padding-top: var(--sp-sm); }
.page-head h1 { font-size: 32px; line-height: 38px; }
.page-head .sub { margin: 0; max-width: 62ch; text-wrap: pretty; }
.section-title { font-size: 19px; line-height: 26px; margin: 0 0 var(--sp-md); }
.site-foot { display: flex; flex-wrap: wrap; gap: var(--sp-lg); justify-content: center; color: var(--muted); }
.site-foot .linkish { font-size: 14px; font-weight: 700; text-decoration: none; }

@media (min-width: 1024px) {
  .shell { flex-direction: row; }
  .nav {
    position: sticky; top: 0; height: 100vh; height: 100dvh; width: var(--sidebar-w); flex: none;
    display: flex; flex-direction: column; gap: var(--sp-xs);
    padding: var(--sp-lg) var(--sp-md);
    border-top: 0; border-right: var(--line) solid var(--border); box-shadow: none;
  }
  .nav-brand { display: inline-flex; padding: var(--sp-sm) var(--sp-md) var(--sp-xl); }
  .nav-item {
    min-height: 48px; padding: 0 var(--sp-md); border-radius: var(--r-md);
    grid-auto-flow: column; justify-content: start; justify-items: start; gap: var(--sp-md);
    font-size: 16px; line-height: 22px;
  }
  .nav-item .ico { padding: 0; background: none !important; }
  .nav-item[aria-current="page"] { background: var(--teal-soft); }
  .shell-main { padding-bottom: 0; }
  .top-brand { display: none; }
}

/* ── Review: what was missed, what is due ────────────────────────────── */
.review-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-md); }
@media (max-width: 420px) { .review-row { grid-template-columns: 1fr; } }
.review-card {
  min-height: 68px; padding: var(--sp-md) var(--sp-lg);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; column-gap: var(--sp-md);
  border: var(--line) solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--card-shadow);
  font: inherit; text-align: left; cursor: pointer;
  transition: border-color var(--dur-micro) var(--ease-standard), transform var(--dur-micro) var(--ease-standard);
}
.review-card:hover:not(:disabled) { border-color: var(--teal-bright); }
.review-card:active:not(:disabled) { transform: translateY(1px); }
.review-card:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.review-card:disabled { cursor: default; box-shadow: none; }
.review-card:disabled .review-ico { background: var(--surface-2); color: var(--muted); }
.review-ico { width: 40px; height: 40px; border-radius: var(--r-full); display: grid; place-items: center; }
.review-card.mistakes .review-ico { background: color-mix(in srgb, var(--coral) 18%, transparent); color: var(--coral-ink); }
.review-card.due .review-ico { background: var(--teal-soft); color: var(--teal-dark); }
:root[data-theme="dark"] .review-card.due .review-ico { color: var(--teal-bright); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .review-card.due .review-ico { color: var(--teal-bright); } }
.review-words { display: grid; gap: var(--sp-2xs); min-width: 0; }
.review-words b { font-family: var(--font-display); font-weight: 900; font-size: 17px; line-height: 22px; }
.review-words small { color: var(--muted); font-size: 13px; line-height: 18px; font-weight: 600; }
.review-n {
  min-width: 30px; height: 30px; padding: 0 var(--sp-sm); border-radius: var(--r-full);
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 900; font-size: 15px;
}
.review-card.mistakes .review-n { background: var(--coral); color: var(--on-bright); }
.review-card.due .review-n { background: var(--teal-bright); color: var(--on-bright); }

/* ── 3D labs: a card each ────────────────────────────────────────────── */
.lab-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-md); }
.lab-card {
  display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: var(--sp-lg); align-items: center;
  padding: var(--sp-md); border: var(--line) solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); text-decoration: none; box-shadow: var(--card-shadow);
  transition: transform var(--dur-short) var(--ease-enter), border-color var(--dur-micro) var(--ease-standard);
}
.lab-card:hover { transform: translateY(-2px); border-color: var(--tint-a); }
.lab-card:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.lab-card-art {
  width: 76px; height: 76px; border-radius: var(--r-lg); display: grid; place-items: center;
  background: linear-gradient(135deg, var(--tint-a), var(--tint-b)); color: #fff;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .12);
}
.lab-icon { width: 46px; height: 46px; }
.lab-card-words { display: grid; gap: var(--sp-2xs); min-width: 0; }
.lab-card-words b { font-family: var(--font-display); font-weight: 900; font-size: 18px; line-height: 24px; }
.lab-card-words small { color: var(--muted); font-size: 13px; line-height: 18px; text-wrap: pretty; }
.lab-card-events { display: flex; flex-wrap: wrap; gap: var(--sp-xs); margin-top: var(--sp-2xs); }
.lab-card-events i {
  font-style: normal; font-size: 11px; line-height: 14px; font-weight: 800; letter-spacing: .04em;
  padding: var(--sp-2xs) var(--sp-sm); border-radius: var(--r-full); background: var(--surface-2); color: var(--muted);
}
.lab-section { display: grid; }

/* ── The welcome ─────────────────────────────────────────────────────── */
body.onboarding { overflow: hidden; }
.onboard { position: fixed; inset: 0; z-index: 60; background: radial-gradient(ellipse at 50% 30%, var(--stage-glow) 0%, var(--stage-bg) 70%); color: var(--stage-text); }
/* The scene keeps to the upper part of the screen and fades out before the
   words begin: a headline laid over the Sun cannot be read. */
.ob-stage {
  position: absolute; inset: 0 0 auto 0; width: 100%; height: 62%; opacity: 0;
  transition: opacity 900ms var(--ease-standard); touch-action: none; cursor: grab;
  -webkit-mask-image: linear-gradient(180deg, #000 62%, transparent 100%); mask-image: linear-gradient(180deg, #000 62%, transparent 100%);
}
.ob-stage.live { opacity: 1; }
.ob-shade { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(13, 17, 23, 0) 0%, rgba(13, 17, 23, .1) 40%, rgba(13, 17, 23, .9) 66%); transition: background var(--dur-long) var(--ease-standard); }
.onboard:not([data-step="0"]) .ob-shade { background: rgba(13, 17, 23, .86); }
.ob-frame {
  position: relative; height: 100%; max-width: 600px; margin: 0 auto;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: var(--sp-lg);
  padding: var(--sp-md) var(--sp-xl) calc(var(--sp-xl) + env(safe-area-inset-bottom));
  pointer-events: none;
}
.ob-frame > * { pointer-events: auto; }
.ob-top { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.ob-brand { color: var(--stage-text); }
.ob-skip, .ob-signin { color: var(--stage-text); opacity: .82; }
.ob-skip:hover, .ob-signin:hover { opacity: 1; }
.ob-body { display: grid; align-content: end; gap: var(--sp-md); overflow-y: auto; min-height: 0; }
/* The first step leaves the picture to the hand: a drag turns the planets. */
.ob-body[data-step="0"] { pointer-events: none; }
.ob-body:not([data-step="0"]) { align-content: start; padding-top: var(--sp-lg); }
.ob-kicker { margin: 0; color: var(--stage-focus); font-size: 12px; line-height: 16px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.ob-title { font-size: clamp(30px, 8vw, 42px); line-height: 1.08; text-wrap: balance; }
.ob-title.small { font-size: clamp(26px, 6.4vw, 34px); }
.ob-lead { margin: 0; font-size: 17px; line-height: 25px; color: rgba(234, 240, 242, .86); text-wrap: pretty; max-width: 46ch; }
.ob-lead.quiet { font-size: 14px; line-height: 20px; color: rgba(234, 240, 242, .66); }
.ob-stats { list-style: none; margin: var(--sp-sm) 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-sm); }
.ob-stats li { display: grid; gap: var(--sp-2xs); padding: var(--sp-md) var(--sp-sm); border-radius: var(--r-md); background: rgba(234, 240, 242, .08); border: 1px solid rgba(234, 240, 242, .14); text-align: center; }
.ob-stats b { font-family: var(--font-display); font-weight: 900; font-size: clamp(18px, 5vw, 24px); line-height: 1.1; }
.ob-stats span { font-size: 11px; line-height: 14px; font-weight: 700; color: rgba(234, 240, 242, .74); }
.ob-drag { visibility: hidden; margin: 0; display: flex; align-items: center; gap: var(--sp-sm); font-size: 13px; line-height: 18px; font-weight: 700; color: rgba(234, 240, 242, .7); }
.has-hero .ob-drag { visibility: visible; }
.ob-drag-dot { width: 18px; height: 18px; border-radius: var(--r-full); border: 2px solid var(--stage-focus); }
@media (prefers-reduced-motion: no-preference) {
  .ob-drag-dot { animation: ob-drag 1.8s var(--ease-standard) infinite; }
  .ob-body > * { animation: rise var(--dur-long) var(--ease-enter) both; }
  .ob-body > *:nth-child(2) { animation-delay: 60ms; }
  .ob-body > *:nth-child(3) { animation-delay: 120ms; }
  .ob-body > *:nth-child(4) { animation-delay: 180ms; }
  .ob-body > *:nth-child(5) { animation-delay: 240ms; }
  .ob-features li { animation: rise var(--dur-long) var(--ease-enter) both; animation-delay: calc(var(--i) * 90ms + 80ms); }
}
@keyframes ob-drag { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(10px); } }

.ob-choices { display: grid; gap: var(--sp-md); margin-top: var(--sp-sm); }
.ob-choice {
  min-height: 72px; padding: var(--sp-md) var(--sp-lg); display: grid; gap: var(--sp-2xs); text-align: left;
  border: 2px solid rgba(234, 240, 242, .18); border-radius: var(--r-lg);
  background: rgba(234, 240, 242, .06); color: var(--stage-text); font: inherit; cursor: pointer;
  transition: border-color var(--dur-micro) var(--ease-standard), background var(--dur-micro) var(--ease-standard);
}
.ob-choice b { font-family: var(--font-display); font-weight: 900; font-size: 19px; line-height: 24px; }
.ob-choice small { font-size: 14px; line-height: 20px; color: rgba(234, 240, 242, .7); }
.ob-choice:hover { border-color: rgba(234, 240, 242, .45); }
/* How do you want to study? — an icon, a name, what it is. */
.ob-mode { grid-template-columns: 48px 1fr; align-items: center; gap: var(--sp-md); }
.ob-mode > span:last-child { display: grid; gap: var(--sp-2xs); }
.ob-choice[aria-pressed="true"] { border-color: var(--stage-focus); background: rgba(46, 221, 211, .14); }
.ob-choice:focus-visible, .ob-chip:focus-visible { outline: 3px solid var(--stage-focus); outline-offset: 2px; }
.ob-search {
  /* (An input is as wide as its `size` unless told: it ran off a phone's edge.) */
  width: 100%; min-width: 0; box-sizing: border-box;
  min-height: 48px; padding: 0 var(--sp-lg); border-radius: var(--r-full);
  border: 1px solid rgba(234, 240, 242, .22); background: rgba(234, 240, 242, .08); color: var(--stage-text);
  font: inherit; font-size: 16px;
}
.ob-search::placeholder { color: rgba(234, 240, 242, .55); }
.ob-search:focus { outline: none; border-color: var(--stage-focus); }
.ob-chips { display: flex; flex-wrap: wrap; gap: var(--sp-sm); padding-bottom: var(--sp-lg); }
.ob-chip {
  min-height: 42px; padding: 0 var(--sp-lg); border-radius: var(--r-full);
  border: 1px solid rgba(234, 240, 242, .22); background: rgba(234, 240, 242, .06); color: var(--stage-text);
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.ob-chip:hover { border-color: rgba(234, 240, 242, .5); }
.ob-chip[aria-pressed="true"] { background: var(--stage-focus); border-color: var(--stage-focus); color: var(--stage-bg); }
.ob-features { list-style: none; margin: var(--sp-sm) 0 0; padding: 0; display: grid; gap: var(--sp-md); }
.ob-features li { display: grid; grid-template-columns: 48px 1fr; gap: var(--sp-md); align-items: center; padding: var(--sp-md); border-radius: var(--r-lg); background: rgba(234, 240, 242, .06); border: 1px solid rgba(234, 240, 242, .12); }
.ob-feature-ico { width: 48px; height: 48px; border-radius: var(--r-md); display: grid; place-items: center; background: rgba(46, 221, 211, .16); color: var(--stage-focus); }
.ob-feature-ico svg { width: 26px; height: 26px; }
.ob-features b { display: block; font-family: var(--font-display); font-weight: 900; font-size: 17px; line-height: 22px; }
.ob-features small { display: block; font-size: 14px; line-height: 20px; color: rgba(234, 240, 242, .74); text-wrap: pretty; }
.ob-foot { display: grid; gap: var(--sp-md); justify-items: center; }
.ob-dots { display: flex; gap: 6px; }
.ob-dots i { width: 8px; height: 8px; border-radius: var(--r-full); background: rgba(234, 240, 242, .28); transition: width var(--dur-short) var(--ease-standard); }
.ob-dots i.on { width: 22px; background: var(--stage-focus); }
.ob-actions { width: 100%; display: flex; gap: var(--sp-md); }
.ob-actions .ob-back { width: auto; padding: 0 var(--sp-2xl); flex: none; background: rgba(234, 240, 242, .1); color: var(--stage-text); border: 1px solid rgba(234, 240, 242, .2); box-shadow: none; }
.ob-next { flex: 1; background: var(--stage-focus); color: var(--stage-bg); box-shadow: 0 10px 28px -10px rgba(46, 221, 211, .7); }
.ob-signin { font-size: 14px; }

/* ── Dialogs and forms ───────────────────────────────────────────────── */
.dlg { border: 0; padding: 0; background: transparent; color: var(--text); width: min(480px, calc(100vw - 2 * var(--sp-lg))); max-height: calc(100dvh - 2 * var(--sp-lg)); }
.dlg:has(.dlg-box.wide) { width: min(560px, calc(100vw - 2 * var(--sp-lg))); }
.dlg::backdrop { background: rgba(13, 17, 23, .62); backdrop-filter: blur(3px); }
.dlg-box {
  display: grid; gap: var(--sp-lg); padding: var(--sp-2xl);
  background: var(--surface); border: var(--line) solid var(--border); border-radius: var(--r-xl);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .4);
}
@media (prefers-reduced-motion: no-preference) { .dlg[open] .dlg-box { animation: rise var(--dur-medium) var(--ease-enter); } }
.dlg-title { font-size: 24px; line-height: 30px; text-wrap: balance; }
.dlg-body { display: grid; gap: var(--sp-md); font-size: 16px; line-height: 24px; }
.dlg-body p { margin: 0; text-wrap: pretty; }
.dlg-body code { font-family: var(--font-mono); font-size: 14px; }
.dlg-actions { display: flex; flex-wrap: wrap-reverse; gap: var(--sp-md); justify-content: flex-end; align-items: center; }
.dlg-actions .cta { width: auto; flex: 1 1 140px; padding: 0 var(--sp-xl); }
.dlg-actions .linkish { margin-right: auto; padding-left: 0; }
.dlg-error { margin: 0; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-sm); background: var(--error-soft); color: var(--error-ink); font-size: 14px; line-height: 20px; font-weight: 700; }
.dlg-links { margin: 0; }
.cta.danger { background: var(--error); color: var(--on-error); box-shadow: 0 var(--depth) 0 var(--error-dark); }
.linkish.danger { color: var(--error-ink); }
.linkish.inline { padding: 0; min-height: 0; font-size: inherit; }
.form-field { display: grid; gap: var(--sp-xs); min-width: 0; }
.form-field > span { font-size: 14px; line-height: 20px; font-weight: 800; }
.form-field small { color: var(--muted); font-size: 13px; line-height: 18px; }
.form-field input {
  min-height: 50px; padding: 0 var(--sp-lg); min-width: 0;
  border: var(--line) solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 17px; font-weight: 600;
}
.form-field input:focus { outline: none; border-color: var(--teal-bright); background: var(--surface); }
.check { display: flex; gap: var(--sp-md); align-items: flex-start; font-size: 15px; line-height: 22px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--teal); }
.name-pick { display: flex; flex-wrap: wrap; gap: var(--sp-sm); }
.name-opt {
  min-height: var(--tap-min); padding: 0 var(--sp-lg); border-radius: var(--r-full);
  border: var(--line) solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 800; cursor: pointer;
}
.name-opt:hover { border-color: var(--teal-bright); }
.name-opt[aria-pressed="true"] { border-color: var(--teal-bright); background: var(--teal-soft); }
.avatar-pick { display: flex; flex-wrap: wrap; gap: var(--sp-sm); }
.avatar-opt { padding: 3px; border: 3px solid transparent; border-radius: var(--r-full); background: none; cursor: pointer; line-height: 0; }
.avatar-opt[aria-pressed="true"] { border-color: var(--teal-bright); }
.avatar-opt:focus-visible, .name-opt:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.avatar {
  display: inline-grid; place-items: center; border-radius: var(--r-full); flex: none;
  background: color-mix(in srgb, var(--avatar) 22%, var(--surface)); color: var(--avatar);
  border: 2px solid color-mix(in srgb, var(--avatar) 55%, transparent);
}
.avatar svg { width: 62%; height: 62%; }
.avatar.pic { background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--avatar) 30%, var(--surface)), color-mix(in srgb, var(--avatar) 12%, var(--surface))); overflow: hidden; }
.avatar.pic img { width: 76%; height: 76%; object-fit: contain; display: block; filter: drop-shadow(0 2px 3px rgba(13, 17, 23, .28)); }
.recovery {
  margin: 0; padding: var(--sp-lg); border-radius: var(--r-md); text-align: center;
  background: var(--surface-2); border: 2px dashed var(--border-depth);
  font-family: var(--font-mono); font-size: 24px; line-height: 30px; font-weight: 700; letter-spacing: .08em;
  user-select: all;
}
.result-art { font-size: 64px; line-height: 1; text-align: center; }

/* A switch: one thing on or off. */
.switch { width: 100%; display: flex; align-items: center; gap: var(--sp-md); padding: var(--sp-sm) 0; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; min-height: var(--tap-min); }
.switch-track { width: 46px; height: 28px; border-radius: var(--r-full); background: var(--border-depth); position: relative; flex: none; transition: background var(--dur-short) var(--ease-standard); }
.switch-track i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: var(--r-full); background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform var(--dur-short) var(--ease-reward); }
.switch[aria-checked="true"] .switch-track { background: var(--teal); }
.switch[aria-checked="true"] .switch-track i { transform: translateX(18px); }
.switch-words { display: grid; gap: var(--sp-2xs); min-width: 0; }
.switch-words b { font-size: 15px; line-height: 20px; font-weight: 800; }
.switch-words small { color: var(--muted); font-size: 13px; line-height: 18px; }
.switch:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; border-radius: var(--r-sm); }

/* ── The league ──────────────────────────────────────────────────────── */
.tier-ladder { list-style: none; margin: 0 0 var(--sp-sm); padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-sm) var(--sp-lg); }
.tier-ladder li { display: inline-flex; align-items: center; gap: var(--sp-xs); color: var(--muted); font-size: 12px; line-height: 16px; font-weight: 800; letter-spacing: .04em; opacity: .55; }
.tier-ladder li.past { opacity: .8; }
.tier-ladder li.on { opacity: 1; color: var(--text); }
.tier-gem { width: 14px; height: 14px; transform: rotate(45deg); border-radius: 3px; display: inline-block; flex: none; margin: 0 3px; background: var(--border-depth); }
.tier-ladder li.on .tier-gem { width: 18px; height: 18px; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 12%, transparent); }
.tier-0 { background: #C08457; } .tier-1 { background: #B8C2CC; } .tier-2 { background: #FFB020; }
.tier-3 { background: #38BDF8; } .tier-4 { background: #EF4444; } .tier-5 { background: #A5F3FC; }
.league-me { margin: 0; font-size: 16px; line-height: 24px; }
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-xs); }
.board-row {
  min-height: 60px; padding: var(--sp-sm) var(--sp-lg);
  display: grid; grid-template-columns: 36px 36px minmax(0, 1fr) auto; align-items: center; column-gap: var(--sp-md);
  border: var(--line) solid var(--border); border-radius: var(--r-md); background: var(--surface);
}
.board-row.me { border-color: var(--teal-bright); background: var(--teal-soft); }
.board-rank { font-family: var(--font-display); font-weight: 900; font-size: 18px; text-align: center; color: var(--muted); }
.board-row.up .board-rank { color: var(--correct-ink); }
.board-name { font-weight: 800; font-size: 16px; line-height: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-name small { margin-left: var(--sp-xs); padding: var(--sp-2xs) var(--sp-sm); border-radius: var(--r-full); background: var(--teal); color: var(--on-teal); font-size: 11px; font-weight: 800; }
.board-xp { font-family: var(--font-display); font-weight: 900; font-size: 16px; white-space: nowrap; }
.board-line { display: flex; align-items: center; gap: var(--sp-md); color: var(--correct-ink); font-size: 12px; line-height: 16px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: var(--sp-xs) 0; }
.board-line::before, .board-line::after { content: ''; flex: 1; border-top: 2px dashed color-mix(in srgb, var(--correct) 55%, transparent); }
.board-empty { padding: var(--sp-2xl) var(--sp-lg); text-align: center; color: var(--muted); border: 2px dashed var(--border); border-radius: var(--r-lg); }
.join-card { display: grid; gap: var(--sp-md); border-color: var(--teal-bright); }
.join-card .card-title { margin: 0; }
.join-card p { margin: 0; text-wrap: pretty; }
.join-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-md); }
.join-actions .cta { width: auto; flex: 1 1 200px; }
.benefits { margin: 0; padding-left: var(--sp-xl); display: grid; gap: var(--sp-xs); }
.league-note { text-align: center; }

/* ── Me ──────────────────────────────────────────────────────────────── */
.me-head { display: flex; align-items: center; gap: var(--sp-lg); padding-top: var(--sp-sm); }
.me-who { min-width: 0; }
.me-who h1 { font-size: 28px; line-height: 34px; overflow-wrap: anywhere; }
.me-who .sub { margin: var(--sp-2xs) 0 0; display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-xs); }
.me-tiles { grid-template-columns: repeat(2, 1fr); text-align: center; }
.me-tiles.four { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .me-tiles.four { grid-template-columns: repeat(4, 1fr); } }
.view.page .card { display: grid; gap: var(--sp-md); }
.view.page .card-title { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-sm); }
.card-title small { color: var(--muted); font-family: var(--font-body); font-size: 13px; line-height: 18px; font-weight: 700; }
.week-bars { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--sp-sm); align-items: end; }
.week-bars li { display: grid; gap: var(--sp-2xs); justify-items: center; font-size: 12px; line-height: 16px; font-weight: 800; color: var(--muted); }
.week-bars .bar { width: 100%; max-width: 44px; height: 96px; border-radius: var(--r-sm); background: var(--surface-2); display: flex; align-items: flex-end; overflow: hidden; }
.week-bars .bar i { display: block; width: 100%; min-height: 0; border-radius: var(--r-sm); background: var(--teal-bright); transition: height var(--dur-long) var(--ease-enter); }
.week-bars li.met .bar i { background: var(--amber); }
.week-bars li.met { color: var(--amber-ink); }
.week-bars li > span.tnum { min-height: 16px; }
.event-stats, .mastery { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-md); }
.event-stats li, .mastery li { display: grid; grid-template-columns: 1fr auto; column-gap: var(--sp-md); row-gap: var(--sp-xs); align-items: baseline; font-size: 15px; line-height: 20px; }
.event-stats .name, .mastery .name { font-weight: var(--label-w); min-width: 0; }
.event-stats .pct, .mastery .pct { color: var(--muted); font-size: 13px; font-weight: 800; white-space: nowrap; }
.mastery .pct.weak { color: var(--amber-ink); }
.event-stats .track, .mastery .track { grid-column: 1 / -1; height: 8px; }
.event-stats .track i, .mastery .track i { background: var(--teal-bright); box-shadow: none; }
.badges { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: var(--sp-md); }
.badges li { display: grid; gap: var(--sp-2xs); justify-items: center; text-align: center; padding: var(--sp-md) var(--sp-sm); border: var(--line) solid var(--border); border-radius: var(--r-lg); opacity: .5; }
.badges li.got { opacity: 1; border-color: var(--amber); background: color-mix(in srgb, var(--amber) 9%, transparent); }
.badge-art { font-size: 26px; line-height: 30px; color: var(--amber-dark); }
.badges b { font-family: var(--font-display); font-weight: 900; font-size: 15px; }
.badges small { color: var(--muted); font-size: 12px; line-height: 16px; }
.set-rows { display: grid; gap: var(--sp-xs); }
.me-name { margin: 0; font-weight: 800; }

/* 3D Labs, sorted by event: a menu over the grid. */
.labs-filter { display: grid; gap: var(--sp-2xs); max-width: 360px; margin-bottom: var(--sp-lg); }
.labs-filter select { min-height: var(--tap-min); padding: 0 var(--sp-md); border-radius: var(--r-md); border: var(--line) solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; }

/* The way to an account (shell.js): what a guest has on this device, in
   their own numbers. Amber, because these are things earned. */
.join-stakes { font-family: var(--font-display); font-weight: 700; font-size: 17px; line-height: 24px; }
.join-stakes b { color: var(--amber-ink); font-weight: 900; }
:root[data-theme="dark"] .join-stakes b { color: var(--amber); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .join-stakes b { color: var(--amber); } }
.join-card.has-stakes { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 7%, var(--surface)); }
.account-btn.keep { border-color: var(--amber); font-weight: 700; }
.account-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: var(--r-full); background: var(--coral); vertical-align: middle; }

/* ── Characters (avatar.js, 2026-11-15) ───────────────────────────────────
   A character a student builds from an illustrator's parts, on a backdrop,
   inside a ring that changes every five levels. The emblem worn is pinned
   to its corner. The ring's metals are not design tokens: they are the
   metals (bronze, silver, gold), as the league's gems are theirs. */
.avatar.look {
  position: relative; overflow: visible; background: var(--back, var(--surface-2)); color: inherit;
  border: 0; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ring, var(--border-depth));
}
.avatar.look > img:first-child { width: 100%; height: 100%; display: block; border-radius: inherit; object-fit: cover; }
.avatar.look.kind-r > img:first-child { transform: scale(.86) translateY(4%); }
.avatar.look.kind-x > img:first-child { image-rendering: pixelated; }
.avatar.look.tier-1 { --ring: #C8894B; }
.avatar.look.tier-2 { --ring: #A9B4C2; }
.avatar.look.tier-3 { --ring: var(--amber); }
.avatar.look.tier-4 { box-shadow: 0 0 0 2px var(--surface); }
.avatar.look.tier-4::before {
  content: ""; position: absolute; inset: -5px; border-radius: inherit; z-index: -1;
  background: conic-gradient(from 210deg, var(--teal-bright), #818CF8, #F472B6, var(--amber), var(--teal-bright));
}
.avatar-badge {
  position: absolute; right: -8%; bottom: -8%; width: 42%; height: 42%; object-fit: contain;
  padding: 6%; border-radius: var(--r-full); background: var(--surface); box-shadow: 0 0 0 1px var(--border);
}
/* (A league row and the top bar are small: the ring is thinner there.) */
.board-row .avatar.look, .account-btn .avatar.look, .av-opt .avatar.look { box-shadow: 0 0 0 1px var(--surface), 0 0 0 3px var(--ring, var(--border-depth)); }
.board-row .avatar.look.tier-4, .account-btn .avatar.look.tier-4 { box-shadow: 0 0 0 1px var(--surface); }
.board-row .avatar.look.tier-4::before, .account-btn .avatar.look.tier-4::before { inset: -3px; }

/* A picture of the student's own (avatar.js): the same disc, ring and badge. */
.avatar.look.photo { background: var(--surface-2); }
.avatar.look.photo > img:first-child { width: 100%; height: 100%; display: block; border-radius: inherit; object-fit: cover; }

/* "Your picture": the file chosen, in the circle it will be shown in. */
.ph-build { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--sp-lg); align-items: center; }
.ph-stage { position: relative; width: 168px; height: 168px; border-radius: var(--r-full); overflow: hidden; background: var(--surface-2); box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px var(--border-depth); }
.ph-canvas { display: none; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.ph-canvas.on { display: block; }
.ph-canvas:active { cursor: grabbing; }
.ph-canvas:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: -3px; }
.ph-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.ph-empty[hidden] { display: none; }
.ph-empty svg { width: 56px; height: 56px; }
.ph-empty img { width: 100%; height: 100%; object-fit: cover; }
.ph-side { display: grid; gap: var(--sp-md); min-width: 0; }
.ph-pick { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-sm); cursor: pointer; text-align: center; }
.ph-pick svg { width: 22px; height: 22px; flex: none; }
/* The input itself is out of sight; its label is the button. */
.ph-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ph-file:focus-visible + .ph-zoom, .ph-pick:focus-within { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.ph-zoom { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-md); align-items: center; font-size: 14px; font-weight: 700; color: var(--muted); }
.ph-zoom[hidden] { display: none; }
.ph-zoom input { width: 100%; accent-color: var(--teal); }
.ph-note { margin: 0; font-size: 14px; line-height: 20px; color: var(--muted); text-wrap: pretty; }
.ph-private { grid-column: 1 / -1; margin: 0; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-md); background: var(--surface-2); font-size: 14px; line-height: 20px; text-wrap: pretty; }
.ph-more { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--sp-xs) var(--sp-lg); }
.ph-more .linkish { padding-left: 0; font-size: 14px; }
@media (max-width: 480px) {
  .ph-build { grid-template-columns: 1fr; justify-items: center; }
  .ph-side { width: 100%; }
}

/* The character on the Me page: itself the way in to the builder. */
.me-face { position: relative; padding: 0; border: 0; background: none; cursor: pointer; line-height: 0; border-radius: var(--r-full); flex: none; }
.me-face:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 6px; }
.me-face .me-edit {
  position: absolute; left: -6px; bottom: -6px; width: 30px; height: 30px; border-radius: var(--r-full); display: grid; place-items: center;
  background: var(--surface); color: var(--text); border: var(--line) solid var(--border-depth); box-shadow: 0 2px 6px rgba(13, 17, 23, .18);
}
.me-face .me-edit svg { width: 16px; height: 16px; }
.me-who .me-dress { margin-top: var(--sp-xs); }

/* The builder. */
.av-build { display: grid; gap: var(--sp-md); min-width: 0; }
.av-top { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-lg); align-items: center; }
.av-preview { padding: 6px; line-height: 0; }
.av-side { display: grid; gap: var(--sp-sm); justify-items: start; min-width: 0; }
.av-level { margin: 0; font-size: 14px; line-height: 20px; color: var(--muted); }
.av-level b { color: var(--text); font-family: var(--font-display); font-weight: 900; font-size: 16px; }
.av-kinds { display: flex; flex-wrap: wrap; gap: var(--sp-xs); }
.av-kind, .av-part, .av-dice, .pill-btn {
  min-height: 40px; padding: 0 var(--sp-md); border-radius: var(--r-full); font: inherit; font-size: 14px; line-height: 20px; font-weight: 800; cursor: pointer;
  border: var(--line) solid var(--border-depth); background: var(--surface); color: var(--text); white-space: nowrap;
}
.av-kind small { font-weight: 700; color: var(--muted); }
.av-kind.locked { color: var(--muted); border-style: dashed; }
.av-kind[aria-pressed="true"], .av-part[aria-selected="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }
.av-dice, .pill-btn { background: var(--surface-2); }
.avatar-pick.up-look { align-items: center; gap: var(--sp-lg); flex-wrap: nowrap; padding: 6px; }
.up-look-side { display: grid; gap: var(--sp-xs); justify-items: start; }
.av-kind:focus-visible, .av-part:focus-visible, .av-dice:focus-visible, .av-opt:focus-visible { outline: 3px solid var(--teal-bright); outline-offset: 2px; }
.av-parts { display: flex; gap: var(--sp-xs); overflow-x: auto; padding: 2px 2px var(--sp-xs); scrollbar-width: thin; }
.av-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: var(--sp-sm);
  /* (Whatever the screen leaves after the rest of the builder: the choices
     scroll, the character and the Save button never do.) */
  height: clamp(132px, calc(100dvh - 590px), 330px); overflow-y: auto; padding: 6px; align-content: start;
  border-radius: var(--r-md); background: var(--surface-2);
}
.av-grid.swatches { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
.av-opt {
  position: relative; display: grid; place-items: center; padding: 6px; aspect-ratio: 1; line-height: 0; cursor: pointer;
  border: 3px solid transparent; border-radius: var(--r-md); background: none;
}
.av-opt[aria-pressed="true"] { border-color: var(--teal-bright); background: var(--surface); }
.av-opt .avatar.look { width: 100% !important; height: 100% !important; }
.av-swatch { display: block; width: 100%; height: 100%; border-radius: var(--r-full); box-shadow: inset 0 0 0 2px rgba(13, 17, 23, .12); }
.av-opt.locked .avatar.look { opacity: .42; filter: saturate(.35); }
.av-opt.locked .av-swatch { opacity: .6; }
.av-lock {
  position: absolute; right: 0; bottom: 0; padding: 1px 6px; border-radius: var(--r-full); font-size: 11px; line-height: 16px; font-weight: 800;
  background: var(--text); color: var(--surface);
}
.av-note { margin: 0; min-height: 20px; font-size: 14px; line-height: 20px; font-weight: 700; color: var(--amber-ink); }
.av-credit { margin: 0; font-size: 12px; line-height: 16px; color: var(--muted); }
.dlg-box:has(.av-build) { gap: var(--sp-md); }
.dlg-box:has(.av-build) .dlg-actions { flex-wrap: nowrap; }
.dlg-box:has(.av-build) .dlg-actions .cta { flex: 1 1 0; }
.av-dice svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
@media (max-width: 480px) {
  .dlg-box:has(.av-build) { padding: var(--sp-lg); }
  .dlg-box:has(.av-build) .dlg-title { font-size: 20px; line-height: 26px; }
  .av-top { gap: var(--sp-md); }
  .av-preview .avatar.look { width: 104px !important; height: 104px !important; }
  .av-grid { height: clamp(132px, calc(100dvh - 500px), 330px); }
}
/* What a level opened, on the summary. */
.levelup-parts { display: flex; align-items: center; gap: var(--sp-md); margin: var(--sp-sm) auto 0; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-lg); background: var(--surface-2); max-width: 420px; text-align: left; }
.levelup-parts p { margin: 0; font-size: 14px; line-height: 20px; flex: 1; }
.levelup-parts b { display: block; font-size: 16px; }
