/* ===========================================================
   Minerva Study Hub — production theme (mobile-first)
   =========================================================== */
:root {
  --navy-deep: #11203a;
  --navy: #1d3a63;
  --navy-2: #28527e;
  --gold: #c8912f;
  --gold-2: #e0ad4b;
  --gold-soft: #f6ecd6;
  --teal: #2f7d77;
  --ink: #1b2330;
  --muted: #586474;
  --faint: #8a94a4;
  --line: #e6e9f0;
  --line-2: #eef1f6;
  --bg: #f4f6f9;
  --bg-2: #eef1f6;
  --card: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --heading: #11203a;
  --link: #1d3a63;
  --ok: #1f8a52; --ok-bg: #e8f6ee; --ok-line: #bfe6cd;
  --bad: #c23b3b; --bad-bg: #fcebeb; --bad-line: #f1c7c7;
  --tag-bg: #e7f1f0;
  --callout-bg: #fffaf0; --callout-info-bg: #eef6f5; --cta-bg: #eef2f8;
  --radius: 16px; --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(17,32,58,.05), 0 10px 30px rgba(17,32,58,.08);
  --shadow-sm: 0 1px 2px rgba(17,32,58,.06), 0 4px 14px rgba(17,32,58,.05);
  --maxw: 860px; --sidenav-w: 286px;
  --topbar-h: 58px;
  --read-scale: 1;
}

[data-theme="dark"] {
  --navy: #2b4d7a; --navy-deep: #1a2e4d;
  --bg: #0e1521; --bg-2: #18222f;
  --card: #161f2c; --surface: #1a2432; --surface-2: #212c3c;
  --heading: #eaf0f8; --link: #9ec3ef; --ink: #dce3ec; --muted: #9aa6b6; --faint: #76828f;
  --line: #2b3647; --line-2: #232e3e;
  --gold-soft: #2e2a1c;
  --tag-bg: rgba(47,125,119,.2);
  --callout-bg: #2a2517; --callout-info-bg: #16211f; --cta-bg: #1b2737;
  --ok-bg: #15311f; --ok-line: #265f3b; --bad-bg: #371c1c; --bad-line: #6c3636;
  --shadow: 0 1px 2px rgba(0,0,0,.45), 0 12px 32px rgba(0,0,0,.5);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
}
[data-theme="dark"] .card__tag { background: var(--tag-bg); }
[data-theme="dark"] .callout { background: var(--callout-bg); }
[data-theme="dark"] .callout--info { background: var(--callout-info-bg); }
[data-theme="dark"] .quiz-cta { background: var(--cta-bg); border-color: var(--line); }
[data-theme="dark"] .nm-cornell__sum { border-color: var(--line); }
[data-theme="dark"] .unitcard__num { background: linear-gradient(140deg, var(--surface), var(--gold-soft)); color: var(--gold-2); border-color: var(--line); }
[data-theme="dark"] .feature__i, [data-theme="dark"] .tile .emoji { filter: saturate(1.1); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink); line-height: 1.62;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; -webkit-font-smoothing: antialiased; overflow-wrap: break-word;
}
h1,h2,h3,h4 { font-family: "Fraunces","Georgia",serif; line-height: 1.2; color: var(--heading); font-weight: 600; }
a { color: var(--link); }
img, svg { max-width: 100%; }

.skip-link { position: absolute; left: -999px; top: 0; z-index: 200; background: var(--surface); padding: 10px 16px; border-radius: 0 0 10px 0; }
.skip-link:focus { left: 0; }

/* ---------------- top bar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
  padding-top: env(safe-area-inset-top);
  background: rgba(17,32,58,.92); backdrop-filter: saturate(140%) blur(10px);
  color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 6px 20px rgba(17,32,58,.22);
}
.topbar__menu {
  display: inline-flex; flex-direction: column; gap: 4px; justify-content: center;
  width: 42px; height: 42px; padding: 11px; border: 0; border-radius: 11px;
  background: rgba(255,255,255,.12); cursor: pointer; flex: 0 0 auto;
}
.topbar__menu span { display: block; height: 2px; border-radius: 2px; background: #fff; transition: .25s; }
.topbar__menu[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.topbar__menu[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.topbar__menu[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.topbar__brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; min-width: 0; margin-right: auto; }
.topbar__logo-img { height: 26px; width: auto; flex: 0 0 auto; display: block; }
.topbar__title { font-size: 1.02rem; letter-spacing: .2px; white-space: nowrap; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.25); }
.topbar__title em { font-style: normal; color: var(--gold-soft); font-weight: 500; }
.topbar__links { display: none; gap: 4px; }
.topbar__links a { color: #d7e0ee; text-decoration: none; padding: 8px 12px; border-radius: 9px; font-weight: 500; font-size: .95rem; }
.topbar__links a:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar__cta {
  margin-left: auto; color: var(--heading); background: var(--gold); text-decoration: none;
  font-weight: 600; font-size: .9rem; padding: 8px 16px; border-radius: 999px; flex: 0 0 auto;
}
.topbar__cta:hover { filter: brightness(1.06); }
.topbar__settings {
  flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: 0;
  width: 42px; height: 42px; justify-content: center; align-items: center;
  border: 0; border-radius: 11px; background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
  font-family: "Fraunces",serif; font-weight: 700; line-height: 1;
}
.topbar__settings span:first-child { font-size: 1.05rem; }
.topbar__settings-a2 { font-size: .8rem; }
.topbar__settings:hover { background: rgba(255,255,255,.2); }

.reading-panel {
  position: fixed; z-index: 90; width: 260px; max-width: calc(100vw - 16px);
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 14px;
}
.reading-panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.reading-panel__head b { font-family: "Fraunces",serif; color: var(--heading); }
.reading-panel__x { border: 0; background: var(--bg-2); width: 28px; height: 28px; border-radius: 8px; font-size: 1.2rem; line-height: 1; color: var(--muted); cursor: pointer; }
.reading-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.reading-row__lbl { font-size: .9rem; color: var(--muted); font-weight: 500; }
.seg { display: inline-flex; background: var(--bg-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; font: inherit; font-size: .85rem; font-weight: 600; color: var(--muted); padding: 7px 11px; border-radius: 8px; cursor: pointer; }
.seg button.is-active { background: var(--card); color: var(--heading); box-shadow: var(--shadow-sm); }
.seg--size button { color: var(--link); padding: 7px 10px; }
.seg__val { min-width: 44px; text-align: center; font-size: .82rem; font-weight: 700; color: var(--heading); align-self: center; }

/* ---------------- layout ---------------- */
.layout { display: block; }
.app { max-width: var(--maxw); margin: 0 auto; padding: 18px 16px 48px; outline: none; }

/* ---------------- side navigation ---------------- */
.sidenav {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 70;
  width: var(--sidenav-w); max-width: 88vw; background: var(--card);
  border-right: 1px solid var(--line); overflow-y: auto;
  padding: 14px 12px calc(28px + env(safe-area-inset-bottom));
  padding-top: max(14px, env(safe-area-inset-top));
  transform: translateX(-104%); transition: transform .26s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 0 60px rgba(17,32,58,.22);
}
.sidenav.is-open { transform: translateX(0); }
.sidenav__scrim { position: fixed; inset: 0; z-index: 65; background: rgba(11,20,38,.5); border: 0; backdrop-filter: blur(2px); }

.nav__home, .nav__subjecthead, .nav__unit, .nav__sub a {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
  border-radius: 10px; border: 1px solid transparent;
}
.nav__home { padding: 11px 12px; font-weight: 600; margin-bottom: 6px; }
.nav__home svg { width: 20px; height: 20px; color: var(--link); flex: 0 0 auto; }
.nav__home:hover, .nav__unit:hover, .nav__sub a:hover { background: var(--bg-2); }
.nav__home.is-active { background: var(--gold-soft); }

.nav__subject { margin-top: 6px; }
.nav__subjecthead { padding: 10px 12px; flex-direction: column; align-items: flex-start; gap: 3px; background: var(--bg-2); }
.nav__subjecthead span:last-child { font-family: "Fraunces",serif; font-weight: 600; color: var(--heading); font-size: .98rem; }
.nav__code { font-size: .68rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--teal); }
.nav__units { margin: 6px 0 0; }
.nav__unit { padding: 9px 10px; font-size: .9rem; margin: 2px 0; }
.nav__unit.is-active { background: var(--navy); color: #fff; }
.nav__num {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--gold-soft); color: var(--heading); font-style: normal; font-weight: 700; font-size: .78rem;
}
.nav__unit.is-active .nav__num { background: var(--gold); color: var(--heading); }
.nav__sub { margin: 2px 0 8px 14px; padding-left: 10px; border-left: 2px solid var(--line); }
.nav__sub a { padding: 7px 10px; font-size: .85rem; color: var(--muted); }
.nav__sub a.is-active { color: var(--heading); font-weight: 600; background: var(--gold-soft); }
.nav__quiz { color: var(--teal) !important; font-weight: 600; }

/* ---------------- buttons ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600;
  cursor: pointer; padding: 12px 18px; border-radius: 12px; border: 1px solid transparent; text-decoration: none; line-height: 1; transition: .16s; }
.btn .ico-arrow { width: 18px; height: 18px; }
.btn--primary { background: var(--navy); color: #fff; }
.btn--primary:hover { background: var(--navy-deep); }
.btn--gold { background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #2c2410; box-shadow: 0 6px 16px rgba(200,145,47,.3); }
.btn--gold:hover { filter: brightness(1.05); }
.btn--ghost { background: var(--surface); color: var(--link); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--link); }

/* ---------------- breadcrumb ---------------- */
.crumbs { font-size: .8rem; color: var(--faint); margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crumbs a { color: var(--faint); text-decoration: none; }
.crumbs a:hover { color: var(--link); text-decoration: underline; }
.crumbs .sep { opacity: .6; }

/* ---------------- hero ---------------- */
.hero {
  position: relative; overflow: hidden; border-radius: 22px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, #2c5a8a 0%, var(--navy) 42%, var(--navy-deep) 100%);
  padding: 28px 22px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center;
}
.hero__text { position: relative; z-index: 2; }
.hero__eyebrow { text-transform: uppercase; letter-spacing: 2.4px; font-size: .68rem; color: var(--gold-soft); margin: 0 0 8px; font-weight: 700; }
.hero h1 { color: #fff; margin: 0 0 10px; font-size: clamp(1.7rem, 7vw, 2.5rem); letter-spacing: -.5px; }
.hero p { margin: 0 0 16px; color: #dde6f2; max-width: 48ch; }
.hero__credit { font-size: .82rem; color: #b9c7db !important; margin: 0 !important; }
.hero .btn { margin-top: 2px; }
.hero__art { position: absolute; right: -10px; bottom: -6px; width: 200px; opacity: .9; z-index: 1; pointer-events: none; }
.hero--subject { background: radial-gradient(120% 140% at 0% 0%, #2f6b66 0%, var(--navy) 55%, var(--navy-deep) 100%); }

/* feature strip */
.features { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 16px 0 4px; }
.feature { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; box-shadow: var(--shadow-sm); }
.feature__i { font-size: 1.4rem; line-height: 1; flex: 0 0 auto; }
.feature b { display: block; color: var(--heading); font-family: "Fraunces",serif; }
.feature span { font-size: .88rem; color: var(--muted); }

.section-title { font-size: 1.3rem; margin: 30px 2px 14px; display: flex; align-items: center; gap: 10px; }
.section-title__count { font-family: "Inter",sans-serif; font-size: .8rem; font-weight: 700; background: var(--gold-soft); color: var(--heading); padding: 3px 10px; border-radius: 999px; }

/* ---------------- cards ---------------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 8px; transition: .18s; }
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #cfd8e6; }
.card__tag { align-self: flex-start; font-size: .68rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--teal); background: #e7f1f0; padding: 4px 10px; border-radius: 999px; }
.card h3 { margin: 2px 0 0; font-size: 1.14rem; }
.card p { margin: 0; color: var(--muted); font-size: .92rem; }
.card__meta { margin-top: 4px; font-size: .8rem; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.card__meta b { color: var(--link); font-weight: 700; }
.card__best b { color: var(--teal); }
.card__go { margin-top: 6px; display: inline-flex; align-items: center; gap: 6px; color: var(--link); font-weight: 600; font-size: .9rem; }
.card__go svg, .card .ico-arrow { width: 17px; height: 17px; }
.card--subject .ico-arrow { display: none; }

.unitcard { display: flex; flex-direction: row; gap: 14px; align-items: center; }
.unitcard__num { flex: 0 0 auto; width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center;
  font-family: "Fraunces",serif; font-weight: 700; font-size: 1.15rem; background: linear-gradient(140deg,#fff,var(--gold-soft)); color: var(--heading); border: 1px solid var(--gold-soft); }
.unitcard__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.unitcard .ico-arrow { width: 20px; height: 20px; color: var(--faint); flex: 0 0 auto; }

/* ---------------- unit head ---------------- */
.unit-head { margin: 4px 0 8px; }
.unit-head .pill { display: inline-block; background: var(--navy); color: #fff; font-size: .68rem; letter-spacing: 1.4px; text-transform: uppercase; padding: 5px 11px; border-radius: 999px; font-weight: 700; }
.unit-head h1 { margin: 10px 0 4px; font-size: clamp(1.5rem,6vw,2.1rem); letter-spacing: -.4px; }
.unit-head__meta { margin: 0; color: var(--faint); font-size: .86rem; }
.unit-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn--tool { background: var(--surface); color: var(--link); border: 1px solid var(--line); padding: 9px 14px; border-radius: 999px; font-size: .88rem; box-shadow: var(--shadow-sm); }
.btn--tool:hover { border-color: var(--link); }
.btn--tool svg { width: 17px; height: 17px; }

/* ---------------- flashcards ---------------- */
.cards { max-width: 560px; margin: 0 auto; }
.cards__bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cards__exit, .cards__shuffle { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--link); border-radius: 999px; padding: 7px 12px; font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.cards__shuffle { padding: 8px; }
.cards__count { font-size: .85rem; color: var(--muted); font-weight: 600; }
.flashcard { display: block; width: 100%; border: 0; background: transparent; padding: 0; cursor: pointer; perspective: 1400px; margin: 6px 0 4px; font: inherit; }
.flashcard__inner { position: relative; width: 100%; min-height: 280px; transition: transform .5s cubic-bezier(.4,.1,.2,1); transform-style: preserve-3d; }
.flashcard.is-flipped .flashcard__inner { transform: rotateY(180deg); }
.flashcard__face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 26px 22px; border-radius: 18px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.flashcard__front { background: linear-gradient(160deg, var(--card), var(--surface-2)); }
.flashcard__back { background: linear-gradient(160deg, var(--navy), var(--navy-deep)); color: #fff; transform: rotateY(180deg); }
.flashcard__topic { font-size: .7rem; text-transform: uppercase; letter-spacing: 1.4px; font-weight: 700; color: var(--teal); margin-bottom: 12px; }
.flashcard__term { font-family: "Fraunces",serif; font-size: 1.5rem; color: var(--heading); line-height: 1.25; }
.flashcard__hint { position: absolute; bottom: 16px; left: 0; right: 0; font-size: .78rem; color: var(--faint); }
.flashcard__known { margin-top: 10px; font-size: .76rem; color: var(--ok); font-weight: 700; }
.flashcard__deflabel { font-size: .7rem; text-transform: uppercase; letter-spacing: 1.4px; font-weight: 700; color: var(--gold-soft); margin-bottom: 12px; }
.flashcard__def { font-size: 1.05rem; line-height: 1.5; color: #fff; }
.cards__actions { display: flex; gap: 10px; margin-top: 16px; }
.cards__actions .btn { flex: 1; }
.cards__tip { text-align: center; font-size: .8rem; color: var(--faint); margin: 12px 0 0; }

/* ---------------- highlights ---------------- */
mark.hl { background: transparent; padding: 0 1px; border-radius: 3px; cursor: pointer; color: inherit; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
mark.hl--yellow { background: rgba(247,208,79,.5); }
mark.hl--green { background: rgba(99,201,141,.45); }
mark.hl--pink { background: rgba(240,140,170,.45); }
[data-theme="dark"] mark.hl--yellow { background: rgba(214,177,64,.4); color: #fff; }
[data-theme="dark"] mark.hl--green { background: rgba(58,160,103,.45); color: #fff; }
[data-theme="dark"] mark.hl--pink { background: rgba(196,96,134,.45); color: #fff; }
mark.hl--noted { border-bottom: 2px dotted currentColor; }
mark.hl--noted::after { content: "✎"; font-size: .7em; vertical-align: super; margin-left: 1px; opacity: .7; }

.hl-bar { position: fixed; z-index: 95; display: flex; align-items: center; gap: 6px; background: var(--heading); padding: 7px 9px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.hl-bar__c { width: 24px; height: 24px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); cursor: pointer; padding: 0; }
.hl-bar__c--yellow { background: #f7d04f; } .hl-bar__c--green { background: #63c98d; } .hl-bar__c--pink { background: #f08caa; }
.hl-bar__note { border: 0; background: rgba(255,255,255,.16); color: #fff; font: inherit; font-size: .8rem; font-weight: 600; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.hl-bar__note:hover { background: rgba(255,255,255,.28); }

.hl-note { position: fixed; z-index: 96; width: 270px; max-width: calc(100vw - 16px); background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 13px; }
.hl-note__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.hl-note__head b { font-family: "Fraunces",serif; color: var(--heading); }
.hl-note__x { border: 0; background: var(--bg-2); width: 26px; height: 26px; border-radius: 7px; font-size: 1.1rem; line-height: 1; color: var(--muted); cursor: pointer; }
.hl-note__ta { width: 100%; min-height: 76px; resize: vertical; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: .9rem; color: var(--ink); background: var(--surface); }
.hl-note__ta:focus { outline: 2px solid var(--link); outline-offset: 1px; }
.hl-note__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.hl-note__del { border: 0; background: transparent; color: var(--bad); font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; padding: 8px 4px; }
.hl-note__save { padding: 9px 16px; }

/* ---------------- note-method switcher ---------------- */
.switcher { position: sticky; top: var(--topbar-h); z-index: 30; margin: 16px -16px 18px; padding: 12px 16px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line-2); }
.switcher__row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.switcher__row::-webkit-scrollbar { display: none; }
.nm-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; font: inherit; font-weight: 600; font-size: .88rem;
  color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; cursor: pointer; transition: .14s; white-space: nowrap; }
.nm-chip:hover { border-color: var(--link); color: var(--link); }
.nm-chip.is-active { background: var(--navy); color: #fff; border-color: var(--link); box-shadow: 0 4px 12px rgba(29,58,99,.25); }
.nm-chip__i { display: inline-flex; }
.nm-chip__i svg { width: 17px; height: 17px; }
.switcher__foot { display: flex; align-items: center; gap: 10px; margin: 8px 2px 0; }
.switcher__blurb { margin: 0; font-size: .82rem; color: var(--faint); flex: 1; min-width: 0; }
.nm-help { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .8rem; font-weight: 600;
  color: var(--link); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.nm-help:hover { border-color: var(--link); background: var(--bg-2); }
.nm-help__q { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: var(--navy); color: #fff; font-size: .72rem; font-weight: 700; }
.nm-help-pop { position: relative; margin-top: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 15px; }
.nm-help-pop__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.nm-help-pop__head b { font-family: "Fraunces",serif; color: var(--heading); font-size: 1.02rem; }
.nm-help-pop__x { border: 0; background: var(--bg-2); width: 28px; height: 28px; border-radius: 8px; font-size: 1.2rem; line-height: 1; color: var(--muted); cursor: pointer; }
.nm-help-pop__x:hover { background: var(--line); color: var(--ink); }
.nm-help-pop__lead { margin: 0 0 10px; font-size: .82rem; color: var(--faint); }
.nm-help-pop ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.nm-help-pop li { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; color: var(--muted); }
.nm-help-pop li b { color: var(--heading); }
.nm-help-pop__i { flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--gold-soft); color: var(--heading); }
.nm-help-pop__i svg { width: 16px; height: 16px; }

/* ---------------- subtopics ---------------- */
.subtopic { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin: 14px 0; box-shadow: var(--shadow-sm); overflow: hidden; scroll-margin-top: calc(var(--topbar-h) + 70px); }
.subtopic > summary { list-style: none; cursor: pointer; padding: 16px 18px; display: flex; align-items: center; gap: 12px; }
.subtopic > summary::-webkit-details-marker { display: none; }
.subtopic__title { font-family: "Fraunces",serif; font-weight: 600; color: var(--heading); font-size: 1.08rem; flex: 1; }
.subtopic > summary .ix { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--gold-soft); color: var(--heading); font-weight: 700; font-size: .85rem; }
.subtopic > summary .chev { flex: 0 0 auto; color: var(--faint); transition: transform .2s; }
.subtopic > summary .chev svg { width: 18px; height: 18px; display: block; }
.subtopic[open] > summary .chev { transform: rotate(90deg); }
.subtopic__body { padding: 6px 18px 18px; border-top: 1px solid var(--line-2); font-size: calc(1rem * var(--read-scale)); }

/* prose */
.prose { font-size: 1em; }
.prose h4 { font-size: 1.05em; margin: 20px 0 8px; color: var(--link); }
.prose p { margin: 11px 0; }
.prose ul, .prose ol { margin: 11px 0; padding-left: 22px; }
.prose li { margin: 7px 0; }
.prose ul ul, .prose ol ol, .prose ul ol, .prose ol ul { margin: 5px 0; }
.prose strong { color: var(--heading); }

/* callout */
.callout { border-left: 4px solid var(--gold); background: #fffaf0; padding: 13px 15px; border-radius: 10px; margin: 15px 0; }
.callout--info { border-left-color: var(--teal); background: #eef6f5; }
.callout__label { font-size: .68rem; text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700; color: var(--gold); margin: 0 0 5px; }
.callout--info .callout__label { color: var(--teal); }
.callout p:first-child { margin-top: 0; } .callout p:last-child { margin-bottom: 0; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 15px 0; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; min-width: 440px; font-size: .92rem; }
caption { caption-side: top; text-align: left; font-family: "Fraunces",serif; font-weight: 600; color: var(--heading); padding: 10px 12px 6px; }
th, td { text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
thead th { background: var(--navy); color: #fff; font-weight: 600; }
tbody tr:nth-child(even) { background: var(--surface-2); }

/* glossary */
.glossary { margin: 15px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.glossary > div { padding: 11px 14px; }
.glossary > div:nth-child(even) { background: var(--surface-2); }
.glossary dt { font-weight: 700; color: var(--heading); }
.glossary dd { margin: 2px 0 0; color: var(--ink); }

/* diagrams */
.diagram { margin: 16px 0; padding: 16px; background: #fbfcfe; border: 1px solid var(--line); border-radius: 14px; }
.diagram__cap { font-size: .8rem; color: var(--faint); margin: 12px 0 0; text-align: center; font-style: italic; }
.orgchart { display: flex; flex-direction: column; align-items: stretch; }
.org-node { background: var(--surface); border: 1.5px solid var(--navy); color: var(--heading); border-radius: 11px; padding: 9px 12px; text-align: center; font-weight: 600; font-size: .86rem; box-shadow: var(--shadow-sm); }
.org-node--root { background: var(--navy); color: #fff; }
.org-node small { display: block; font-weight: 400; font-size: .74rem; color: var(--muted); }
.org-node--root small { color: #cdd9ea; }
.org-level { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.org-connector { width: 2px; height: 16px; background: var(--line); margin: 0 auto; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(124px,1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 12px; text-align: center; font-size: .85rem; font-weight: 600; color: var(--heading); }
.tile .emoji { font-size: 1.5rem; display: block; margin-bottom: 4px; }
.tile--front { border-top: 3px solid var(--teal); } .tile--back { border-top: 3px solid var(--gold); }
.flow { display: flex; flex-direction: column; }
.flow__step { display: flex; gap: 12px; align-items: flex-start; }
.flow__dot { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.flow__body { padding-bottom: 14px; } .flow__body b { color: var(--heading); }
.flow__line { width: 2px; background: var(--line); margin-left: 14px; flex: 1; min-height: 12px; }
.flow__step:last-child .flow__line { display: none; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 12px; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* =========================================================
   NOTE METHODS
   ========================================================= */
.nm-label { font-size: .66rem; text-transform: uppercase; letter-spacing: 1.4px; font-weight: 700; color: var(--faint); margin-bottom: 8px; }

/* Boxing */
.nm-boxgrid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 4px; }
.nm-box { border: 1px solid var(--line); border-top: 3px solid var(--c, var(--navy)); border-radius: 13px; background: var(--surface); overflow: hidden; box-shadow: var(--shadow-sm); }
.nm-box__h { margin: 0; padding: 12px 15px; font-size: 1rem; color: var(--heading); background: color-mix(in srgb, var(--c, var(--navy)) 8%, var(--surface)); border-bottom: 1px solid var(--line-2); }
.nm-box__b { padding: 4px 15px 14px; }

/* Sentence */
.nm-sentence { margin-top: 4px; counter-reset: sline; }
.nm-sentence__h { font-family: "Fraunces",serif; font-weight: 600; color: var(--link); margin: 18px 0 6px; font-size: 1.02rem; }
.nm-sentence__line { position: relative; margin: 0; padding: 9px 12px 9px 40px; border-bottom: 1px solid var(--line-2); }
.nm-sentence__line::before { counter-increment: sline; content: counter(sline); position: absolute; left: 10px; top: 9px; width: 22px; height: 22px; background: var(--bg-2); color: var(--link); border-radius: 6px; font-size: .72rem; font-weight: 700; display: grid; place-items: center; }
.nm-sentence__block { margin: 10px 0; }

/* Cornell */
.nm-cornell { margin-top: 4px; }
.nm-cornell__grid { display: grid; grid-template-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.nm-cornell__cues { background: var(--bg-2); padding: 14px; border-bottom: 1px solid var(--line); }
.nm-cornell__hint { margin: 0 0 10px; font-size: .78rem; color: var(--faint); font-style: italic; }
.nm-cornell__cues ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 7px; }
.nm-cornell__cues li { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: .8rem; font-weight: 600; color: var(--heading); }
.nm-cornell__notes { padding: 14px; }
.nm-cornell__sum { background: var(--gold-soft); border: 1px solid #ecdcb8; border-top: 0; border-radius: 0 0 13px 13px; padding: 13px 15px; margin-top: -1px; }
.nm-cornell__sum p { margin: 0; color: #5a4a25; font-size: .92rem; }

/* Charting */
.nm-chart { margin-top: 4px; }
.nm-chart .table-wrap { margin: 12px 0; }

/* Mapping (mind map) */
.nm-map { margin-top: 6px; padding: 8px 4px; }
.nm-map__center { display: block; margin: 0 auto 6px; max-width: 100%; text-align: center; }
.nm-map__center span { display: inline-block; background: linear-gradient(135deg, var(--navy), var(--navy-deep)); color: #fff; font-family: "Fraunces",serif; font-weight: 600; font-size: 1.05rem; padding: 12px 20px; border-radius: 14px; box-shadow: var(--shadow); }
.nm-map__branches { display: grid; grid-template-columns: 1fr; gap: 12px; position: relative; padding-top: 10px; }
.nm-map__branch { position: relative; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 6%, var(--surface)); border-radius: 0 12px 12px 0; padding: 12px 14px; }
.nm-map__node { font-weight: 700; color: var(--c); margin-bottom: 8px; }
.nm-map__leaves { display: flex; flex-wrap: wrap; gap: 7px; }
.nm-map__leaf { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: .8rem; color: var(--ink); }

/* quiz cta in notes */
.quiz-cta { margin: 18px 0 4px; padding: 15px; border-radius: 13px; background: linear-gradient(120deg,var(--surface-2),#e9eff8); border: 1px solid #d6e0ee; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.quiz-cta > div { flex: 1; min-width: 170px; }
.quiz-cta__k { display: inline-block; font-size: .66rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; color: var(--teal); margin-bottom: 3px; }
.quiz-cta p { margin: 0; font-size: .9rem; color: var(--muted); }

/* unit quiz band */
.unit-quiz-band { position: relative; overflow: hidden; margin: 28px 0 8px; padding: 22px; border-radius: var(--radius); background: radial-gradient(120% 160% at 100% 0%, #347b75, #245e59); color: #fff; }
.unit-quiz-band__txt { position: relative; z-index: 2; }
.unit-quiz-band h3 { color: #fff; margin: 0 0 6px; font-size: 1.3rem; }
.unit-quiz-band p { margin: 0 0 14px; color: #d9efec; }
.unit-quiz-band__art { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 88px; opacity: .5; z-index: 1; }

/* pager */
.pager { display: flex; gap: 10px; margin-top: 26px; justify-content: space-between; }
.pager .btn { flex-direction: column; align-items: flex-start; padding: 12px 16px; min-width: 120px; }
.pager .btn small { font-weight: 400; opacity: .65; font-size: .72rem; margin-bottom: 3px; }
.pager .pager__next { text-align: right; align-items: flex-end; }

/* quiz engine */
.quiz { max-width: 660px; margin: 0 auto; }
.quiz__head { text-align: center; margin-bottom: 8px; }
.quiz__head .pill { display: inline-block; background: var(--navy); color: #fff; font-size: .66rem; letter-spacing: 1.2px; text-transform: uppercase; padding: 5px 11px; border-radius: 999px; font-weight: 700; }
.quiz__head h1 { margin: 12px 0 0; font-size: clamp(1.4rem,6vw,1.9rem); }
.quiz__meta { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); margin: 16px 0 6px; }
.quiz__progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 20px; }
.quiz__progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-2), var(--gold)); transition: width .3s; }
.qcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.qcard__q { font-family: "Fraunces",serif; font-size: 1.15rem; color: var(--heading); margin: 0 0 16px; line-height: 1.35; }
.opt { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 13px 15px; margin: 9px 0; font: inherit; cursor: pointer; transition: .12s; color: var(--ink); }
.opt:hover:not(:disabled) { border-color: var(--link); background: var(--surface-2); }
.opt__key { flex: 0 0 auto; width: 27px; height: 27px; border-radius: 8px; background: var(--surface-2); color: var(--link); display: grid; place-items: center; font-weight: 700; font-size: .82rem; }
.opt__txt { flex: 1; }
.opt--correct { border-color: var(--ok); background: var(--ok-bg); }
.opt--correct .opt__key { background: var(--ok); color: #fff; }
.opt--wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt--wrong .opt__key { background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; }
.feedback { margin: 14px 0 4px; padding: 13px 15px; border-radius: 12px; font-size: .92rem; display: none; }
.feedback.show { display: block; }
.feedback--ok { background: var(--ok-bg); border: 1px solid var(--ok-line); }
.feedback--bad { background: var(--bad-bg); border: 1px solid var(--bad-line); }
.feedback b { display: block; margin-bottom: 3px; }
.feedback--ok b { color: var(--ok); } .feedback--bad b { color: var(--bad); }
.quiz__actions { display: flex; gap: 10px; margin-top: 18px; }
.quiz__actions .btn { flex: 1; }
.result { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 22px; box-shadow: var(--shadow-sm); }
.result__ring { width: 120px; height: 120px; margin: 0 auto 12px; color: var(--heading); }
.result__score { font-family: "Fraunces",serif; font-size: 2.1rem; color: var(--heading); }
.result h2 { margin: 6px 0; } .result__msg { color: var(--muted); margin: 0 0 18px; }
.result__actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.review { text-align: left; margin-top: 24px; }
.review h3 { font-size: 1.05rem; margin: 0 0 10px; }
.review__item { border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; margin: 10px 0; background: var(--surface); }
.review__item .qq { font-weight: 600; }
.review__item.ok { border-left: 4px solid var(--ok); } .review__item.bad { border-left: 4px solid var(--bad); }
.review__item .ans { font-size: .88rem; margin: 6px 0 0; }
.review__item .ans .good { color: var(--ok); font-weight: 600; } .review__item .ans .miss { color: var(--bad); font-weight: 600; }

.notice { text-align: center; padding: 56px 20px; color: var(--muted); }

/* footer */
.sitefoot { margin-top: 30px; background: var(--navy-deep); color: #b9c7db; padding: 26px 16px calc(26px + env(safe-area-inset-bottom)); }
.sitefoot__inner { max-width: var(--maxw); margin: 0 auto; }
.sitefoot__logo { height: 34px; width: auto; display: block; margin-bottom: 12px; opacity: .95; }
.sitefoot p { margin: 3px 0; font-size: .84rem; }
.sitefoot__brand { font-family: "Fraunces",serif; color: #fff; font-size: 1rem; font-weight: 600; }
.sitefoot__note { color: #7e8da3; margin-top: 10px !important; font-size: .78rem; }

/* =========================================================
   DESKTOP
   ========================================================= */
@media (min-width: 760px) {
  .features { grid-template-columns: repeat(3,1fr); }
  .hero { padding: 36px 32px; }
  .hero__art { width: 240px; }
}
@media (min-width: 900px) {
  :root { --maxw: 780px; }
  .topbar__menu { display: none; }
  .topbar__links { display: flex; }
  .topbar__cta { display: none; }
  .layout { display: grid; grid-template-columns: var(--sidenav-w) minmax(0,1fr); max-width: 1180px; margin: 0 auto; gap: 8px; align-items: start; }
  .sidenav { position: sticky; top: var(--topbar-h); transform: none !important; box-shadow: none; background: transparent; border-right: 1px solid var(--line); height: calc(100vh - var(--topbar-h)); }
  .sidenav__scrim { display: none !important; }
  .grid { grid-template-columns: repeat(2,1fr); }
  .grid--subjects { grid-template-columns: 1fr; }
  .switcher { top: var(--topbar-h); }
  /* Cornell true 3-zone on wide screens */
  .nm-cornell__grid { grid-template-columns: 230px minmax(0,1fr); }
  .nm-cornell__cues { border-bottom: 0; border-right: 1px solid var(--line); }
  .nm-map__branches { grid-template-columns: repeat(2,1fr); }
}
@media (min-width: 1180px) {
  .grid--subjects { grid-template-columns: repeat(2,1fr); }
}

/* hide the "Study Hub" suffix on very narrow phones so the logo never crowds */
@media (max-width: 400px) { .topbar__title { display: none; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
