/* ==========================================================================
   Nota Bene - MYP 4-5 revision notes
   Shared stylesheet. Editorial design system.
   ========================================================================== */

/* ---- Fonts (Google Fonts loaded in each HTML head) -----------------------
   Fraunces  - display / wordmark (crafted, optical)
   Newsreader - body & notes (scholarly serif, easy long-read)
   Public Sans - UI labels, nav, eyebrows (clean humanist sans)
   -------------------------------------------------------------------------- */

:root {
  /* Paper & ink */
  --paper:        #f7f4ee;   /* warm off-white background            */
  --paper-2:      #fffdf8;   /* card / raised surfaces               */
  --ink:          #1c1a17;   /* primary text                         */
  --ink-2:        #4c4842;   /* secondary text                      */
  --ink-3:        #857f75;   /* muted / captions                    */
  --rule:         #e3ddd1;   /* hairlines & borders                 */
  --rule-2:       #d3ccbd;   /* stronger borders                    */

  /* Subject accents - muted, editorial, distinct */
  --c-smaths:     #2f5d84;   /* Standard Maths - steel blue         */
  --c-emaths:     #16324a;   /* Extended Maths - deep navy          */
  --c-physics:    #5a4f8a;   /* Physics - muted indigo              */
  --c-chem:       #b0553a;   /* Chemistry - rust                    */
  --c-bio:        #3d7a51;   /* Biology - forest green              */
  --c-english:    #8a3b4c;   /* English L&L - burgundy              */

  --accent:       var(--c-emaths); /* default page accent           */

  /* Type scale */
  --f-display: "Fraunces", Georgia, "Times New Roman", serif;
  --f-body:    "Newsreader", Georgia, "Times New Roman", serif;
  --f-ui:      "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --f-mono:    "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Layout */
  --measure: 42rem;          /* comfortable reading width            */
  --wrap:    72rem;          /* page max width                       */
  --radius:  4px;
  --shadow:  0 1px 2px rgba(28,26,23,.04), 0 8px 28px -18px rgba(28,26,23,.28);
}

/* ---- Reset-ish ----------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 1.125rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
a { color: inherit; }

/* Subtle paper texture via layered gradients (no images, prints clean) */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(90,79,138,.05), transparent 60%),
    radial-gradient(1000px 500px at -10% 110%, rgba(47,93,132,.05), transparent 60%);
  z-index: 0;
}

/* ---- Utilities ----------------------------------------------------------- */
.wrap { width: min(var(--wrap), 92%); margin-inline: auto; }
.eyebrow {
  font-family: var(--f-ui);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.rule { height: 1px; background: var(--rule); border: 0; }

/* ==========================================================================
   Header / navigation
   ========================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 68px;
}
.wordmark {
  display: inline-flex; align-items: baseline; gap: .5rem;
  text-decoration: none; color: var(--ink);
}
.wordmark .nb {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: -.01em;
}
.wordmark .nb-abbr {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 1rem;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  padding: .05em .35em;
  line-height: 1;
}
.wordmark .tag {
  font-family: var(--f-ui);
  font-size: .7rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-3);
}
.nav { display: flex; gap: 1.75rem; align-items: center; }
.nav a {
  font-family: var(--f-ui);
  font-size: .82rem; font-weight: 500; letter-spacing: .02em;
  text-decoration: none; color: var(--ink-2);
  padding: .3rem 0;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.nav a:hover { color: var(--ink); border-color: var(--rule-2); }
.nav a.active { color: var(--ink); border-color: var(--accent); }
.nav-toggle { display: none; }

/* ==========================================================================
   Hero (homepage)
   ========================================================================== */
.hero { position: relative; z-index: 1; padding: 5.5rem 0 3.5rem; }
.hero .measure { max-width: 40rem; }
.hero h1 {
  font-family: var(--f-display);
  font-weight: 560;
  font-size: clamp(2.5rem, 6vw, 4rem);
  line-height: 1.04;
  letter-spacing: -.02em;
  margin: .6rem 0 1rem;
}
.hero h1 em { font-style: italic; color: var(--ink-2); }
.hero p.lede {
  font-size: 1.28rem;
  color: var(--ink-2);
  line-height: 1.5;
  max-width: 34rem;
  margin: 0 0 2rem;
}
.hero .actions { display: flex; gap: .9rem; flex-wrap: wrap; align-items: center; }

.btn {
  font-family: var(--f-ui);
  font-size: .9rem; font-weight: 600; letter-spacing: .01em;
  text-decoration: none;
  padding: .8rem 1.4rem; border-radius: var(--radius);
  display: inline-flex; align-items: center; gap: .5rem;
  transition: transform .12s, background .15s, box-shadow .15s;
}
.btn-primary { background: var(--ink); color: var(--paper-2); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-ghost { color: var(--ink); border: 1px solid var(--rule-2); background: transparent; }
.btn-ghost:hover { border-color: var(--ink); }

/* small stat row under hero */
.hero-meta {
  display: flex; gap: 2.5rem; margin-top: 3rem; flex-wrap: wrap;
  font-family: var(--f-ui);
}
.hero-meta .stat b {
  display: block; font-family: var(--f-display); font-weight: 600;
  font-size: 1.7rem; letter-spacing: -.01em;
}
.hero-meta .stat span { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

/* ==========================================================================
   Section headings
   ========================================================================== */
.section { position: relative; z-index: 1; padding: 3.5rem 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.section-head h2 {
  font-family: var(--f-display);
  font-weight: 560; font-size: clamp(1.7rem, 3.5vw, 2.3rem);
  letter-spacing: -.015em; margin: .3rem 0 0;
}
.section-head p { color: var(--ink-2); margin: .2rem 0 0; max-width: 30rem; }

/* ==========================================================================
   Subject grid + cards
   ========================================================================== */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}
.subject-card {
  --c: var(--accent);
  position: relative;
  display: flex; flex-direction: column;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.6rem 1.6rem 1.4rem;
  text-decoration: none; color: inherit;
  overflow: hidden;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.subject-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--c);
}
.subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--rule-2); }
.subject-card .subj-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; }
.subj-badge {
  font-family: var(--f-ui); font-size: .66rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, var(--paper-2));
  padding: .3em .6em; border-radius: 100px;
}
.subj-glyph {
  width: 40px; height: 40px; border-radius: 8px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 12%, var(--paper-2));
  color: var(--c);
}
.subject-card h3 {
  font-family: var(--f-display); font-weight: 560;
  font-size: 1.45rem; letter-spacing: -.01em;
  margin: 0 0 .35rem;
}
.subject-card p { color: var(--ink-2); font-size: .98rem; line-height: 1.5; margin: 0 0 1.2rem; }
.subject-card .subj-foot {
  margin-top: auto; display: flex; align-items: center; justify-content: space-between;
  font-family: var(--f-ui); font-size: .8rem; color: var(--ink-3);
  padding-top: 1rem; border-top: 1px solid var(--rule);
}
.subject-card .go { color: var(--c); font-weight: 600; display: inline-flex; align-items: center; gap: .35rem; }
.subject-card .go svg { transition: transform .16s; }
.subject-card:hover .go svg { transform: translateX(3px); }

.status-soon {
  font-family: var(--f-ui); font-size: .72rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
}

/* ==========================================================================
   "How it works" - trust strip
   ========================================================================== */
.principles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.principle .num {
  font-family: var(--f-display); font-weight: 600; font-size: 1.1rem;
  color: var(--accent);
  border: 1.5px solid currentColor; width: 2rem; height: 2rem;
  border-radius: 50%; display: grid; place-items: center; margin-bottom: .9rem;
}
.principle h4 { font-family: var(--f-display); font-weight: 560; font-size: 1.2rem; margin: 0 0 .4rem; letter-spacing: -.01em; }
.principle p { color: var(--ink-2); font-size: .98rem; margin: 0; }

.criteria-note {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--accent);
  border-radius: 6px; padding: 1.5rem 1.7rem; margin-top: 2.5rem;
}
.criteria-note h4 { font-family: var(--f-ui); font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 .8rem; }
.criteria-note .crit-row { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.criteria-note .crit { flex: 1 1 180px; }
.criteria-note .crit b { font-family: var(--f-display); }
.criteria-note .crit span { display: block; font-size: .92rem; color: var(--ink-2); }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  position: relative; z-index: 1;
  border-top: 1px solid var(--rule);
  margin-top: 2rem; padding: 3rem 0 4rem;
  font-family: var(--f-ui);
}
.site-footer .cols { display: flex; justify-content: space-between; gap: 2rem; flex-wrap: wrap; }
.site-footer .brand-note { max-width: 22rem; }
.site-footer .brand-note .nb { font-family: var(--f-display); font-weight: 600; font-size: 1.2rem; }
.site-footer .brand-note p { color: var(--ink-3); font-size: .88rem; line-height: 1.5; font-family: var(--f-body); }
.site-footer h5 { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 .8rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: .5rem; }
.site-footer a { color: var(--ink-2); text-decoration: none; font-size: .9rem; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; }
.site-footer .legal { margin-top: 2.5rem; font-size: .8rem; color: var(--ink-3); }

/* ==========================================================================
   NOTES PAGE
   ========================================================================== */
.note-hero {
  position: relative; z-index: 1;
  border-bottom: 1px solid var(--rule);
  padding: 2.5rem 0 2.2rem;
}
.breadcrumb { font-family: var(--f-ui); font-size: .8rem; color: var(--ink-3); margin-bottom: 1rem; }
.breadcrumb a { color: var(--ink-3); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.note-hero h1 {
  font-family: var(--f-display); font-weight: 560;
  font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.02em; line-height: 1.08;
  margin: .3rem 0 .6rem;
}
.note-hero .sub { color: var(--ink-2); font-size: 1.15rem; max-width: var(--measure); margin: 0 0 1.2rem; }
.note-tags { display: flex; gap: .5rem; flex-wrap: wrap; }
.note-tag {
  font-family: var(--f-ui); font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--rule));
  background: color-mix(in srgb, var(--accent) 8%, var(--paper-2));
  padding: .3em .7em; border-radius: 100px;
}

/* layout: article + sticky TOC */
.note-layout {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr minmax(0, var(--measure)) 1fr;
  gap: 2rem; padding: 2.5rem 0 4rem;
}
.toc { position: sticky; top: 92px; align-self: start; font-family: var(--f-ui); }
.toc h6 { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 .8rem; }
.toc ol { list-style: none; padding: 0; margin: 0; counter-reset: toc; }
.toc li { margin-bottom: .1rem; }
.toc a {
  display: block; text-decoration: none; color: var(--ink-2);
  font-size: .85rem; line-height: 1.35; padding: .35rem .6rem .35rem .8rem;
  border-left: 2px solid var(--rule); border-radius: 0 4px 4px 0;
  transition: color .15s, border-color .15s, background .15s;
}
.toc a:hover { color: var(--ink); background: var(--paper-2); }
.toc a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }

.note-body { max-width: var(--measure); }
.note-body > * { grid-column: 2; }
.note-body h2 {
  font-family: var(--f-display); font-weight: 560; font-size: 1.65rem;
  letter-spacing: -.01em; margin: 2.6rem 0 .8rem; scroll-margin-top: 90px;
  padding-top: 1.4rem; border-top: 1px solid var(--rule);
}
.note-body h2:first-of-type { border-top: 0; padding-top: 0; margin-top: .5rem; }
.note-body h3 { font-family: var(--f-display); font-weight: 560; font-size: 1.25rem; margin: 1.8rem 0 .5rem; }
.note-body p { margin: 0 0 1.1rem; }
.note-body ul, .note-body ol { margin: 0 0 1.2rem; padding-left: 1.3rem; }
.note-body li { margin-bottom: .45rem; }
.note-body strong { font-weight: 600; }
.note-body a.inline { color: var(--accent); text-underline-offset: 3px; }

/* Definition / key term */
.keyterm {
  background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 6px; padding: 1rem 1.2rem; margin: 1.4rem 0;
}
.keyterm dt { font-family: var(--f-display); font-weight: 600; font-size: 1.05rem; margin-bottom: .2rem; }
.keyterm dd { margin: 0; color: var(--ink-2); }

/* Worked example */
.worked {
  border: 1px solid var(--rule-2); border-radius: 8px; overflow: hidden;
  margin: 1.6rem 0; background: var(--paper-2);
}
.worked .worked-head {
  font-family: var(--f-ui); font-size: .74rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--paper-2); background: var(--accent);
  padding: .5rem 1.1rem; display: flex; align-items: center; gap: .5rem;
}
.worked .worked-body { padding: 1.2rem 1.3rem; }
.worked .q { font-style: italic; color: var(--ink-2); margin-bottom: 1rem; }
.worked .step { display: grid; grid-template-columns: auto 1fr; gap: .8rem; margin-bottom: .7rem; align-items: start; }
.worked .step .n {
  font-family: var(--f-ui); font-size: .72rem; font-weight: 700;
  background: color-mix(in srgb, var(--accent) 14%, var(--paper-2)); color: var(--accent);
  width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; margin-top: .15rem;
}
.worked .answer {
  margin-top: 1rem; padding-top: .9rem; border-top: 1px dashed var(--rule-2);
  font-weight: 600;
}
.worked .answer::before { content: "Answer  "; font-family: var(--f-ui); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }

/* Exam tip / criteria callout */
.callout {
  display: grid; grid-template-columns: auto 1fr; gap: 1rem;
  border-radius: 8px; padding: 1.1rem 1.3rem; margin: 1.6rem 0;
  border: 1px solid var(--rule);
}
.callout.tip   { background: color-mix(in srgb, var(--c-bio) 7%, var(--paper-2)); border-color: color-mix(in srgb, var(--c-bio) 22%, var(--rule)); }
.callout.crit  { background: color-mix(in srgb, var(--accent) 7%, var(--paper-2)); border-color: color-mix(in srgb, var(--accent) 22%, var(--rule)); }
.callout.warn  { background: color-mix(in srgb, var(--c-chem) 7%, var(--paper-2)); border-color: color-mix(in srgb, var(--c-chem) 22%, var(--rule)); }
.callout .ico { width: 30px; height: 30px; }
.callout .ttl { font-family: var(--f-ui); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 .3rem; }
.callout p { margin: 0; font-size: 1rem; color: var(--ink-2); }
.callout.tip  .ttl { color: var(--c-bio); }
.callout.crit .ttl { color: var(--accent); }
.callout.warn .ttl { color: var(--c-chem); }

/* Formula display block */
.formula {
  background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 6px; padding: 1.1rem 1.3rem; margin: 1.3rem 0;
  overflow-x: auto; text-align: center;
}

/* Tables */
.note-body table { width: 100%; border-collapse: collapse; margin: 1.4rem 0; font-size: .98rem; }
.note-body th, .note-body td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--rule); }
.note-body thead th { font-family: var(--f-ui); font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); border-bottom: 1.5px solid var(--rule-2); }
.note-body tbody tr:hover { background: var(--paper-2); }

/* Check-your-understanding */
.cyu { border: 1px solid var(--rule); border-radius: 8px; margin: 1.4rem 0; overflow: hidden; }
.cyu summary {
  cursor: pointer; list-style: none; padding: .95rem 1.2rem;
  font-family: var(--f-body); font-weight: 600; background: var(--paper-2);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.cyu summary::-webkit-details-marker { display: none; }
.cyu summary .plus { font-family: var(--f-ui); color: var(--accent); transition: transform .2s; }
.cyu[open] summary .plus { transform: rotate(45deg); }
.cyu .cyu-body { padding: .3rem 1.2rem 1.1rem; color: var(--ink-2); }

/* progress bar for reading */
.read-progress { position: fixed; top: 0; left: 0; height: 3px; background: var(--accent); width: 0; z-index: 30; transition: width .1s linear; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .note-layout { grid-template-columns: 1fr; }
  .note-body > * { grid-column: 1; }
  .note-body { max-width: var(--measure); margin-inline: auto; }
  .toc { display: none; }
  .principles { grid-template-columns: 1fr; gap: 1.5rem; }
}
@media (max-width: 640px) {
  body { font-size: 1.06rem; }
  .nav { display: none; }
  .nav.open { display: flex; position: absolute; top: 68px; right: 0; left: 0;
    flex-direction: column; gap: 0; background: var(--paper-2);
    border-bottom: 1px solid var(--rule); padding: .5rem 6% 1rem; }
  .nav.open a { padding: .8rem 0; border-bottom: 1px solid var(--rule); border-left: 0; }
  .nav-toggle { display: inline-flex; background: none; border: 1px solid var(--rule-2);
    border-radius: 6px; width: 40px; height: 40px; align-items: center; justify-content: center; cursor: pointer; }
  .hero { padding: 3.5rem 0 2.5rem; }
  .hero-meta { gap: 1.5rem; }
  .criteria-note .crit-row { flex-direction: column; gap: 1rem; }
}

@media print {
  .site-header, .site-footer, .toc, .read-progress, .nav-toggle { display: none; }
  body::before { display: none; }
  body { background: #fff; }
}

/* ==========================================================================
   Subject-index page (topic listing) + byline credit
   ========================================================================== */
.subject-hero {
  position: relative; z-index: 1;
  border-bottom: 1px solid var(--rule);
  padding: 3rem 0 2.4rem;
}
.subject-hero .breadcrumb { font-family: var(--f-ui); font-size: .8rem; color: var(--ink-3); margin-bottom: 1rem; }
.subject-hero .breadcrumb a { color: var(--ink-3); text-decoration: none; }
.subject-hero .breadcrumb a:hover { color: var(--accent); }
.subject-hero h1 {
  font-family: var(--f-display); font-weight: 560;
  font-size: clamp(2.2rem, 5vw, 3.2rem); letter-spacing: -.02em; line-height: 1.05;
  margin: .4rem 0 .6rem;
}
.subject-hero h1 .accent-bar {
  display: inline-block; width: .6ch; height: .9em; background: var(--accent);
  border-radius: 2px; margin-right: .5rem; vertical-align: -.02em;
}
.subject-hero .sub { color: var(--ink-2); font-size: 1.2rem; max-width: 40rem; margin: 0; }
.subject-hero .subj-meta { display: flex; gap: 2rem; margin-top: 1.6rem; font-family: var(--f-ui); flex-wrap: wrap; }
.subject-hero .subj-meta .m b { font-family: var(--f-display); font-weight: 600; font-size: 1.3rem; display: block; }
.subject-hero .subj-meta .m span { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

.strand { position: relative; z-index: 1; padding: 2.6rem 0 0; }
.strand-head {
  display: flex; align-items: baseline; gap: .8rem; margin-bottom: 1.1rem;
  padding-bottom: .6rem; border-bottom: 2px solid var(--accent);
}
.strand-head h2 { font-family: var(--f-display); font-weight: 560; font-size: 1.5rem; letter-spacing: -.01em; margin: 0; }
.strand-head .count { font-family: var(--f-ui); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }

.topic-list { display: flex; flex-direction: column; }
.topic {
  display: grid; grid-template-columns: 2.6rem 1fr auto; align-items: center; gap: 1rem;
  padding: 1rem .4rem; border-bottom: 1px solid var(--rule);
  text-decoration: none; color: inherit; transition: background .14s;
}
.topic:hover { background: var(--paper-2); }
.topic .t-num { font-family: var(--f-mono); font-size: .85rem; color: var(--ink-3); }
.topic .t-main h3 { font-family: var(--f-display); font-weight: 560; font-size: 1.15rem; margin: 0 0 .15rem; }
.topic .t-main p { margin: 0; font-size: .92rem; color: var(--ink-3); }
.topic .t-status { font-family: var(--f-ui); font-size: .72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.topic.live .t-status { color: var(--accent); }
.topic.soon { cursor: default; }
.topic.soon .t-status { color: var(--ink-3); }
.topic.live:hover .t-main h3 { color: var(--accent); }
.topic .t-status .arrow { display: inline-block; margin-left: .3rem; transition: transform .14s; }
.topic.live:hover .t-status .arrow { transform: translateX(3px); }

/* Byline credit under note/subject hero */
.byline {
  font-family: var(--f-ui); font-size: .82rem; color: var(--ink-3);
  margin-top: 1.1rem; display: flex; align-items: center; gap: .5rem;
}
.byline a { color: var(--accent); text-decoration: none; font-weight: 600; }
.byline a:hover { text-decoration: underline; }
.byline .dot { color: var(--rule-2); }

/* Credit line in footer */
.site-footer .credit {
  font-family: var(--f-body); font-size: .9rem; color: var(--ink-2); margin: 0 0 .4rem;
}
.site-footer .credit a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }

/* ==========================================================================
   Dark mode
   ========================================================================== */
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="dark"] {
  --paper:   #1a1815;
  --paper-2: #232019;
  --ink:     #f1ece2;
  --ink-2:   #cbc4b6;
  --ink-3:   #948d7f;
  --rule:    #34302a;
  --rule-2:  #47423a;
  --c-smaths:  #8fb8dd;
  --c-emaths:  #7ba7d6;
  --c-physics: #b4a7e6;
  --c-chem:    #e0a184;
  --c-bio:     #82c79a;
  --c-english: #e28ba0;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -18px rgba(0,0,0,.7);
}
body, .site-header, .subject-card, .topic, .worked, .callout, .cyu summary,
.keyterm, .formula, .criteria-note, .criteria-strip, .note-tag, .nb-tool,
.nb-search-box, a, .strand-head { transition: background-color .25s ease, color .25s ease, border-color .25s ease; }
html[data-theme="dark"] .btn-primary { background: var(--ink); color: var(--paper); }
html[data-theme="dark"] .wordmark .nb-abbr { border-color: var(--ink); }
html[data-theme="dark"] img { opacity: .92; }

/* ==========================================================================
   Floating tools (search + theme)
   ========================================================================== */
.nb-tools {
  position: fixed; left: 1.1rem; bottom: 1.1rem; z-index: 40;
  display: flex; gap: .55rem;
}
.nb-tool {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--paper-2); color: var(--ink);
  border: 1px solid var(--rule-2); box-shadow: var(--shadow);
}
.nb-tool:hover { border-color: var(--ink-3); transform: translateY(-1px); }

/* ==========================================================================
   Search overlay
   ========================================================================== */
.nb-search {
  position: fixed; inset: 0; z-index: 50;
  background: color-mix(in srgb, var(--ink) 42%, transparent);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 1rem 1rem;
  opacity: 0; visibility: hidden; transition: opacity .16s ease;
}
.nb-search.open { opacity: 1; visibility: visible; }
.nb-search-box {
  width: min(620px, 100%); background: var(--paper-2);
  border: 1px solid var(--rule-2); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
.nb-search-head { display: flex; align-items: center; gap: .7rem; padding: .95rem 1.1rem; border-bottom: 1px solid var(--rule); color: var(--ink-3); }
.nb-search-head input {
  flex: 1; border: 0; background: transparent; outline: none;
  font-family: var(--f-body); font-size: 1.15rem; color: var(--ink);
}
.nb-search-head kbd {
  font-family: var(--f-ui); font-size: .68rem; color: var(--ink-3);
  border: 1px solid var(--rule-2); border-radius: 5px; padding: .15em .45em;
}
.nb-search-results { max-height: 52vh; overflow-y: auto; }
.nb-search-hint { font-family: var(--f-ui); font-size: .9rem; color: var(--ink-3); padding: 1.4rem 1.2rem; margin: 0; }
.nb-result {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.2rem; text-decoration: none; color: var(--ink);
  border-bottom: 1px solid var(--rule);
}
.nb-result:hover { background: color-mix(in srgb, var(--accent, var(--c-emaths)) 10%, var(--paper-2)); }
.nb-result-t { font-family: var(--f-display); font-weight: 560; font-size: 1.05rem; }
.nb-result-s { font-family: var(--f-ui); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }

/* ==========================================================================
   Mark as revised
   ========================================================================== */
.nb-revised-btn {
  margin-top: 1.1rem; font-family: var(--f-ui); font-size: .82rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: .4rem; cursor: pointer;
  padding: .5rem .9rem; border-radius: 100px;
  background: var(--paper-2); color: var(--ink-2);
  border: 1px solid var(--rule-2);
}
.nb-revised-btn:hover { border-color: var(--ink-3); }
.nb-revised-btn.done { background: color-mix(in srgb, var(--c-bio) 16%, var(--paper-2)); color: var(--c-bio); border-color: color-mix(in srgb, var(--c-bio) 40%, var(--rule)); }

/* ==========================================================================
   Prev / next
   ========================================================================== */
.nb-prevnext {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: stretch;
  margin: 1rem auto 3rem; padding-top: 2rem; border-top: 1px solid var(--rule);
}
.nb-pn {
  display: flex; flex-direction: column; gap: .2rem; text-decoration: none;
  padding: 1rem 1.2rem; border: 1px solid var(--rule); border-radius: 10px;
  color: var(--ink); background: var(--paper-2); transition: border-color .15s, transform .15s;
}
.nb-pn:hover { border-color: var(--accent, var(--c-emaths)); transform: translateY(-2px); }
.nb-pn-next { text-align: right; }
.nb-pn-empty { visibility: hidden; }
.nb-pn-dir { font-family: var(--f-ui); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.nb-pn-t { font-family: var(--f-display); font-weight: 560; font-size: 1.05rem; }
.nb-pn-up {
  align-self: center; font-family: var(--f-ui); font-size: .78rem; font-weight: 600;
  text-decoration: none; color: var(--ink-3); white-space: nowrap; padding: 0 .5rem; text-align: center;
}
.nb-pn-up:hover { color: var(--accent, var(--c-emaths)); }
@media (max-width: 640px) {
  .nb-prevnext { grid-template-columns: 1fr; }
  .nb-pn-next { text-align: left; }
  .nb-pn-up { order: -1; }
}

/* ==========================================================================
   Revised state on subject pages
   ========================================================================== */
.topic.nb-done .t-status { color: var(--c-bio) !important; }
.topic.nb-done::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--c-bio);
}
.topic { position: relative; }
.nb-progress-stat b { color: var(--c-bio); }

.nb-report-link { margin-left: 1rem; font-family: var(--f-ui); font-size: .8rem; color: var(--ink-3); text-decoration: underline; text-underline-offset: 2px; }
.nb-report-link:hover { color: var(--accent); }

.study-chat {
  position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 50;
  font-family: var(--f-ui); color: var(--ink);
}
.study-chat button, .study-chat textarea { font: inherit; }
.study-chat button { -webkit-tap-highlight-color: transparent; }

.study-chat__launcher {
  display: flex; align-items: center; gap: .75rem;
  min-height: 3.6rem; padding: .65rem 1rem .65rem .72rem;
  color: var(--paper-2); background: var(--ink); border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px; box-shadow: 0 12px 34px -12px rgba(28,26,23,.48);
  cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.study-chat__launcher:hover {
  transform: translateY(-2px); background: #2b2823;
  box-shadow: 0 16px 40px -12px rgba(28,26,23,.52);
}
.study-chat__launcher:active { transform: translateY(0) scale(.98); }
.study-chat__launcher:focus-visible, .study-chat__close:focus-visible,
.study-chat__send:focus-visible, .study-chat__suggestions button:focus-visible,
.study-chat textarea:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 3px; }
.study-chat__launcher svg {
  width: 2.25rem; height: 2.25rem; padding: .45rem;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  color: var(--ink); background: var(--paper-2); border-radius: 50%;
}
.study-chat__launcher span { display: grid; text-align: left; }
.study-chat__launcher strong { font-size: .84rem; font-weight: 650; letter-spacing: .01em; }
.study-chat__launcher small { margin-top: .08rem; color: #c9c2b7; font-size: .68rem; letter-spacing: .02em; }

.study-chat__panel {
  position: absolute; right: 0; bottom: 4.5rem;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(25rem, calc(100vw - 2rem)); height: min(39rem, calc(100vh - 7.5rem));
  overflow: hidden; background: var(--paper-2); border: 1px solid var(--rule-2);
  border-radius: 14px 14px 6px 14px;
  box-shadow: 0 24px 70px -24px rgba(28,26,23,.5), 0 2px 8px rgba(28,26,23,.08);
  transform-origin: bottom right; animation: study-chat-in .2s ease-out both;
}
.study-chat__panel[hidden] { display: none; }

.study-chat__header {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem;
  min-height: 4.5rem; padding: .75rem .85rem;
  background: var(--ink); color: var(--paper-2); border-bottom: 3px solid var(--accent);
}
.study-chat__mark {
  display: grid; place-items: center; width: 2.4rem; height: 2.4rem;
  border: 1px solid #716b62; border-radius: 50%;
  font-family: var(--f-display); font-size: .83rem; font-weight: 650; letter-spacing: -.02em;
}
.study-chat__header h2 { margin: 0; font-family: var(--f-display); font-size: 1.08rem; font-weight: 560; }
.study-chat__header p { display: flex; align-items: center; gap: .4rem; margin: .13rem 0 0; color: #c9c2b7; font-size: .68rem; }
.study-chat__header p span {
  width: .42rem; height: .42rem; background: #8eaa83; border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(142,170,131,.14);
}
.study-chat__close {
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem;
  padding: 0; color: #d8d1c6; background: transparent; border: 0; border-radius: 50%; cursor: pointer;
  transition: color .15s, background .15s, transform .15s;
}
.study-chat__close:hover { color: var(--paper-2); background: rgba(255,255,255,.1); transform: rotate(3deg); }
.study-chat__close svg { width: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

.study-chat__messages {
  overflow-y: auto; overscroll-behavior: contain; padding: 1.1rem .95rem 1.4rem;
  background-color: var(--paper);
  background-image: linear-gradient(rgba(211,204,189,.22) 1px, transparent 1px);
  background-size: 100% 1.75rem; scroll-behavior: smooth;
}
.study-chat__message { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 1rem; }
.study-chat__message--user { align-items: flex-end; }
.study-chat__label {
  margin: 0 .4rem .3rem; color: var(--ink-3); font-size: .61rem;
  font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
}
.study-chat__bubble {
  max-width: 88%; padding: .72rem .86rem;
  font-family: var(--f-body); font-size: .98rem; line-height: 1.43; white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--ink); background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 4px 12px 12px 12px; box-shadow: 0 6px 18px -16px rgba(28,26,23,.45);
}
.study-chat__message--user .study-chat__bubble {
  color: var(--paper-2); background: var(--accent); border-color: var(--accent);
  border-radius: 12px 4px 12px 12px;
}
.study-chat__bubble.is-error { color: #7b3427; background: #fbede8; border-color: #e8b9ab; }
.study-chat__bubble.is-thinking { display: flex; align-items: center; gap: .28rem; min-width: 3.4rem; min-height: 2.5rem; }
.study-chat__bubble.is-thinking i {
  width: .36rem; height: .36rem; background: var(--ink-3); border-radius: 50%;
  animation: study-chat-thinking 1s ease-in-out infinite;
}
.study-chat__bubble.is-thinking i:nth-child(2) { animation-delay: .12s; }
.study-chat__bubble.is-thinking i:nth-child(3) { animation-delay: .24s; }

.study-chat__suggestions { display: flex; flex-wrap: wrap; gap: .45rem; padding-top: .2rem; }
.study-chat__suggestions button {
  padding: .48rem .68rem; color: var(--ink-2); background: rgba(255,253,248,.78);
  border: 1px solid var(--rule-2); border-radius: 999px; font-size: .7rem; font-weight: 600;
  cursor: pointer; transition: color .15s, border-color .15s, background .15s, transform .15s;
}
.study-chat__suggestions button:hover {
  color: var(--accent); background: var(--paper-2); border-color: var(--accent); transform: translateY(-1px);
}

.study-chat__form { position: relative; padding: .75rem .75rem .55rem; background: var(--paper-2); border-top: 1px solid var(--rule); }
.study-chat__form textarea {
  display: block; width: 100%; min-height: 3rem; max-height: 7rem; resize: none;
  padding: .78rem 3.2rem .72rem .82rem; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule-2); border-radius: 8px; font-family: var(--f-body); font-size: 1rem; line-height: 1.35;
  transition: border-color .15s, box-shadow .15s;
}
.study-chat__form textarea::placeholder { color: var(--ink-3); }
.study-chat__form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); outline: 0; }
.study-chat__form textarea:disabled { opacity: .68; cursor: wait; }
.study-chat__send {
  position: absolute; right: 1.12rem; top: 1.08rem;
  display: grid; place-items: center; width: 2.35rem; height: 2.35rem; padding: 0;
  color: var(--paper-2); background: var(--accent); border: 0; border-radius: 6px; cursor: pointer;
  transition: transform .15s, filter .15s, opacity .15s;
}
.study-chat__send:hover { filter: brightness(1.08); transform: translateY(-1px); }
.study-chat__send:active { transform: translateY(0) scale(.96); }
.study-chat__send:disabled { opacity: .48; cursor: wait; transform: none; }
.study-chat__send svg { width: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.study-chat__form > p { margin: .42rem .1rem 0; color: var(--ink-3); font-size: .59rem; letter-spacing: .01em; }
.study-chat__form > p span { margin: 0 .22rem; color: var(--rule-2); }

@keyframes study-chat-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes study-chat-thinking {
  0%, 70%, 100% { opacity: .35; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-3px); }
}

@media (max-width: 640px) {
  .study-chat { right: .75rem; bottom: .75rem; }
  .study-chat__panel {
    position: fixed; right: .75rem; bottom: 4.85rem;
    width: calc(100vw - 1.5rem); height: min(42rem, calc(100dvh - 5.7rem));
    border-radius: 12px;
  }
  .study-chat__launcher { min-width: 3.6rem; padding-right: .72rem; }
  .study-chat.is-open .study-chat__launcher span { display: none; }
  .study-chat__bubble { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  .study-chat__panel, .study-chat__bubble.is-thinking i { animation: none; }
  .study-chat__messages { scroll-behavior: auto; }
}

@media print {
  .study-chat { display: none; }
