:root {
  color-scheme: light;
  --paper: #fffdf7;
  --canvas: #f5efe3;
  --ink: #173f3a;
  --muted: #64736f;
  --line: rgba(23, 63, 58, 0.14);
  --brand: #173f3a;
  --brand-soft: #dce9e4;
  --sun: #e2a52f;
  --sun-soft: #fff0c9;
  --leaf: #31866f;
  --leaf-soft: #d8efe7;
  --berry: #bd5368;
  --berry-soft: #f7dce2;
  --danger: #a63f37;
  --shadow: 0 10px 0 rgba(23, 63, 58, 0.08);
  --radius: 24px;
  --sans: "Aptos", "Segoe UI", system-ui, sans-serif;
  --rounded: "Arial Rounded MT Bold", "Trebuchet MS", var(--sans);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: hidden; }
body { margin: 0; min-width: 320px; overflow-x: hidden; background: var(--canvas); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; opacity: .45; background-image: radial-gradient(rgba(23,63,58,.16) 1px, transparent 1px); background-size: 22px 22px; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }

.auth-view { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr); background: var(--paper); }
.auth-copy { display: flex; flex-direction: column; justify-content: center; padding: clamp(40px, 8vw, 120px); background: var(--brand); color: #fffdf7; position: relative; overflow: hidden; }
.auth-copy::after { content: ""; position: absolute; width: 420px; height: 420px; right: -150px; bottom: -180px; border: 70px solid rgba(255,255,255,.08); border-radius: 48% 52% 43% 57%; transform: rotate(24deg); }
.auth-copy h1 { margin: 12px 0 24px; max-width: 740px; font: 800 clamp(42px, 6vw, 82px)/.98 var(--rounded); letter-spacing: -.045em; }
.auth-lede { max-width: 650px; margin: 0; font-size: clamp(18px, 2vw, 23px); line-height: 1.55; color: rgba(255,255,255,.78); }
.eyebrow { margin: 0 0 8px; color: var(--leaf); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.auth-copy .eyebrow { color: #f4c96f; }
.day-ribbon { width: fit-content; margin-top: 48px; display: flex; align-items: center; gap: 16px; padding: 13px 18px; border: 1px solid rgba(255,255,255,.18); border-radius: 999px; background: rgba(255,255,255,.08); }
.day-ribbon span { display: flex; gap: 7px; }
.day-ribbon i { width: 34px; height: 1px; background: rgba(255,255,255,.35); }
.auth-panel { width: min(440px, calc(100% - 48px)); align-self: center; justify-self: center; padding: 36px; border: 1px solid var(--line); border-radius: 30px; background: #fff; box-shadow: var(--shadow); }
.brand-mark { display: inline-flex; align-items: center; gap: 10px; color: var(--brand); font: 800 20px/1 var(--rounded); text-decoration: none; }
.brand-seed { width: 28px; height: 28px; display: inline-block; border: 8px solid var(--leaf); border-right-color: var(--sun); border-radius: 50% 50% 46% 54%; transform: rotate(-20deg); }
.auth-panel h2 { margin: 36px 0 6px; font: 800 32px/1.1 var(--rounded); }
.auth-panel > p { margin: 0 0 24px; color: var(--muted); }
form { display: grid; gap: 10px; }
label, legend { font-size: 14px; font-weight: 750; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); color: var(--ink); padding: 13px 14px; }
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--leaf); box-shadow: 0 0 0 4px rgba(49,134,111,.12); outline: none; }
.pin-lock-switch { display: flex; align-items: center; gap: 10px; }
.pin-lock-switch input { width: auto; }
.button { min-height: 46px; border: 1px solid transparent; border-radius: 14px; padding: 11px 18px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; font-weight: 800; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:hover { transform: translateY(-2px); }
.button:active { transform: scale(.98); }
.button:disabled { opacity: .5; cursor: wait; }
.button-primary { background: var(--brand); color: #fff; box-shadow: 0 5px 0 rgba(23,63,58,.18); }
.button-quiet { background: var(--paper); color: var(--ink); border-color: var(--line); }
.auth-panel .button-primary { margin-top: 8px; }
.privacy-note { margin-top: 22px !important; font-size: 12px; text-align: center; }
.form-message { margin: 2px 0; padding: 10px 12px; border-radius: 10px; background: #f9e3df; color: var(--danger); font-size: 13px; }
.form-message.success { background: var(--leaf-soft); color: var(--brand); }

.app-shell { min-height: 100dvh; }
.topbar { position: fixed; z-index: 30; top: 0; left: 0; right: 0; height: 70px; padding: 0 24px 0 104px; display: flex; justify-content: space-between; align-items: center; background: rgba(255,253,247,.9); backdrop-filter: blur(18px); border-bottom: 1px solid var(--line); }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.sync-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.sync-status svg { width: 18px; }
.sync-status.saving { color: var(--sun); }
.sync-status.error { color: var(--danger); }
.text-button, .edit-link { border: 0; background: transparent; color: var(--brand); font-weight: 800; padding: 8px; }
.side-rail { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 82px; display: flex; flex-direction: column; align-items: center; background: var(--brand); color: #fff; }
.rail-brand { height: 70px; display: grid; place-items: center; }
.rail-brand .brand-seed { border-color: #fff; border-right-color: var(--sun); }
.rail-nav { width: 100%; margin: auto 0; display: grid; gap: 12px; }
.nav-button { border: 0; background: transparent; color: inherit; min-height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; font-size: 11px; border-radius: 18px; }
.side-rail .nav-button { margin: 0 9px; color: rgba(255,255,255,.6); }
.side-rail .nav-button.active { background: rgba(255,255,255,.13); color: #fff; }
.workspace { padding: 94px 28px 60px 110px; max-width: 1460px; margin: 0 auto; }
.child-switcher { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.child-tabs { min-width: 0; max-width: 100%; display: flex; gap: 10px; overflow-x: auto; padding: 4px; scrollbar-width: none; }
.child-tabs::-webkit-scrollbar { display: none; }
.child-tab { min-width: max-content; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.72); padding: 7px 14px 7px 8px; display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-weight: 800; }
.child-tab.active { color: var(--ink); background: #fff; border-color: var(--ink); box-shadow: 0 4px 0 rgba(23,63,58,.09); }
.mini-avatar, .hero-avatar { display: grid; place-items: center; border-radius: 50%; font-family: var(--rounded); font-weight: 900; }
.mini-avatar { width: 34px; height: 34px; }
.accent-sun { background: var(--sun-soft); color: #7b5410; }
.accent-leaf { background: var(--leaf-soft); color: #145c4a; }
.accent-berry { background: var(--berry-soft); color: #873044; }
.surface { background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.child-hero { min-height: 330px; margin-bottom: 24px; padding: clamp(28px, 4vw, 56px); display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); align-items: center; gap: 36px; overflow: hidden; position: relative; background: var(--brand); color: #fff; border-radius: 34px; box-shadow: 0 12px 0 rgba(23,63,58,.12); }
.child-hero::after { content: ""; position: absolute; width: 430px; height: 430px; right: -120px; top: -110px; border-radius: 44% 56% 61% 39%; background: var(--accent-soft); opacity: .94; transform: rotate(18deg); }
.hero-copy, .hero-portrait, .school-path { min-width: 0; }
.hero-copy { position: relative; z-index: 2; }
.hero-kicker { color: rgba(255,255,255,.7); font-weight: 800; }
.hero-copy h1 { margin: 7px 0 14px; overflow-wrap: anywhere; font: 900 clamp(44px, 7vw, 88px)/.92 var(--rounded); letter-spacing: -.045em; }
.hero-copy p { max-width: 600px; margin: 0; color: rgba(255,255,255,.78); font-size: 18px; line-height: 1.5; }
.hero-portrait { position: relative; z-index: 3; display: grid; justify-items: center; gap: 16px; }
.hero-avatar { width: 156px; height: 156px; border: 8px solid rgba(255,255,255,.85); font-size: 48px; box-shadow: 0 12px 0 rgba(23,63,58,.14); }
.school-path { width: 100%; display: grid; gap: 9px; }
.school-stop { min-width: 0; padding: 12px 15px; display: flex; justify-content: space-between; gap: 10px; border-radius: 15px; background: rgba(255,255,255,.92); color: var(--ink); }
.school-stop b { min-width: 0; }
.school-stop span { min-width: 0; color: var(--muted); text-align: right; overflow-wrap: anywhere; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .55fr); gap: 24px; align-items: start; }
.composer, .grade-snapshot, .grade-form-card, .profile-form-card { padding: 26px; }
.section-heading h2, .grade-snapshot h2, .grade-form-card h2, .profile-form-card h2 { margin: 0 0 18px; font: 800 24px/1.15 var(--rounded); }
.field-help { margin: -4px 0 4px; color: var(--muted); font-size: 13px; }
.composer-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.composer-actions select { width: auto; margin-left: auto; }
.file-button svg { width: 19px; }
.photo-preview { min-height: 180px; border-radius: 18px; overflow: hidden; position: relative; background: var(--canvas); }
.photo-preview img { width: 100%; max-height: 360px; object-fit: cover; display: block; }
.photo-preview button { position: absolute; top: 10px; right: 10px; border: 0; border-radius: 999px; padding: 8px 12px; background: rgba(23,63,58,.9); color: #fff; }
.snapshot-score { padding: 18px; border-radius: 18px; background: var(--brand-soft); }
.snapshot-score strong { display: block; font: 900 46px/1 var(--rounded); }
.snapshot-score span { color: var(--muted); }
.snapshot-schools { display: grid; gap: 10px; margin-top: 16px; }
.snapshot-school { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.snapshot-empty { color: var(--muted); line-height: 1.5; }
.state-panel { min-height: 420px; display: grid; align-content: center; gap: 14px; max-width: 700px; margin: auto; text-align: center; color: var(--muted); }
.skeleton { height: 78px; border-radius: 18px; background: linear-gradient(90deg,#e7e0d5,#f8f3e9,#e7e0d5); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
.skeleton-title { height: 150px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.page-heading { min-height: 180px; margin-bottom: 24px; padding: 30px 34px; display: flex; justify-content: space-between; align-items: end; gap: 24px; border-radius: 30px; background: #fff; border: 1px solid var(--line); }
.page-heading h1 { margin: 0 0 8px; font: 900 clamp(36px, 5vw, 62px)/1 var(--rounded); letter-spacing: -.035em; }
.page-heading p:last-child { margin: 0; color: var(--muted); }
.story-feed { max-width: 820px; display: grid; gap: 18px; }
.story-card { padding: 18px; border-radius: 24px; background: #fff; border: 1px solid var(--line); box-shadow: 0 7px 0 rgba(23,63,58,.07); }
.story-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; }
.story-author { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; }
.story-card > p { white-space: pre-wrap; line-height: 1.65; }
.story-card img { width: 100%; max-height: 620px; object-fit: cover; border-radius: 18px; margin-top: 8px; }
.story-empty, .grade-empty { padding: 46px 28px; text-align: center; color: var(--muted); background: rgba(255,255,255,.7); border: 1px dashed var(--line); border-radius: 24px; }
.school-badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.delete-button { border: 0; background: transparent; color: var(--danger); font-weight: 800; font-size: 12px; }

.school-toggle { width: fit-content; margin-bottom: 24px; display: flex; padding: 5px; border-radius: 999px; background: rgba(23,63,58,.09); }
.school-toggle button { min-height: 42px; border: 0; border-radius: 999px; padding: 8px 18px; background: transparent; color: var(--muted); font-weight: 800; }
.school-toggle button.active { background: #fff; color: var(--ink); box-shadow: 0 3px 0 rgba(23,63,58,.09); }
.grades-layout { display: grid; grid-template-columns: minmax(300px,.7fr) minmax(0,1.3fr); gap: 24px; align-items: start; }
.score-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px; }
.score-row label { display: grid; gap: 10px; }
.score-row span { padding-bottom: 14px; color: var(--muted); }
.grade-form-card .button { margin-top: 8px; }
.summary-strip { margin-bottom: 18px; display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.summary-item { padding: 18px; border-radius: 20px; background: #fff; border: 1px solid var(--line); }
.summary-item strong { display: block; font: 900 32px/1 var(--rounded); }
.summary-item span { color: var(--muted); font-size: 12px; }
.grade-list { display: grid; gap: 12px; }
.grade-row { display: grid; grid-template-columns: 1fr auto auto; gap: 18px; align-items: center; padding: 18px 20px; border-radius: 20px; background: #fff; border: 1px solid var(--line); }
.grade-row h3 { margin: 0 0 4px; font: 800 18px/1.2 var(--rounded); }
.grade-row p { margin: 0; color: var(--muted); font-size: 13px; }
.grade-value { font: 900 28px/1 var(--rounded); }

.profile-layout { display: grid; grid-template-columns: minmax(320px,.8fr) minmax(0,1.2fr); gap: 24px; align-items: start; }
.profile-preview { min-height: 520px; padding: 38px; display: flex; flex-direction: column; justify-content: space-between; border-radius: 32px; background: var(--brand); color: #fff; overflow: hidden; position: sticky; top: 94px; }
.profile-preview::after { content: ""; position: absolute; width: 340px; height: 340px; right: -120px; bottom: -130px; border-radius: 45%; background: var(--accent-soft); opacity: .9; }
.profile-preview .hero-avatar { position: relative; z-index: 2; }
.profile-preview h2 { position: relative; z-index: 2; margin: 28px 0 10px; font: 900 48px/1 var(--rounded); }
.profile-preview p { position: relative; z-index: 2; color: rgba(255,255,255,.78); line-height: 1.6; }
.profile-school-list { position: relative; z-index: 2; display: grid; gap: 10px; }
.profile-form-card fieldset { border: 0; padding: 8px 0; margin: 0; }
.accent-options { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.accent-options label { display: flex; align-items: center; gap: 7px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 999px; }
.accent-options input { width: auto; }
.accent-swatch { width: 18px; height: 18px; border-radius: 50%; }
.accent-swatch.sun { background: var(--sun); }.accent-swatch.leaf { background: var(--leaf); }.accent-swatch.berry { background: var(--berry); }
.connected-apps { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.connected-apps h3 { font: 800 18px/1.2 var(--rounded); }
.connected-apps a { display: flex; justify-content: space-between; align-items: center; padding: 13px 0; border-top: 1px solid var(--line); text-decoration: none; font-weight: 800; }
.connected-apps svg { width: 18px; }
.bottom-nav { display: none; }
.offline-banner { position: fixed; z-index: 80; left: 50%; bottom: 88px; transform: translateX(-50%); padding: 10px 16px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 13px; font-weight: 800; }

@media (max-width: 820px) {
  .auth-view { grid-template-columns: 1fr; background: var(--canvas); }
  .auth-copy { min-height: 44dvh; padding: 42px 24px 58px; justify-content: end; border-radius: 0 0 34px 34px; }
  .auth-copy h1 { font-size: clamp(40px, 13vw, 64px); }
  .auth-lede { font-size: 16px; }
  .day-ribbon { margin-top: 28px; flex-wrap: wrap; font-size: 13px; }
  .auth-panel { width: calc(100% - 28px); margin: -24px auto 30px; z-index: 2; padding: 26px 22px; }
  .topbar { height: 62px; padding: 0 16px; }
  .topbar .brand-mark { font-size: 17px; }
  .sync-status span { display: none; }
  .side-rail { display: none; }
  .workspace { padding: 78px 14px 108px; }
  .child-switcher { align-items: start; }
  .edit-link { display: none; }
  .child-tabs { margin-inline: -4px; }
  .child-hero { min-height: 0; padding: 28px 22px; grid-template-columns: 1fr; gap: 28px; border-radius: 28px; }
  .child-hero::after { width: 260px; height: 260px; right: -90px; top: auto; bottom: -80px; }
  .hero-copy h1 { font-size: clamp(40px, 13vw, 54px); }
  .hero-copy p { font-size: 16px; }
  .hero-portrait { grid-template-columns: auto 1fr; align-items: center; justify-items: stretch; }
  .hero-avatar { width: 94px; height: 94px; border-width: 5px; font-size: 30px; }
  .home-grid, .grades-layout, .profile-layout { grid-template-columns: 1fr; }
  .composer, .grade-snapshot, .grade-form-card, .profile-form-card { padding: 20px; }
  .composer-actions select { order: 3; width: 100%; margin-left: 0; }
  .composer-actions .button-primary { flex: 1; }
  .page-heading { min-height: 0; padding: 26px 22px; align-items: start; flex-direction: column; border-radius: 26px; }
  .page-heading h1 { font-size: 42px; }
  .school-toggle { width: 100%; overflow-x: auto; }
  .school-toggle button { flex: 1; min-width: max-content; padding-inline: 12px; }
  .summary-strip { grid-template-columns: 1fr 1fr; }
  .summary-item:first-child { grid-column: 1 / -1; }
  .grade-row { grid-template-columns: 1fr auto; }
  .grade-row .delete-button { grid-column: 1 / -1; justify-self: end; }
  .profile-preview { min-height: 420px; position: static; padding: 28px; }
  .profile-preview h2 { font-size: 42px; }
  .bottom-nav { position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; padding: 7px max(8px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); background: rgba(255,253,247,.94); backdrop-filter: blur(20px); border-top: 1px solid var(--line); }
  .bottom-nav .nav-button { min-width: 0; color: var(--muted); min-height: 58px; font-size: 10px; }
  .bottom-nav .nav-button.active { color: var(--brand); background: var(--brand-soft); }
}

@media (max-width: 460px) {
  .hero-portrait { grid-template-columns: 1fr; justify-items: start; }
  .hero-avatar { display: none; }
  .score-row { grid-template-columns: 1fr 1fr; }
  .score-row span { display: none; }
  .summary-strip { grid-template-columns: 1fr; }
  .summary-item:first-child { grid-column: auto; }
}

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

@media (prefers-contrast: more) {
  :root { --line: rgba(23,63,58,.55); }
  .surface, .story-card, .grade-row, .page-heading { border-width: 2px; }
}
