/* Ghost Tutor: a notebook on a desk, late at night. */
:root {
  --desk: #14161f;
  --desk-2: #1b1e2a;
  --lamp: rgba(255, 190, 110, 0.42);
  --lamp-soft: rgba(255, 160, 80, 0.14);
  --grain-a: rgba(255, 255, 255, 0.018);
  --grain-b: rgba(0, 0, 0, 0.12);
  --widget: #e9e0ca;
  --ring: rgba(92, 54, 24, 0.55);
  --moth: #d8c9a8;
  --cat: #0d0f16;
  --paper: #efe7d4;
  --paper-edge: #d9cfb6;
  --ink: #1c2140;
  --ink-soft: #4a4f6d;
  --rule: rgba(56, 92, 168, 0.16);
  --margin-line: rgba(194, 54, 43, 0.5);
  --red: #c2362b;
  --green: #2d7a4b;
  --pencil: #8b8778;
  --chalk: rgba(236, 230, 214, 0.2);
  --desk-text: #b9b4a3;
  --tab-1: #e6d6a8;
  --tab-2: #cfdcc4;
  --tab-3: #d8c9de;
  --tab-4: #c9d6e2;
  --tab-5: #ecc9b8;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.25), 0 30px 60px -20px rgba(0, 0, 0, 0.7);
}
:root[data-theme="day"] {
  --desk: #cbc4b4;
  --desk-2: #d6cfc0;
  --lamp: rgba(255, 252, 240, 0.55);
  --lamp-soft: rgba(255, 250, 235, 0.2);
  --grain-a: rgba(255, 255, 255, 0.12);
  --grain-b: rgba(120, 90, 50, 0.08);
  --widget: #f6f1e4;
  --ring: rgba(120, 78, 40, 0.3);
  --moth: #8a7a5c;
  --cat: #4a4032;
  --paper: #fbf7ee;
  --paper-edge: #e4dccb;
  --chalk: rgba(28, 33, 64, 0.07);
  --desk-text: #5d5848;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.08), 0 24px 50px -24px rgba(60, 50, 30, 0.45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--desk);
  color: var(--ink);
  font: 400 16px/1.6 'IBM Plex Sans', system-ui, sans-serif;
  overflow-x: hidden;
}
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.hand { font-family: 'Kalam', cursive; }
.small { font-size: 0.85rem; }
.muted { color: var(--ink-soft); }

/* ---------- desk + ghostwriting ---------- */
.desk { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.wood { /* walnut planks with grain, lit from the lamp */
  position: absolute; inset: 0;
  background-color: var(--desk);
  background-image:
    repeating-linear-gradient(180deg, transparent 0 179px, rgba(0, 0, 0, 0.45) 179px 181px, rgba(255, 255, 255, 0.03) 181px 182px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1800' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0044444 0.0888889' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.55 0 0 0 0 0.33 0 0 0 0 0.18 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  background-size: auto, 1800px 180px;
}.vignette { position: absolute; inset: 0; background: radial-gradient(ellipse at 30% 20%, transparent 40%, rgba(0, 0, 0, 0.55) 100%); }
:root[data-theme="day"] .vignette { background: radial-gradient(ellipse at 30% 20%, transparent 50%, rgba(80, 60, 30, 0.18) 100%); }
.dust i {
  position: absolute; width: 3px; height: 3px; border-radius: 50%; background: rgba(255, 220, 170, 0.55);
  filter: blur(0.5px); animation: mote var(--d, 18s) linear infinite; opacity: 0;
}
:root[data-theme="day"] .dust i { background: rgba(255, 255, 255, 0.8); }
@keyframes mote {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: var(--o, 0.6); }
  85% { opacity: var(--o, 0.6); }
  100% { transform: translate(var(--dx, 40px), var(--dy, -120px)); opacity: 0; }
}
/* coffee rings soak into the desk as the mug fills */
.rings b {
  position: absolute; border-radius: 50%; border: 2px solid var(--ring); opacity: 0;
  box-shadow: inset 0 0 6px var(--ring); animation: soak 1.6s ease-out forwards;
}
@keyframes soak { to { opacity: 1; } }

/* stationery lying about */
.kit { position: absolute; filter: drop-shadow(2px 4px 5px rgba(0, 0, 0, 0.5)); opacity: 0.95; }
.pencil { width: 186px; left: 45vw; bottom: 7vh; rotate: -7deg; }
.ruler { width: 250px; left: 8vw; bottom: 3vh; rotate: -4deg; }
.eraser { width: 54px; left: 61vw; bottom: 3.5vh; rotate: -19deg; }
.clips { width: 56px; left: 31vw; bottom: 3vh; rotate: 12deg; opacity: 0.8; }
.books { width: 168px; left: 1vw; top: 30vh; rotate: 4deg; }
.marker { width: 132px; left: 1.5vw; top: 54vh; rotate: 68deg; }
.sharp { width: 80px; left: 72vw; bottom: 4vh; rotate: -9deg; }

/* crumpled rejects pile up with every wrong answer */
.crumples b {
  position: absolute; display: block; border-radius: 48% 54% 46% 52% / 52% 46% 56% 44%;
  background: radial-gradient(circle at 35% 30%, var(--paper), var(--paper-edge) 60%, #b9ad92);
  box-shadow: 2px 5px 8px rgba(0, 0, 0, 0.5), inset -4px -5px 7px rgba(0, 0, 0, 0.18), inset 3px 3px 5px rgba(255, 255, 255, 0.55);
  animation: toss 0.65s cubic-bezier(.2,1.4,.5,1) backwards;
}
@keyframes toss { from { transform: translate(-28vw, -40vh) scale(0.3) rotate(-220deg); opacity: 0; } }

/* the cat does a lap of the desk now and then */
.cat { position: fixed; bottom: 0; left: -170px; width: 130px; z-index: 29; pointer-events: none; opacity: 0; }
.cat path { fill: none; stroke: var(--cat); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.cat .c-body { fill: var(--cat); }
.cat .c-tail { stroke-width: 5; animation: swish 1.1s ease-in-out infinite alternate; transform-origin: 24px 62px; }
.cat .c-leg { stroke-width: 5; }
@keyframes swish { to { rotate: -16deg; } }
.cat.go { animation: prowl 17s linear forwards; }
@keyframes prowl {
  0% { opacity: 0; transform: translateX(0); }
  6% { opacity: 1; }
  48% { transform: translateX(48vw) translateY(-3px); }
  50% { transform: translateX(50vw); }
  94% { opacity: 1; }
  100% { opacity: 0; transform: translateX(118vw); }
}

/* a moth that keeps bumping into the lamp */
.moth { position: absolute; width: 26px; height: 20px; left: 14vw; top: 16vh; opacity: 0.65; animation: flit 23s ease-in-out infinite; }
.m-body { fill: var(--moth); }
.m-wing { fill: var(--moth); opacity: 0.8; transform-origin: 20px 14px; animation: flap 0.16s ease-in-out infinite alternate; }
.m-wing.l { transform-origin: 19px 14px; }
@keyframes flap { from { transform: scaleX(1); } to { transform: scaleX(0.45); } }
@keyframes flit {
  0%   { transform: translate(0, 0) rotate(8deg); }
  12%  { transform: translate(14vw, 9vh) rotate(-14deg); }
  25%  { transform: translate(5vw, -4vh) rotate(20deg); }
  38%  { transform: translate(22vw, 6vh) rotate(-6deg); }
  52%  { transform: translate(9vw, 13vh) rotate(16deg); }
  66%  { transform: translate(26vw, -2vh) rotate(-18deg); }
  80%  { transform: translate(11vw, 5vh) rotate(10deg); }
  100% { transform: translate(0, 0) rotate(8deg); }
}
:root[data-theme="day"] .moth { opacity: 0.3; }

.desk::before { /* paper grain on the desk */
  content: ''; position: absolute; inset: 0; opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.08 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.lamp { /* a warm pool from a desk lamp just off-screen, top left */
  position: absolute; left: -20vw; top: -40vh; width: 100vw; height: 100vw; border-radius: 50%;
  mix-blend-mode: screen;
  background: radial-gradient(closest-side, var(--lamp) 0%, var(--lamp-soft) 45%, transparent 100%);
  animation: flicker 9s ease-in-out infinite;
}
@keyframes flicker { 0%, 100% { opacity: 1; } 47% { opacity: 0.96; } 50% { opacity: 0.9; } 53% { opacity: 0.97; } }
.ghostwriting span {
  position: absolute; font-family: 'Kalam', cursive; color: var(--chalk); white-space: nowrap;
  text-shadow: 0 0 12px var(--chalk);
  clip-path: inset(0 100% 0 0);
  animation: write var(--dur, 9s) ease-in-out forwards;
}
@keyframes write {
  0% { clip-path: inset(0 100% 0 0); opacity: 1; }
  28% { clip-path: inset(0 0 0 0); opacity: 1; }
  75% { clip-path: inset(0 0 0 0); opacity: 1; }
  100% { clip-path: inset(0 0 0 0); opacity: 0; }
}

/* ---------- notebook ---------- */
.notebook {
  position: relative; z-index: 1; max-width: 1260px; margin: 0 auto; padding: 36px 24px 48px;
  display: grid; grid-template-columns: minmax(0, 1fr) 250px; grid-template-areas: 'head head' 'book tray' 'foot foot';
  column-gap: 34px;
}
.masthead { grid-area: head; }
.book { grid-area: book; min-width: 0; }
.tray { grid-area: tray; }
.colophon { grid-area: foot; }
.masthead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; color: var(--desk-text); margin-bottom: 22px; }
.masthead h1 { font: 400 clamp(2.6rem, 6vw, 3.6rem)/1 'Instrument Serif', Georgia, serif; margin: 0; color: var(--paper); letter-spacing: -0.01em; }
:root[data-theme="day"] .masthead h1 { color: var(--ink); }
.masthead h1 em { font-style: italic; }
/* embossed label-maker tape */
.kicker {
  display: inline-block; margin: 0 0 8px; padding: 4px 13px 3px;
  font-size: 0.7rem; letter-spacing: 0.22em; text-transform: uppercase;
  color: #f3efe4; background: linear-gradient(180deg, #4a4a52, #2c2c33);
  border-radius: 3px; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 2px 5px rgba(0, 0, 0, 0.45);
  rotate: -0.8deg;
}
body.crunch .kicker { background: linear-gradient(180deg, #8d2b3a, #5e1a24); color: #fde8e4; }
.meta { text-align: right; font-size: 0.8rem; }
.meta p { margin: 0 0 4px; }
.streak b { color: var(--paper); font-weight: 500; }
:root[data-theme="day"] .streak b { color: var(--ink); }

/* divider tabs */
.dividers { display: flex; gap: 4px; padding-left: 120px; position: relative; z-index: 2; }
.dividers button {
  border: 0; cursor: pointer; font: 500 0.92rem 'IBM Plex Sans', sans-serif; color: var(--ink);
  padding: 9px 16px 12px; border-radius: 8px 8px 0 0; margin-bottom: -4px;
  transform: translateY(5px); transition: transform 0.2s ease; opacity: 0.85;
}
.dividers button span { font-size: 0.72rem; opacity: 0.6; margin-right: 4px; }
.dividers button:nth-child(1) { background: var(--tab-1); }
.dividers button:nth-child(2) { background: var(--tab-2); }
.dividers button:nth-child(3) { background: var(--tab-3); }
.dividers button:nth-child(4) { background: var(--tab-4); }
.dividers button:nth-child(5) { background: var(--tab-5); }
.dividers button:hover { transform: translateY(1px); }
.dividers button.active { transform: translateY(0); opacity: 1; background: var(--paper); }
.dividers button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* the page */
.page {
  position: relative; display: grid; grid-template-columns: 120px 1fr; min-height: 560px;
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent 119px, var(--margin-line) 119px, var(--margin-line) 121px, transparent 121px),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px);
  background-position: 0 0, 0 18px;
  border-radius: 3px 3px 3px 3px; box-shadow: var(--shadow);
}
.page::after { /* stacked pages underneath */
  content: ''; position: absolute; left: 6px; right: -6px; bottom: -6px; height: 100%; z-index: -1;
  background: var(--paper-edge); border-radius: 3px; box-shadow: var(--shadow);
}
.margin { padding: 34px 0 0 22px; }
.ghost { width: 74px; height: 86px; display: block; animation: drift 7s ease-in-out infinite; }
.g-body { fill: var(--paper); stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; }
.g-eye { fill: var(--ink); transition: transform 0.3s; transform-origin: center; transform-box: fill-box; }
.g-mouth { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.ghost.sad .g-eye { transform: scaleY(0.6); }
.ghost.thinking .g-eye { transform: scaleY(0.3); }
.ghost.happy { animation: drift 7s ease-in-out infinite, hop 0.5s ease; }
@keyframes drift { 0%, 100% { translate: 0 0; } 50% { translate: 0 -7px; } }
@keyframes hop { 40% { rotate: -7deg; } 80% { rotate: 5deg; } }

/* turning a page: the old leaf lifts on its spine, the new one settles under it */
.page { perspective: 2000px; perspective-origin: left center; }
.panel { display: none; padding: 30px 40px 40px 28px; min-width: 0; }
.panel.active { display: block; animation: leaf-in 0.42s cubic-bezier(.2,.7,.3,1); transform-origin: left center; }
.panel.leaving {
  display: block; position: absolute; left: 120px; right: 0; top: 0; bottom: 0; z-index: 3;
  background: var(--paper); transform-origin: left center; backface-visibility: hidden;
  animation: leaf-out 0.42s cubic-bezier(.6,.05,.85,.5) forwards;
  box-shadow: 14px 0 28px -10px rgba(0, 0, 0, 0.45); overflow: hidden;
}
@keyframes leaf-out { to { transform: rotateY(-96deg); opacity: 0.1; } }
@keyframes leaf-in { from { transform: rotateY(42deg); opacity: 0.2; } to { transform: none; opacity: 1; } }

/* spiral binding down the spine + a bookmark ribbon */
.binding { position: absolute; left: 0; top: 0; bottom: 0; width: 26px; display: flex; flex-direction: column; justify-content: space-evenly; align-items: center; pointer-events: none; }
.binding i { width: 11px; height: 11px; border-radius: 50%; border: 2.5px solid rgba(0, 0, 0, 0.28); border-right-color: transparent; rotate: -25deg; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); }
.ribbon { position: absolute; right: 56px; top: -10px; width: 16px; height: 150px; pointer-events: none;
  background: linear-gradient(90deg, #8d2b3a, #c2362b 35%, #8d2b3a); transition: height 0.6s ease;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%); box-shadow: -2px 0 6px rgba(0, 0, 0, 0.3); }

/* ink blot: red ink soaking into the paper where a wrong answer was */
.blot { position: fixed; width: 10px; height: 10px; pointer-events: none; z-index: 40; opacity: 0; }
.blot.go { animation: soak-in 1.5s ease-out forwards; }
.blot::before, .blot::after {
  content: ''; position: absolute; inset: -26px; background: var(--red);
  filter: blur(0.4px); opacity: 0.5;
  border-radius: 48% 56% 42% 60% / 55% 44% 58% 46%;
}
.blot::after { inset: -14px; rotate: 35deg; border-radius: 60% 40% 58% 44% / 42% 60% 44% 56%; opacity: 0.38; }
@keyframes soak-in { 0% { opacity: 0; scale: 0.2; } 25% { opacity: 1; scale: 1.1; } 100% { opacity: 0; scale: 1.5; } }

/* the ghost sometimes leaves the margin and drifts across the room */
.roamer { position: fixed; width: 86px; height: 100px; z-index: 30; pointer-events: none; opacity: 0; left: -140px; top: 40vh; }
.roamer.go { animation: roam 9s ease-in-out forwards; }
@keyframes roam {
  0% { opacity: 0; transform: translate(0, 0) rotate(-6deg); }
  12% { opacity: 0.5; }
  50% { transform: translate(52vw, -14vh) rotate(5deg); }
  88% { opacity: 0.5; }
  100% { opacity: 0; transform: translate(112vw, 4vh) rotate(-4deg); }
}

/* margin doodles the ghost sketches as topics are learned */
.doodles { position: absolute; left: 14px; top: 148px; width: 92px; pointer-events: none; overflow: visible; }
.doodles path, .doodles circle, .doodles line { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.4; }
.doodles .ink { stroke: var(--red); opacity: 0.55; }
.doodles .drawn { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: sketch 1.1s ease-out forwards; }
@keyframes sketch { to { stroke-dashoffset: 0; } }
.section-title { font: 400 2.1rem/1.1 'Instrument Serif', Georgia, serif; margin: 0 0 22px; }
.label { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 10px; }

/* ghost speech: handwriting in the margin of the conversation */
.ghost-says { font-size: 1.35rem; line-height: 1.45; margin: 4px 0 26px; max-width: 34em; min-height: 2.9em; color: var(--ink); }

/* buttons */
button { font: inherit; cursor: pointer; }
.ink-btn {
  background: var(--ink); color: var(--paper); border: 0; padding: 11px 22px; border-radius: 3px;
  font: 500 0.95rem 'IBM Plex Sans', sans-serif; letter-spacing: 0.01em;
  box-shadow: 2px 2px 0 var(--red); transition: transform 0.12s, box-shadow 0.12s;
}
.ink-btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--red); }
.ink-btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--red); }
.ink-btn:disabled { opacity: 0.55; cursor: wait; transform: none; }
.text-btn {
  background: none; border: 0; padding: 2px 0; color: inherit; font-size: 0.8rem;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; cursor: pointer;
}
.text-btn:hover { color: var(--red); }
.text-btn.danger { color: var(--red); margin-top: 18px; }
.text-btn.listening { color: var(--red); text-decoration: none; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.4; } }
.masthead .text-btn { color: var(--desk-text); }
.row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 14px; }

.start { position: relative; }
.start p { margin: 0 0 16px; }
.tonight { font: 400 2.3rem/1 'Instrument Serif', serif; margin: 0 0 14px !important; }
.tonight .mono { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); vertical-align: middle; margin-left: 8px; }
.checklist { list-style: none; padding: 0; margin: 0 0 22px; max-width: 460px; }
.checklist li { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; height: 32px; font: 400 1.18rem 'Kalam', cursive; }
.checklist .box { width: 15px; height: 15px; border: 1.6px solid var(--ink); border-radius: 2px; position: relative; }
.checklist .done .box::after { content: '✓'; position: absolute; left: 1px; top: -12px; font: 700 1.4rem 'Kalam', cursive; color: var(--green); }
.checklist .done .name { color: var(--ink-soft); }
.checklist .pct { font-size: 1.05rem; }
.checklist .weak .pct { color: var(--red); }
.checklist .weak .name { text-decoration: underline wavy var(--red); text-decoration-thickness: 1px; text-underline-offset: 5px; }
.doodle { position: absolute; right: 0; bottom: -10px; width: 220px; opacity: 0.55; pointer-events: none; }
.doodle path { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-dasharray: 4 5; }
.doodle path + path { stroke-dasharray: none; }
.doodle text { font: 400 13px 'Kalam', cursive; fill: var(--ink-soft); }
@media (max-width: 900px) { .doodle { display: none; } }

/* question */
.qmeta { font-size: 0.75rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 8px; display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }
.qmeta .text-btn { margin-left: auto; text-transform: none; letter-spacing: 0; }
.qmeta .run:not(:empty) { color: var(--green); border: 1px solid currentColor; border-radius: 99px; padding: 1px 8px; font-size: 0.68rem; }
.question h2 { font: 400 1.65rem/1.3 'Instrument Serif', Georgia, serif; margin: 0 0 18px; }
.answers { list-style: none; padding: 0; margin: 0; }
.answers li { margin: 0; }
.answers button {
  position: relative; display: flex; gap: 14px; align-items: baseline; width: 100%; text-align: left;
  background: none; border: 0; padding: 7px 4px; min-height: 32px; color: var(--ink); font-size: 1.02rem; line-height: 1.5;
}
.answers .letter { font: 500 0.85rem 'IBM Plex Mono', monospace; width: 26px; height: 26px; flex: none; display: grid; place-items: center; border: 1.5px solid var(--ink); border-radius: 50%; }
.answers button:hover:not(:disabled) .letter { background: var(--ink); color: var(--paper); }
.answers button:disabled { cursor: default; }
.answers .right .letter { border-color: var(--green); color: var(--green); }
.answers .right .text { color: var(--green); }
.answers .right::after { content: '✓'; font: 700 1.5rem 'Kalam', cursive; color: var(--green); margin-left: 6px; line-height: 1; }
.answers .wrong .text { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; color: var(--ink-soft); }
.answers .wrong .letter { border-color: var(--red); color: var(--red); }
.answers .dim { opacity: 0.45; }
.explain { font-family: 'Kalam', cursive; color: var(--red); font-size: 1.08rem; line-height: 1.5; margin: 14px 0 0; padding-left: 14px; border-left: 2px solid var(--red); }
.q-actions { justify-content: space-between; margin-top: 22px; }

/* pinned note (Temporal nudge) */
.note-pinned {
  background: #f7e27c; color: #3a3420; padding: 14px 18px 12px; max-width: 360px; margin: 0 0 22px auto;
  transform: rotate(1.4deg); box-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.35);
}
.note-pinned .label { color: #6b6036; }
.note-pinned .hand { font-size: 1.1rem; line-height: 1.4; margin: 0; }
.note-pinned .row { margin-top: 8px; }

/* forms */
.cols { display: grid; grid-template-columns: 1fr 1.4fr; gap: 40px; }
label { display: block; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 14px; }
label.file { display: inline; margin: 0; color: inherit; }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 6px 2px; font: 400 1rem 'IBM Plex Sans', sans-serif; color: var(--ink);
  background: transparent; border: 0; border-bottom: 1.5px solid var(--ink-soft); border-radius: 0;
}
textarea { border: 1.5px solid var(--ink-soft); padding: 10px; background: rgba(255, 255, 255, 0.35); line-height: 1.55; resize: vertical; font-size: 0.95rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); }
.topics { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.topics li { font-family: 'Kalam', cursive; font-size: 1.1rem; }
.topics li::before { content: '— '; color: var(--pencil); }

/* report card */
.report { display: grid; grid-template-columns: 240px 1fr; gap: 40px; align-items: start; }
.grade-mark { position: relative; width: 200px; height: 130px; display: grid; place-items: center; }
.grade-mark span { font: 700 3.6rem/1 'Kalam', cursive; color: var(--red); position: relative; z-index: 1; }
.circle-mark { position: absolute; inset: 0; width: 100%; height: 100%; }
.circle-mark path { fill: none; stroke: var(--red); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 520; stroke-dashoffset: 520; }
.circle-mark.drawn path { animation: draw 1.1s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.marks { width: 100%; border-collapse: collapse; }
.marks td { padding: 7px 8px 7px 0; vertical-align: middle; border-bottom: 1px solid var(--rule); font-size: 0.95rem; }
.marks .t { font-weight: 500; }
.marks .n { font: 400 0.75rem 'IBM Plex Mono', monospace; color: var(--ink-soft); white-space: nowrap; }
.marks .pct { font: 700 1.15rem 'Kalam', cursive; text-align: right; width: 48px; }
.marks .bar { width: 34%; }
.hatch { height: 10px; border: 1px solid var(--ink); position: relative; }
.hatch i { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(-45deg, var(--ink) 0 1.5px, transparent 1.5px 5px); transition: width 0.9s ease; }
.marks .acts { text-align: right; white-space: nowrap; }
.marks .acts .text-btn { margin-left: 10px; }
.links { padding-left: 18px; }
.links li { margin-bottom: 10px; }
.links a { color: var(--ink); }

/* timetable */
.timetable { width: 100%; border-collapse: collapse; }
.timetable td { padding: 0 10px 0 0; height: 64px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.timetable .day { font: 400 1.3rem 'Instrument Serif', serif; width: 120px; }
.timetable .day small { display: block; font: 400 0.7rem 'IBM Plex Mono', monospace; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }
.timetable .focus { font-family: 'Kalam', cursive; font-size: 1.12rem; }
.timetable .kind { font: 400 0.75rem 'IBM Plex Mono', monospace; color: var(--ink-soft); text-align: right; white-space: nowrap; }
.timetable tr.today .day { color: var(--red); }
.timetable tr.mock .focus { color: var(--red); }

/* ask */
.chat-log { display: flex; flex-direction: column; gap: 16px; max-height: 52vh; overflow-y: auto; padding-right: 8px;
  scrollbar-width: thin; scrollbar-color: var(--ink-soft) transparent; }
.chat-log::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb { background: var(--ink-soft); border-radius: 99px; opacity: 0.5; }
.msg { margin: 0; max-width: 88%; white-space: pre-wrap; }
.ghost-msg { font-family: 'Kalam', cursive; font-size: 1.12rem; line-height: 1.5; }
.me-msg { align-self: flex-end; text-align: right; color: var(--ink-soft); font-style: italic; }
.me-msg::before { content: 'you: '; font: 400 0.72rem 'IBM Plex Mono', monospace; font-style: normal; }
.msg .via { display: block; font: 400 0.68rem 'IBM Plex Mono', monospace; color: var(--pencil); margin-top: 4px; }
.chat-form { display: flex; gap: 14px; align-items: flex-end; margin-top: 22px; }
.chat-form input { flex: 1; }

/* --- NOTES: the inside cover of the book --- */
.nameplate {
  border: 2px double var(--ink); padding: 14px 18px 12px; margin-bottom: 22px; text-align: center;
  background: repeating-linear-gradient(135deg, transparent 0 9px, rgba(28, 33, 64, 0.035) 9px 10px);
}
.nameplate p { margin: 0; font-size: 0.64rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-soft); }
.nameplate h2 { font-size: 1.9rem; margin: 6px 0 4px; border-bottom: 1.5px solid var(--ink-soft); display: inline-block; min-width: 180px; padding: 0 10px 2px; }
.nameplate .sub { font-size: 0.7rem; letter-spacing: 0.1em; }

.feeder { position: relative; }
/* graph paper, so pasted notes feel like rough work */
.feeder textarea {
  background-color: rgba(255, 255, 255, 0.5);
  background-image: repeating-linear-gradient(90deg, rgba(56, 92, 168, 0.13) 0 1px, transparent 1px 18px),
                    repeating-linear-gradient(180deg, rgba(56, 92, 168, 0.13) 0 1px, transparent 1px 18px);
}
.chomp { position: absolute; inset: 0; display: grid; place-content: center; gap: 10px; grid-auto-flow: column; background: rgba(239, 231, 212, 0.82); }
.chomp span { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); animation: chew 0.9s ease-in-out infinite; }
.chomp span:nth-child(2) { animation-delay: 0.15s; } .chomp span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chew { 50% { transform: translateY(-9px) scale(1.25); } }

/* chapters as sticky index flags */
.topics { gap: 8px; --flag: #f2d9a0; }
.topics li { position: relative; background: var(--flag); padding: 4px 20px 4px 10px; font-size: 0.95rem; color: #3a3420;
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 50%, 100% 100%, 0 100%); box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.18); }
.topics li::before { content: none; }
.topics li:nth-child(4n+2) { --flag: #bcd9c4; } .topics li:nth-child(4n+3) { --flag: #d6c3e0; } .topics li:nth-child(4n) { --flag: #c6d7e8; }

/* pick the ghost's mood by its face, not a dropdown */
.moods { border: 0; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.moods legend { font-size: 0.85rem; color: var(--ink-soft); padding: 0; margin-bottom: 8px; }
.mood { position: relative; margin: 0; text-align: center; cursor: pointer; padding: 10px 4px 8px; border: 1.5px dashed transparent; border-radius: 4px; transition: background 0.15s, border-color 0.15s; }
.mood input { position: absolute; opacity: 0; width: 0; height: 0; }
.mood svg { width: 42px; height: 48px; display: block; margin: 0 auto 4px; }
.mood .g-body { fill: var(--paper); stroke: var(--ink); stroke-width: 2.6; stroke-linejoin: round; }
.mood .g-eye, .mood .g-fill { fill: var(--ink); }
.mood .g-mouth { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }
.mood b { display: block; font-size: 0.9rem; color: var(--ink); }
.mood span { display: block; font-size: 0.72rem; color: var(--ink-soft); }
.mood:hover { background: rgba(28, 33, 64, 0.05); }
.mood:has(:focus-visible) { outline: 2px solid var(--red); outline-offset: 2px; }
.mood:has(:checked) { border-color: var(--ink); background: rgba(28, 33, 64, 0.07); }
.mood:has(:checked) svg { animation: hop 0.5s ease; }
.mood:has(:checked)::after { content: '✓'; position: absolute; top: 2px; right: 6px; font: 700 1.3rem 'Kalam', cursive; color: var(--green); }

/* --- REPORT: teacher's rubber stamp + signature --- */
.stamp {
  margin: 18px auto 0; width: max-content; padding: 7px 16px; rotate: -11deg;
  border: 3px double var(--red); color: var(--red); border-radius: 5px;
  font: 700 0.95rem 'IBM Plex Mono', monospace; letter-spacing: 0.14em; opacity: 0.78;
  animation: thud 0.45s cubic-bezier(.2,1.6,.4,1) both;
}
.stamp.pass { border-color: var(--green); color: var(--green); }
@keyframes thud { from { scale: 2.6; opacity: 0; rotate: -24deg; } to { scale: 1; opacity: 0.78; rotate: -11deg; } }
.signed { text-align: right; color: var(--ink-soft); font-size: 0.8rem; margin: 10px 6px 0; }
.signed .sig { font: 400 1.7rem 'Kalam', cursive; color: var(--ink); margin-left: 8px; }

/* --- PLAN: taped to the page --- */
.taped { position: relative; padding-top: 6px; }
.tape { position: absolute; top: -16px; width: 92px; height: 26px; background: rgba(206, 188, 128, 0.85);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); border-left: 1px dashed rgba(0,0,0,0.12); border-right: 1px dashed rgba(0,0,0,0.12); }
.tape.tl { left: 8px; rotate: -4deg; } .tape.tr { right: 96px; rotate: 3deg; }
.timetable tr.done .day, .timetable tr.done .focus { opacity: 0.45; }
.timetable tr.done .focus { text-decoration: line-through; text-decoration-color: var(--red); }

/* --- ASK: folded notes passed under the desk --- */
.chat-log .msg { position: relative; padding: 12px 15px; }
.chat-log .ghost-msg { background: var(--paper); box-shadow: 2px 3px 7px rgba(0, 0, 0, 0.14); rotate: -0.5deg;
  background-image: linear-gradient(180deg, transparent calc(50% - 1px), rgba(0,0,0,0.07) 50%, transparent calc(50% + 1px)); }
.chat-log .me-msg { background: #f7e27c; color: #3a3420; rotate: 0.8deg; box-shadow: 2px 3px 7px rgba(0, 0, 0, 0.2); font-style: normal; }
.chat-log .me-msg::before { color: #6b6036; }
.pen { display: inline-flex; gap: 4px; align-items: center; }
.pen i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft); animation: chew 0.9s ease-in-out infinite; }
.pen i:nth-child(2) { animation-delay: .15s; } .pen i:nth-child(3) { animation-delay: .3s; }

/* ---------- desk widgets ---------- */
.tray { display: flex; flex-direction: column; gap: 22px; padding-top: 40px; }
.w { position: relative; color: var(--ink); }
.w-label { font-size: 0.72rem; color: var(--desk-text); text-align: center; margin: 6px 0 0; }
.w-label b { color: var(--paper); font-weight: 500; }
:root[data-theme="day"] .w-label b { color: var(--ink); }
.w .label { margin-bottom: 6px; }

/* tear-off calendar */
.calendar { width: 150px; align-self: center; cursor: pointer; transform: rotate(-3deg); filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.4)); }
.cal-ring { display: flex; justify-content: space-around; height: 10px; position: relative; z-index: 2; }
.cal-ring i { width: 8px; height: 18px; border-radius: 4px; background: linear-gradient(#bbb, #666); margin-top: -8px; }
.cal-head { background: var(--red); color: #fff; text-align: center; font-size: 0.72rem; letter-spacing: 0.15em; padding: 6px 0 5px; border-radius: 4px 4px 0 0; }
.cal-sheet { background: var(--widget); text-align: center; padding: 6px 8px 12px; border-radius: 0 0 4px 4px; transform-origin: top center; }
.cal-num { display: block; font: 400 4.2rem/1 'Instrument Serif', serif; }
.cal-sub { display: block; font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.cal-sheet.tear { animation: tear 0.7s ease-in forwards; }
@keyframes tear { 30% { transform: rotate(-6deg); } 100% { transform: translate(40px, 120px) rotate(24deg); opacity: 0; } }

/* clock */
.clock svg { width: 120px; height: 120px; display: block; margin: 0 auto; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.35)); }
.clock .face { fill: var(--widget); stroke: var(--ink); stroke-width: 2.5; }
.clock .ticks line { stroke: var(--ink); stroke-width: 1.4; }
.clock .hand { stroke: var(--ink); stroke-linecap: round; }
.clock .h { stroke-width: 3.6; } .clock .m { stroke-width: 2.4; } .clock .s { stroke: var(--red); stroke-width: 1.2; }
.clock .pin { fill: var(--red); }

/* mug */
.mug svg { width: 120px; height: 120px; display: block; margin: 0 auto; overflow: visible; }
.mug-body { fill: none; stroke: var(--paper); stroke-width: 3.2; stroke-linejoin: round; }
:root[data-theme="day"] .mug-body { stroke: var(--ink); }
.coffee { fill: #6b4226; transition: y 1s ease, height 1s ease; }
.steam path { fill: none; stroke: var(--paper); stroke-width: 2; stroke-linecap: round; opacity: 0; animation: steam 3.6s ease-in-out infinite; }
:root[data-theme="day"] .steam path { stroke: var(--ink-soft); }
.steam path:nth-child(2) { animation-delay: 1.2s; } .steam path:nth-child(3) { animation-delay: 2.4s; }
@keyframes steam { 0% { opacity: 0; transform: translateY(8px); } 40% { opacity: 0.45; } 100% { opacity: 0; transform: translateY(-10px); } }
.mug.empty .steam { display: none; }

/* timer */
.timer { display: flex; align-items: center; gap: 14px; justify-content: center; }
.timer svg { width: 74px; height: 74px; transform: rotate(-90deg); }
.t-track { fill: var(--widget); stroke: rgba(0, 0, 0, 0.15); stroke-width: 8; }
.t-fill { fill: none; stroke: var(--red); stroke-width: 8; stroke-dasharray: 264; stroke-dashoffset: 264; transition: stroke-dashoffset 1s linear; }
.t-read { display: flex; flex-direction: column; color: var(--desk-text); }
.t-read span { font-size: 1.5rem; color: var(--paper); }
:root[data-theme="day"] .t-read span { color: var(--ink); }
.t-read .text-btn { color: var(--desk-text); text-align: left; }

/* sticky note */
.sticky { background: #f7e27c; color: #3a3420; padding: 12px 14px 10px; transform: rotate(2deg); box-shadow: 0 12px 18px -10px rgba(0, 0, 0, 0.5); }
.sticky::before { content: ''; position: absolute; top: -9px; left: 50%; width: 60px; height: 18px; translate: -50% 0; rotate: -4deg; background: rgba(255, 255, 255, 0.45); }
.sticky .label { color: #6b6036; }
.sticky .hand { font-size: 1.25rem; margin: 0; line-height: 1.25; }
.sticky .text-btn { color: #3a3420; }

/* week sketch + tally */
.week { background: var(--widget); padding: 12px 14px; transform: rotate(-1deg); box-shadow: 0 12px 18px -12px rgba(0, 0, 0, 0.5);
  background-image: repeating-linear-gradient(180deg, transparent 0 15px, var(--rule) 15px 16px); }
.week svg { width: 100%; display: block; }
.week .bar { fill: url(#hatch); stroke: var(--ink); stroke-width: 1.2; }
.week .bar.today { stroke: var(--red); }
.week text { font: 400 9px 'IBM Plex Mono', monospace; fill: var(--ink-soft); }
.tally line { stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
.tally .cross { stroke: var(--red); }

.colophon { padding: 18px 0 0; }

/* which engine is actually running, tucked in the masthead */
.rig { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 0.72rem; color: var(--desk-text); margin: 0 0 4px; }
.rig i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 7px var(--green); flex: none; }
.rig.off i { background: var(--red); box-shadow: 0 0 7px var(--red); }
.rig.off { color: var(--red); }

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  .notebook { grid-template-columns: 1fr; grid-template-areas: 'head' 'book' 'tray' 'foot'; }
  .tray { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: center; gap: 24px; padding-top: 34px; }
  .calendar { justify-self: center; }
}
@media (max-width: 760px) {
  .notebook { padding: 22px 12px 32px; }
  .dividers { padding-left: 0; overflow-x: auto; scrollbar-width: none; }
  .dividers button { padding: 8px 10px 11px; font-size: 0.85rem; white-space: nowrap; flex: 1; }
  .dividers button span { display: none; }
  .page {
    grid-template-columns: 1fr;
    background-image:
      linear-gradient(90deg, transparent 15px, var(--margin-line) 15px, var(--margin-line) 17px, transparent 17px),
      repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px);
  }
  .margin { position: absolute; right: 10px; top: 14px; padding: 0; }
  .ghost { width: 50px; height: 58px; }
  .panel { padding: 24px 16px 28px 30px; }
  .ghost-says { padding-right: 56px; font-size: 1.2rem; }
  .cols, .report { grid-template-columns: 1fr; gap: 24px; }
  .marks .bar { display: none; }
  .timetable .day { width: 92px; }
  .note-pinned { margin-right: 50px; }
  .masthead { align-items: flex-start; }
  .binding, .doodles, .kit, .crumples { display: none; }
  .moods { grid-template-columns: repeat(3, 1fr); gap: 4px; }
  .mood svg { width: 36px; height: 40px; }
  .mood span { font-size: 0.65rem; }
  .rig { justify-content: flex-start; }
  .panel.leaving { left: 0; }
  .ribbon { display: none; }
  .roamer { width: 60px; height: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .ghostwriting span { clip-path: none; }
  .circle-mark path { stroke-dashoffset: 0; }
  .dust, .moth, .roamer, .cat { display: none; }
  .crumples b { animation: none; }
  .doodles .drawn { stroke-dashoffset: 0; }
  .panel.leaving { display: none; }
}
