:root {
  color: #263657;
  background: #f5f8ff;
  --ink: #263657;
  --muted: #51617a;
  --line: #dde5f3;
  --paper-shadow: 0 3px 0 #dce5f5;
  --blue: #3158ad;
}

.topbar { background: #fff; }
.brand strong, .heading h1 { color: var(--ink); }
.side-note { background: #fff3d6; color: #57452e; border-radius: 20px; }
.nav button.active { color: #284f9f; background: #eaf1ff; }
.nav button.active::before { background: #5c80d4; }
.nav button.active svg { color: #3158ad; }
.btn { border-radius: 13px; }
.btn.primary { background: var(--blue); box-shadow: 0 3px 0 #214184; }
.btn.primary:hover { background: #244a9e; }
.btn.soft { background: #ebf2ff; color: #2d5098; }

.reading-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .95fr);
  gap: clamp(6px, 2vw, 24px);
  min-height: 280px;
  border: 1px solid #cbdcf5;
  border-radius: 29px;
  background: radial-gradient(ellipse at 80% 75%, #c9d9ff 0%, transparent 53%), #e4f0ff;
  box-shadow: 0 4px 0 #cfdff6;
}
.reading-hero .hero-copy { max-width: none; }
.reading-hero .hero-copy h2 { color: #223d72; font-size: clamp(25px, 3.5vw, 44px); line-height: 1.28; letter-spacing: .02em; }
.reading-hero .hero-copy p { color: #405a83; font-size: 15px; margin-bottom: 20px; }
.reading-friends { display: block; width: 100%; height: auto; max-height: 265px; object-fit: contain; }
.stat, .lesson-feature, .tool-card, .daily, .review-card, .course-card, .practice-card, .paper { box-shadow: var(--paper-shadow); }
.stat, .tool-card, .course-card, .daily, .review-card { border-radius: 21px; }
.stat:nth-child(1) .icon-box, .tool-card:nth-child(1) .tool-icon { background: #e1edff; color: #3158ad; }
.stat:nth-child(2) .icon-box, .tool-card:nth-child(2) .tool-icon { background: #ffedbd; color: #8a570c; }
.stat:nth-child(3) .icon-box, .tool-card:nth-child(3) .tool-icon { background: #d9f4e6; color: #217350; }
.tool-card:hover, .course-card:focus-within { border-color: #9ab4e6; }
.reader-tabs { background: #eaf1ff; border-color: #d1dff6; }
.reader-tabs button.selected, .reader-tabs [data-reader-tab="exercises"].selected { background: var(--blue); }
.worksheet-banner { background: #e8eeff; border-color: #d7defc; box-shadow: 0 3px 0 #e3e8fa; }
.worksheet-banner .pencil-mascot { background: #ffe7aa; }
.worksheet-question[data-scan="true"] .exercise-option { min-height: 46px; }

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  min-width: 0;
  padding: 5px 11px 5px 5px;
  border: 1px solid #c9d8f3;
  border-radius: 16px;
  background: #f3f7ff;
  box-shadow: 0 2px 0 #d6e2f8;
  text-align: left;
}
.profile-trigger:hover, .profile-choice:hover { background: #edf3ff; border-color: #90ace3; }
.profile-trigger-label { display: grid; gap: 1px; min-width: 0; }
.profile-trigger-label strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 10em; font-size: 14px; }
.profile-trigger-label small { font-size: 12px; color: #345894; white-space: nowrap; }
.profile-avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 39px;
  height: 39px;
  font-size: 24px;
  line-height: 1;
  border-radius: 13px;
  background: #ffebcc;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.profile-avatar[data-animal="rabbit"] { background: #eadfff; }
.profile-avatar[data-animal="bear"] { background: #dcefe6; }
.profile-avatar[data-animal="duck"] { background: #fff0b2; }
.profile-avatar[data-animal="panda"] { background: #dcebff; }
.profile-avatar[data-animal="koala"] { background: #fde4ef; }
.profile-avatar.large { width: 66px; height: 66px; border-radius: 22px; font-size: 41px; }

dialog:has(.profile-choices, .profile-list, .avatar-picker) { border-radius: 27px; border-color: #cad8f5; }
.profile-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.profile-choice {
  display: grid;
  place-items: center;
  align-content: start;
  gap: 8px;
  min-width: 0;
  padding: 14px 6px 12px;
  border: 1px solid #d5e1f6;
  border-radius: 19px;
  background: #f8faff;
}
.profile-choice.is-current { border-color: #7c9bda; box-shadow: inset 0 0 0 1px #7c9bda; background: #edf3ff; }
.profile-choice strong, .profile-row-name strong { overflow-wrap: anywhere; }
.profile-choice small, .profile-row-name small { color: #3f5c91; font-size: 12px; }
.profile-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.profile-row { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid #dfe8f8; border-radius: 14px; background: #f8faff; }
.profile-row-name { display: grid; gap: 2px; flex: 1; min-width: 0; }
.profile-row-actions { display: flex; align-items: center; gap: 6px; }
.profile-row-actions button { min-height: 40px; }
.archived-profiles { margin-top: 18px; color: #345894; }
.archived-profiles summary { cursor: pointer; }
.avatar-picker { border: 0; padding: 0; margin: 0; }
.avatar-picker legend { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.avatar-picker > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.avatar-picker label { position: relative; display: grid; justify-items: center; gap: 5px; padding: 9px 4px; border: 1px solid #dfe8f8; border-radius: 13px; cursor: pointer; font-size: 13px; text-align: center; }
.avatar-picker label:has(input:checked) { background: #edf3ff; border-color: #5278c1; box-shadow: inset 0 0 0 1px #5278c1; }
.avatar-picker label:has(input:focus-visible) { outline: 3px solid #edab57; outline-offset: 2px; }
.avatar-picker input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.settings-profile { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.settings-profile .btn { margin-left: auto; }

@media (max-width: 720px) {
  .topbar { padding-inline: 15px; }
  .topbar .streak { display: none; }
  .profile-trigger { max-width: 48vw; }
  .profile-trigger .profile-avatar { width: 32px; height: 32px; font-size: 21px; }
  .profile-trigger-label strong { max-width: 9em; }
  .reading-hero { min-height: 218px; padding: 20px 14px 20px 18px; border-radius: 22px; }
  .reading-hero .hero-copy h2 { font-size: clamp(21px, 5.4vw, 31px); }
  .reading-hero .hero-copy p { font-size: 13px; margin-bottom: 14px; }
}

@media (max-width: 370px) {
  .profile-choice strong { font-size: 13px; }
  .profile-choice .profile-avatar.large { width: 50px; height: 50px; font-size: 32px; border-radius: 16px; }
  .mobile-logo { font-size: 14px; gap: 5px; }
  .reading-hero { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); }
}

@media (prefers-reduced-motion: reduce) {
  .view-enter { animation: none; }
}
