/* AveoNote — notebook ink + sunrise */
:root {
  --ink: #1b2a4a;          /* notebook ink blue: text, primary buttons */
  --ink-soft: #52607d;     /* secondary text */
  --page: #f3f6fb;         /* cool page background */
  --paper: #ffffff;        /* cards, notes */
  --rule: #cfdaee;         /* notebook ruling, borders */
  --sun: #ffc23a;          /* sunrise: the one bright accent */
  --margin: #d9534f;       /* notebook margin red: errors only */
  --ok: #1f7a55;

  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --font-hand: "Caveat", "Comic Sans MS", cursive;

  --radius-sm: 6px;
  --radius-lg: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6ecf7;
    --ink-soft: #a5b1c9;
    --page: #0f1829;
    --paper: #17223a;
    --rule: #2c3a58;
    --sun: #ffc94f;
    --margin: #ef7471;
    --ok: #4cc28f;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1; }

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.1;
  margin: 0 0 0.5em;
  letter-spacing: -0.015em;
}
h1 { font-size: clamp(2.2rem, 5.5vw, 3.75rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 1em; }

a { color: inherit; text-underline-offset: 3px; }

:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 4px; }

.wrap { width: min(1080px, 100% - 2.5rem); margin-inline: auto; }

.skip-link {
  position: absolute; left: -999px; top: 0.5rem;
  background: var(--paper); padding: 0.5rem 1rem; z-index: 10;
}
.skip-link:focus { left: 0.5rem; }

/* ---------- Header ---------- */
.brand { display: inline-flex; align-items: center; gap: 0.5rem; text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; }
.brand-mark { width: 34px; height: 34px; flex: none; object-fit: contain; filter: drop-shadow(0 1px 1.5px rgba(15, 24, 41, .22)); }
.brand-word { letter-spacing: -0.01em; }
.brand-word b { font-weight: 800; color: #1a6cf0; }
.brand-long { display: block; max-width: 100%; filter: drop-shadow(0 1px 1px rgba(15, 24, 41, .28)); }   /* keeps the light "Aveo" letters readable on white */
.brand-light .brand-long { filter: none; }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.75rem 1.35rem; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--page);
  font: 700 1rem var(--font-body); text-decoration: none;
  border: 2px solid var(--ink); cursor: pointer;
}
.btn:hover { background: transparent; color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--page); }
.btn-small { padding: 0.4rem 0.9rem; font-size: 0.95rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--ink); color: var(--page); }

/* ---------- Home: hero ---------- */
.hero { padding: clamp(2.5rem, 7vw, 5.5rem) 0 clamp(2.5rem, 6vw, 4.5rem); }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(2rem, 5vw, 4rem); align-items: center; }
.hero h1 { max-width: 13ch; }
.hero-lead { font-size: 1.15rem; color: var(--ink-soft); max-width: 46ch; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.75rem; }
.hero-private { margin-top: 1.25rem; font-size: 0.95rem; color: var(--ink-soft); }

/* The signature moment: a photographed page becoming a clean note */
.scan-demo { position: relative; min-height: 420px; }
.scan-photo {
  position: absolute; left: 0; top: 0; width: 68%;
  padding: 1.1rem 1.1rem 1.4rem 2.6rem;
  background:
    linear-gradient(90deg, transparent 1.9rem, var(--margin) 1.9rem, var(--margin) 2rem, transparent 2rem),
    repeating-linear-gradient(to bottom, #fffdf6 0 29px, #b9cbe8 29px 30px);
  color: #24325a;
  font: 500 1.35rem/30px var(--font-hand);
  transform: rotate(-4deg);
  border-radius: 3px;
  box-shadow: 0 18px 40px -18px rgba(15, 24, 41, 0.45);
}
.scan-photo p { margin: 0; }
.scan-note {
  position: absolute; right: 0; bottom: 0; width: 68%;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--radius-lg); padding: 1.25rem 1.35rem;
  box-shadow: 0 22px 50px -24px rgba(15, 24, 41, 0.5);
  animation: note-in 0.7s 0.35s cubic-bezier(.2,.8,.2,1) both;
}
.scan-note h3 { font-size: 1.25rem; margin-bottom: 0.4rem; }
.scan-note ul { margin: 0 0 0.9rem; padding-left: 1.1rem; font-size: 0.95rem; }
.scan-note li { margin-bottom: 0.2rem; }
.scan-note strong { background: linear-gradient(transparent 55%, color-mix(in srgb, var(--sun) 55%, transparent) 55%); }
.scan-figure { margin: 0; display: grid; grid-template-columns: 90px 1fr; gap: 0.75rem; align-items: center; }
.scan-figure svg { width: 90px; height: 64px; background: var(--page); border-radius: var(--radius-sm); }
.scan-figure figcaption { font-size: 0.8rem; color: var(--ink-soft); line-height: 1.35; }
@keyframes note-in {
  from { opacity: 0; transform: translate(-40px, 30px) rotate(-4deg); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Home: sections ---------- */
.section { padding: clamp(2.5rem, 6vw, 4.5rem) 0; border-top: 1px solid var(--rule); }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 2rem 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.steps li { counter-increment: step; }
.steps li::before {
  content: counter(step);
  display: grid; place-items: center; width: 2.4rem; height: 2.4rem; margin-bottom: 0.9rem;
  border-radius: 50%; background: var(--sun); color: #1b2a4a;
  font: 800 1.1rem var(--font-display);
}
.steps p { color: var(--ink-soft); margin: 0; }

.plans { display: grid; grid-template-columns: repeat(2, minmax(0, 360px)); gap: 1.5rem; margin-top: 2rem; }
.plan { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 1.5rem 1.6rem; }
.plan-featured { border: 2px solid var(--ink); }
.plan-price { font: 800 2.2rem var(--font-display); margin: 0.2rem 0 1rem; }
.plan-price span { font: 400 1rem var(--font-body); color: var(--ink-soft); }
.plan ul { margin: 0; padding-left: 1.1rem; }
.plan li { margin-bottom: 0.3rem; }

/* ---------- Forms (login / signup) ---------- */
.auth-page { padding: clamp(2rem, 6vw, 4.5rem) 0; }
.auth-card {
  width: min(440px, 100%); margin-inline: auto;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--radius-lg); padding: clamp(1.5rem, 4vw, 2.25rem);
}
.auth-card h1 { font-size: 2rem; }
.auth-card .sub { color: var(--ink-soft); margin-bottom: 1.5rem; }
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.field .hint { font-size: 0.9rem; color: var(--ink-soft); margin: 0.3rem 0 0; }
.field input, .field select, .field textarea {
  width: 100%; padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--rule); border-radius: var(--radius-sm);
  background: var(--page); color: var(--ink); font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); outline: 3px solid color-mix(in srgb, var(--sun) 60%, transparent); outline-offset: 0; }
.auth-card .btn { width: 100%; margin-top: 0.5rem; }
.auth-switch { margin: 1.25rem 0 0; text-align: center; color: var(--ink-soft); }

.form-errors {
  border-left: 4px solid var(--margin); background: color-mix(in srgb, var(--margin) 10%, transparent);
  padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem;
}
.form-errors ul { margin: 0; padding-left: 1.1rem; }
.flash { margin: 1.25rem 0 0; padding: 0.75rem 1rem; border-radius: var(--radius-sm); border-left: 4px solid var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.flash-error { border-left-color: var(--margin); background: color-mix(in srgb, var(--margin) 10%, transparent); }

/* ---------- Dashboard ---------- */
.dash { padding: clamp(2rem, 5vw, 3.5rem) 0; }
.dash-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 2rem; }
.dash-top h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 0; }
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; align-items: start; }
.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 1.4rem 1.5rem; }
.panel h2 { font-size: 1.3rem; }
.note-list { list-style: none; margin: 0; padding: 0; }
.note-list li { border-top: 1px solid var(--rule); }
.note-list a { display: flex; justify-content: space-between; gap: 1rem; padding: 0.8rem 0; text-decoration: none; }
.note-list a:hover .note-title { text-decoration: underline; }
.note-meta { color: var(--ink-soft); font-size: 0.9rem; white-space: nowrap; }
.empty { color: var(--ink-soft); margin: 0; }
.meter { height: 10px; background: var(--page); border: 1px solid var(--rule); border-radius: 99px; overflow: hidden; margin: 0.6rem 0 0.4rem; }
.meter span { display: block; height: 100%; background: var(--sun); }
.meter-label { font-size: 0.95rem; color: var(--ink-soft); margin: 0; }
.quick-actions { display: grid; gap: 0.6rem; margin-top: 0.5rem; }
.quick-actions .btn { width: 100%; }
.soon { font-size: 0.85rem; color: var(--ink-soft); margin: 0.6rem 0 0; }

/* ---------- Footer ---------- */

/* ---------- Content pages (about, privacy, terms, help, pricing) ---------- */
.page { padding: clamp(2rem, 5vw, 4rem) 0 clamp(3rem, 6vw, 5rem); }
.prose { max-width: 68ch; }
.prose h1 { font-size: clamp(2rem, 4.5vw, 3rem); }
.prose h2 { font-size: 1.4rem; margin-top: 2.4rem; }
.prose h3 { margin-top: 1.6rem; }
.prose ul, .prose ol { padding-left: 1.2rem; margin: 0 0 1em; }
.prose li { margin-bottom: 0.35rem; }
.lead { font-size: 1.15rem; color: var(--ink-soft); }
.updated { color: var(--ink-soft); font-size: 0.95rem; }

.table-wrap { overflow-x: auto; margin: 1.5rem 0; border: 1px solid var(--rule); border-radius: var(--radius-lg); background: var(--paper); }
.compare { width: 100%; min-width: 520px; border-collapse: collapse; }
.compare th, .compare td { text-align: left; padding: 0.75rem 1rem; border-bottom: 1px solid var(--rule); }
.compare tr:last-child td { border-bottom: 0; }
.compare thead th { font-family: var(--font-display); font-size: 1.1rem; }
.compare tbody th { font-weight: 400; color: var(--ink-soft); }

.faq details { border-top: 1px solid var(--rule); padding: 0.95rem 0; }
.faq details:last-child { border-bottom: 1px solid var(--rule); }
.faq summary { font-weight: 700; cursor: pointer; }
.faq details p { margin: 0.6rem 0 0; }

.field textarea { min-height: 9rem; resize: vertical; line-height: 1.5; }
.auth-card.wide { width: min(620px, 100%); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero-grid, .dash-grid { grid-template-columns: 1fr; }
  .scan-demo { min-height: 400px; max-width: 520px; }
  .steps { grid-template-columns: 1fr; gap: 1.5rem; }
  .plans { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .scan-photo, .scan-note { width: 86%; }
  .scan-demo { min-height: 460px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.footer-credit { margin-left: 0.6rem; font-size: 0.8rem; opacity: 0.75; }
.footer-credit a { color: inherit; }

/* ---------- Site header (public pages) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 70%, transparent);
}
.header-row { display: flex; align-items: center; gap: 1.5rem; min-height: 66px; }
.site-nav { display: flex; align-items: center; gap: 0.25rem; margin-left: auto; }
.nav-link { text-decoration: none; color: var(--ink-soft); font-weight: 700; font-size: 0.97rem; padding: 0.45rem 0.8rem; border-radius: 99px; }
.nav-link:hover { color: var(--ink); background: var(--page); }
.header-cta { display: flex; align-items: center; gap: 0.6rem; }
.header-cta .btn { gap: 0.4rem; }
.nav-login { text-decoration: none; font-weight: 700; padding: 0.4rem 0.6rem; }
.nav-login:hover { text-decoration: underline; }
.nav-menu { position: relative; display: none; }
.nav-menu summary { list-style: none; cursor: pointer; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--rule); font-size: 1.3rem; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu[open] summary { background: var(--ink); color: var(--page); border-color: var(--ink); }
.nav-menu-list { position: absolute; right: 0; top: calc(100% + 0.5rem); width: 230px; background: var(--paper); border: 1px solid var(--rule); border-radius: 14px; padding: 0.4rem; box-shadow: 0 18px 40px rgba(15, 24, 41, 0.16); display: grid; }
.nav-menu-list a, .nav-menu-list button { text-align: left; text-decoration: none; padding: 0.65rem 0.8rem; border-radius: 9px; border: 0; background: none; font: inherit; color: var(--ink); cursor: pointer; }
.nav-menu-list a:hover, .nav-menu-list button:hover { background: var(--page); }
.nav-menu-list form { margin: 0; display: grid; }
@media (max-width: 820px) {
  .site-nav, .nav-login { display: none; }
  .header-cta { margin-left: auto; }
  .nav-menu { display: block; }
}

/* ---------- Site footer ---------- */
.site-footer { margin-top: 3rem; background: var(--paper); border-top: 1px solid var(--rule); padding: 3rem 0 1.5rem; color: var(--ink-soft); font-size: 0.95rem; }
.footer-grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 2rem; }
.footer-about p { margin: 0.75rem 0 1rem; max-width: 34ch; }
.site-footer h3 { font: 700 1rem var(--font-display); letter-spacing: -0.01em; color: var(--ink); margin: 0 0 0.75rem; }
.site-footer nav { display: grid; align-content: start; gap: 0.45rem; }
.site-footer nav a { text-decoration: none; }
.site-footer nav a:hover { color: var(--ink); text-decoration: underline; }
.footer-bottom { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); font-size: 0.88rem; }
@media (max-width: 760px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-about { grid-column: 1 / -1; }
}

/* ---------- Log in, sign up, codes, onboarding: split screen ---------- */
body[class*="auth-layout"] { background: var(--page); }
.auth-shell { display: grid; grid-template-columns: minmax(340px, 0.95fr) 1.25fr; min-height: 100vh; }
.auth-side {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
  padding: clamp(1.75rem, 4vw, 3rem); background: #1b2a4a; color: #e6ecf7;
}
.auth-side::before {   /* the sunrise */
  content: ""; position: absolute; width: 520px; height: 520px; right: -170px; bottom: -300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 194, 58, 0.55), rgba(255, 194, 58, 0.08) 55%, transparent 70%);
}
.auth-side::after {   /* notebook ruling */
  content: ""; position: absolute; inset: 0; opacity: 0.05; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 31px, #fff 31px 32px);
}
.brand-light { color: #fff; position: relative; z-index: 1; }
.auth-side-copy { position: relative; z-index: 1; }
.auth-side-copy h2 { font-size: clamp(1.9rem, 3.2vw, 2.7rem); color: #fff; margin-bottom: 0.6rem; }
.auth-side-copy p { color: #b9c5de; max-width: 36ch; }
.auth-points { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 0.7rem; }
.auth-points li { display: flex; gap: 0.7rem; align-items: center; color: #dfe6f3; }
.auth-points i { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; background: rgba(255, 255, 255, 0.08); color: var(--sun); font-size: 1.1rem; }
.auth-demo { position: relative; z-index: 1; display: flex; align-items: center; gap: 1rem; }
.auth-demo-photo, .auth-demo-note { width: 130px; height: 150px; border-radius: 10px; padding: 0.8rem; display: grid; align-content: start; gap: 0.45rem; }
.auth-demo-photo { gap: 0; padding: 0.7rem 0.5rem 0 1.3rem; transform: rotate(-5deg); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  background: linear-gradient(90deg, transparent 0.85rem, #e2706c 0.85rem, #e2706c calc(0.85rem + 1.5px), transparent calc(0.85rem + 1.5px)),
              repeating-linear-gradient(180deg, #fbfcff 0 19px, #c9d7f0 19px 20px);
  font: 500 0.98rem/20px var(--font-hand); color: #24324f; }   /* a photographed notebook page, as on the home page */
.auth-demo-photo p { margin: 0; white-space: nowrap; overflow: hidden; }
.auth-demo-photo s { opacity: 0.7; }
.auth-demo-note { background: #fff; color: #1b2a4a; transform: rotate(3deg); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); font-size: 0.75rem; }
.auth-demo-note b { font-family: var(--font-display); }
.auth-demo-note span { height: 6px; border-radius: 3px; background: #dfe6f3; }
.auth-demo-arrow { color: var(--sun); font-size: 1.6rem; }
.auth-main { display: flex; flex-direction: column; min-width: 0; }
.auth-top { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; padding: 1.1rem clamp(1.25rem, 4vw, 2.5rem); }
.auth-top-brand { display: none; margin-right: auto; }
.auth-top-link { color: var(--ink-soft); font-size: 0.95rem; text-decoration: none; display: inline-flex; align-items: center; gap: 0.3rem; }
.auth-top-link a { color: var(--ink); font-weight: 700; }
.auth-main main { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.auth-main .auth-page { padding: 1.5rem 0 2.5rem; }
.auth-main .auth-card { border: 0; background: transparent; padding: 0; }
.auth-main .auth-card.wide { width: min(560px, 100%); }
.auth-main .auth-card h1 { font-size: clamp(1.8rem, 3vw, 2.3rem); }
.auth-footer { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.4rem 1.2rem; padding: 1.25rem; font-size: 0.85rem; color: var(--ink-soft); }
.auth-footer a { text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-top { justify-content: space-between; border-bottom: 1px solid var(--rule); background: var(--paper); }
  .auth-top-brand { display: inline-flex; }
  .auth-main main { justify-content: flex-start; }
  .auth-main .auth-card { background: var(--paper); border: 1px solid var(--rule); padding: clamp(1.25rem, 5vw, 2rem); }
}
.footer-about .brand { color: var(--ink); }
@media (max-width: 480px) { .auth-top-link { font-size: 0; } .auth-top-link a, .auth-top-link i { font-size: 0.95rem; } }

/* Math in notes */
.note-body span.math[data-display="1"] { display: block; text-align: center; margin: 0.8rem 0; overflow-x: auto; overflow-y: hidden; }
.doc-body span.math[data-display="1"] { overflow-x: auto; overflow-y: hidden; }

/* Worked math steps: explanation on the left, equation on the right */
.math-step { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 0.3rem 1.75rem; align-items: center; margin: 0.9rem 0; }
.math-step > p { margin: 0; }
.math-step > p:first-child { grid-column: 1; grid-row: 1; color: var(--ink-soft, #52607d); }
.math-step > p:last-child { grid-column: 2; grid-row: 1; }
.math-step span.math[data-display="1"] { display: block; text-align: left; margin: 0; overflow-x: auto; overflow-y: hidden; }
.math-step mjx-container[display="true"] { text-align: left !important; margin: 0.2em 0 !important; }
@media (max-width: 640px) {
  .math-step { grid-template-columns: minmax(0, 1fr); }
  .math-step > p:first-child, .math-step > p:last-child { grid-column: 1; grid-row: auto; }
}

/* Exam/quiz progress: yellow bar with moving stripes while it works */
.exam-bar-live { background-image: linear-gradient(45deg, rgba(255,255,255,.35) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.35) 50%, rgba(255,255,255,.35) 75%, transparent 75%, transparent); background-size: 22px 22px; animation: exam-stripes 0.9s linear infinite; }
@keyframes exam-stripes { from { background-position: 0 0; } to { background-position: 22px 0; } }
.exam-working { display: flex; align-items: center; gap: 0.45rem; margin-top: 0.35rem; }
.exam-working[hidden] { display: none; }
.exam-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sun); animation: exam-pulse 1.2s ease-in-out infinite; flex: none; }
@keyframes exam-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) { .exam-bar-live, .exam-dot { animation: none; } }

/* ---------- Messages ("Group created", "Saved", errors): centered at the top, above everything ---------- */
.toast-wrap { position: fixed; top: 1rem; left: 0; right: 0; z-index: 10050; display: flex; justify-content: center; padding: 0 1rem; pointer-events: none; animation: toast-in .25s ease-out, toast-out .4s ease-in 7s forwards; }
.flash.toast { pointer-events: auto; margin: 0; max-width: min(560px, 100%); display: flex; align-items: center; gap: 0.75rem; text-align: center; justify-content: center;
  background: var(--paper); border: 1px solid var(--rule); border-left-width: 1px; border-top: 4px solid var(--ok); border-radius: 12px; padding: 0.75rem 0.9rem 0.75rem 1.2rem;
  box-shadow: 0 14px 40px rgba(15, 24, 41, 0.18); font-weight: 700; }
.flash.toast.flash-error { border-top-color: var(--margin); }
.toast-close { border: 0; background: none; font-size: 1.3rem; line-height: 1; color: var(--ink-soft); cursor: pointer; padding: 0 0.2rem; }
.toast-wrap:hover { animation-play-state: paused; }
@keyframes toast-in { from { transform: translateY(-12px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(-12px); opacity: 0; visibility: hidden; } }
/* Other messages on pages (form errors, notices) are centered too */
.form-errors, main > .flash, .app-content > .flash { margin-left: auto; margin-right: auto; }
.toast-wrap:has(.flash-error) { animation: toast-in .25s ease-out; }   /* errors stay until closed */
.app-content > .toast-wrap { max-width: none !important; margin: 0 !important; width: auto !important; }

/* Math: while it loads (or if it can't be drawn), show the equation's text instead of a blank space */
span.math:empty::before { content: attr(data-tex); color: var(--ink-soft, #52607d); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; white-space: pre-wrap; }
/* MathJax's hidden copy for screen readers: never shown on screen, even if MathJax's own styles don't load */
mjx-container { position: relative; }
mjx-assistive-mml { position: absolute !important; top: 0; left: 0; clip: rect(1px, 1px, 1px, 1px) !important; padding: 1px 0 0 0 !important; border: 0 !important; display: block !important; width: auto !important; height: auto !important; overflow: hidden !important; user-select: none; }
/* An equation with a mistake: shown as its text, underlined, with the reason on hover */
span.math.math-bad { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; color: var(--ink, #1b2a4a); border-bottom: 1.5px dashed #d9534f; white-space: pre-wrap; }

/* ---------- Install the app (phones) ---------- */
[data-install-app][hidden] { display: none !important; }
.install-banner { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 900; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; align-items: center; gap: 0.7rem; padding: 0.7rem 0.6rem 0.7rem 0.8rem; background: var(--paper, #fff); color: var(--ink, #1b2a4a); border: 1px solid var(--rule, #e3e8f2); border-radius: 16px; box-shadow: 0 14px 40px rgba(15, 24, 41, .22); transform: translateY(140%); transition: transform .35s cubic-bezier(.2, .8, .2, 1); }
.install-banner.is-in { transform: none; }
.install-banner img { border-radius: 10px; }
.install-banner span { display: grid; min-width: 0; }
.install-banner strong { font-size: 0.95rem; }
.install-banner small { color: var(--ink-soft, #52607d); font-size: 0.8rem; }
.install-banner-x { border: 0; background: none; font-size: 1.4rem; line-height: 1; color: var(--ink-soft, #52607d); padding: 0.3rem 0.45rem; cursor: pointer; border-radius: 8px; }
.install-guide { width: min(460px, 94vw); }
.install-steps { list-style: none; margin: 0.4rem 0 1rem; padding: 0; display: grid; gap: 0.6rem; }
.install-steps li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.75rem; align-items: center; padding: 0.75rem 0.85rem; border: 1px solid var(--rule, #e3e8f2); border-radius: 14px; background: var(--page, #f3f6fb); line-height: 1.45; }
.install-steps svg { vertical-align: -0.3em; margin: 0 0.1rem; color: #2563eb; }
.install-step-label { display: inline-grid; place-items: center; min-width: 4.2rem; padding: 0.3rem 0.5rem; border-radius: 99px; background: var(--ink, #1b2a4a); color: var(--paper, #fff); font-weight: 800; font-size: 0.78rem; }
.install-why { color: var(--ink-soft, #52607d); font-size: 0.88rem; margin: 0 0 1rem; }
/* Opened as the installed app: keep clear of the notch and the home bar */
@media (display-mode: standalone) {
  .app-topbar, .site-header { padding-top: max(env(safe-area-inset-top), 0px); }
  .sidebar { padding-top: max(env(safe-area-inset-top), 0.75rem); padding-bottom: max(env(safe-area-inset-bottom), 0.75rem); }
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* ---------- File picker (assets/js/file-drop.js): drop area instead of the browser's "Choose Files" button ---------- */
.file-drop { display: grid; gap: 0.5rem; }
.file-drop-zone {
  position: relative; display: flex; align-items: center; gap: 0.85rem;
  padding: 0.95rem 1rem; border: 1.5px dashed color-mix(in srgb, var(--ink) 28%, var(--rule)); border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--paper) 70%, var(--page)); color: var(--ink);
  transition: border-color .15s, background .15s, box-shadow .15s; cursor: pointer;
}
.file-drop-zone:hover, .file-drop-zone.is-over { border-color: var(--ink); background: color-mix(in srgb, var(--sun) 10%, var(--paper)); }
.file-drop-zone.is-over { border-style: solid; box-shadow: 0 0 0 4px color-mix(in srgb, var(--sun) 35%, transparent); }
.file-drop-zone.is-focus { outline: 3px solid color-mix(in srgb, var(--sun) 60%, transparent); outline-offset: 2px; }
.field .file-drop-zone .file-drop-input, .file-drop-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; padding: 0; border: 0; margin: 0; z-index: 1; font-size: 0; }
.file-drop-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: color-mix(in srgb, var(--sun) 28%, var(--paper)); color: var(--ink); }
.file-drop-text { flex: 1; min-width: 0; line-height: 1.35; }
.file-drop-text strong { font-weight: 700; }
.file-drop-text > span { color: var(--ink-soft); }
.file-drop-text small { display: block; margin-top: 0.1rem; color: var(--ink-soft); font-size: 0.8rem; letter-spacing: .01em; }
.file-drop-btn { flex: none; padding: 0.45rem 0.9rem; border-radius: 999px; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 0.85rem; }
.file-drop-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.file-drop-list:empty { display: none; }
.file-drop-list li { display: flex; align-items: center; gap: 0.7rem; padding: 0.45rem 0.5rem 0.45rem 0.45rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); }
.file-drop-thumb { flex: none; width: 40px; height: 40px; border-radius: 7px; object-fit: cover; display: grid; place-items: center; background: color-mix(in srgb, var(--ink) 7%, var(--paper)); color: var(--ink-soft); }
.file-drop-thumb.is-pdf { background: color-mix(in srgb, var(--margin) 14%, var(--paper)); color: var(--margin); font: 800 0.7rem/1 var(--font-display); letter-spacing: .04em; }
.file-drop-name { flex: 1; min-width: 0; display: grid; }
.file-drop-name b { font-weight: 700; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-drop-name small { color: var(--ink-soft); font-size: 0.8rem; }
.file-drop-x { flex: none; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-soft); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.file-drop-x:hover { background: color-mix(in srgb, var(--margin) 12%, transparent); color: var(--margin); }
@media (max-width: 520px) { .file-drop-btn { display: none; } .file-drop-text > span { display: none; } }
.field-note { font-weight: 400; color: var(--ink-soft); font-size: 0.85rem; margin-left: 0.35rem; }

/* ---------- E-signature (assets/js/signature-pad.js) ---------- */
.sig { --sig-ink: #14213d; }
.sig-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.sig-label { font-weight: 700; }
.sig-tabs { display: inline-flex; padding: 3px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 7%, var(--page)); }
.sig-tabs button { border: 0; background: transparent; color: var(--ink-soft); font: 700 0.85rem var(--font-body); padding: 0.4rem 0.95rem; border-radius: 999px; cursor: pointer; }
.sig-tabs button[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.sig-type-row, .sig-upload-row { display: none; margin-bottom: 0.5rem; }
.sig[data-mode="type"] .sig-type-row { display: block; }
.sig[data-mode="upload"] .sig-upload-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.sig-upload-row small { color: var(--ink-soft); font-size: 0.82rem; flex: 1 1 14rem; }
.sig-pick { position: relative; display: inline-flex; align-items: center; padding: 0.5rem 0.95rem; border-radius: 999px; background: var(--ink); color: var(--paper); font-weight: 700; font-size: 0.88rem; cursor: pointer; }
.sig-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.sig-pad { position: relative; height: 170px; border-radius: var(--radius-lg); background: #fffdf7; border: 1.5px solid var(--rule); overflow: hidden;
  background-image: linear-gradient(transparent calc(100% - 1px), color-mix(in srgb, #1b2a4a 6%, transparent) 0); background-size: 100% 28px; }
.sig-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; z-index: 1; }
.sig[data-mode="type"] .sig-pad canvas, .sig[data-mode="upload"] .sig-pad canvas { cursor: default; }
.sig-line { position: absolute; left: 1.25rem; right: 1.25rem; bottom: 44px; border-bottom: 1.5px solid color-mix(in srgb, #1b2a4a 35%, transparent); }
.sig-x { position: absolute; left: 1.3rem; bottom: 48px; color: color-mix(in srgb, #1b2a4a 45%, transparent); font-size: 0.9rem; }
.sig-hint { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; font-size: 0.82rem; color: #6b7690; pointer-events: none; transition: opacity .15s; }
.sig.has-ink .sig-hint { opacity: 0; }
.sig-tools { position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; gap: 0.35rem; opacity: 0; transition: opacity .15s; }
.sig.has-ink .sig-tools { opacity: 1; }
.sig:not([data-mode="draw"]) [data-sig-undo] { display: none; }
.sig-tools button { border: 1px solid #d6dcea; background: #fff; color: #1b2a4a; border-radius: 999px; padding: 0.25rem 0.7rem; font: 700 0.78rem var(--font-body); cursor: pointer; }
.sig-tools button:hover { background: #f1f4fa; }
.sig-legal { margin-top: 0.45rem !important; }
.sig-missing { display: none; margin: 0.35rem 0 0; color: var(--margin); font-weight: 700; font-size: 0.9rem; }
.sig.is-missing .sig-pad { border-color: var(--margin); box-shadow: 0 0 0 4px color-mix(in srgb, var(--margin) 20%, transparent); }
.sig.is-missing .sig-missing { display: block; }
