/* Mobile-first. This is read on a phone, standing in a hallway.
   A school app: light and warm on purpose, with colour where there is
   good news (grades, attendance) and calm everywhere else. */
:root {
  --bg: #fffaf2;
  --sky: #e0f2fe;
  --sun-soft: #fef3c7;
  --surface: #ffffff;
  --border: #f0e6d6;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #0369a1;
  --accent-2: #0f766e;
  --accent-contrast: #ffffff;
  --unread: #f97316;
  --unread-bg: #fff7ed;
  --error-bg: #fff1f2;
  --error-text: #be123c;
  --flash-bg: #ecfdf5;
  --flash-text: #047857;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 41, 55, 0.05), 0 6px 18px rgba(31, 41, 55, 0.06);
  --shadow-lift: 0 2px 4px rgba(31, 41, 55, 0.06), 0 10px 26px rgba(31, 41, 55, 0.10);

  /* Grade families, 6 down to 1: sunny at the top, gentle at the bottom. */
  --top-bg: linear-gradient(135deg, #fde68a, #fbbf24 55%, #f59e0b);
  --top-text: #78350f;
  --great-bg: #bbf7d0;  --great-text: #166534;  --great-bar: #22c55e;
  --good-bg: #bae6fd;   --good-text: #075985;   --good-bar: #38bdf8;
  --fair-bg: #fef9c3;   --fair-text: #854d0e;   --fair-bar: #facc15;
  --weak-bg: #fed7aa;   --weak-text: #9a3412;   --weak-bar: #fb923c;
  --low-bg: #fecaca;    --low-text: #991b1b;    --low-bar: #f87171;
  --other-bg: #f1f5f9;  --other-text: #475569;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 320px at 100% -40px, var(--sun-soft), transparent 70%),
    linear-gradient(180deg, var(--sky) 0, var(--bg) 300px) no-repeat,
    var(--bg);
  color: var(--text);
  font: 16px/1.5 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }

main { padding: 12px 16px 32px; max-width: 760px; margin: 0 auto; }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid rgba(240, 230, 214, 0.8);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 1.15rem; letter-spacing: -0.01em;
}
.brand-name {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8, #14b8a6);
  color: #fff; font-size: 1rem;
  box-shadow: 0 3px 10px rgba(14, 165, 233, 0.35);
}
.logo svg { display: block; }
.actions { display: flex; align-items: center; gap: 6px; }
.inline { display: inline; margin: 0; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 1.1rem; cursor: pointer;
  box-shadow: 0 1px 2px rgba(31, 41, 55, 0.05);
  transition: transform 0.15s ease, background 0.15s ease;
}
.icon-btn:active { transform: scale(0.92); background: var(--sky); }
.icon-btn .ico { display: block; }
.icon-btn.spinning .ico { animation: spin 0.9s linear infinite; }

/* --- child switcher & tabs --- */
.childbar {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 2px 2px 10px; margin: 0 -2px 6px;
  scrollbar-width: none;
}
.childbar::-webkit-scrollbar { display: none; }

/* All eight categories in one row: on a phone the chosen tab carries its
   label and the rest are icons with their unread badge; wider screens have
   room to label them all. Deliberately not animated — every tab is a page
   load, and a transition would replay on each one. */
/* On the feed the tab row, not the top bar, is what stays on screen: the
   tabs are what you reach for mid-list, while refresh, settings and the
   child switcher are one scroll up. Full-bleed, so cards pass under it. */
.with-tabs .topbar { position: relative; }
.tabs {
  display: flex; gap: 4px;
  position: sticky; top: 0; z-index: 9;
  margin: 0 -16px 14px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  border-bottom: 1px solid transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
/* A background only once it has something scrolling under it; at the top of
   the page it sits on the page's own wash. */
.tabs.stuck {
  background: rgba(255, 250, 242, 0.96);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom-color: var(--border); box-shadow: 0 6px 16px rgba(31, 41, 55, 0.06);
}
/* The row is shared out: every tab an equal part, the chosen one two parts
   (and never less than its label needs). With few tabs the icons get room;
   with all eight they are still at least 36px. */
.tabs .tab {
  position: relative; flex: 1 1 0; min-width: 36px; height: 48px; padding: 0;
  flex-direction: column; justify-content: center; gap: 3px;
  border-radius: 13px; font-size: 0.7rem; font-weight: 700;
}
.tabs .tab.active { flex: 2 1 0; min-width: max-content; padding: 0 8px; }
.tab-icon { font-size: 1.15rem; line-height: 1; }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs .tab:not(.active) .tab-label { display: none; }
.tabs .badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 17px; line-height: 17px; font-size: 0.65rem;
  box-shadow: 0 0 0 2px var(--bg);
}
.tabs .tab.active .badge { top: 4px; right: 6px; box-shadow: none; }
@media (min-width: 600px) {
  .tabs { margin-inline: -16px; padding-inline: 16px; }
  .tabs .tab, .tabs .tab.active { flex: 1 1 0; min-width: 0; }
  .tabs .tab:not(.active) .tab-label { display: block; }
}

.chip, .tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 0.875rem; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(31, 41, 55, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.chip:active, .tab:active { transform: scale(0.95); }
.chip.active, .tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-contrast); border-color: transparent;
  box-shadow: 0 4px 12px rgba(3, 105, 161, 0.28);
}
.chip { font-weight: 600; }
.avatar {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--sun-soft); color: #92400e; font-size: 0.72rem; font-weight: 800;
}
.chip.active .avatar { background: rgba(255, 255, 255, 0.9); color: var(--accent); }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--unread); color: #fff;
  font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center;
  animation: pop 0.4s cubic-bezier(.34, 1.56, .64, 1) both;
}
.tab.active .badge { background: #fff; color: var(--accent); }

/* --- search (on the 'Wszystko' tab) --- */
.search { position: relative; margin: 2px 0 12px; }
.search input[type="search"] {
  width: 100%; padding: 11px 42px 11px 40px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.95rem; box-shadow: 0 1px 2px rgba(31, 41, 55, 0.04);
  -webkit-appearance: none; appearance: none;
}
.search input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.search input[type="search"]:focus { outline: 2px solid #7dd3fc; outline-offset: 1px; }
.search-icon, .search-clear {
  position: absolute; top: 50%; transform: translateY(-50%);
  display: inline-grid; place-items: center; color: var(--muted);
}
.search-icon { left: 14px; pointer-events: none; }
.search-icon .ico, .search-clear .ico { width: 18px; height: 18px; }
.search-clear { right: 6px; width: 32px; height: 32px; border-radius: 50%; }
.search-clear:active { background: var(--other-bg); }
.search-count { margin: -4px 4px 10px; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
mark { background: #fde68a; color: inherit; border-radius: 3px; padding: 0 1px; }

/* --- cards --- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.list > li {
  animation: rise 0.38s ease-out both;
  animation-delay: calc(min(var(--i, 0), 14) * 28ms);
}
.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:active { transform: scale(0.985); }
@media (hover: hover) {
  .card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
}
.card > a { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; }
.card .content { flex: 1; min-width: 0; }
.card.unread { background: var(--unread-bg); border-color: #fed7aa; }
.card.unread .card-title::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin: 0 7px 2px 0;
  border-radius: 50%; background: var(--unread); vertical-align: middle;
  box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.5);
  animation: ping 2.4s ease-out 3;
}
.card-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 6px;
}
.card-title { font-weight: 650; line-height: 1.35; }
.card-sub { color: var(--muted); font-size: 0.875rem; margin-top: 2px; }
.card-preview {
  color: var(--muted); font-size: 0.875rem; margin-top: 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.when { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.soon {
  font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: #fde68a; color: #92400e; margin-left: 6px;
}
.soon.today { background: #fecdd3; color: #9f1239; }
.span-chip {
  display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; background: #f1f5f9; color: #475569;
}

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 9px 2px 7px; border-radius: 999px;
  background: var(--other-bg); color: var(--other-text); font-weight: 700;
}
.tag-message      { background: #e0f2fe; color: #075985; }
.tag-grade        { background: #dcfce7; color: #166534; }
.tag-homework     { background: #fef3c7; color: #92400e; }
.tag-announcement { background: #fce7f3; color: #9d174d; }
.tag-attendance   { background: #ffedd5; color: #9a3412; }
.tag-schedule     { background: #ccfbf1; color: #115e59; }
.tag-lesson       { background: #f1f5f9; color: #475569; }

/* --- the day line: where upcoming ends and today begins --- */
.divider {
  display: flex; align-items: center; gap: 10px; margin: 4px 2px;
  font-size: 0.78rem; font-weight: 700; color: var(--muted);
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.divider span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider.today {
  color: #0f766e; margin-top: 10px;
  /* Sticky tabs plus a peek of the item above, so it is plain there is
     more to scroll up to. */
  scroll-margin-top: calc(128px + env(safe-area-inset-top));
}
.divider.today::before, .divider.today::after { height: 2px; background: linear-gradient(90deg, transparent, #5eead4); }
.divider.today::after { background: linear-gradient(90deg, #5eead4, transparent); }
.divider.today span { padding: 3px 12px; border-radius: 999px; background: #ccfbf1; }
.divider.today.quiet span { background: #f0fdfa; color: #0f766e; font-weight: 600; }
/* A Terminarz event happening today. */
.card.today { border-color: #5eead4; box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.22), var(--shadow); }

/* --- grade medallions --- */
.medal {
  position: relative; flex: 0 0 auto;
  display: grid; place-items: center;
  width: 46px; height: 46px; border-radius: 50%;
  font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em;
  background: var(--other-bg); color: var(--other-text);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.06);
}
.medal.tier-top   { background: var(--top-bg); color: var(--top-text); overflow: hidden;
                    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.45), inset 0 -2px 0 rgba(0,0,0,.08); }
.medal.tier-great { background: var(--great-bg); color: var(--great-text);
                    box-shadow: 0 3px 10px rgba(34, 197, 94, 0.3), inset 0 -2px 0 rgba(0,0,0,.06); }
.medal.tier-good  { background: var(--good-bg);  color: var(--good-text); }
.medal.tier-fair  { background: var(--fair-bg);  color: var(--fair-text); }
.medal.tier-weak  { background: var(--weak-bg);  color: var(--weak-text); }
.medal.tier-low   { background: var(--low-bg);   color: var(--low-text); }
/* A light sweep across a 6, now and then. */
.medal.tier-top::after {
  content: ""; position: absolute; inset: -20%;
  background: linear-gradient(110deg, transparent 35%, rgba(255,255,255,.75) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: shine 3.2s ease-in-out 0.6s infinite;
}
.sparkle {
  position: absolute; top: -7px; right: -7px; font-size: 0.9rem;
  animation: twinkle 1.8s ease-in-out infinite;
  pointer-events: none;
}
.medal-wrap { position: relative; flex: 0 0 auto; }

/* --- calendar leaf (Terminarz) --- */
.leaf {
  flex: 0 0 auto; width: 50px; text-align: center;
  border-radius: 12px; overflow: hidden; background: var(--surface);
  border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(31, 41, 55, 0.08);
  line-height: 1.1;
}
.leaf-month {
  background: linear-gradient(135deg, #14b8a6, #0ea5e9); color: #fff;
  font-size: 0.65rem; font-weight: 800; text-transform: uppercase; padding: 3px 0;
}
.leaf-day { font-size: 1.3rem; font-weight: 800; padding-top: 3px; }
.leaf-weekday { font-size: 0.65rem; color: var(--muted); padding-bottom: 4px; }

/* --- detail --- */
.back {
  display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px;
  color: var(--accent); font-weight: 600;
}
.detail {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  animation: rise 0.35s ease-out both;
}
.detail h1 { font-size: 1.3rem; margin: 6px 0 4px; line-height: 1.3; }
.body { white-space: pre-wrap; word-wrap: break-word; margin: 14px 0; }
.meta {
  margin: 16px 0 0; padding: 12px 14px; border-radius: 12px;
  background: #fffbf5; border: 1px solid var(--border);
}
.meta > div { display: flex; gap: 8px; padding: 3px 0; font-size: 0.875rem; }
.meta dt { color: var(--muted); flex: 0 0 44%; }
.meta dd { margin: 0; font-weight: 550; }

/* The grade hero, with a burst of confetti for a 5 or a 6. */
.hero {
  position: relative; display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 8px 0 4px; margin-bottom: 14px;
}
.hero .medal { width: 92px; height: 92px; font-size: 2.3rem; animation: bounce-in 0.7s cubic-bezier(.34, 1.56, .64, 1) both; }
.hero .sparkle { top: -4px; right: -10px; font-size: 1.4rem; }
.praise { margin: 12px 0 0; font-size: 1.25rem; font-weight: 800; color: var(--great-text);
          animation: rise 0.45s ease-out 0.25s both; }
.praise.tier-top { color: #b45309; }
.praise-line { margin: 2px 0 0; color: var(--muted); animation: rise 0.45s ease-out 0.35s both; }
.confetti { position: absolute; left: 50%; top: 54px; width: 0; height: 0; pointer-events: none; z-index: 2; }
.confetti i {
  position: absolute; left: -4px; top: -6px; width: 8px; height: 12px; border-radius: 2px;
  opacity: 0;
  background: var(--c, #f59e0b);
  transform: rotate(calc(var(--i) * 20deg)) translateY(0);
  animation: burst 1.25s cubic-bezier(.15, .7, .3, 1) 0.2s forwards;
}
.confetti i:nth-child(4n + 1) { --c: #f59e0b; --d: -120px; }
.confetti i:nth-child(4n + 2) { --c: #22c55e; --d: -95px; border-radius: 50%; width: 9px; height: 9px; }
.confetti i:nth-child(4n + 3) { --c: #38bdf8; --d: -135px; }
.confetti i:nth-child(4n + 4) { --c: #f472b6; --d: -105px; }

/* --- panels & forms --- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.panel h1 { font-size: 1.3rem; margin: 0 0 8px; }
.panel h2 { margin: 0 0 10px; font-size: 1rem; }
.toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.toggle:last-of-type { border-bottom: none; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent-2); }
.sub-toggle { padding-left: 30px; font-size: 0.9rem; }
.sub-toggle input { width: 18px; height: 18px; }
.sub-toggle small { display: block; }

.primary {
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-contrast);
  font-size: 1rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 6px 16px rgba(3, 105, 161, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.primary:active { transform: scale(0.98); box-shadow: 0 3px 8px rgba(3, 105, 161, 0.25); }

.login {
  max-width: 340px; margin: 12vh auto 0; display: grid; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; padding: 28px 22px; box-shadow: var(--shadow-lift);
  animation: rise 0.4s ease-out both;
}
.login .logo { width: 56px; height: 56px; border-radius: 18px; font-size: 1.7rem; justify-self: center; }
.login h1 { text-align: center; margin: 0 0 6px; }
.login input {
  padding: 13px; border-radius: 12px; border: 1px solid var(--border);
  background: #fffbf5; color: var(--text); font-size: 1rem;
}
.login input:focus { outline: 2px solid #7dd3fc; outline-offset: 1px; }

/* --- notices --- */
.banner, .error, .flash { padding: 10px 16px; font-size: 0.875rem; }
.banner { background: #fef3c7; color: #92400e; text-align: center; }
.error {
  background: var(--error-bg); color: var(--error-text); border: 1px solid #fecdd3;
  border-radius: var(--radius); margin-bottom: 12px;
}
.flash {
  background: var(--flash-bg); color: var(--flash-text); border: 1px solid #a7f3d0;
  border-radius: var(--radius); margin: 10px 16px 0; font-weight: 600;
  animation: pop 0.45s cubic-bezier(.34, 1.56, .64, 1) both;
}

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.pager { display: flex; justify-content: space-between; margin-top: 16px; }
.pager a {
  color: var(--accent); font-weight: 600; padding: 8px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
}
.footer { text-align: center; color: var(--muted); font-size: 0.75rem; padding: 16px; }
pre {
  background: #fffbf5; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px; overflow-x: auto; font-size: 0.8rem;
}
code { font-size: 0.85em; }

.empty {
  text-align: center; padding: 36px 16px; color: var(--muted);
  animation: rise 0.4s ease-out both;
}
.empty-icon { font-size: 2.6rem; display: inline-block; animation: float 3s ease-in-out infinite; }

/* --- replies --- */
.replies, .reply-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-top: 14px;
  box-shadow: var(--shadow);
}
.replies h2, .reply-box h2 { margin: 0 0 10px; font-size: 1rem; }
.reply-sent { border-left: 3px solid #7dd3fc; padding-left: 12px; }
.reply-sent + .reply-sent { margin-top: 12px; }
.reply-sent .body { margin: 6px 0 0; }
.unconfirmed { color: var(--error-text); }
.reply-box textarea {
  width: 100%; box-sizing: border-box; padding: 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: #fffbf5; color: var(--text);
  font: inherit; resize: vertical;
}
.reply-box .primary { margin-top: 10px; }

/* --- send confirmation --- */
.confirm {
  width: min(92vw, 440px); border: none; border-radius: 20px; padding: 20px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lift);
}
.confirm::backdrop { background: rgba(31, 41, 55, 0.45); }
.confirm h2 { margin: 0 0 12px; font-size: 1.15rem; }
.confirm-meta { margin: 0 0 12px; font-size: 0.9rem; }
.confirm-meta > div { display: flex; gap: 8px; padding: 3px 0; }
.confirm-meta dt { flex: 0 0 64px; color: var(--muted); }
.confirm-meta dd { margin: 0; font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.confirm-text {
  margin: 0 0 8px; padding: 10px 12px; max-height: 30vh; overflow: auto;
  border-radius: 12px; background: #fffbf5; border: 1px solid var(--border);
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.9rem;
}
.confirm-actions { display: flex; gap: 10px; margin-top: 14px; }
.confirm-actions .primary { flex: 1; margin: 0; }
.secondary {
  flex: 1; padding: 13px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer;
}

/* --- attendance ring --- */
@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }
.stat { display: flex; align-items: center; gap: 16px; }
.ring {
  --p: 0; --ring: #22c55e;
  flex: 0 0 auto; position: relative; width: 104px; height: 104px; border-radius: 50%;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), #f1f5f9 0);
  display: grid; place-items: center;
  animation: fill-ring 1.2s cubic-bezier(.2, .8, .2, 1) 0.15s both;
}
.ring::before {
  content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--surface);
}
.ring.mid { --ring: #f59e0b; }
.ring.low { --ring: #fb7185; }
.ring-label { position: relative; font-weight: 800; font-size: 1.15rem; }
.stat-figure { font-size: 1.8rem; font-weight: 800; color: var(--accent); }
.toggle small { display: block; }

/* --- grade overview --- */
.overview h2 { display: flex; align-items: center; gap: 8px; }
.dist {
  display: flex; height: 16px; border-radius: 999px; overflow: hidden;
  background: #f1f5f9; gap: 2px;
}
.dist span {
  transform-origin: left center;
  animation: grow 0.8s cubic-bezier(.2, .8, .2, 1) both;
  animation-delay: calc(var(--i, 0) * 90ms + 0.1s);
}
.bar-top { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.bar-great { background: var(--great-bar); }
.bar-good { background: var(--good-bar); }
.bar-fair { background: var(--fair-bar); }
.bar-weak { background: var(--weak-bar); }
.bar-low { background: var(--low-bar); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 10px 0 4px; font-size: 0.8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.behaviour-line {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 14px 0 0; padding-top: 8px; border-top: 1px dashed var(--border);
}
.behaviour-line .name { flex: 0 0 38%; font-size: 0.875rem; font-weight: 600; }
.note-count { font-size: 0.8rem; font-weight: 800; padding: 1px 8px; border-radius: 8px; }
.note-count.positive { background: var(--great-bg); color: var(--great-text); }
.note-count.negative { background: var(--low-bg); color: var(--low-text); }
.subjects { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.subjects li {
  display: flex; align-items: center; gap: 10px; padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.subjects .name { flex: 0 0 38%; font-size: 0.875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pill {
  min-width: 28px; padding: 1px 7px; border-radius: 8px; text-align: center;
  font-size: 0.8rem; font-weight: 800;
  background: var(--other-bg); color: var(--other-text);
  animation: pop 0.35s cubic-bezier(.34, 1.56, .64, 1) both;
  animation-delay: calc(min(var(--i, 0), 20) * 25ms + 0.2s);
}
.pill.tier-top   { background: var(--top-bg); color: var(--top-text); }
.pill.tier-great { background: var(--great-bg); color: var(--great-text); }
.pill.tier-good  { background: var(--good-bg);  color: var(--good-text); }
.pill.tier-fair  { background: var(--fair-bg);  color: var(--fair-text); }
.pill.tier-weak  { background: var(--weak-bg);  color: var(--weak-text); }
.pill.tier-low   { background: var(--low-bg);   color: var(--low-text); }

/* --- motion --- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes bounce-in { 0% { opacity: 0; transform: scale(0.3) rotate(-12deg); } 100% { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes fill-ring { from { --p: 0; } }
@keyframes shine { 0%, 55% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(0); opacity: 1; } 50% { transform: scale(1.3) rotate(15deg); opacity: 0.75; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.5); }
  70%, 100% { box-shadow: 0 0 0 7px rgba(249, 115, 22, 0); }
}
@keyframes burst {
  0% { opacity: 1; transform: rotate(calc(var(--i) * 20deg)) translateY(0) scale(0.6); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: rotate(calc(var(--i) * 20deg)) translateY(var(--d, -110px)) rotate(300deg) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    animation-delay: 0s !important; transition: none !important;
  }
  .confetti { display: none; }
}
