/* ============ ReviseWise — burnt orange & white ============ */
:root {
  --o: #CC5500; --o-deep: #A64400; --o-mid: #F2A65A; --o-soft: #FFE9D9;
  --cream: #FFF8F2; --white: #fff; --ink: #1F1410; --muted: #77625A; --line: #EAD9CC;
  --r: 22px; --r-sm: 14px;
  --sh: 4px 4px 0 var(--ink); --sh-lg: 7px 7px 0 var(--ink); --sh-sm: 3px 3px 0 var(--ink);
  --font-d: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-b: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
  --ease: cubic-bezier(.2, .9, .3, 1.2);
  --side: 256px;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font-b); color: var(--ink); line-height: 1.6; font-size: 16px;
  background: var(--cream) radial-gradient(rgba(204, 85, 0, .13) 1.500px, transparent 1.500px) 0 0 / 26px 26px;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--font-d); line-height: 1.08; margin: 0; letter-spacing: -.02em; text-wrap: balance; }
p { margin: 0 0 1em; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; color: inherit; }
.ico { flex: none; vertical-align: middle; }
:focus-visible { outline: 3px solid var(--o); outline-offset: 3px; border-radius: 8px; }
::selection { background: var(--o); color: #fff; }

/* ---------- layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--white); border-right: 2.500px solid var(--ink);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 6px; z-index: 20;
}
.main { margin-left: var(--side); padding: 34px clamp(18px, 4vw, 52px) 90px; max-width: calc(1240px + var(--side)); outline: none; }
.bottomnav { display: none; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-family: var(--font-d); font-weight: 800; font-size: 25px; letter-spacing: -.04em; }
.brand b { color: var(--o); font-weight: 800; }
.brand:hover .logo-mark { animation: wiggle .6s var(--ease); }
.logo-pupils { animation: look 6s infinite; }
@keyframes look { 0%, 40%, 100% { transform: translate(0, 0); } 45%, 60% { transform: translate(-2.500px, -1px); } 65%, 85% { transform: translate(2px, 1px); } }

.nav { display: flex; flex-direction: column; gap: 4px; position: relative; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 14px; font-weight: 700; font-size: 15.500px;
  border: 2.500px solid transparent; transition: transform .2s var(--ease), background .2s, border-color .2s; position: relative;
}
.nav a:hover { background: var(--o-soft); transform: translateX(4px); }
.nav a:hover .ico { animation: wiggle .5s var(--ease); }
.nav a.active { background: var(--o); color: #fff; border-color: var(--ink); box-shadow: var(--sh-sm); }
.nav .count { margin-left: auto; background: var(--ink); color: #fff; font-size: 12px; min-width: 24px; height: 24px; display: grid; place-items: center; border-radius: 99px; padding: 0 7px; }
.nav a.active .count { background: #fff; color: var(--ink); }
.count.bump { animation: bump .5s var(--ease); }
@keyframes bump { 40% { transform: scale(1.6); } }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.side-card { background: var(--o-soft); border: 2.500px solid var(--ink); border-radius: 18px; padding: 14px; font-size: 13.500px; position: relative; overflow: hidden; }
.side-card b { font-family: var(--font-d); font-size: 15px; display: block; margin-bottom: 4px; }
.side-card .meter { height: 10px; background: #fff; border: 2px solid var(--ink); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.side-card .meter i { display: block; height: 100%; background: var(--o); border-radius: 99px; transition: width .8s var(--ease); }
.userchip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 16px; width: 100%; text-align: left; transition: background .2s; }
.userchip:hover { background: var(--o-soft); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--o); color: #fff; display: grid; place-items: center; font-family: var(--font-d); font-weight: 800; font-size: 18px; border: 2.500px solid var(--ink); flex: none; }
.userchip span { display: block; font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userchip small { color: var(--muted); font-weight: 500; display: block; }

/* ---------- buttons, chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 12px 20px; border-radius: 99px; font-weight: 700; font-size: 15.500px; color: var(--ink);
  background: var(--white); border: 2.500px solid var(--ink); box-shadow: var(--sh-sm); transition: transform .15s var(--ease), box-shadow .15s, background .2s; white-space: nowrap; position: relative;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn-primary { background: var(--o); color: #fff; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 14px; }
.btn.is-on { background: var(--ink); color: #fff; }
.btn:hover .ico { animation: wiggle .5s var(--ease); }
.iconbtn { color: var(--ink); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 2.500px solid var(--ink); transition: transform .15s var(--ease), background .2s, color .2s; flex: none; }
.iconbtn:hover { transform: scale(1.12) rotate(-6deg); background: var(--o-soft); }
.iconbtn:active { transform: scale(.9); }
.iconbtn.is-on { background: var(--o); color: #fff; }
.iconbtn.danger:hover { background: var(--ink); color: #fff; }
.iconbtn:disabled { opacity: .3; pointer-events: none; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 99px; border: 2.500px solid var(--ink); background: #fff; font-weight: 700; font-size: 14px; transition: transform .15s var(--ease), background .2s, color .2s; }
button.chip:hover, a.chip:hover { transform: translateY(-2px) rotate(-1.500deg); background: var(--o-soft); }
.chip.active { background: var(--o); color: #fff; box-shadow: var(--sh-sm); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.500px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--o-soft); border: 2px solid var(--ink); }
.muted { color: var(--muted); }

/* ---------- entry + reveal animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(26px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-14deg); } 60% { transform: rotate(10deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(var(--rot, 0deg)); } 50% { transform: translateY(-16px) rotate(calc(var(--rot, 0deg) + 8deg)); } }
@keyframes popIn { 0% { opacity: 0; transform: scale(.5); } 70% { transform: scale(1.08); } 100% { opacity: 1; transform: none; } }
.enter .rise { animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
[data-reveal] { opacity: 0; transform: translateY(30px); transition: opacity .6s ease, transform .7s var(--ease); transition-delay: calc(var(--i, 0) * 70ms); }
[data-reveal].in { opacity: 1; transform: none; }

/* ---------- hero ---------- */
.hero {
  position: relative; background: var(--o); color: #fff; border: 2.500px solid var(--ink); border-radius: 34px; box-shadow: var(--sh-lg);
  padding: clamp(28px, 5vw, 56px); display: grid; grid-template-columns: 1.500fr 1fr; gap: 20px; align-items: center; overflow: hidden; isolation: isolate;
}
.hero::before { content: ''; position: absolute; inset: 0; z-index: -1; background: radial-gradient(rgba(255, 255, 255, .17) 2px, transparent 2px) 0 0 / 22px 22px; animation: drift 30s linear infinite; }
@keyframes drift { to { background-position: 220px 220px; } }
.hero .blob { position: absolute; z-index: -1; width: 420px; height: 420px; right: -110px; top: -140px; background: var(--o-deep); border-radius: 42% 58% 63% 37% / 45% 40% 60% 55%; animation: morph 12s ease-in-out infinite; opacity: .75; }
@keyframes morph { 50% { border-radius: 60% 40% 35% 65% / 55% 62% 38% 45%; transform: rotate(40deg) scale(1.08); } }
.hero h1 { font-size: clamp(42px, 6.500vw, 84px); font-weight: 800; letter-spacing: -.045em; display: flex; flex-wrap: wrap; align-items: center; gap: 0 .22em; }
.hero h1 .w { display: inline-block; animation: wordUp .7s var(--ease) both; animation-delay: calc(var(--i) * 90ms + 100ms); }
@keyframes wordUp { from { opacity: 0; transform: translateY(60%) rotate(6deg); } to { opacity: 1; transform: none; } }
.hero-name { background: #fff; color: var(--o); padding: 0 .22em .06em; border-radius: .28em; border: 2.500px solid var(--ink); box-shadow: var(--sh); transform: rotate(-2deg); display: inline-block; max-width: 100%; overflow-wrap: anywhere; }
.wave { display: inline-grid; place-items: center; width: 1.050em; height: 1.050em; background: #fff; color: var(--ink); border-radius: 50%; border: 2.500px solid var(--ink); transform-origin: 70% 80%; animation: wave 2.600s ease-in-out infinite; }
.wave .ico { width: .58em; height: .58em; }
@keyframes wave { 0%, 55%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(18deg); } 20%, 40% { transform: rotate(-10deg); } }
.hero p { font-size: clamp(16px, 1.700vw, 20px); max-width: 30em; margin: 18px 0 26px; opacity: .96; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.sticker { display: inline-flex; align-items: center; gap: 8px; background: var(--ink); color: #fff; padding: 7px 14px; border-radius: 99px; font-weight: 700; font-size: 13.500px; margin-bottom: 20px; transform: rotate(-2deg); }
.hero-art { position: relative; display: grid; place-items: center; min-height: 240px; }
.owl { width: min(250px, 100%); filter: drop-shadow(6px 6px 0 var(--ink)); animation: floaty 5s ease-in-out infinite; }
.owl-pupils { transition: transform .12s ease-out; }
.owl-lids { transform-origin: 110px 62px; transform: scaleY(0); animation: blink 5s infinite; }
@keyframes blink { 0%, 46%, 50%, 100% { transform: scaleY(0); } 48% { transform: scaleY(1); } }
.badge-spin { position: absolute; right: 0; bottom: -6px; width: 112px; height: 112px; animation: spin 14s linear infinite; }
.badge-spin text { font-family: var(--font-d); font-weight: 800; font-size: 13.500px; letter-spacing: .14em; fill: #fff; }
.shape { position: absolute; animation: floaty 6s ease-in-out infinite; z-index: -1; }
.shape.s1 { left: 46%; top: 12%; --rot: 12deg; animation-duration: 7s; }
.shape.s2 { left: 56%; bottom: 10%; --rot: -20deg; animation-duration: 5s; }
.shape.s3 { left: 3%; bottom: 6%; --rot: 30deg; animation-duration: 8s; opacity: .5; }

/* ---------- marquee ---------- */
.marquee { margin: 26px -6px; border: 2.500px solid var(--ink); background: #fff; border-radius: 99px; overflow: hidden; transform: rotate(-.6deg); box-shadow: var(--sh-sm); }
.marquee-track { display: flex; width: max-content; animation: marquee 32s linear infinite; padding: 10px 0; }
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee span { display: inline-flex; align-items: center; gap: 10px; padding: 0 18px; font-family: var(--font-d); font-weight: 700; font-size: 17px; white-space: nowrap; }
.marquee .ico { color: var(--o); }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- sections, cards ---------- */
.section { margin-top: 46px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(26px, 3vw, 36px); font-weight: 800; }
.section-head h2 em { font-style: normal; color: var(--o); position: relative; white-space: nowrap; }
.section-head h2 em::after { content: ''; position: absolute; left: 0; right: 0; bottom: -4px; height: 8px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 8' preserveAspectRatio='none'%3E%3Cpath d='M0 5q5-6 10 0t10 0 10 0 10 0' fill='none' stroke='%23CC5500' stroke-width='2.500'/%3E%3C/svg%3E") repeat-x 0 0 / 20px 8px; }
.link { font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.link .ico { transition: transform .2s var(--ease); }
.link:hover .ico { transform: translateX(5px); }

.card { background: #fff; border: 2.500px solid var(--ink); border-radius: var(--r); box-shadow: var(--sh); transition: transform .22s var(--ease), box-shadow .22s; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-top: 4px; }
.stat { padding: 18px 20px; display: flex; align-items: center; gap: 16px; }
.stat:hover { transform: translate(-3px, -3px) rotate(-.6deg); box-shadow: var(--sh-lg); }
.stat-ico { width: 54px; height: 54px; border-radius: 16px; background: var(--o-soft); border: 2.500px solid var(--ink); display: grid; place-items: center; color: var(--o); flex: none; }
.stat:nth-child(2) .stat-ico { background: var(--o); color: #fff; transform: rotate(6deg); }
.stat:nth-child(3) .stat-ico { background: var(--ink); color: #fff; transform: rotate(-6deg); }
.stat b { font-family: var(--font-d); font-size: 34px; line-height: 1; display: block; letter-spacing: -.03em; }
.stat div > span { color: var(--muted); font-weight: 500; font-size: 14.500px; }

/* subject cards */
.subject { padding: 22px; position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 6px; min-height: 190px; color: var(--on); background: var(--c); transform-style: preserve-3d; transform: perspective(700px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }
.subject:hover { box-shadow: var(--sh-lg); }
.subject h3 { font-size: 28px; font-weight: 800; margin-top: auto; }
.subject p { margin: 0; font-size: 14.500px; opacity: .92; }
.subject .big { position: absolute; right: -18px; top: -18px; opacity: .22; transition: transform .5s var(--ease); }
.subject:hover .big { transform: rotate(-16deg) scale(1.15); }
.subject .sub-ico { width: 52px; height: 52px; border-radius: 16px; background: #fff; color: var(--ink); border: 2.500px solid var(--ink); display: grid; place-items: center; box-shadow: var(--sh-sm); transition: transform .3s var(--ease); }
.subject:hover .sub-ico { transform: rotate(-10deg) scale(1.1); }
.subject .go { position: absolute; right: 18px; bottom: 18px; width: 38px; height: 38px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; transition: transform .3s var(--ease); }
.subject:hover .go { transform: translateX(4px) scale(1.12); }

/* patterns */
.pat { position: absolute; inset: 0; opacity: .2; pointer-events: none; }
.pat-dots { background: radial-gradient(currentColor 2.500px, transparent 2.500px) 0 0 / 18px 18px; }
.pat-stripes { background: repeating-linear-gradient(45deg, currentColor 0 3px, transparent 3px 16px); }
.pat-grid { background: linear-gradient(currentColor 2px, transparent 2px) 0 0 / 22px 22px, linear-gradient(90deg, currentColor 2px, transparent 2px) 0 0 / 22px 22px; }
.pat-rings { background: radial-gradient(circle, transparent 7px, currentColor 7px 9.500px, transparent 9.500px) 0 0 / 30px 30px; }

/* note cards */
.note-card { display: flex; flex-direction: column; overflow: hidden; position: relative; }
.note-card:hover { transform: translate(-4px, -4px) rotate(-.5deg); box-shadow: var(--sh-lg); }
.note-card .band { height: 92px; background: var(--c); color: var(--on); position: relative; border-bottom: 2.500px solid var(--ink); display: flex; align-items: end; padding: 12px 16px; overflow: hidden; }
.note-card .band .big { position: absolute; right: 62px; top: 10px; opacity: .9; transition: transform .45s var(--ease); }
.note-card:hover .band .big { transform: rotate(-14deg) scale(1.2); }
.note-card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.note-card h3 { font-size: 21px; font-weight: 700; }
.note-card h3 a::after { content: ''; position: absolute; inset: 0; }
.note-card p { font-size: 14.500px; color: var(--muted); margin: 0; flex: 1; }
.note-card .meta { display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 6px; }
.note-card .meta span { display: inline-flex; align-items: center; gap: 5px; }
.note-card .meta .done { color: var(--o); }
.note-card .save { position: absolute; right: 12px; top: 12px; z-index: 2; }
.note-card .band .tag { position: relative; background: #fff; color: var(--ink); }

/* CTA band */
.cta { margin-top: 50px; padding: clamp(24px, 4vw, 40px); background: var(--ink); color: #fff; border-radius: 30px; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; position: relative; overflow: hidden; }
.cta h2 { font-size: clamp(26px, 3.400vw, 40px); font-weight: 800; max-width: 14em; }
.cta h2 em { font-style: normal; color: var(--o-mid); }
.cta p { margin: 10px 0 0; opacity: .8; max-width: 34em; }
.cta .star { position: absolute; right: 30%; top: -30px; color: var(--o); opacity: .5; animation: spin 20s linear infinite; }
.cta .btn { border-color: #fff; box-shadow: 3px 3px 0 var(--o); }

/* ---------- page header, library ---------- */
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: clamp(38px, 5.500vw, 64px); font-weight: 800; letter-spacing: -.04em; }
.page-head h1 em { font-style: normal; color: var(--o); }
.page-head p { margin: 10px 0 0; color: var(--muted); max-width: 38em; font-size: 17px; }
.searchbar { display: flex; align-items: center; gap: 12px; background: #fff; border: 2.500px solid var(--ink); border-radius: 99px; padding: 6px 8px 6px 20px; box-shadow: var(--sh); transition: transform .2s var(--ease), box-shadow .2s; }
.searchbar:focus-within { transform: translate(-2px, -2px); box-shadow: var(--sh-lg); }
.searchbar input { flex: 1; border: 0; outline: 0; background: none; font-size: 17px; padding: 10px 0; min-width: 0; }
.searchbar .ico { color: var(--o); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 26px; }
.empty { text-align: center; padding: 50px 20px; border: 2.500px dashed var(--ink); border-radius: var(--r); background: rgba(255, 255, 255, .7); }
.empty .owl { width: 130px; margin-bottom: 8px; }
.empty h3 { font-size: 26px; margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 30em; margin: 0 auto 18px; }

/* ---------- note page ---------- */
.crumbs { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14.500px; margin-bottom: 18px; flex-wrap: wrap; }
.crumbs a:hover { color: var(--o); }
.crumbs .ico { color: var(--muted); }
.note-hero { background: var(--c); color: var(--on); border: 2.500px solid var(--ink); border-radius: 30px; box-shadow: var(--sh-lg); padding: clamp(24px, 4vw, 44px); position: relative; overflow: hidden; }
.note-hero > * { position: relative; }
.note-hero h1 { font-size: clamp(36px, 5.500vw, 66px); font-weight: 800; letter-spacing: -.04em; margin: 14px 0 12px; }
.note-hero p { font-size: 18px; max-width: 34em; margin: 0; opacity: .95; }
.note-hero .big { position: absolute; right: -30px; bottom: -40px; opacity: .2; animation: floaty 7s ease-in-out infinite; --rot: -12deg; }
.note-hero .tags { display: flex; gap: 8px; flex-wrap: wrap; }
.note-hero .tag { background: #fff; color: var(--ink); }
.note-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 6px; position: sticky; top: 12px; z-index: 10; padding: 10px; background: rgba(255, 255, 255, .86); backdrop-filter: blur(10px); border: 2.500px solid var(--ink); border-radius: 99px; width: fit-content; max-width: 100%; box-shadow: var(--sh-sm); }
.note-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 30px; align-items: start; margin-top: 20px; }
.toc { position: sticky; top: 96px; padding: 18px; }
.toc b { font-family: var(--font-d); font-size: 17px; display: block; margin-bottom: 10px; }
.toc a { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 10px; font-size: 14.500px; font-weight: 500; transition: background .2s, transform .2s var(--ease); }
.toc a:hover { background: var(--o-soft); transform: translateX(4px); }
.toc a i { font-style: normal; font-family: var(--font-d); font-weight: 800; color: var(--o); width: 18px; }

.note-body { min-width: 0; }
.note-sec { background: #fff; border: 2.500px solid var(--ink); border-radius: var(--r); padding: clamp(18px, 3vw, 30px); margin-bottom: 22px; box-shadow: var(--sh); scroll-margin-top: 96px; }
.note-sec > h2 { font-size: clamp(23px, 2.600vw, 30px); font-weight: 800; display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.note-sec > h2 .num { width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--o); color: #fff; display: grid; place-items: center; font-size: 19px; border: 2.500px solid var(--ink); transform: rotate(-6deg); }
.note-sec p:last-child { margin-bottom: 0; }
.note-body b { font-weight: 700; }
.note-sec p b, .ticks b { background: linear-gradient(transparent 62%, var(--o-soft) 62%); }

ul.ticks { list-style: none; padding: 0; margin: 0 0 1em; display: grid; gap: 9px; }
ul.ticks li { padding-left: 34px; position: relative; }
ul.ticks li::before { content: ''; position: absolute; left: 0; top: 2px; width: 22px; height: 22px; border-radius: 7px; background: var(--o) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.500' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 14px no-repeat; border: 2px solid var(--ink); }

.formula { background: var(--o-soft); border: 2.500px solid var(--ink); border-radius: 18px; padding: 18px 20px; margin: 0 0 1em; text-align: center; position: relative; overflow: hidden; }
.formula::before { content: ''; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 40%, rgba(255, 255, 255, .8) 50%, transparent 60%); transform: translateX(-100%); animation: shine 4.500s ease-in-out infinite; }
@keyframes shine { 0%, 60% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.formula-main { display: block; font-family: var(--font-d); font-weight: 800; font-size: clamp(20px, 2.600vw, 28px); letter-spacing: -.01em; position: relative; }
.formula-cap { display: block; font-size: 14px; color: var(--muted); margin-top: 5px; position: relative; }

.fig { margin: 0 0 1.200em; border: 2.500px solid var(--ink); border-radius: 18px; overflow: hidden; background: var(--cream); }
.fig .dg { display: block; width: 100%; height: auto; padding: 12px; }
.fig figcaption { background: var(--ink); color: #fff; font-size: 13.500px; padding: 9px 16px; font-weight: 500; }

.table-wrap { overflow-x: auto; border: 2.500px solid var(--ink); border-radius: 16px; margin: 0 0 1em; }
table { border-collapse: collapse; width: 100%; font-size: 15px; background: #fff; }
th { background: var(--o); color: #fff; font-family: var(--font-d); font-weight: 700; text-align: left; padding: 11px 14px; }
td { padding: 10px 14px; border-top: 2px solid var(--line); vertical-align: top; }
td:first-child { font-weight: 700; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--o-soft); }

ol.legend { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; counter-reset: none; }
ol.legend li { position: relative; padding: 10px 12px 10px 48px; background: var(--cream); border: 2px solid var(--ink); border-radius: 14px; font-size: 14.500px; transition: transform .2s var(--ease), background .2s; }
ol.legend li:hover { transform: translateX(4px); background: var(--o-soft); }
ol.legend li::before { content: attr(value); position: absolute; left: 10px; top: 9px; width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 800; font-family: var(--font-d); font-size: 14px; }

.worked { border: 2.500px dashed var(--ink); border-radius: 18px; padding: 18px 20px; margin: 0 0 1em; background: #fff; }
.worked-title { display: inline-block; background: var(--ink); color: #fff; font-family: var(--font-d); font-weight: 700; font-size: 13px; padding: 4px 12px; border-radius: 99px; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .06em; }
.worked-q { font-weight: 700; font-size: 17px; }
.worked ol { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 8px; }
.worked ol li { counter-increment: s; padding-left: 38px; position: relative; }
.worked ol li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--o-soft); border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 13px; font-family: var(--font-d); }

.tipbox { display: flex; gap: 16px; background: var(--o); color: #fff; border: 2.500px solid var(--ink); border-radius: var(--r); padding: 20px 22px; margin-bottom: 22px; box-shadow: var(--sh); position: relative; }
.tipbox .tip-ico { width: 50px; height: 50px; border-radius: 50%; background: #fff; color: var(--o); display: grid; place-items: center; border: 2.500px solid var(--ink); flex: none; animation: glow 2.400s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 9px rgba(255, 255, 255, .28); transform: rotate(-8deg); } }
.tipbox b.h { font-family: var(--font-d); font-size: 19px; display: block; margin-bottom: 2px; }
.tipbox p { margin: 0; }

.terms { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.term { border: 2px solid var(--ink); border-radius: 16px; padding: 14px; background: var(--cream); transition: transform .25s var(--ease), background .2s; }
.term:hover { transform: rotate(-1.500deg) translateY(-3px); background: var(--o-soft); }
.term b { font-family: var(--font-d); font-size: 17px; display: block; color: var(--o-deep); margin-bottom: 3px; }
.term span { font-size: 14.500px; }

.quiz { display: grid; gap: 12px; }
.q { border: 2.500px solid var(--ink); border-radius: 16px; overflow: hidden; background: #fff; transition: transform .2s var(--ease); }
.q:hover { transform: translateX(3px); }
.q button { width: 100%; text-align: left; padding: 14px 16px; display: flex; gap: 12px; align-items: center; font-weight: 700; }
.q button .qn { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; flex: none; font-family: var(--font-d); font-size: 14px; }
.q button .reveal { margin-left: auto; font-size: 13px; color: var(--o); display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.q button .reveal .ico { transition: transform .3s var(--ease); }
.q.open button .reveal .ico { transform: rotate(180deg); }
.q .a { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .35s ease; background: var(--o-soft); }
.q.open .a { grid-template-rows: 1fr; border-top: 2.500px solid var(--ink); }
.q .a > div { overflow: hidden; }
.q .a p { margin: 0; padding: 13px 16px 13px 58px; }

.done-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 22px; margin-bottom: 22px; }
.done-row h3 { font-size: 22px; }
.next-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.next { padding: 18px; display: flex; flex-direction: column; gap: 4px; }
.next:hover { transform: translate(-3px, -3px); box-shadow: var(--sh-lg); background: var(--o-soft); }
.next small { color: var(--muted); font-weight: 700; display: flex; gap: 6px; align-items: center; }
.next b { font-family: var(--font-d); font-size: 19px; }
.next.r { text-align: right; align-items: flex-end; }

.progress-bar { position: fixed; left: 0; top: 0; height: 5px; width: 100%; background: var(--o); transform-origin: left; transform: scaleX(0); z-index: 60; }

/* ---------- diagrams ---------- */
.dg text { font-family: var(--font-b); fill: var(--ink); font-size: 14px; }
.dg .th { font-family: var(--font-d); font-weight: 800; font-size: 18px; }
.dg .tb { font-weight: 700; font-size: 14.500px; }
.dg .ts { font-size: 13.500px; }
.dg .tt { font-size: 11.500px; font-weight: 700; }
.dg .tx { font-family: var(--font-d); font-weight: 800; font-size: 28px; }
.dg .pin circle { fill: #fff; stroke: var(--ink); stroke-width: 2.500; }
.dg .pin text { font-family: var(--font-d); font-weight: 800; font-size: 13px; }
.dg .pin { transform-box: fill-box; transform-origin: center; animation: pinPulse 2.600s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes pinPulse { 0%, 80%, 100% { transform: scale(1); } 88% { transform: scale(1.35); } }
.dg .jig, .dg .vib, .dg .flow, .dg .fly, .dg .bob, .dg .bob-s, .dg .pop, .dg .pulse, .dg .wobble { transform-box: fill-box; transform-origin: center; }
.dg .jig { animation: jig 2.200s ease-in-out infinite alternate; animation-delay: calc(var(--d, 0s) * -1); }
@keyframes jig { 0% { transform: translate(0, 0); } 33% { transform: translate(5px, -4px); } 66% { transform: translate(-4px, 5px); } 100% { transform: translate(3px, 3px); } }
.dg .vib { animation: vib .22s linear infinite alternate; animation-delay: calc(var(--d, 0s) * -1); }
@keyframes vib { from { transform: translate(-1.200px, .8px); } to { transform: translate(1.200px, -.8px); } }
.dg .flow { animation: flow 3s ease-in-out infinite alternate; animation-delay: calc(var(--d, 0s) * -1); }
@keyframes flow { 0% { transform: translate(-4px, 0); } 50% { transform: translate(4px, -4px); } 100% { transform: translate(-2px, 3px); } }
.dg .fly { animation: fly 2.400s ease-in-out infinite alternate; animation-delay: calc(var(--d, 0s) * -1); }
@keyframes fly { 0% { transform: translate(-12px, 10px); } 35% { transform: translate(14px, -8px); } 70% { transform: translate(-8px, -12px); } 100% { transform: translate(12px, 12px); } }
.dg .bob { animation: bob 1.800s ease-in-out infinite alternate; }
@keyframes bob { from { transform: translateY(-5px); } to { transform: translateY(6px); } }
.dg .bob-s { animation: bobS .5s ease-in-out infinite alternate; }
@keyframes bobS { from { transform: translateY(0); } to { transform: translateY(1.500px); } }
.dg .road { animation: road 1s linear infinite; }
@keyframes road { to { stroke-dashoffset: 48; } }
.dg .wobble { animation: wobble 5s ease-in-out infinite; }
@keyframes wobble { 50% { transform: scale(1.025, .975) rotate(1.500deg); } }
.dg .pulse { animation: pulse 1.600s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.5); } }
.dg .draw { stroke-dasharray: 1; stroke-dashoffset: 0; }
.fig.in .draw { animation: draw 1.800s ease-out both; }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.fig.in .pop { animation: popIn .5s var(--ease) both; animation-delay: var(--d, 0s); }

/* ---------- notebooks ---------- */
.nb-grid { display: grid; gap: 26px 22px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.nb { position: relative; aspect-ratio: 3 / 3.700; background: var(--c, var(--o)); color: var(--on, #fff); border: 2.500px solid var(--ink); border-radius: 10px 22px 22px 10px; box-shadow: var(--sh-lg); padding: 22px 20px 20px 38px; display: flex; flex-direction: column; overflow: hidden; transition: transform .3s var(--ease), box-shadow .3s; transform-origin: left center; }
.nb::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 22px; background: rgba(31, 20, 16, .28); border-right: 2.500px solid var(--ink); }
.nb::after { content: ''; position: absolute; left: 7px; top: 14px; bottom: 14px; width: 8px; background: radial-gradient(circle, #fff 3px, transparent 3.500px) 0 0 / 8px 22px; }
.nb:hover { transform: perspective(900px) rotateY(-12deg) translateY(-6px); box-shadow: 14px 10px 0 var(--ink); }
.nb h3 { font-size: 25px; font-weight: 800; overflow-wrap: anywhere; position: relative; }
.nb .nb-label { background: #fff; color: var(--ink); border: 2.500px solid var(--ink); border-radius: 12px; padding: 12px; margin-top: 12px; transform: rotate(-2deg); position: relative; }
.nb .nb-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 14px; position: relative; }
.nb-new { aspect-ratio: 3 / 3.700; border: 2.500px dashed var(--ink); border-radius: 10px 22px 22px 10px; display: grid; place-items: center; text-align: center; padding: 20px; font-weight: 700; background: rgba(255, 255, 255, .6); transition: background .2s, transform .3s var(--ease); width: 100%; }
.nb-new:hover { background: var(--o-soft); transform: scale(1.03) rotate(1deg); }
.nb-new .plus { width: 60px; height: 60px; border-radius: 50%; background: var(--o); color: #fff; display: grid; place-items: center; margin: 0 auto 12px; border: 2.500px solid var(--ink); box-shadow: var(--sh-sm); transition: transform .4s var(--ease); }
.nb-new:hover .plus { transform: rotate(180deg) scale(1.1); }

.nb-hero { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; padding: clamp(20px, 3.500vw, 34px); background: var(--c); color: var(--on); border: 2.500px solid var(--ink); border-radius: 30px; box-shadow: var(--sh-lg); position: relative; overflow: hidden; }
.nb-hero > * { position: relative; }
.nb-hero h1 { font-size: clamp(34px, 5vw, 58px); font-weight: 800; letter-spacing: -.04em; overflow-wrap: anywhere; }
.nb-hero .acts { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.nb-list { display: grid; gap: 12px; margin-top: 26px; }
.nb-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; }
.nb-item:hover { transform: translate(-2px, -2px); box-shadow: var(--sh-lg); }
.nb-item .idx { width: 40px; height: 40px; border-radius: 12px; background: var(--c); color: var(--on); border: 2.500px solid var(--ink); display: grid; place-items: center; font-family: var(--font-d); font-weight: 800; flex: none; }
.nb-item .info { flex: 1; min-width: 0; }
.nb-item .info a { font-family: var(--font-d); font-weight: 700; font-size: 18px; display: block; }
.nb-item .info a:hover { color: var(--o); }
.nb-item .info small { color: var(--muted); font-weight: 500; }
.nb-item .ctrl { display: flex; gap: 6px; }
.nb-item .ctrl .iconbtn { width: 36px; height: 36px; }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(31, 20, 16, .55); backdrop-filter: blur(5px); z-index: 80; display: grid; place-items: center; padding: 18px; animation: fade .25s both; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border: 2.500px solid var(--ink); border-radius: 28px; box-shadow: 9px 9px 0 var(--ink); width: min(520px, 100%); max-height: min(88vh, 720px); overflow: auto; padding: 26px; animation: modalIn .45s var(--ease) both; position: relative; }
@keyframes modalIn { from { opacity: 0; transform: translateY(40px) scale(.9) rotate(-2deg); } }
.modal h2 { font-size: 30px; font-weight: 800; margin-bottom: 6px; padding-right: 44px; }
.modal > p { color: var(--muted); }
.modal .close { position: absolute; right: 18px; top: 18px; }
.field { display: block; margin: 16px 0; }
.field span { font-weight: 700; font-size: 14px; display: block; margin-bottom: 6px; }
.field input[type=text] { width: 100%; padding: 14px 16px; border: 2.500px solid var(--ink); border-radius: 16px; font-size: 18px; font-weight: 500; outline: 0; background: var(--cream); transition: box-shadow .2s, transform .2s var(--ease), background .2s; }
.field input[type=text]:focus { box-shadow: var(--sh); transform: translate(-2px, -2px); background: #fff; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatches label { cursor: pointer; }
.swatches input { position: absolute; opacity: 0; }
.swatches i { display: block; width: 42px; height: 42px; border-radius: 50%; border: 2.500px solid var(--ink); transition: transform .2s var(--ease), box-shadow .2s; }
.swatches input:checked + i { transform: scale(1.15); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink); }
.swatches input:focus-visible + i { outline: 3px solid var(--o); outline-offset: 6px; }
.pick { display: grid; gap: 8px; margin: 16px 0; }
.pick-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 11px 14px; border: 2.500px solid var(--ink); border-radius: 16px; background: #fff; font-weight: 700; transition: transform .15s var(--ease), background .2s; }
.pick-row:hover { transform: translateX(4px); background: var(--o-soft); }
.pick-row .dot { width: 26px; height: 26px; border-radius: 8px; border: 2.500px solid var(--ink); flex: none; display: grid; place-items: center; color: #fff; }
.pick-row .box { margin-left: auto; width: 28px; height: 28px; border-radius: 9px; border: 2.500px solid var(--ink); display: grid; place-items: center; color: transparent; transition: background .2s, color .2s, transform .3s var(--ease); flex: none; }
.pick-row.on .box { background: var(--o); color: #fff; transform: rotate(-8deg) scale(1.1); }
.pick-row small { display: block; font-weight: 500; color: var(--muted); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* onboarding */
.welcome { position: fixed; inset: 0; z-index: 90; background: var(--o); display: grid; place-items: center; padding: 20px; overflow: auto; }
.welcome::before { content: ''; position: absolute; inset: 0; background: radial-gradient(rgba(255, 255, 255, .17) 2px, transparent 2px) 0 0 / 22px 22px; animation: drift 30s linear infinite; }
.welcome.out { animation: wipe .7s cubic-bezier(.7, 0, .3, 1) forwards; }
@keyframes wipe { to { clip-path: circle(0% at 50% 40%); } }
.welcome { clip-path: circle(150% at 50% 40%); }
.welcome-card { position: relative; background: #fff; border: 2.500px solid var(--ink); border-radius: 34px; box-shadow: 10px 10px 0 var(--ink); padding: clamp(24px, 5vw, 44px); width: min(500px, 100%); text-align: center; animation: modalIn .7s var(--ease) both; }
.welcome-card .owl { width: 130px; margin-top: -10px; }
.welcome-card h1 { font-size: clamp(34px, 6vw, 48px); font-weight: 800; letter-spacing: -.04em; margin: 6px 0 8px; }
.welcome-card h1 b { color: var(--o); }
.welcome-card p { color: var(--muted); margin-bottom: 4px; }
.welcome-card .field { text-align: left; }
.welcome-card .btn { width: 100%; padding: 15px; font-size: 17px; }
.welcome-card small { display: block; margin-top: 14px; color: var(--muted); font-size: 12.500px; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }

/* toasts + confetti */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: grid; gap: 10px; justify-items: end; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px 12px 12px; border-radius: 99px; font-weight: 700; display: flex; align-items: center; gap: 10px; box-shadow: 4px 4px 0 var(--o); animation: toastIn .5s var(--ease) both; font-size: 15px; }
.toast i { width: 30px; height: 30px; border-radius: 50%; background: var(--o); display: grid; place-items: center; font-style: normal; }
.toast.out { animation: toastOut .35s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(30px) scale(.8); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }
.confetti { position: fixed; z-index: 120; width: 10px; height: 10px; pointer-events: none; border: 1.500px solid var(--ink); }

#print-root { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .note-layout { grid-template-columns: 1fr; }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px 16px 110px; }
  .bottomnav { display: flex; position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 40; background: #fff; border: 2.500px solid var(--ink); border-radius: 99px; box-shadow: var(--sh); padding: 6px; justify-content: space-between; }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 99px; font-size: 11.500px; font-weight: 700; transition: background .2s, color .2s, transform .2s var(--ease); }
  .bottomnav a.active { background: var(--o); color: #fff; transform: translateY(-4px); box-shadow: var(--sh-sm); border: 2px solid var(--ink); }
  .hero { grid-template-columns: 1fr; }
  .hero-art { min-height: 0; position: absolute; right: -30px; bottom: -40px; opacity: .28; pointer-events: none; z-index: -1; }
  .badge-spin, .shape { display: none; }
  .stats { grid-template-columns: 1fr; }
  .next-row { grid-template-columns: 1fr; }
  .toasts { bottom: 96px; right: 12px; left: 12px; justify-items: center; }
  .note-actions { border-radius: 24px; top: 8px; }
  .nb-item { flex-wrap: wrap; }
  .nb-item .ctrl { margin-left: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; scroll-behavior: auto !important; }
  [data-reveal] { opacity: 1; transform: none; }
}

/* ---------- print ---------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 11.500pt; }
  #app, #modal-root, .toasts, .progress-bar, .welcome { display: none !important; }
  #print-root { display: block; }
  * { animation: none !important; transition: none !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-cover { height: 240mm; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 20mm 14mm; background: var(--c, var(--o)); color: var(--on, #fff); border: 2.500px solid var(--ink); border-radius: 30px; break-after: page; }
  .print-cover h1 { font-size: 54pt; font-weight: 800; overflow-wrap: anywhere; }
  .print-cover p { font-size: 15pt; margin-top: 10mm; }
  .print-cover ol { font-size: 13pt; margin: 8mm 0 0; padding-left: 1.200em; }
  .print-note { break-before: page; }
  .print-note:first-child, .print-cover + .print-note { break-before: auto; }
  .print-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 2.500px solid var(--ink); padding-bottom: 8px; margin-bottom: 14px; font-weight: 700; font-size: 10pt; }
  .print-head .brand { padding: 0; font-size: 16pt; }
  .print-note > h1 { font-size: 30pt; font-weight: 800; margin-bottom: 4px; }
  .print-note > .lead { color: var(--muted); margin-bottom: 14px; }
  .note-sec, .tipbox { box-shadow: none; margin-bottom: 12px; padding: 14px 16px; }
  .note-sec > h2 { font-size: 16pt; margin-bottom: 10px; break-after: avoid; }
  .fig, .worked, .formula, .table-wrap, .term, .q, .tipbox, ol.legend li { break-inside: avoid; }
  .q .a { grid-template-rows: 1fr; border-top: 2.500px solid var(--ink); }
  .q button .reveal { display: none; }
  .formula::before { display: none; }
}

/* ---------- late tweaks ---------- */
.subject > :not(.pat):not(.big):not(.go) { position: relative; }
@media (max-width: 600px) {
  .fig { overflow-x: auto; }
  .fig .dg { min-width: 540px; }
  .fig figcaption { position: sticky; left: 0; }
}
@media print { .fig .dg { min-width: 0; } }
