:root {
  --portal-neon: #bd87ff;
  --portal-graphite: #17141e;
  --portal-focus: #a66af7;
  --portal-muted-dark: #bcb1cb;
}

/* Sign-in */
:root:has(body.signed-out),
:root body.signed-out { background: #09070c; }

#login-halftone {
  position: fixed;
  z-index: 0;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 63% 42%, #cd98ff, #8658b2 29%, #3c2455 62%, #251c32) 0 0 / 160% 150% no-repeat,
    radial-gradient(circle, #8346d3 0 1.05px, #09070c 1.7px) 0 0 / 11px 11px;
  background-blend-mode: multiply, normal;
  mask-image: linear-gradient(#000 78%, transparent 100%);
}

body.signed-out #login-halftone { display: block; }

@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  body.signed-out #login-halftone:not([data-webgl]) { animation: login-halftone-drift 18s ease-in-out infinite alternate; }
}

@keyframes login-halftone-drift {
  to { background-position: 100% 100%, 0 0; }
}

#auth-screen:not([hidden]) {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  min-height: 100dvh;
  padding: max(22px, env(safe-area-inset-top)) 20px max(18px, env(safe-area-inset-bottom));
  color-scheme: dark;
  background: transparent;
}

#auth-screen::before,
#auth-screen::after { content: none; }

#auth-content { min-width: 0; width: 100%; }

.portal-login {
  width: min(100%, 398px);
  min-width: 0;
  margin-inline: auto;
  padding: 28px;
  border: 1px solid #d7b0ff30;
  border-radius: 20px;
  background:
    radial-gradient(ellipse at 50% 0, #a063f020, transparent 58%),
    linear-gradient(164deg, #20192bdb, #131018e6 75%);
  box-shadow: 0 20px 56px #07050bc4;
  backdrop-filter: blur(3px);
  color: #f8f3ff;
  text-align: center;
}

.login-brand { display: grid; justify-items: center; gap: 8px; margin-bottom: 19px; }
.login-brand img { width: 46px; height: 46px; border-radius: 12px; box-shadow: 0 5px 18px #993eff37; }
.login-brand span { color: #e4d7f0; font-size: 13px; font-weight: 700; }

.portal-login h1 {
  margin: 0 0 8px;
  color: #f8f3ff;
  font-size: 29px;
  line-height: 1.16;
  letter-spacing: -.035em;
  text-wrap: balance;
}

.portal-login .login-instruction {
  margin: 0 0 19px;
  color: var(--portal-muted-dark);
  font-size: 14px;
  line-height: 1.55;
}

.login-roles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid #392d46;
  border-radius: 11px;
  background: #15121b;
}

.login-roles button {
  min-height: 40px;
  padding: 5px 3px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #cbbfdb;
  font-size: 13px;
  font-weight: 700;
  transition: background-color .18s, color .18s;
}

.login-roles button[aria-pressed=true] {
  border-color: #74519b;
  background: #3b2850;
  color: #f9f1ff;
}

.login-roles button:hover:not(:disabled, [aria-pressed=true]) { background: #272032; }
.portal-login form { display: grid; gap: 12px; text-align: left; }
.login-field { display: grid; gap: 6px; }
.portal-login .login-field label { color: #e9dff3; font-size: 13px; font-weight: 700; }

.portal-login .login-field input {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  border: 1px solid #4a3b57;
  border-radius: 9px;
  background: #17131e;
  color: #f8f3ff;
  caret-color: var(--portal-neon);
  font-size: 16px;
  transition: border-color .18s, box-shadow .18s;
}

.portal-login .login-field input::placeholder { color: #aa9cb8; font-size: 14px; }
.portal-login .login-field input:focus { border-color: var(--portal-neon); box-shadow: 0 0 0 3px #bd87ff25; outline: none; }
.login-code { position: relative; }
.portal-login .login-code input { padding-right: 54px; }

.login-code button {
  position: absolute;
  inset: 2px 3px 2px auto;
  display: grid;
  place-items: center;
  width: 44px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #b9a5cc;
}

.login-code button svg { width: 18px; height: 18px; stroke-width: 1.7; }
.login-code button:hover, .login-code button[aria-pressed=true] { color: #f1d8ff; background: #2c2139; }
.portal-login .login-error { margin: 0; color: #ffb0c8; font-size: 13px; overflow-wrap: anywhere; }
.login-error:empty { display: none; }

.login-submit {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 14px;
  margin-top: 2px;
  border: 1px solid #d0a3ff;
  border-radius: 9px;
  background: #bb83fc;
  color: #241432;
  box-shadow: 0 7px 22px #a153ee37;
  font-size: 14px;
  font-weight: 800;
  transition: background-color .18s, box-shadow .18s;
}

.login-submit svg { width: 16px; height: 16px; }
.login-submit:hover:not(:disabled) { background: #d0a6ff; box-shadow: 0 8px 26px #a153ee52; }
.login-submit:disabled { opacity: .72; }
.login-demo {
  display: grid;
  place-content: center;
  gap: 3px;
  min-height: 52px;
  padding: 8px 14px;
  border: 1px solid #76509c;
  border-radius: 9px;
  background: #2a1d38;
  color: #f3e6ff;
  text-align: center;
  line-height: 1.35;
}
.login-demo:hover:not(:disabled) { background: #39264d; border-color: #c38ff7; }
.login-demo:disabled { opacity: .72; }
.login-demo span { color: #e0cbee; font-size: 12px; }
.portal-login .login-help { margin: 13px 0 0; color: var(--portal-muted-dark); font-size: 12px; line-height: 1.55; }

/* Workspace atmosphere */
body:not(.signed-out) {
  --aurora-violet: #a86bf647;
  --aurora-lilac: #d49bf644;
  --aurora-indigo: #7773e533;
  --aurora-ribbon: #9764f321;
  isolation: isolate;
}

:root[data-theme=dark] body:not(.signed-out) {
  --aurora-violet: #a04dfc51;
  --aurora-lilac: #b265d638;
  --aurora-indigo: #5f57eb42;
  --aurora-ribbon: #ae68ff36;
}

body:not(.signed-out)::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 91% 36% at 28% 0%, transparent 47%, var(--aurora-ribbon) 63%, transparent 80%),
    radial-gradient(ellipse 72% 33% at 21% 6%, var(--aurora-violet), transparent 74%),
    radial-gradient(ellipse 44% 65% at 95% 38%, var(--aurora-lilac), transparent 79%),
    radial-gradient(ellipse 68% 34% at 50% 100%, var(--aurora-indigo), transparent 80%);
}

@media (prefers-reduced-motion: no-preference) {
  body:not(.signed-out)::before { animation: workspace-aurora 18s ease-in-out infinite alternate; }
  body[data-portal-hidden]::before { animation-play-state: paused; }
}

@keyframes workspace-aurora {
  from { transform: scale(1.04); }
  to { transform: scale(1.16) translate(2%, -2%); }
}

@media (any-hover: hover) and (any-pointer: fine) and (prefers-reduced-motion: no-preference) {
  body:not(.signed-out)[data-portal-pointer]::after {
    content: "";
    position: fixed;
    inset: 0 auto auto 0;
    z-index: 25;
    width: 144px;
    height: 144px;
    pointer-events: none;
    background: radial-gradient(circle, #d5aaff9e 0, #ae69ff52 7%, #a958ff36 16%, #9343f51c 35%, transparent 69%);
    transform: translate3d(calc(var(--pointer-x) - 50%), calc(var(--pointer-y) - 50%), 0);
  }
}

/* Navigation */
body > aside::before, body > aside::after { display: none; }
body > aside .sidebar-brand { padding: 2px 0 28px; }
body > aside .sidebar-brand > span,
body > aside .sidebar-brand > strong {
  background: none;
  color: #eee3fa;
}

body > aside .sidebar-brand > strong { color: #d8afff; }
body > aside .sidebar-brand i { color: #c995ff; }

#nav {
  --dock-tint: #f0e6f978;
  --dock-sheen-start: #fff5;
  --dock-sheen-end: #906ab61c;
  --dock-ink: #39264f;
  --dock-current: #3a2060;
  --dock-hover: #ffffff70;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-auto-flow: row;
  grid-auto-columns: auto;
  grid-auto-rows: minmax(47px, 1fr);
  width: 100%;
  height: auto;
  padding: 14px 8px 14px 24px;
  gap: 4px;
  overflow: visible;
}

:root[data-theme=dark] #nav {
  --dock-tint: #29233766;
  --dock-sheen-start: #ddcaff28;
  --dock-sheen-end: #8e54c41c;
  --dock-ink: #e2d6ef;
  --dock-current: #fff5ff;
  --dock-hover: #c9a1ff26;
}

#nav > a {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  justify-content: start;
  gap: 11px;
  min-width: 0;
  min-height: 47px;
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: var(--dock-ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  text-align: left;
  transform: none;
  transition: none;
}

#nav > a:hover:not([aria-current]) { color: var(--dock-current); background-color: var(--dock-hover); transform: none; }
#nav > a[aria-current] { background: transparent; }
#nav .navicon { width: 22px; height: 22px; color: inherit; }
#nav :is(.navicon, .dock-orb, .dock-icon-flight) svg { width: 19px; height: 19px; filter: none; }
#nav :is(.navicon, .dock-orb, .dock-icon-flight) .dock-exchange-glyph { width: 21px; height: 21px; }
#nav > a[aria-current] .navicon, #nav .navicon[data-dock-flight] { opacity: 0; }
#nav .nav-label { overflow-wrap: anywhere; }

.dock-glass, .dock-surface {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.dock-glass {
  z-index: -1;
  clip-path: url(#dock-glass-clip);
  background: linear-gradient(145deg, var(--dock-sheen-start), var(--dock-sheen-end)), var(--dock-tint);
  backdrop-filter: blur(18px) saturate(160%);
}

.dock-orb {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 21%, #f2dfff, #c994ff 43%, #a271e0 84%);
  color: #251033;
  box-shadow: 0 5px 19px #b35cf074;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.dock-orb[hidden] { display: none; }

.dock-icon-flight {
  position: absolute;
  inset: 0 auto auto 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  pointer-events: none;
}

@media (min-width: 768px) {
  body:not(.signed-out) > aside {
    inset: 22px auto auto 0;
    height: auto;
    max-height: calc(100dvh - 36px);
    padding: 4px 18px 14px 22px;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  body > aside .sidebar-brand { padding: 0 0 20px; }
  :root:not([data-theme=dark]) .sidebar-brand > span { color: #3f2c54; }
  :root:not([data-theme=dark]) .sidebar-brand > strong { color: #63379a; }
  body > aside .aside-bottom { margin-top: 0; padding-top: 0; }
  body > aside .aside-bottom .demo { display: none; }
  body > aside .logout-link {
    gap: 8px;
    background: #f9f3ffad !important;
    border: 0 !important;
    color: #513570 !important;
    font-size: 11px !important;
  }
  body > aside .logout-link:hover { background: #f4e7ff !important; }
  :root[data-theme=dark] body > aside .logout-link { background: #2c253bb8 !important; color: #eee1fc !important; }
  :root[data-theme=dark] body > aside .logout-link:hover { background: #45345b !important; }
}

/* Workspace surfaces */
body:not(.signed-out) {
  --workspace-card: #fbf9fd;
  --workspace-card-hover: #f4edf9;
  --home-card-glass: #fbf4ff49;
  --home-card-glass-hover: #f4e7ff72;
  --metric-icon: #ebe4f4;
  --metric-ink: #594371;
  --metric-value: #352443;
}

:root[data-theme=dark] body:not(.signed-out) {
  --workspace-card: #221e2c;
  --workspace-card-hover: #2b2438;
  --home-card-glass: #50356a36;
  --home-card-glass-hover: #57397a63;
  --metric-icon: #352b43;
  --metric-ink: #d1b8eb;
  --metric-value: #f2e9fa;
}

body:not(.signed-out) :is(.shell, #modal) :is(
  header, section, article, a, button, input, select, textarea, label, fieldset, table, th, td,
  .card, .school-mark, .header-class, .tabs, .segment-indicator, .subject-list, .empty,
  .exchange-row-icon, .subject-row-icon, .tile, .detail-icon, .progress, .pill, .notification-status
) {
  border-color: transparent !important;
}

body:not(.signed-out) #modal { border-color: transparent; }
:root body:not(.signed-out) .portal-topbar { border-bottom: 0; background: transparent; }

body:not(.signed-out) :is(.shell, #modal) :is(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--portal-focus);
  outline-offset: 2px;
}

@property --surface-beam-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 110deg;
}

#app :is(.card, .ranking-card, .subject-row) { position: relative; }

#app .exchange-row { background: var(--workspace-card); }
#app .next-action { background: var(--home-card-glass); backdrop-filter: blur(2px); }

/* Student motivation */
.motivation {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  display: grid;
  align-items: center;
  min-height: clamp(250px, 27vw, 294px);
  margin-bottom: 24px;
  padding: clamp(22px, 3vw, 36px) clamp(24px, 4.2vw, 53px);
  overflow: hidden;
  border-radius: 21px;
  background: linear-gradient(140deg, #292043, #181124 49%, #2a1b42 84%, #382357);
  box-shadow: inset 0 1px 9px #c4a5ff1f, inset 0 -8px 24px #b681f414, 0 15px 33px #110a2629;
}

.motivation::before,
.motivation::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.motivation::before {
  z-index: -2;
  background:
    radial-gradient(ellipse at 9% 4%, #b69ae650, transparent 46%),
    radial-gradient(ellipse at 78% 24%, #7847ab48, transparent 51%),
    radial-gradient(ellipse at 91% 104%, #a360e36b, transparent 48%);
}

.motivation::after {
  z-index: 2;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(132deg, #e3d5ffc2 0, #b8a0f563 12%, #a58dda28 35%, #be8cf05d 68%, #d5afffa6 93%, #9459db89);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.motivation-content {
  position: relative;
  z-index: 1;
  width: 62%;
}

#app .motivation h2 {
  display: grid;
  perspective: 620px;
  margin: 0 0 15px;
  color: #f5f3fa;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: clamp(27px, 5.1cqw, 41px);
  font-weight: 600;
  line-height: 1.13;
  letter-spacing: -.02em;
}

.motivation h2 span { grid-area: 1 / 1; }
.motivation-title-intro { display: none; }

#app .motivation p {
  max-width: 42ch;
  margin: 0 0 22px;
  color: #c4b9d9;
  font-size: clamp(14px, 1.9cqw, 17px);
  line-height: 1.5;
}

.motivation-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 45px;
  padding: 9px 20px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(145deg, #9e7fda63, #5f467b61 52%, #976bce6e);
  box-shadow: inset 0 0 0 1px #dac6fb59, inset 0 2px 7px #dfcaff48, inset 0 -3px 8px #bf97f32a, 0 5px 15px #130c2260;
  color: #f9f5ff;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.motivation-button:hover {
  background-color: #ac82e82e;
  box-shadow: inset 0 0 0 1px #ebdcff81, inset 0 2px 8px #e7d2ff60, 0 7px 17px #150c2867;
}

.motivation-button:active { box-shadow: inset 0 0 0 1px #d9bfff80, inset 0 3px 9px #25153b86; }
#app .motivation-button:focus-visible { outline-color: #ebd7ff; outline-offset: 3px; }
.motivation-button svg { flex: none; }

.motivation-waves, .motivation-scene {
  position: absolute;
  pointer-events: none;
}

.motivation-waves {
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
}

.motivation-scene {
  inset: auto 0 -3px auto;
  width: min(49%, 540px);
  height: min(91%, 282px);
}

.motivation-stairs { display: block; width: 100%; height: 100%; }
.motivation-star-halo { opacity: .77; }

@media (max-width: 1000px) {
  .motivation { padding: clamp(22px, 3vw, 33px) clamp(22px, 3.8vw, 38px); }
  .motivation-scene { width: 51%; right: -1%; }
}

@media (max-width: 590px) {
  .motivation { min-height: 232px; padding: 20px 17px; border-radius: 17px; }
  .motivation-content { width: 100%; }
  #app .motivation h2 { font-size: clamp(23px, 7.7cqw, 33px); margin-bottom: 12px; }
  #app .motivation p { width: 62%; max-width: 28ch; margin-bottom: 16px; font-size: 13px; }
  .motivation-button { min-height: 44px; padding-inline: 12px; font-size: 13px; }
  .motivation-scene { width: 51%; height: auto; right: 0; bottom: 6px; opacity: .78; }
  .motivation-stairs { height: auto; }
}

@media (max-width: 340px) {
  .motivation { padding-inline: 13px; }
  #app .motivation h2 { font-size: clamp(21px, 8.2cqw, 26px); }
  #app .motivation p { width: 66%; }
  .motivation-scene { width: 47%; bottom: 10px; }
}

@media (prefers-reduced-motion: no-preference) {
  .motivation-title-intro { display: block; }
  .motivation-title-result { opacity: 0; }
  .motivation h2 span { backface-visibility: hidden; }
  .motivation[data-motivation-visible] :is(.motivation-title-intro, .motivation-title-result) {
    animation: motivation-title-cycle 10s cubic-bezier(.24,.66,.29,1) infinite both;
  }
  .motivation[data-motivation-visible] .motivation-title-result {
    animation-delay: -5s;
  }
  .motivation::before { animation: motivation-light 22s ease-in-out infinite alternate; }
  .motivation-waves { animation: motivation-wave-drift 24s ease-in-out infinite alternate; }
  .motivation-star-halo { animation: motivation-star-glow 18s ease-in-out infinite alternate; }
  .motivation[data-motivation-offscreen]::before, body[data-portal-hidden] .motivation::before,
  :is(.motivation[data-motivation-offscreen], body[data-portal-hidden] .motivation)
    :is(.motivation-waves, .motivation-star-halo, .motivation-title-intro, .motivation-title-result) {
    animation-play-state: paused;
  }
  .motivation-button { transition: box-shadow .23s ease, background-color .23s ease; }
  .motivation-button svg { transition: transform .23s ease; }
  .motivation-button:hover svg { transform: translate(2px, -2px); }
  .motivation-button:active svg { transform: translate(1px, -1px); }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .motivation-scene {
    transform: translate3d(var(--motivation-x, 0px), var(--motivation-y, 0px), 0);
    transition: transform .24s ease-out;
  }
}

@keyframes motivation-light {
  from { transform: scale(1.02); }
  to { transform: translate3d(1%, -1.5%, 0) scale(1.075); }
}
@keyframes motivation-wave-drift {
  from { transform: scale(1.015); }
  to { transform: translate3d(1%, -1%, 0) scale(1.06); }
}
@keyframes motivation-star-glow {
  from { opacity: .64; }
  to { opacity: .91; }
}

@keyframes motivation-title-cycle {
  0%, 44%, 100% { transform: translateZ(0) rotateX(0); opacity: 1; }
  50%, 74% { transform: translateY(-.33em) translateZ(-65px) rotateX(88deg); opacity: 0; }
  94% { transform: translateY(.31em) translateZ(-65px) rotateX(-88deg); opacity: 0; }
}

/* Student level progress */
.level-progress-card {
  position: relative;
  isolation: isolate;
  align-self: start;
  min-width: 0;
  padding: clamp(18px, 2.3vw, 27px);
  overflow: hidden;
  border-radius: 18px;
  background: linear-gradient(145deg, #27203d, #15121f 47%, #251a3a);
  box-shadow: inset 0 1px 13px #c4a6ff18, inset 0 -5px 17px #8855d013, 0 12px 30px #10091e26;
  color: #f5f2ff;
}

.level-progress-card::before,
.level-progress-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.level-progress-card::before {
  z-index: -2;
  background:
    radial-gradient(ellipse at 6% 0%, #9570df37, transparent 55%),
    radial-gradient(ellipse at 93% 37%, #8756cb3f, transparent 61%);
}

.level-progress-card::after {
  z-index: 1;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(138deg, #c4a6ff80, #b18ae223 26%, #9977d83d 64%, #c59df37f);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.level-landscape {
  position: absolute;
  z-index: -1;
  inset: 5px -1% auto auto;
  width: min(46%, 360px);
  height: auto;
  max-height: 124px;
  opacity: .79;
  pointer-events: none;
}

#app .level-progress-card h2 {
  margin: 0 0 9px;
  color: #d0bdf4;
  font-size: clamp(14px, 1.6vw, 16px);
  font-weight: 700;
  line-height: 1.25;
}

.level-progress-identity {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  margin-bottom: 17px;
}

.level-emblem { flex: 0 0 clamp(62px, 8vw, 91px); }
.level-emblem-art { display: block; width: 100%; height: auto; }
.level-progress-name { display: block; color: #f5f2ff; font-size: clamp(23px, 2.5vw, 29px); line-height: 1.12; }
#app .level-progress-xp { margin: 5px 0 0; color: #c1b1dc; font-size: 13px; line-height: 1.3; }

.level-progress-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #cbb9ed;
  font-size: 13px;
  line-height: 1.25;
}

.level-progress-label strong { color: #efe3ff; font-size: 18px; font-variant-numeric: tabular-nums; }
.level-progress-track {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 99px;
  background: #49396596;
  box-shadow: inset 0 1px 2px #b693f235, inset 0 -2px 3px #130d226e;
}

.level-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  width: var(--level-width);
  overflow: hidden;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 21px 9px at calc(100% - 4px) 10%, #ead0ffe0, #b67cf34a 54%, transparent),
    linear-gradient(180deg, #c7a2f9 0, #9e70e7 20%, #7751c1 72%, #9263df);
  box-shadow: inset 0 0 0 1px #c8a9f86e, 0 0 8px #a26aed5b;
}

.level-progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(108deg, transparent 31%, #e1c3ff67 50%, transparent 69%);
}

#app .level-progress-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 13px 0 0;
  color: #b8accc;
  font-size: 11px;
  line-height: 1.48;
}
.level-progress-note svg { flex: none; color: #b594ed; }

@media (max-width: 590px) {
  .level-landscape { width: 47%; right: -3%; top: 12px; opacity: .57; }
  .level-progress-identity { gap: 10px; margin-bottom: 14px; }
}

@media (prefers-reduced-motion: no-preference) {
  .level-progress-card::before { animation: level-card-light 26s ease-in-out infinite alternate; }
  .level-landscape { animation: level-landscape-drift 28s ease-in-out infinite alternate; }
  .level-summit-glow, .level-emblem-halo { animation: level-glow 23s ease-in-out infinite alternate; }
  .level-progress-fill::after { animation: level-fill-reflection 22s ease-in-out infinite; }
  .level-progress-card[data-level-animate]:not([data-level-visible]) .level-progress-fill { width: var(--level-from); }
  .level-progress-card[data-level-animate][data-level-visible] .level-progress-fill { animation: level-fill-in .78s cubic-bezier(.22,.7,.3,1) both; }
  :is(.level-progress-card[data-level-offscreen], body[data-portal-hidden] .level-progress-card)::before,
  :is(.level-progress-card[data-level-offscreen], body[data-portal-hidden] .level-progress-card) :is(.level-landscape, .level-summit-glow, .level-emblem-halo),
  :is(.level-progress-card[data-level-offscreen], body[data-portal-hidden] .level-progress-card) .level-progress-fill::after {
    animation-play-state: paused;
  }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .level-emblem { transform: translate3d(var(--level-emblem-x, 0px), var(--level-emblem-y, 0px), 0); transition: transform .24s ease-out; }
}

@keyframes level-card-light { to { transform: translate3d(1%, -1%, 0) scale(1.07); } }
@keyframes level-landscape-drift { to { transform: translate3d(-2%, 1%, 0); } }
@keyframes level-glow { from { opacity: .64; } to { opacity: .92; } }
@keyframes level-fill-in { from { width: var(--level-from); } to { width: var(--level-width); } }
@keyframes level-fill-reflection {
  0%, 43%, 65%, 100% { opacity: 0; }
  43% { transform: translateX(-55%); }
  53% { opacity: .35; }
  65% { transform: translateX(55%); }
}

@media (forced-colors: active) {
  .level-progress-track { outline: 1px solid CanvasText; }
  .level-progress-fill { background: Highlight; forced-color-adjust: none; }
}

#app .student-metrics { gap: clamp(12px, 1.6vw, 22px); }

#app .student-metrics .metric {
  --metric-shape: from 15px 0, hline to calc(100% - 54px),
    curve to calc(100% - 44px) 10px with calc(100% - 47px) 0 / calc(100% - 44px) 3px,
    vline to 30px,
    curve to calc(100% - 30px) 44px with calc(100% - 44px) 38px / calc(100% - 38px) 44px,
    hline to calc(100% - 10px), curve to 100% 54px with calc(100% - 3px) 44px / 100% 47px,
    vline to calc(100% - 15px), curve to calc(100% - 15px) 100% with 100% 100%,
    hline to 15px, curve to 0 calc(100% - 15px) with 0 100%,
    vline to 15px, curve to 15px 0 with 0 0, close;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-content: center;
  gap: 12px;
  min-height: 112px;
  padding: 16px 45px 16px 16px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  isolation: isolate;
  text-align: left;
}

#app .student-metrics .metric::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--home-card-glass);
  backdrop-filter: blur(2px);
  pointer-events: none;
  clip-path: shape(var(--metric-shape));
}

#app .student-metrics .metric:is(:hover, :focus-visible)::before { background: var(--home-card-glass-hover); }
#app .student-metrics .metric .tile {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--metric-icon);
  color: var(--metric-ink);
  font-size: 19px;
}

#app .student-metrics .metric small { min-height: 0; font-size: 13px; line-height: 1.3; }
#app .student-metrics .metric strong {
  margin: 5px 0 0;
  color: var(--metric-value);
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

#app .student-metrics .metric-arrow {
  position: absolute;
  top: 3px;
  right: 3px;
  bottom: auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0;
  border-radius: 9px;
  background: var(--metric-icon);
  color: var(--metric-ink);
}

@media (max-width: 900px) {
  #app .student-metrics .metric {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    padding: 14px;
  }
  #app .student-metrics .metric small { min-height: 2.6em; }
}

@media (max-width: 560px) {
  #app .student-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #app .student-metrics > .balance-display { grid-column: 1 / -1; }
}

#app :is(.next-action, .task-list:has(.empty), .card:hover, .card:focus-within,
  .ranking-card:hover, .subject-row:is(:hover, :focus-visible))::after,
#app .student-metrics .metric::after,
#app .leaderboard::after,
#modal.reward-glass[open]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 2px;
  border-radius: inherit;
  pointer-events: none;
  background: conic-gradient(from var(--surface-beam-angle), transparent 0 289deg,
    #9853ef00 290deg, #9853ef92 325deg, #b476f5 345deg, #e3aaff 352deg, transparent 360deg);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

@supports (clip-path: shape(evenodd from 0 0, hline to 100%, close)) {
  #app .student-metrics .metric::after {
    mask: none;
    clip-path: shape(evenodd var(--metric-shape),
      move to 15px 2px, hline to calc(100% - 55px),
      curve to calc(100% - 46px) 11px with calc(100% - 49px) 2px / calc(100% - 46px) 5px,
      vline to 30px,
      curve to calc(100% - 30px) 46px with calc(100% - 46px) 39px / calc(100% - 39px) 46px,
      hline to calc(100% - 11px),
      curve to calc(100% - 2px) 55px with calc(100% - 5px) 46px / calc(100% - 2px) 49px,
      vline to calc(100% - 15px),
      curve to calc(100% - 15px) calc(100% - 2px) with calc(100% - 2px) calc(100% - 2px),
      hline to 15px, curve to 2px calc(100% - 15px) with 2px calc(100% - 2px),
      vline to 15px, curve to 15px 2px with 2px 2px, close);
  }
}

.balance-display {
  --balance-ink: #572b9b;
  --balance-spectrum: #472580 5%, #6440ad 30%, #9639a5 47%, #6442c4 57%, #472580 76%;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 5px;
  min-width: 0;
  padding: 10px 6px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--balance-ink);
  text-align: center;
}

:root[data-theme=dark] .balance-display {
  --balance-ink: #dec0ff;
  --balance-spectrum: #ac84ff 5%, #c49cff 30%, #fff0ff 46%, #f7b9eb 54%, #aa92ff 70%;
}

button.balance-display:hover .balance-label { text-decoration: underline; text-underline-offset: 4px; }
.exchange-balance { margin: 0 auto clamp(23px, 4vw, 40px); padding-block: 16px 4px; }
.balance-label { font-size: clamp(18px, 2.1vw, 25px); font-weight: 750; line-height: 1.2; }
.balance-number { font-size: clamp(64px, 8vw, 110px); line-height: 1; font-variant-numeric: tabular-nums; }
.balance-unit { font-size: clamp(15px, 1.7vw, 19px); font-weight: 650; }
.metrics .balance-number { font-size: clamp(50px, 6vw, 75px); }

@supports (background-clip: text) {
  .balance-display :is(.balance-label, .balance-number, .balance-unit) {
    background-image: linear-gradient(110deg, var(--balance-spectrum));
    background-size: 215% 100%;
    background-clip: text;
    color: transparent;
  }
}

@media (prefers-reduced-motion: no-preference) {
  #app :is(.next-action, .task-list:has(.empty), .card:hover, .card:focus-within,
    .ranking-card:hover, .subject-row:is(:hover, :focus-visible))::after,
  #app .student-metrics .metric::after,
  #app .leaderboard::after,
  #modal.reward-glass[open]::after {
    animation: surface-beam-travel 5.5s linear infinite;
  }
  .balance-display :is(.balance-label, .balance-number, .balance-unit) { animation: balance-spectrum-shift 3.2s ease-in-out infinite alternate; }
  body[data-portal-hidden] #app *::after,
  body[data-portal-hidden] #modal.reward-glass::after,
  body[data-portal-hidden] .balance-display :is(.balance-label, .balance-number, .balance-unit) { animation-play-state: paused; }
}

@keyframes surface-beam-travel { to { --surface-beam-angle: 470deg; } }
@keyframes balance-spectrum-shift { to { background-position: 100% 50%; } }

/* Reward dialogs */
#modal.reward-glass {
  width: min(430px, calc(100% - 28px));
  max-height: calc(100dvh - 24px);
  color: #f6edff;
  background:
    radial-gradient(ellipse at 18% 9%, #a666df48, transparent 47%) 0 0 / 142% 132%,
    linear-gradient(137deg, #100c17e8 14%, #301943dc 48%, #16101eea 74%) 0 0 / 175% 175%;
  backdrop-filter: blur(17px) saturate(125%);
  box-shadow: 0 20px 72px #0d03199c;
  overflow-y: auto;
}

#modal.reward-glass::backdrop { background: #0e061974; }
#modal.reward-glass::after { padding: 1.5px; }
#modal.reward-glass .celebrate-close { color: #e8d9f4; }
#modal.reward-glass .celebrate-art { margin-bottom: 18px; }
#modal.reward-glass .celebrate-check {
  background: linear-gradient(145deg, #e9cfff, #ad6cf2);
  color: #32144b;
  box-shadow: inset 0 2px 0 #fff8, 0 10px 30px #9a42d65c;
}
#modal.reward-glass.level-reward .celebrate-check {
  width: 94px;
  height: 94px;
  background: transparent;
  box-shadow: none;
}
#modal.reward-glass.level-reward .celebrate-points {
  font: 700 clamp(34px, 8vw, 44px) / 1.15 "Segoe UI", system-ui, sans-serif;
  letter-spacing: -.025em;
}
#modal.reward-glass .celebrate-ring { border-color: #d6a2f380; }
#modal.reward-glass .celebrate-kicker { color: #cfb6e7; }
#modal.reward-glass .confetti:nth-child(odd) { background-color: #c38efc; }
#modal.reward-glass .confetti:nth-child(even) { background-color: #ecc4f9; }

#modal.reward-glass .reward-title {
  position: relative;
  margin-bottom: 12px;
  color: #fff3ff;
  font-size: clamp(24px, 6vw, 34px);
  line-height: 1.15;
}
.reward-title-outline { display: none; }
#modal.reward-glass .reward-title-fill { display: block; }
#modal.reward-glass .celebrate-description { color: #e0ccec; font-size: 13px; }
#modal.reward-glass .celebrate-description strong { color: #fff3ff; overflow-wrap: anywhere; }
#modal.reward-glass .celebrate-points { color: #e3b1ff; }
#modal.reward-glass .celebrate-points span { color: #e0ccec; font-size: 12px; }
#modal.reward-glass .celebrate-level { border-color: transparent; background: #d4a5ff21; color: #eedcfa; font-size: 11px; }
#modal.reward-glass > .btn { background: linear-gradient(105deg, #d2a0ff, #bc8af2); color: #251334; font-weight: 750; }
#modal.reward-glass > .btn:hover { background: #e1b7ff; }
#modal.reward-glass > .link { color: #e7c9ff; font-size: 12px; }

@media (prefers-reduced-motion: no-preference) {
  #modal.reward-glass[open] {
    animation: rewardEnter .45s cubic-bezier(.2,.8,.2,1), reward-glass-shift 7.5s ease-in-out .45s infinite alternate;
  }
  body[data-portal-hidden] #modal.reward-glass[open] { animation-play-state: paused; }
}

@media (prefers-reduced-motion: no-preference) {
  @supports (-webkit-text-stroke: 1px black) {
    #modal.reward-glass .reward-title-outline {
      position: absolute;
      inset: 0;
      display: block;
      color: transparent;
      -webkit-text-stroke: 1px #e7baff;
      animation: reward-text-outline 1s cubic-bezier(.35,0,.25,1) .12s both;
      pointer-events: none;
    }
    #modal.reward-glass .reward-title-fill { animation: reward-text-fill .6s cubic-bezier(.22,.68,.33,1) .54s both; }
  }
}

@keyframes reward-glass-shift { to { background-position: 100% 66%, 78% 90%; } }
@keyframes reward-text-outline {
  from { clip-path: inset(-3px 100% -3px -3px); }
  64% { clip-path: inset(-3px -3px -3px -3px); opacity: 1; }
  to { clip-path: inset(-3px -3px -3px -3px); opacity: 0; }
}
@keyframes reward-text-fill {
  from { clip-path: inset(100% -3px -3px); }
  to { clip-path: inset(-3px); }
}

@media (max-height: 650px) {
  #modal.reward-glass { padding-block: 22px 20px !important; }
  #modal.reward-glass .celebrate-art { width: 84px; height: 84px; margin-bottom: 22px; }
  #modal.reward-glass .celebrate-check { width: 64px; height: 64px; font-size: 34px; }
  #modal.reward-glass.level-reward .celebrate-check { width: 72px; height: 72px; }
  #modal.reward-glass .celebrate-level { margin-bottom: 17px; }
}

@media (forced-colors: active) {
  #modal.reward-glass .reward-title-fill { color: CanvasText; animation: none; }
  #modal.reward-glass .reward-title-outline { display: none; }
}

@media (forced-colors: active) {
  .dock-glass { background: Canvas; }
  #nav > a[aria-current] { color: LinkText; text-decoration: underline; }
  .balance-display :is(.balance-label, .balance-number, .balance-unit) { color: CanvasText; }
}

/* Task detail */
#modal.task-detail-sheet {
  --task-ink: #30243f;
  --task-muted: #5b4a70;
  --task-accent: #593596;
  --task-glass: #faf5fedf;
  --task-toolbar: #faf5fef0;
  --task-photo-base: #ece2f6;
  --task-inset: #e3d1f36b;
  --task-rim: #ac83d860;
  width: min(640px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background:
    radial-gradient(ellipse at 96% 8%, #b38ce135, transparent 61%),
    var(--task-glass);
  color: var(--task-ink);
  box-shadow: inset 0 0 0 1px var(--task-rim), 0 20px 65px #10091f50;
  backdrop-filter: blur(14px);
  overscroll-behavior: contain;
}

:root[data-theme=dark] #modal.task-detail-sheet {
  --task-ink: #f4ecfb;
  --task-muted: #cec1dd;
  --task-accent: #dfbbff;
  --task-glass: #221a31eb;
  --task-toolbar: #261c35f4;
  --task-photo-base: #342548;
  --task-inset: #b082dc1d;
  --task-rim: #c198f052;
}

#modal.task-detail-sheet .sheet-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border: 0;
  background: var(--task-toolbar);
  color: var(--task-muted);
  font-size: 13px;
  font-weight: 700;
}

#modal.task-detail-sheet :is(.sheet-close, .sheet-back) {
  display: grid;
  width: 42px;
  height: 42px;
  margin: 0;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--task-accent);
}

#modal.task-detail-sheet :is(.sheet-close, .sheet-back):hover { background: var(--task-inset); }
#modal.task-detail-sheet .sheet-close svg { width: 19px; height: 19px; }
#modal.task-detail-sheet :is(.sheet-close, .sheet-back):focus-visible { outline-offset: -3px; }

.task-detail-content {
  display: grid;
  gap: 15px;
  padding: clamp(12px, 3.8vw, 25px);
}

.task-detail-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  align-content: end;
  gap: 10px;
  min-height: 125px;
  padding: clamp(13px, 3.4vw, 21px);
  overflow: hidden;
  border-radius: 13px;
  background: var(--task-photo-base);
}

.task-detail-hero::before {
  content: "";
  position: absolute;
  inset: 0 0 0 29%;
  z-index: -1;
  background:
    linear-gradient(90deg, var(--task-photo-base), color-mix(in srgb, var(--task-photo-base) 78%, transparent) 47%,
      color-mix(in srgb, var(--task-photo-base) 35%, transparent)),
    var(--subject-photo) center / cover no-repeat;
  pointer-events: none;
}

#modal.task-detail-sheet #task-detail-title {
  max-width: 26ch;
  margin: 0;
  color: var(--task-ink);
  font: 600 clamp(21px, 4.8vw, 29px) / 1.16 "Segoe UI", system-ui, sans-serif;
  letter-spacing: -.018em;
  overflow-wrap: anywhere;
  outline: none;
}

.task-detail-tags, .task-detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  color: var(--task-muted);
  font-size: 12px;
}

.task-detail-tags > * {
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--task-toolbar);
}
.task-detail-tags strong { color: var(--task-accent); font-weight: 700; }
.task-detail-meta span + span { padding-inline-start: 9px; border-inline-start: 1px solid var(--task-rim); }
#modal.task-detail-sheet :is(.task-description, .task-detail-extra, .instruction-list, .teacher-feedback p) {
  margin: 0;
  color: var(--task-muted);
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
#modal.task-detail-sheet h3 { margin: 0 0 7px; color: var(--task-ink); font-size: 14px; font-weight: 700; }
#modal.task-detail-sheet .instruction-list { padding-inline-start: 20px; }
#modal.task-detail-sheet .teacher-feedback { margin: 0; padding: 12px 14px; background: var(--task-inset); border: 0; border-radius: 11px; }

#modal.task-detail-sheet .task-detail-status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--status-surface);
  color: var(--status-ink);
  font-size: 13px;
  line-height: 1.4;
}

.task-detail-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(150deg, #8057b8, #583587 68%, #6d429f);
  box-shadow: inset 0 1px 0 #e2c5ff7a, inset 0 0 0 1px #c8a8ef56, 0 6px 14px #22113638;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.task-detail-cta:hover { background: linear-gradient(150deg, #8a62c2, #653d99 68%, #784bad); }
.task-detail-cta svg { flex: none; }

@media (max-width: 480px) {
  #modal.task-detail-sheet { border-radius: 15px; }
  .task-detail-content { gap: 12px; }
  .task-detail-hero { min-height: 104px; }
  .task-detail-hero::before { inset-inline-start: 19%; }
  .task-detail-meta span + span { padding-inline-start: 0; border: 0; }
}

/* Student leaderboard */
.leaderboard {
  --rank-glass: #faf4ff65;
  --rank-ink: #352443;
  --rank-muted: #695878;
  --rank-accent: #593490;
  --rank-highlight: #eee5fa;
  --rank-top: #eee2fa;
  --rank-second: #efebf8;
  --rank-third: #f5e9f1;
  display: grid;
  position: relative;
  gap: 22px;
  max-width: 940px;
  padding: clamp(12px, 3vw, 32px);
  border-radius: 20px;
  background: var(--rank-glass);
  backdrop-filter: blur(4px);
  color: var(--rank-ink);
}

:root[data-theme=dark] .leaderboard {
  --rank-glass: #24183161;
  --rank-ink: #f0e8fa;
  --rank-muted: #c0afcf;
  --rank-accent: #dfc4ff;
  --rank-highlight: #372a49;
  --rank-top: #463256;
  --rank-second: #332b46;
  --rank-third: #3b2a40;
}

.leaderboard-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.leaderboard-heading h2 { margin: 0; color: var(--rank-ink); font-size: clamp(18px, 2.6vw, 25px); }
.leaderboard-heading .portal-segments { margin: 0; background: var(--workspace-card-hover); }
.leaderboard-heading .segment-indicator { background: var(--rank-top); box-shadow: none; }
:root .leaderboard-heading .portal-segments > button { color: var(--rank-muted); }
:root .leaderboard-heading .portal-segments > button.active { color: var(--rank-ink); }
.leaderboard-empty { margin: 0; padding: 15px 12px; border-radius: 10px; background: var(--workspace-card-hover); color: var(--rank-muted); }

.leaderboard-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: clamp(6px, 1.5vw, 14px);
  width: min(100%, 564px);
  margin: 0 auto;
  padding: 9px 0 0;
  list-style: none;
}

.leaderboard-podium li { display: flex; grid-row: 1; min-width: 0; }
.leaderboard-podium [data-place="1"] {
  grid-column: 2;
  --medal: #f0ca93;
  --medal-shadow: #221b1a;
  --medal-surface: #392a24;
  --medal-rim: #765944;
  --medal-avatar: #ddc9bb;
  --medal-avatar-text: #47362e;
}
.leaderboard-podium [data-place="2"] {
  grid-column: 1;
  padding-block-start: 7px;
  --medal: #d5dbe8;
  --medal-shadow: #1d1c22;
  --medal-surface: #2d2c38;
  --medal-rim: #5d6073;
  --medal-avatar: #d2d1df;
  --medal-avatar-text: #393747;
}
.leaderboard-podium [data-place="3"] {
  grid-column: 3;
  padding-block-start: 14px;
  --medal: #e5b199;
  --medal-shadow: #241b1c;
  --medal-surface: #362628;
  --medal-rim: #6b4942;
  --medal-avatar: #dbb9ab;
  --medal-avatar-text: #513630;
}

.leaderboard-leader {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 93px;
  padding: 8px 5px 10px;
  border: 0;
  border-radius: 11px;
  background:
    radial-gradient(ellipse 70% 49% at 91% -3%, var(--medal-rim), transparent 92%),
    radial-gradient(ellipse 77% 48% at 4% 104%, var(--medal-rim), transparent 99%),
    linear-gradient(170deg, var(--medal-surface), var(--medal-shadow) 51%, var(--medal-shadow) 70%, var(--medal-surface));
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--medal) 16%, transparent),
    inset 0 0 8px color-mix(in srgb, var(--medal) 10%, transparent),
    0 4px 10px #10090826;
  color: #f5ebe6;
  text-align: center;
}

.leaderboard-leader:hover { filter: brightness(1.07); }
.leaderboard-portrait { position: relative; display: grid; place-items: end center; width: min(100%, 65px); height: 39px; }
.leaderboard-laurel {
  position: absolute;
  inset: 11% 24% auto;
  z-index: -1;
  width: 52%;
  height: 50%;
  color: var(--medal);
  opacity: .16;
  pointer-events: none;
}
.leaderboard-portrait > .avatar {
  position: relative;
  width: 31px;
  height: 31px;
  margin: 0 0 3px;
  background: var(--medal-avatar);
  color: var(--medal-avatar-text);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--medal) 24%, transparent);
  font-size: 10px;
}
.leaderboard-crown {
  position: absolute;
  inset: -9px auto auto 50%;
  width: 16px;
  height: 12px;
  transform: translateX(-50%);
  color: #f2cc91;
  filter: drop-shadow(0 0 5px #eac28d70);
  pointer-events: none;
}
.leaderboard-leader > .leaderboard-place {
  position: absolute;
  inset: 7px 9px auto auto;
  min-width: 19px;
  min-height: 17px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--medal) 21%, transparent);
  color: var(--medal);
  font-size: 10px;
}
.leaderboard-name { display: block; color: var(--rank-ink); font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.leaderboard-leader > .leaderboard-name { max-width: 100%; color: #f5ebe6; font-size: 11px; font-weight: 700; }
.leaderboard-score { color: var(--rank-accent); font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.leaderboard-score small { color: var(--rank-muted); font-weight: 550; }
.leaderboard-leader > .leaderboard-score,
.leaderboard-leader > .leaderboard-score small { color: #d0c2bb; font-size: 10px; font-weight: 550; }

.leaderboard-personal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--rank-highlight);
}

.leaderboard-personal strong, .leaderboard-personal small { display: block; }
.leaderboard-personal small, .leaderboard-profile small { color: var(--rank-muted); font-size: 11px; }
#find-my-position {
  min-height: 44px;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: var(--workspace-card);
  color: var(--rank-accent);
  font-weight: 750;
}

.leaderboard-table { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0 3px; text-align: left; }
.leaderboard-table :is(th, td) { padding: 4px 8px; }
.leaderboard-table thead th { color: var(--rank-muted); font-size: 12px; }
.leaderboard-table thead th:first-child { width: 61px; }
.leaderboard-table thead th:last-child { width: 87px; }
.leaderboard-table :is(th, td):last-child { text-align: right; }
.leaderboard-table tbody tr > :first-child { border-radius: 9px 0 0 9px; }
.leaderboard-table tbody tr > :last-child { border-radius: 0 9px 9px 0; }
.leaderboard-table tbody tr:hover > * { background: var(--workspace-card-hover); }
.leaderboard-table tbody :is(.leaderboard-self, tr:has(.is-located)) > * { background: var(--rank-highlight); }
.leaderboard-place {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  min-height: 24px;
  border-radius: 7px;
  color: var(--rank-accent);
  font-size: 12px;
  font-weight: 750;
}

.leaderboard-place[data-place="1"] { background: var(--rank-top); }
.leaderboard-place[data-place="2"] { background: var(--rank-second); }
.leaderboard-place[data-place="3"] { background: var(--rank-third); }
.leaderboard-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 44px;
  padding: 4px 1px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.leaderboard-profile .avatar { flex: none; width: 33px; height: 33px; margin: 0; font-size: 11px; }
.leaderboard-profile.is-located { outline: 2px solid var(--portal-focus); outline-offset: 2px; }

@media (max-width: 480px) {
  .leaderboard { gap: 16px; }
  .leaderboard-leader > .leaderboard-name { font-size: 11px; }
  .leaderboard-table :is(th, td) { padding-inline: 4px; }
  .leaderboard-table thead th:first-child { width: 43px; }
  .leaderboard-table thead th:last-child { width: 58px; }
  .leaderboard-personal { font-size: 12px; }
}

@media (max-width: 380px) {
  .leaderboard-portrait { height: 39px; }
  .leaderboard-portrait > .avatar { width: 27px; height: 27px; margin-bottom: 5px; }
  .leaderboard-leader > .leaderboard-place { inset: 4px 4px auto auto; min-width: 19px; min-height: 19px; }
}

/* Header */
.portal-topbar {
  --header-surface: #fbf9ff;
  --header-line: #e7def0;
  --header-text: #2f2440;
  --header-muted: #665775;
  --header-control: #f1eaf8;
  --header-hover: #eae0f6;
  --header-accent: #6337a4;
  position: relative;
  z-index: 10;
  min-height: 72px;
  padding-block: 10px;
  border-color: var(--header-line);
}

:root[data-theme=dark] .portal-topbar {
  --header-surface: #1b1722;
  --header-line: #393044;
  --header-text: #f1e8fa;
  --header-muted: #b9a9ca;
  --header-control: #2a2135;
  --header-hover: #352842;
  --header-accent: #dbb4ff;
}

.portal-topbar .school { display: flex; gap: 11px; color: var(--header-text); }
.school-mark {
  flex: 0 0 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--header-line);
  border-radius: 10px;
  background: var(--header-control);
  color: var(--header-accent);
}

.school-mark svg { width: 19px; height: 19px; stroke-width: 1.8; }
.portal-topbar .school-name {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.portal-topbar .header-right { gap: 10px; }
.header-class {
  max-width: 105px;
  overflow: hidden;
  padding: 6px 10px;
  border: 1px solid var(--header-line);
  border-radius: 7px;
  background: var(--header-control);
  color: var(--header-accent);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.portal-topbar .notification-bell,
:root[data-theme=dark] .portal-topbar .notification-bell {
  width: 44px;
  height: 44px;
  border: 1px solid var(--header-line);
  border-radius: 11px;
  background: transparent;
  color: var(--header-accent);
}

.portal-topbar .notification-bell:is(:hover, [aria-expanded=true]),
:root[data-theme=dark] .portal-topbar .notification-bell:is(:hover, [aria-expanded=true]) { background: var(--header-hover); }

.portal-topbar #notification-count {
  top: -4px;
  right: -5px;
  min-width: 19px;
  height: 19px;
  padding-inline: 3px;
  border-color: var(--header-surface);
  background: #7538bb;
  color: #fff;
  font-size: 9px;
  font-weight: 750;
}

.portal-topbar #notification-count[hidden] { display: none; }

.portal-topbar .header-profile {
  display: inline-flex;
  justify-content: flex-start;
  gap: 9px;
  width: auto;
  max-width: 238px;
  height: auto;
  min-height: 44px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--header-line);
  border-radius: 11px;
  background: transparent;
  color: var(--header-text);
  text-align: left;
  transition: background-color .18s;
}

.portal-topbar .header-profile:is(:hover, [aria-current]) { background: var(--header-hover); }
.portal-topbar .header-profile > .avatar { display: grid; width: 34px; height: 34px; border-radius: 8px; overflow: hidden; }
.header-profile-text { min-width: 0; }
.header-profile-text strong, .header-profile-text small { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.header-profile-text strong { font-size: 12px; line-height: 1.25; }
.portal-topbar .header-profile-text small { color: var(--header-muted); font-size: 11px; line-height: 1.35; }
.header-profile-arrow { display: grid; place-items: center; color: var(--header-accent); }
.header-profile-arrow svg { width: 13px; height: 13px; }

/* Notifications */
dialog.notifications-sheet {
  color-scheme: light;
  --notice-bg: #fbf8ff;
  --notice-text: #2e2438;
  --notice-muted: #63566c;
  --notice-line: #e5daef;
  --notice-neutral: #fff;
  --notice-accent: #6c3ca2;
  position: fixed;
  inset: 80px var(--page-gutter) auto auto;
  width: min(448px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100dvh - 96px);
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--notice-line);
  border-radius: 16px;
  background: var(--notice-bg);
  color: var(--notice-text);
  box-shadow: 0 22px 72px #10081d4a;
}

dialog.notifications-sheet::backdrop { background: #130b2138; backdrop-filter: none; }
dialog.notifications-sheet[open] { display: flex; flex-direction: column; animation: notices-in .18s ease-out both; }

:root[data-theme=dark] dialog.notifications-sheet {
  color-scheme: dark;
  --notice-bg: #1d1725;
  --notice-text: #f3eafc;
  --notice-muted: #c7b9d3;
  --notice-line: #44354f;
  --notice-neutral: #251c30;
  --notice-accent: #d8aeff;
}

@keyframes notices-in { from { opacity: 0; transform: translateY(-5px); } }

.notice-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--notice-line);
}

.notice-panel-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; color: var(--notice-text); }
.notice-total { display: block; margin-top: 2px; color: var(--notice-muted); font-size: 12px; }
.notice-close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--notice-line);
  border-radius: 10px;
  background: var(--notice-neutral);
  color: var(--notice-accent);
}

.notice-close svg { width: 17px; height: 17px; }
.notice-close:hover { border-color: var(--notice-accent); }
.notifications-sheet .notification-list {
  display: grid;
  gap: 9px;
  max-height: none;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--notice-accent) transparent;
}

#modal.notifications-sheet .notification-item {
  --state-color: #8d51cd;
  --state-ink: light-dark(#683795, #d8adff);
  align-items: flex-start;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--notice-line);
  border-radius: 10px;
  background: var(--notice-neutral);
  color: var(--notice-text);
  transition: background-color .18s, border-color .18s;
}

#modal.notifications-sheet .notification-item[data-tone=success] { --state-color: #2a9876; --state-ink: light-dark(#17644d, #8ee3bd); }
#modal.notifications-sheet .notification-item[data-tone=warning] { --state-color: #c78c32; --state-ink: light-dark(#855510, #ffd694); }
#modal.notifications-sheet .notification-item[data-tone=danger] { --state-color: #d65f84; --state-ink: light-dark(#a03b61, #ffabc6); }

#modal.notifications-sheet .notification-item.unread {
  background: linear-gradient(105deg, color-mix(in srgb, var(--state-color) 14%, var(--notice-neutral)), var(--notice-neutral) 78%);
}

#modal.notifications-sheet .notification-item:hover { border-color: var(--notice-accent); }
#modal.notifications-sheet .notification-item:disabled { opacity: .7; }
#modal.notifications-sheet .notification-item > .tile {
  width: 39px;
  height: 39px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--state-color) 23%, var(--notice-neutral));
  color: var(--state-ink, var(--notice-accent));
}

#modal.notifications-sheet .notification-item strong { color: var(--notice-text); font-size: 14px; }
#modal.notifications-sheet .notification-item small, #modal.notifications-sheet .notification-item time { color: var(--notice-muted); }
#modal.notifications-sheet .notification-item small { margin-top: 2px; line-height: 1.45; }
#modal.notifications-sheet .notification-item time { margin-top: 5px; line-height: 1.35; }
#modal.notifications-sheet .notification-item i { width: 7px; height: 7px; background: var(--notice-accent); }
#modal.notifications-sheet .notification-status svg { width: 13px; height: 13px; }
.notice-empty { padding: 28px 10px; text-align: center; }
.notice-empty svg { margin-bottom: 8px; color: var(--notice-accent); }
.notice-empty h3 { margin: 0 0 6px; color: var(--notice-text); }
.notice-empty p { margin: 0; color: var(--notice-muted); font-size: 13px; }

/* Subjects */
.subject-list {
  --subject-text: #2c2239;
  --subject-muted: #62536d;
  width: min(100%, 890px);
  display: grid;
  gap: 9px;
  padding: 0;
  margin: 0;
  list-style: none;
}

:root[data-theme=dark] .subject-list {
  --subject-text: #f1e9f8;
  --subject-muted: #c7b9d3;
}

.subject-list li { min-width: 0; }

.subject-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  align-items: center;
  gap: 12px;
  min-height: 84px;
  padding: 15px 18px;
  border: 0;
  border-radius: 12px;
  color: var(--subject-text);
  text-align: left;
}

#app .subject-photo {
  --photo-card: var(--workspace-card);
  position: relative;
  isolation: isolate;
  background: var(--photo-card);
}

#app .subject-photo::before {
  content: "";
  position: absolute;
  inset: 0 0 0 39%;
  z-index: -1;
  border-radius: inherit;
  background:
    linear-gradient(90deg, var(--photo-card), color-mix(in srgb, var(--photo-card) 83%, transparent) 40%, color-mix(in srgb, var(--photo-card) 53%, transparent)),
    var(--subject-photo) center 47% / cover no-repeat;
  pointer-events: none;
}

#app .subject-photo:hover { --photo-card: var(--workspace-card-hover); }
.subject-row-text strong { display: block; font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
.subject-row .subject-row-text small { display: block; margin-top: 3px; color: var(--subject-muted); font-size: 12px; }
.subject-row-arrow { display: grid; place-items: center; color: var(--subject-muted); border-radius: 7px; background: var(--photo-card); }
.subject-row-arrow svg { width: 17px; height: 17px; }

#app .task-list:has(> .task.subject-photo) { display: grid; gap: 10px; padding: 0; background: transparent; }
.report-task-list { grid-template-columns: minmax(0, 1fr); }

/* Teacher statistics shares the student's glass and subject-photo surfaces. */
.teacher-statistics {
  --stats-rim: #80609a33;
  --stats-sheen: #fff9;
  --stats-bar: linear-gradient(180deg, #a47bcc, #7952a6);
  display: grid;
  gap: clamp(16px, 2vw, 24px);
  min-width: 0;
}

:root[data-theme=dark] .teacher-statistics {
  --stats-rim: #c29deb2b;
  --stats-sheen: #d3b2ff23;
  --stats-bar: linear-gradient(180deg, #c9a4f3, #8154b5);
}

#app .teacher-statistics > .filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, .8fr)) minmax(0, 1.6fr);
  gap: 10px;
  margin: 0;
}

#app .teacher-statistics .filters > :is(input, select) {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--stats-rim);
  border-radius: 11px;
  background-color: color-mix(in srgb, var(--workspace-card) 84%, transparent);
  font-size: 16px;
}

.teacher-statistics :where(.stats-metrics, .stats-indicators, .stats-chart, dd) { margin: 0; }
.stats-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stats-glass {
  min-width: 0;
  border-radius: 15px;
  background: var(--home-card-glass);
  box-shadow: inset 0 1px 0 var(--stats-sheen);
}

.stats-metrics > div {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-content: center;
  column-gap: 12px;
  row-gap: 4px;
  padding: clamp(12px, 1.8vw, 20px);
}

.stats-icon {
  grid-row: span 2;
  align-self: center;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--metric-icon);
  box-shadow: inset 0 1px 0 var(--stats-sheen);
  color: var(--metric-ink);
}

.stats-icon svg { width: 19px; height: 19px; }
.teacher-statistics dt { font-size: 13px; line-height: 1.35; }
.stats-metrics dd,
.stats-indicators dd {
  color: var(--metric-value);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stats-metrics dd { font-size: clamp(24px, 3vw, 33px); }
.stats-indicators dd { margin-top: 5px; font-size: clamp(17px, 2vw, 23px); }

.stats-overview {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(165px, 1fr);
  align-items: center;
  gap: clamp(14px, 3vw, 32px);
  padding: clamp(14px, 2.6vw, 28px);
}

#app .teacher-statistics h2 { margin: 0 0 14px; font-size: clamp(16px, 2vw, 20px); line-height: 1.3; }
.stats-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(4px, 1.4vw, 14px);
  padding: 0;
  list-style: none;
}
.stats-chart li {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 0;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.stats-chart-track {
  display: flex;
  align-items: end;
  width: min(100%, 40px);
  height: clamp(72px, 10vw, 108px);
  overflow: hidden;
  border-radius: 7px;
  background: color-mix(in srgb, var(--metric-icon) 76%, transparent);
}
.stats-chart-track > span {
  width: 100%;
  height: var(--stats-bar-size);
  border-radius: inherit;
  background: var(--stats-bar);
  box-shadow: inset 0 1px 0 var(--stats-sheen);
}
.stats-indicators { border-inline-start: 1px solid var(--stats-rim); padding-inline-start: clamp(14px, 3vw, 30px); }
.stats-indicators > div + div { margin-top: 17px; }

#app .stats-work-list { position: relative; grid-template-columns: minmax(0, 1fr); }
#app .stats-work-list > .subject-photo {
  --photo-card: color-mix(in srgb, var(--workspace-card) 88%, transparent);
  box-shadow: inset 0 1px 0 var(--stats-sheen);
}
#app .stats-work-list > .subject-photo::before { mask-image: linear-gradient(to right, transparent, #000 38%); }
#app .stats-work-list > .subject-photo:hover { --photo-card: var(--workspace-card-hover); }
#app .stats-work-list .task-body { min-width: 0; }
#app .stats-work-list .task-body :is(h3, .meta) { overflow-wrap: anywhere; }
#app .stats-work-list .meta { align-items: center; }
#app #export-results,
#app .stats-work-list .btn {
  min-height: 44px;
  border: 1px solid color-mix(in srgb, var(--metric-ink) 24%, transparent);
  background: var(--home-card-glass);
  color: var(--metric-value);
}
#app #export-results:hover { background: var(--home-card-glass-hover); }
#app .stats-work-list .btn { background: color-mix(in srgb, var(--workspace-card) 94%, transparent); }
#app .stats-work-list .btn:hover { background: var(--workspace-card-hover); }

@media (max-width: 760px) {
  #app .teacher-statistics > .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #app .teacher-statistics .filters > input { grid-column: 1 / -1; }
  .stats-overview { grid-template-columns: minmax(0, 1fr); }
  .stats-indicators {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    border-inline-start: 0;
    border-top: 1px solid var(--stats-rim);
    padding: 12px 0 0;
  }
  .stats-indicators > div + div { margin-top: 0; }
}

@media (max-width: 520px) {
  .stats-metrics { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .stats-metrics > div { grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; }
  .stats-icon { grid-row: auto; width: 34px; height: 34px; }
}

.student-home-task-list { display: grid; gap: 12px; }
#app .student-home-task-list .subject-photo { --photo-card: #f6f0fa; }
#app .student-home-task-list .subject-photo:hover { --photo-card: #eee3f7; }
:root[data-theme=dark] #app .student-home-task-list .subject-photo { --photo-card: #2b2436; }
:root[data-theme=dark] #app .student-home-task-list .subject-photo:hover { --photo-card: #352a42; }
#app .task.subject-photo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px 16px;
  min-height: 92px;
  margin: 0;
  padding: 14px 18px;
  border: 0;
  border-radius: 12px;
}
#app .task.subject-photo .task-body { flex: 1 1 190px; }
#app .task.subject-photo :is(.btn, .task-tools) { margin: 0; }
#app .activity-list:has(> .activity-row) {
  display: grid;
  gap: 10px;
  padding: 0;
  background: transparent;
}
#app .activity-row {
  min-height: 84px;
  padding: 14px 17px;
  gap: 10px;
  border: 0;
  border-radius: 12px;
}
#app .activity-exchange { background: var(--workspace-card); }
#app .activity-row .activity-body { flex-basis: 188px; }
#app .activity-row .meta { align-items: center; }
#app .activity-row .activity-comment { display: block; margin-top: 7px; overflow-wrap: anywhere; }
:is(#app .activity-status, #modal .task-detail-status) {
  --status-ink: #514065;
  --status-surface: #eae2f3;
}
#app .activity-status {
  padding: 4px 8px;
  border-radius: 7px;
  background: var(--status-surface);
  color: var(--status-ink);
  font-weight: 750;
  line-height: 1.25;
}
:is(#app .activity-status, #modal .task-detail-status)[data-status=approved] { --status-ink: #20583b; --status-surface: #d7eddd; }
:is(#app .activity-status, #modal .task-detail-status)[data-status=rejected] { --status-ink: #8b2b3a; --status-surface: #f7dce2; }
:is(#app .activity-status, #modal .task-detail-status)[data-status=revision] { --status-ink: #6c4b05; --status-surface: #f7ebc6; }
:root[data-theme=dark] :is(#app .activity-status, #modal .task-detail-status) { --status-ink: #e7dbf5; --status-surface: #3a2d4d; }
:root[data-theme=dark] :is(#app .activity-status, #modal .task-detail-status)[data-status=approved] { --status-ink: #b5efc8; --status-surface: #264439; }
:root[data-theme=dark] :is(#app .activity-status, #modal .task-detail-status)[data-status=rejected] { --status-ink: #ffc4cd; --status-surface: #532d3b; }
:root[data-theme=dark] :is(#app .activity-status, #modal .task-detail-status)[data-status=revision] { --status-ink: #ffe5a0; --status-surface: #514022; }

#app .exchange-row.subject-photo { grid-template-columns: minmax(0, 1fr) 68px 110px 166px; }

/* Exchange requests */
.exchange-requests {
  --request-glass: #ede3f7ab;
  --request-highlight: #fff8;
  --request-ink: #362749;
  --request-muted: #5f4d72;
  --request-accent: #63449c;
  --request-edge: #9776bb6b;
  --request-edge-hover: #a784cd9e;
  --request-inset: #f8eeff8c;
  --request-hover: #f7effb78;
  position: relative;
  isolation: isolate;
  margin-top: 24px;
  padding: clamp(14px, 2.6vw, 25px);
  overflow: hidden;
  border-radius: 17px;
  background:
    radial-gradient(ellipse at 14% 0%, var(--request-highlight), transparent 58%),
    var(--request-glass);
  box-shadow: 0 12px 32px #1c0f301f, inset 0 0 15px #abadf021;
  backdrop-filter: blur(5px);
}

:root[data-theme=dark] .exchange-requests {
  --request-glass: #211a36b5;
  --request-highlight: #9b7fd442;
  --request-ink: #f3edf9;
  --request-muted: #c9bddb;
  --request-accent: #d8c2ff;
  --request-edge: #b397e174;
  --request-edge-hover: #be9fe4a6;
  --request-inset: #a688dc24;
  --request-hover: #b89cf51b;
}

.exchange-requests::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(143deg, var(--request-edge), #aa88d427 33%, #9775c324 63%, var(--request-edge));
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

#app #exchange-requests-title {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding-bottom: 14px;
  color: var(--request-ink);
  font-size: clamp(16px, 2.1vw, 22px);
  font-weight: 700;
  line-height: 1.25;
}

#exchange-requests-title::before {
  content: "";
  flex: 0 0 4px;
  height: 1em;
  border-radius: 6px;
  background: linear-gradient(#e1d2ff, #9a75db);
  box-shadow: 0 0 10px #9d76dd78;
}

#exchange-requests-title::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: linear-gradient(90deg, var(--request-edge), #a489c848, #997ad31b);
}

.exchange-request-list { display: grid; gap: 4px; }
.exchange-request {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 14px;
  min-height: 74px;
  padding: 10px 7px 10px 2px;
  border-radius: 10px;
}

.exchange-request:is(:hover, :focus-within) {
  background-color: var(--request-hover);
  box-shadow: inset 0 0 0 1px var(--request-edge-hover);
}

.exchange-request-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(143deg, var(--request-highlight), transparent 78%), var(--request-inset);
  box-shadow: inset 0 0 0 1px var(--request-edge), inset 0 -3px 9px #ad8ef12b, 0 4px 13px #49347232;
  color: var(--request-accent);
}

#app .exchange-request h3 {
  margin: 0 0 5px;
  color: var(--request-ink);
  font-size: clamp(15px, 1.7vw, 19px);
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

#app .exchange-request-body p {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 8px;
  margin: 0;
  color: var(--request-muted);
  font-size: 12px;
  line-height: 1.4;
}
.exchange-request-person { overflow-wrap: anywhere; }
.exchange-request-person::before { content: "·"; margin-inline-end: 8px; color: var(--request-accent); }
.exchange-request-end { display: grid; justify-items: end; gap: 7px; }
.exchange-request-status {
  --request-status-ink: var(--request-ink);
  --request-status-fill: var(--request-inset);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 33px;
  padding: 6px 11px;
  border-radius: 99px;
  background: var(--request-status-fill);
  box-shadow: inset 0 0 0 1px var(--request-edge), inset 0 2px 6px var(--request-highlight);
  color: var(--request-status-ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.exchange-request-status svg { flex: none; width: 17px; height: 17px; }
.exchange-request-status[data-status=approved] { --request-status-fill: #d7edddaf; --request-status-ink: #20583b; }
.exchange-request-status[data-status=rejected] { --request-status-fill: #f7dce2ac; --request-status-ink: #8b2b3a; }
:root[data-theme=dark] .exchange-request-status[data-status=approved] { --request-status-fill: #284738b5; --request-status-ink: #c2f3d3; }
:root[data-theme=dark] .exchange-request-status[data-status=rejected] { --request-status-fill: #522e3ab8; --request-status-ink: #ffd0d8; }
.exchange-request-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 6px; }
.exchange-request-actions button {
  min-height: 36px;
  padding: 4px 8px;
  border: 0;
  border-radius: 7px;
  background: var(--request-inset);
  color: var(--request-accent);
  font-size: 12px;
  font-weight: 700;
}
.exchange-request-actions button:hover { background: var(--request-highlight); }

@media (max-width: 560px) {
  .exchange-request { grid-template-columns: 41px minmax(0, 1fr); gap: 7px 10px; padding-inline: 2px; }
  .exchange-request-icon { width: 41px; height: 41px; border-radius: 9px; }
  .exchange-request-icon svg { width: 21px; height: 21px; }
  .exchange-request-end { grid-column: 2; justify-items: start; }
  .exchange-request-actions { justify-content: start; }
  .exchange-request-actions button { min-height: 44px; }
}

@media (max-width: 400px) {
  #app .exchange-request-body p { display: grid; gap: 3px; }
  .exchange-request-person::before { content: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .exchange-request, .exchange-request-actions button { transition: background-color .26s ease, box-shadow .26s ease; }
  .exchange-requests[data-requests-visible]:not([data-requests-settled]) .exchange-request {
    animation: exchange-request-arrive .31s cubic-bezier(.2,.69,.28,1) var(--request-delay) both;
  }
}
@keyframes exchange-request-arrive { from { opacity: 0; transform: translateY(5px); } }

@media (max-width: 1199px) {
  #app .exchange-row.subject-photo { grid-template-columns: minmax(0, 1fr) 64px 148px; }
}

@media (max-width: 767px) {
  #app .exchange-row.subject-photo { grid-template-columns: minmax(0, 1fr) 62px; }
  #app .subject-photo::before {
    inset-inline-start: 32%;
    background: linear-gradient(90deg, var(--photo-card), color-mix(in srgb, var(--photo-card) 72%, transparent)),
      var(--subject-photo) center / cover no-repeat;
  }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    #app {
      --list-edge-inset: 0px;
      --list-fade-extension: 44px;
    }
    #app :is(.subject-list, .task-list, .exchange-list, .activity-list, .member-list, .leaderboard-table tbody):has(> :nth-child(4))
      > :is(li, .task, .exchange-row, .activity-row, tr) {
      animation: list-row-reveal linear both;
      animation-timeline: view(block 0px var(--list-edge-inset));
      animation-range: entry 0% entry calc(100% + var(--list-fade-extension));
    }
    #app :is(.subject-list, .task-list, .exchange-list, .activity-list, .member-list, .leaderboard-table tbody):has(> :nth-child(4))
      > :is(li, .task, .exchange-row, .activity-row, tr):focus-within {
      animation: none;
    }
    @media (max-width: 767px) {
      #app {
        --list-edge-inset: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
        --list-fade-extension: 24px;
      }
    }
  }
}

@keyframes list-row-reveal {
  from { opacity: .15; }
  55% { opacity: .57; }
  to { opacity: 1; }
}

@media (min-width: 768px) and (max-width: 1199px) {
  :root { --sidebar-width: 145px; }
  body:not(.signed-out) > aside { padding-inline: 20px 8px; }
  #nav { padding-left: 24px; padding-right: 4px; }
  #nav > a { gap: 4px; padding-inline: 3px; font-size: 11px; }
  #nav .nav-label { overflow-wrap: normal; }
  body > aside .sidebar-brand > span { font-size: 10px; }
}

@media (max-width: 767px) {
  :root { --bottom-nav-height: 98px; }
  body:not(.signed-out) > aside {
    inset: auto max(10px, env(safe-area-inset-right)) max(9px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    width: auto;
    height: 63px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }
  #nav {
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-rows: minmax(0, 1fr);
    align-items: stretch;
    height: 100%;
    padding: 0 4px 4px;
    gap: 0;
  }
  #nav > a {
    display: flex;
    flex-direction: column;
    justify-content: start;
    gap: 3px;
    min-height: 0;
    padding: 10px 1px 2px;
    font-size: 10px;
    line-height: 1.1;
    text-align: center;
  }
  #nav .navicon { width: 21px; height: 21px; }
  #nav .nav-label {
    display: inline-grid;
    place-items: center;
    width: fit-content;
    max-width: 100%;
    min-height: 20px;
    padding: 2px 4px;
    border-radius: 10px;
  }
  #nav > a:is([aria-current], :hover:not([aria-current])) { background-color: transparent; }
  #nav > a:hover:not([aria-current]) .nav-label { background-color: var(--dock-hover); }
  #nav > a[href="#subjects"] .nav-label {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 1px 0;
    line-height: 1.15;
    overflow-wrap: normal;
  }
  #nav > a[href="#subjects"] .nav-label > span { display: block; }
  .subject-row-text { min-width: 0; }
  .subject-row .subject-row-text small { overflow-wrap: anywhere; }
  .portal-topbar {
    min-height: calc(64px + env(safe-area-inset-top));
    padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
    gap: 8px;
  }
  .portal-topbar .school { gap: 8px; }
  .portal-topbar .school-name {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    white-space: normal;
    font-size: 12px;
  }
  .school-mark { flex-basis: 34px; height: 34px; }
  .portal-topbar .header-right { gap: 6px; }
  .portal-topbar .header-profile { width: 44px; justify-content: center; padding: 4px; }
  .portal-topbar .header-profile-text, .portal-topbar .header-profile-arrow { display: none; }
  .header-class { max-width: 58px; padding-inline: 7px; }
  dialog.notifications-sheet {
    inset: calc(72px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) auto auto;
    max-height: calc(100dvh - 88px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .portal-login { padding: 21px 18px; border-radius: 17px; }
  .portal-login h1 { font-size: 25px; }
  .login-brand { margin-bottom: 15px; }
  .subject-row { padding-inline: 10px; gap: 10px; }
}

@media (max-width: 359px) {
  #nav > a { font-size: 9px; }
  #nav .nav-label { padding-inline: 2px; overflow-wrap: normal; }
  #nav > a[href="#subjects"] .nav-label { font-size: 9px; }
  .school-mark { display: none; }
}

:is(#nav, .portal-topbar, .notifications-sheet, .portal-login, .subject-list) :is(button, a):focus-visible {
  outline: 2px solid var(--portal-focus);
  outline-offset: 2px;
}

#nav > a:focus-visible { outline-width: 1px; outline-style: dashed; outline-offset: -1px; }

@media (prefers-reduced-motion: reduce) {
  dialog.notifications-sheet[open] { animation: none; }
}

/* Segmented filters */
.tabs.portal-segments {
  position: relative;
  isolation: isolate;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, auto);
  gap: 4px;
  max-width: 100%;
  padding: 4px;
  overflow: visible;
  border: 1px solid #3d3249;
  border-radius: 10px;
  background: var(--portal-graphite);
  vertical-align: top;
}

:root .tabs.portal-segments > button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #c9bfd5;
  box-shadow: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.28;
  text-align: center;
}

:root .tabs.portal-segments > button:is(.active, [aria-selected=true]) {
  border-color: transparent;
  background: transparent;
  color: #fcf3ff;
}

.tabs.portal-segments > button:hover:not(.active) { background: #30263b; color: #f3e7fb; }
.tabs.portal-segments > button:focus-visible { outline: 2px solid #e5baff; outline-offset: -3px; }
:root .tabs.portal-segments > button[role=tab] span { background: #9466be36; color: #f0dfff; }

.segment-indicator {
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  border: 1px solid #b77aef;
  border-radius: 6px;
  background: #593777;
  box-shadow: 0 2px 11px #9c5adc3d;
  pointer-events: none;
}

@media (max-width: 1023px) {
  .portal-segments[data-segments=tasks] { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-flow: row; grid-auto-rows: 1fr; }
  :root .tabs.portal-segments[data-segments=tasks] > button { padding-inline: 4px; }
}

@media (max-width: 359px) {
  :root .tabs.portal-segments > button { font-size: 12px; }
  .portal-segments[data-segments=tasks]:has([data-tab=archived]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Profile avatars and school directory */
.public-profile .profile-cover-neon {
  height: 136px;
}

#app .public-profile,
#modal.achievements-sheet {
  --profile-glass: linear-gradient(145deg, #fcf9ffe8, #f4edf7ad);
  --profile-tile: linear-gradient(150deg, #fbf5fed9, #e9def2a6);
  --profile-glyph: linear-gradient(145deg, #ebdcfa, #e0cfee92);
  --profile-rim: #774c9c30;
  --profile-highlight: #fffc;
  --profile-ink: #382a49;
  --profile-muted: #62536f;
  --profile-accent: #70449a;
  background: var(--profile-glass);
  border: 1px solid var(--profile-rim);
  border-radius: 19px;
  box-shadow: inset 0 1px 0 var(--profile-highlight), 0 14px 35px #10091b1c;
}

:root[data-theme=dark] #app .public-profile,
:root[data-theme=dark] #modal.achievements-sheet {
  --profile-glass: radial-gradient(ellipse at 94% 0, #69489429, transparent 58%),
    linear-gradient(145deg, #211a2cd4, #191522b8);
  --profile-tile: linear-gradient(150deg, #52376c45, #34254139);
  --profile-glyph: linear-gradient(145deg, #8b5ca84a, #70539528);
  --profile-rim: #b693df28;
  --profile-highlight: #d3b2ff26;
  --profile-ink: #f2edf9;
  --profile-muted: #c8b9d6;
  --profile-accent: #d5b5f5;
}

#app .public-profile { padding: 0; }
#app .public-profile .profile-cover-neon {
  background: radial-gradient(ellipse at 76% 0, #a776d45c, transparent 78%),
    linear-gradient(116deg, #6448865c, #9c69be3c 62%, #7660b567);
  box-shadow: inset 0 1px 0 var(--profile-highlight);
}
#app .public-profile .public-profile-avatar { border-color: var(--profile-rim); }
#app .public-profile .profile-role-pill {
  background: var(--profile-tile);
  border: 1px solid var(--profile-rim);
  color: var(--profile-accent);
}

#app .public-profile-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--profile-rim);
}

#app .public-profile .profile-stat,
#app .public-profile .mini-award,
#modal.achievements-sheet .earned-achievement {
  position: relative;
  min-width: 0;
  background: var(--profile-tile);
  border: 1px solid transparent;
  border-radius: 13px;
  box-shadow: inset 0 1px 0 var(--profile-highlight);
  color: var(--profile-ink);
}

#app .public-profile .profile-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 15px;
}

.profile-glyph {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  color: var(--profile-accent);
  background: var(--profile-glyph);
  box-shadow: inset 0 1px 0 var(--profile-highlight);
  border: 1px solid var(--profile-rim);
  border-radius: 10px;
}

.profile-glyph svg { width: 19px; height: 19px; }
.profile-metric-copy { display: grid; min-width: 0; gap: 4px; }
#app .public-profile .profile-stat strong {
  font-size: 29px;
  line-height: 1.1;
  font-weight: 650;
  color: var(--profile-ink);
  font-variant-numeric: tabular-nums;
}
#app .public-profile .profile-stat small,
#app .public-profile .mini-award :is(small, time),
#modal.achievements-sheet :is(.achievement-owner small, .earned-achievement p, .earned-achievement time) {
  color: var(--profile-muted);
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.profile-link-arrow { position: absolute; inset: 13px 13px auto auto; color: var(--profile-accent); }
.profile-link-arrow svg, .achievements-button > svg { display: block; width: 15px; height: 15px; }
#app .public-profile .achievement-stat { cursor: pointer; transition: border-color 240ms, box-shadow 240ms; }
#app .public-profile .achievement-stat:hover {
  transform: none;
  border-color: var(--profile-rim);
  box-shadow: inset 0 1px 0 var(--profile-highlight), 0 0 16px var(--profile-rim);
}

#app .public-profile .achievements-button,
#app .public-profile .profile-logout {
  min-height: 44px;
  background: var(--profile-tile);
  border: 1px solid var(--profile-rim);
  border-radius: 11px;
  box-shadow: inset 0 1px 0 var(--profile-highlight);
  color: var(--profile-ink);
  transition: box-shadow 240ms, background 240ms;
}
#app .public-profile .achievements-button { justify-content: flex-start; margin-top: 16px; padding: 10px 14px; }
#app .public-profile .achievements-button > span { background: var(--profile-glyph); color: var(--profile-accent); font-size: 11px; text-align: center; }
#app .public-profile .achievements-button > svg { margin-inline-start: auto; color: var(--profile-accent); }
#app .public-profile .profile-logout { display: flex; margin: 20px auto 0; background: transparent; box-shadow: none; color: var(--profile-muted); }
#app .public-profile :is(.achievements-button, .profile-logout):hover { background: var(--profile-glyph); }
#app .public-profile :is(.achievement-stat, .achievements-button, .profile-logout):focus-visible,
#modal.achievements-sheet .sheet-close:focus-visible { outline: 2px solid var(--portal-focus); outline-offset: 2px; }
#app .public-profile .profile-awards-preview { grid-template-columns: repeat(auto-fit, minmax(min(100%, 175px), 1fr)); gap: 10px; margin-top: 10px; }
#app .public-profile .mini-award { gap: 12px; padding: 13px; }
#app .public-profile .mini-award strong { color: var(--profile-ink); font-size: 13px; overflow-wrap: anywhere; }
#app .public-profile .mini-award time { display: block; margin-top: 4px; font-size: 11px; }

#modal.achievements-sheet { --achievement-spacing: clamp(14px, 4vw, 24px); backdrop-filter: blur(16px); }
#modal.achievements-sheet .sheet-header {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--profile-rim);
  padding: 10px var(--achievement-spacing);
}
#modal.achievements-sheet .sheet-header h2 { color: var(--profile-ink); font-size: 19px; font-weight: 650; }
#modal.achievements-sheet .sheet-close {
  display: grid;
  place-items: center;
  position: static;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: var(--profile-accent);
  background: transparent;
}
#modal.achievements-sheet .sheet-close:hover { background: var(--profile-glyph); }
#modal.achievements-sheet .sheet-close svg { width: 19px; height: 19px; }
#modal.achievements-sheet .achievement-catalog { padding: 16px var(--achievement-spacing) var(--achievement-spacing); }
#modal.achievements-sheet .achievement-owner { padding: 0 0 16px; }
#modal.achievements-sheet .achievement-owner strong { color: var(--profile-ink); overflow-wrap: anywhere; }
#modal.achievements-sheet .achievement-owner .avatar { flex-shrink: 0; }
#modal.achievements-sheet .achievement-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 10px;
}
#modal.achievements-sheet .earned-achievement {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  text-align: start;
  padding: 14px;
}
#modal.achievements-sheet .earned-achievement h3 { color: var(--profile-ink); margin: 1px 0 4px; font-size: 15px; overflow-wrap: anywhere; }
#modal.achievements-sheet .earned-achievement p { margin: 0; min-height: 0; }
#modal.achievements-sheet .earned-achievement time { border: 0; padding: 0; margin-top: 6px; }

@media (max-width: 520px) {
  #app .public-profile-stats { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  #app .public-profile .profile-stat { flex-direction: row; align-items: center; padding: 10px 12px; }
  #app .public-profile .profile-stat strong { font-size: 24px; }
  #app .public-profile .profile-stat small { font-size: 12px; }
  #app .public-profile .achievement-stat { padding-inline-end: 39px; }
  .profile-link-arrow { inset-block: 50% auto; transform: translateY(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  #app .public-profile :is(.achievement-stat, .achievements-button, .profile-logout) { transition: none; }
}

.avatar:has(> .avatar-face) { position: relative; }
.avatar > .avatar-face { position: absolute; inset: 0; width: auto; height: auto; }
.header-profile .avatar-face { border-radius: inherit; }

.avatar-face {
  --avatar-base: #271c49;
  --avatar-light: #ab83ff;
  --avatar-shade: #7154d4;
  --avatar-ink: #231046;
  --avatar-shape: 52% 47% 45% 49%;
  position: relative;
  isolation: isolate;
  display: inline-block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
  background: var(--avatar-base);
  color: var(--avatar-ink);
  vertical-align: middle;
}

.avatar-face::before {
  content: '';
  position: absolute;
  inset: 14% 15% 15%;
  border-radius: var(--avatar-shape);
  background: linear-gradient(145deg, var(--avatar-light), var(--avatar-shade));
  box-shadow: inset 0 1px 0 #ffffff45, 0 3px 8px #10091c46;
  transform: rotate(-13deg);
}

.avatar-face::after {
  content: '';
  position: absolute;
  top: 55%;
  left: 44%;
  width: 12%;
  height: 9%;
  border-radius: 0 0 60% 60%;
  background: currentColor;
}

.avatar-face > span { position: absolute; inset: 42% 34% auto; height: 9%; }

.avatar-face > span::before,
.avatar-face > span::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  aspect-ratio: 1;
  border-radius: 50%;
  background: currentColor;
}

.avatar-face > span::after { inset-inline: auto 0; }
.avatar-face[data-avatar-face=ember] { --avatar-base: #4a2538; --avatar-light: #ffd18a; --avatar-shade: #ef805a; --avatar-ink: #491d2b; --avatar-shape: 65% 41% 54% 42%; }
.avatar-face[data-avatar-face=mint] { --avatar-base: #173f42; --avatar-light: #affecc; --avatar-shade: #43b7a3; --avatar-ink: #164650; --avatar-shape: 55% 55% 46% 47%; }
.avatar-face[data-avatar-face=berry] { --avatar-base: #501f47; --avatar-light: #ff9ac7; --avatar-shade: #db448e; --avatar-ink: #4c163e; --avatar-shape: 42% 47% 53% 54%; }
.avatar-face[data-avatar-face=moon] { --avatar-base: #33263c; --avatar-light: #ffe7a8; --avatar-shade: #b498d4; --avatar-ink: #452961; --avatar-shape: 50%; }
.avatar-face[data-avatar-face=sky] { --avatar-base: #25334f; --avatar-light: #b3e9ff; --avatar-shade: #7797ff; --avatar-ink: #223771; --avatar-shape: 54% 51% 37% 44%; }

.profile-avatar-editor {
  --picker-text: #32263c;
  --picker-border: #e0d1ed;
  --picker-focus: #7746b3;
  --picker-hover: #f3eafb;
  min-width: 0;
  padding: 0;
  margin: 23px 0 20px;
  border: none;
}

:root[data-theme=dark] .profile-avatar-editor {
  --picker-text: #efe6f8;
  --picker-border: #534361;
  --picker-focus: #d6a7ff;
  --picker-hover: #30253e;
}

.profile-avatar-editor legend { padding: 0; margin: 0 0 11px; color: var(--picker-text); font-size: 15px; font-weight: 750; }
.avatar-options { display: grid; grid-template-columns: repeat(6, minmax(0, 74px)); gap: 7px; }
.avatar-options > button {
  display: grid;
  justify-items: center;
  gap: 5px;
  min-width: 0;
  padding: 6px 3px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--picker-text);
  transition: background-color .18s, border-color .18s;
}

.avatar-options .avatar-face {
  width: 43px;
  height: 43px;
  border-radius: 50%;
  transition: transform .2s cubic-bezier(.2,.72,.25,1);
}

.avatar-option-name { font-size: 12px; line-height: 1.2; overflow-wrap: anywhere; }
.avatar-options > button:hover:not(:disabled) { background: var(--picker-hover); }
.avatar-options > button:hover:not(:disabled) .avatar-face { transform: translateY(-2px) scale(1.05); }
.avatar-options > button[aria-pressed=true] { border-color: var(--picker-focus); background: var(--picker-hover); }
.avatar-options > button[aria-pressed=true] .avatar-face { outline: 2px solid var(--picker-focus); outline-offset: 2px; }

.profile-avatar-actions { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 12px; }
.profile-photo-reset {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--picker-border);
  border-radius: 8px;
  background: transparent;
  color: var(--picker-text);
  font-size: 13px;
  font-weight: 700;
  transition: background-color .18s, border-color .18s;
}
.profile-photo-reset { border-color: transparent; }
.profile-photo-reset:hover { background: var(--picker-hover); border-color: var(--picker-border); }
.profile-avatar-editor:disabled :is(.avatar-options, .profile-avatar-actions) { opacity: .66; }
.profile-avatar-editor .avatar-edit-message { margin: 9px 0 0; color: var(--picker-text); font-size: 13px; }
.avatar-edit-message:empty { display: none; }

.profile-directory {
  --member-surface: #fffcff;
  --member-hover: #f7effd;
  --member-line: #e4d9ef;
  --member-text: #332542;
  --member-muted: #6b5b79;
  --member-ink: #6b3cb1;
  --member-tag: #efe5fa;
  max-width: 820px;
  margin-inline: auto;
  scroll-margin-block-start: 4px;
}

:root[data-theme=dark] .profile-directory {
  --member-surface: #211a2a;
  --member-hover: #2c2138;
  --member-line: #493954;
  --member-text: #f2e9f9;
  --member-muted: #bfaecc;
  --member-ink: #d7afff;
  --member-tag: #39294b;
}

.profile-directory .directory-heading h2 { margin: 0; font-size: 22px; }
.profile-directory .tabs.portal-segments { margin: 15px 0; }
.member-list { display: grid; gap: 8px; padding: 0; margin: 0; list-style: none; }

.member-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 10px 14px;
  border: 1px solid var(--member-line);
  border-radius: 12px;
  background: var(--member-surface);
  color: var(--member-text);
  text-align: left;
  transition: background-color .18s, border-color .18s;
}

.member-row:hover { background: var(--member-hover); border-color: var(--member-ink); }
.member-avatar > .avatar { display: grid; width: 44px; height: 44px; margin: 0; overflow: hidden; border-radius: 50%; }
.member-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-name { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.member-name strong { font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.profile-directory .member-name small { padding: 1px 7px; border-radius: 6px; background: var(--member-tag); color: var(--member-ink); font-size: 11px; font-weight: 750; }
.member-detail { display: block; margin-top: 3px; color: var(--member-muted); font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.member-open { display: grid; place-items: center; color: var(--member-ink); }
.member-open svg { width: 17px; height: 17px; }

@media (max-width: 767px) {
  .public-profile .profile-cover-neon { height: 105px; }
}

@media (max-width: 479px) {
  .avatar-options { grid-template-columns: repeat(3, minmax(0, 74px)); gap: 7px 9px; }
  .member-row { gap: 10px; padding: 10px 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .avatar-options > button:hover:not(:disabled) .avatar-face { transform: none; }
}

/* File uploads */
.file-upload { width: 100%; min-width: 0; color-scheme: dark; }

label.file-upload-drop {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 29px;
  align-items: center;
  gap: 11px;
  min-height: 64px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 12px;
  background:
    linear-gradient(112deg, #100d14, #191022 68%, #120c1c) padding-box,
    linear-gradient(109deg, #392d49 14%, #a86af8 38%, #4a285e 57%, #271f32 80%) border-box;
  background-position: 0 0, 10% 0;
  background-size: auto, 235% 100%;
  cursor: pointer;
  transition: box-shadow .18s, background-color .18s;
}

@media (prefers-reduced-motion: no-preference) {
  label.file-upload-drop { animation: file-border-drift 7s ease-in-out infinite alternate; }
}

@keyframes file-border-drift {
  to { background-position: 0 0, 92% 0; }
}

label.file-upload-drop:is(:hover, :focus-within, .is-dragging):not(:has(input:disabled)) {
  box-shadow: 0 0 0 1px #b579f99c, 0 5px 20px #a047f348;
}

label.file-upload-drop.is-dragging {
  background:
    linear-gradient(112deg, #1a1026, #2b153f) padding-box,
    linear-gradient(110deg, #8251ba, #e0b4ff 65%, #9960ed) border-box;
  animation: none;
}

label.file-upload-drop:has(input:disabled) { cursor: default; }

.file-upload-drop input[type=file] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: inherit;
}

.file-upload-icon,
.file-upload-action {
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #dfbbff;
  background: #2b1d39;
}

.file-upload-icon { width: 36px; height: 36px; }
.file-upload-action { width: 29px; height: 29px; border: 1px solid #5d3a7c; background: #251633; }
.file-upload-copy { min-width: 0; }
.file-upload-copy strong { display: block; color: #f6eeff; font-size: 14px; line-height: 1.3; }
.file-upload-copy small { display: block; margin-top: 3px; color: #c6b2d8; font-size: 12px; line-height: 1.35; }
.file-upload[data-upload-state=busy] label.file-upload-drop { cursor: progress; }
.file-upload[data-upload-state=error] label.file-upload-drop { box-shadow: inset 0 0 0 1px #f293bd; }

.file-upload .file-upload-status {
  margin: 6px 2px 0;
  color: #68439a;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

:root[data-theme=dark] .file-upload .file-upload-status { color: #d5b1fa; }
:root .file-upload[data-upload-state=error] .file-upload-status { color: #9c375d; }
:root[data-theme=dark] .file-upload[data-upload-state=error] .file-upload-status { color: #ffb0d1; }
.file-upload .file-upload-status:empty { margin: 0; }
.profile-avatar-actions .file-upload { max-width: 460px; }
