/* Lean Learn — styled to sit inside www.uzerbinati.eu.
 *
 * The host site (eleven-theme + custom.css) is: white ground, black ink,
 * monospace, hairline black boxes, and one accent, the link blue #4478A6.
 * This app keeps all of that and borrows only the *mechanics* of a
 * gamified language app: chunky buttons that press down, a winding path of
 * lesson circles, a feedback sheet that slides up from the thumb.
 *
 * Two accents, as in /drum: the site's blue for "right" and every
 * affordance, and its mirror across the hue circle, terracotta, for
 * "wrong", hearts and the streak.
 */

:root {
  --paper: #ffffff;
  --paper-2: #f6f6f6;
  --ink: #000000;
  --ink-soft: #555555;
  --ink-faint: #9a9a9a;
  --line: #000000;
  --line-soft: #d6d6d6;
  --blue: #4478a6;
  --blue-deep: #264463;
  --blue-tint: #dbe6f0;
  --terra: #a77044;
  --terra-deep: #6e4626;
  --terra-tint: #f3e6dc;
  /* Text-weight variants of the two accents: the brand values are kept for
     fills and borders, these pass WCAG AA (4.5:1) on every ground they sit on. */
  --blue-ink: #3c6a92;
  --terra-ink: #8c5e39;
  --code-bg: #f1f1f1;
  --code-inline: #e3e3e3;
  --on-accent: #ffffff;

  --font: ui-monospace, 'SF Mono', Menlo, 'DejaVu Sans Mono', 'Noto Sans Mono', Consolas, monospace;
  --press: 4px;
  --col: 34rem;
  --tabbar-h: 3.6rem;
  --topbar-h: 3.1rem;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

/* Dark: the same two accents, lifted so they read on near-black. The host site
   has no dark mode, but a phone at 11pm deserves one; Me → Theme overrides. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #111213;
    --paper-2: #1b1c1e;
    --ink: #ececec;
    --ink-soft: #a9a9a9;
    --ink-faint: #6b6b6b;
    --line: #ececec;
    --line-soft: #3a3b3d;
    --blue: #7fa9cf;
    --blue-deep: #4f7aa1;
    --blue-tint: #1d2c3a;
    --terra: #d09a6c;
    --terra-deep: #9c6a40;
    --terra-tint: #3a2a1e;
    --blue-ink: #7fa9cf;
    --terra-ink: #d09a6c;
    --code-bg: #1c1d1f;
    --code-inline: #2b2c2f;
    --on-accent: #0d0e0f;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --paper: #111213;
  --paper-2: #1b1c1e;
  --ink: #ececec;
  --ink-soft: #a9a9a9;
  --ink-faint: #6b6b6b;
  --line: #ececec;
  --line-soft: #3a3b3d;
  --blue: #7fa9cf;
  --blue-deep: #4f7aa1;
  --blue-tint: #1d2c3a;
  --terra: #d09a6c;
  --terra-deep: #9c6a40;
  --terra-tint: #3a2a1e;
  --blue-ink: #7fa9cf;
  --terra-ink: #d09a6c;
  --code-bg: #1c1d1f;
  --code-inline: #2b2c2f;
  --on-accent: #0d0e0f;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
/* Headings the app moves focus to for screen readers: no ring for anyone else. */
.focus-target:focus {
  outline: none;
}

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* No pull-to-refresh reloading a lesson half-way (Android Chrome). */
  overscroll-behavior-y: none;
  /* scrollIntoView keeps targets clear of the fixed tab bar. */
  scroll-padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 0.75rem);
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
@media (min-width: 600px) {
  body {
    font-size: 16px;
  }
}

a {
  color: var(--blue);
  text-decoration: none;
}
a:not(.btn):hover {
  color: var(--blue-deep);
  border-bottom: 1px solid var(--blue-deep);
}
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  touch-action: manipulation;
  cursor: pointer;
}
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

code,
.code {
  font-family: var(--font);
}
code {
  background: var(--code-inline);
  padding: 0.05em 0.3em;
  border-radius: 2px;
  font-size: 0.95em;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* ───────────────────────────── App frame ───────────────────────────── */

#app {
  max-width: var(--col);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(var(--safe-t)) 0 calc(var(--tabbar-h) + var(--safe-b) + 1rem);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) 1rem 0;
  margin-top: calc(-1 * var(--safe-t));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.home-link {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  font-weight: 700;
  font-size: 1.1rem;
  margin-left: -0.75rem;
}
.home-link:hover {
  border-bottom: 0;
}
.brand {
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-turnstile {
  color: var(--blue);
  margin: 0 0.05em;
}
.stats {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.stat {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat svg {
  width: 1.15rem;
  height: 1.15rem;
}
.stat.streak {
  color: var(--terra-ink);
}
.stat.streak.cold {
  color: var(--ink-faint);
}
.stat.xp {
  color: var(--blue-ink);
}
.ring {
  width: 1.6rem;
  height: 1.6rem;
  display: block;
}
.ring circle {
  fill: none;
  stroke-width: 3.2;
}
.ring .track {
  stroke: var(--line-soft);
}
.ring .fill {
  stroke: var(--blue);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}
.icon-fill {
  fill: currentColor;
}
.icon-stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

#view {
  outline: none;
  padding: 0 1rem;
}

.tabbar {
  position: fixed;
  z-index: 30;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  background: var(--paper);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar a {
  flex: 1 1 0;
  max-width: calc(var(--col) / 4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  height: var(--tabbar-h);
  color: var(--ink-soft);
  font-size: 0.72rem;
  border: 0;
}
.tabbar a:hover {
  border: 0;
}
.tabbar svg {
  width: 1.45rem;
  height: 1.45rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tabbar a[aria-current='page'] {
  color: var(--blue-ink);
  font-weight: 700;
}
.tabbar a[aria-current='page'] svg {
  stroke-width: 2.4;
}

body.in-lesson .topbar,
body.in-lesson .tabbar {
  display: none;
}
body.in-lesson #app {
  padding: 0;
}

/* ───────────────────────────── Boxes & text ───────────────────────────── */

.box {
  border: 1px solid var(--line);
  padding: 0.9rem 1rem;
  margin: 1rem 0;
  background: var(--paper);
}
.box h1,
.box h2 {
  margin: 0 0 0.5rem;
}
h1 {
  font-size: 1.3em;
  line-height: 1.2;
}
h2 {
  font-size: 1.1em;
  line-height: 1.25;
}
h3 {
  font-size: 1em;
  text-decoration: underline;
  font-weight: normal;
  margin: 1.2rem 0 0.4rem;
}
p {
  margin: 0.5rem 0;
}
.muted {
  color: var(--ink-soft);
}
.kicker {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-soft);
}
.md p:first-child {
  margin-top: 0;
}
.md p:last-child {
  margin-bottom: 0;
}

/* ───────────────────────────── Buttons ───────────────────────────── */

/* The one borrowed gesture: a button sits on a hard shadow and presses into it. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 3rem;
  padding: 0.65rem 1.1rem;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.9rem;
  box-shadow: 0 var(--press) 0 var(--line);
  transform: translateY(0);
  transition: transform 0.06s ease, box-shadow 0.06s ease, background 0.15s;
  user-select: none;
  -webkit-user-select: none;
  margin-bottom: var(--press);
}
.btn:active:not(:disabled) {
  transform: translateY(var(--press));
  box-shadow: 0 0 0 var(--line);
}
.btn.block {
  display: flex;
  width: 100%;
}
.btn.primary {
  background: var(--blue-ink);
  border-color: var(--blue-deep);
  color: var(--on-accent);
  box-shadow: 0 var(--press) 0 var(--blue-deep);
}
.btn.primary:active:not(:disabled) {
  box-shadow: 0 0 0 var(--blue-deep);
}
.btn.danger {
  background: var(--terra-ink);
  border-color: var(--terra-deep);
  color: var(--on-accent);
  box-shadow: 0 var(--press) 0 var(--terra-deep);
}
.btn.danger:active:not(:disabled) {
  box-shadow: 0 0 0 var(--terra-deep);
}
.btn.ghost {
  border-color: transparent;
  box-shadow: none;
  background: transparent;
  color: var(--blue);
}
.btn:disabled {
  background: var(--paper-2);
  border-color: var(--line-soft);
  color: var(--ink-faint);
  box-shadow: 0 var(--press) 0 var(--line-soft);
  cursor: default;
}
.btn.small {
  min-height: 2.4rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}
.row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}
.row > .btn {
  flex: 1 1 auto;
}

/* ───────────────────────────── Learn path ───────────────────────────── */

.welcome {
  border: 1px solid var(--line);
  padding: 1rem;
  margin: 1rem 0 0.5rem;
  position: relative;
}
.welcome .close {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  background: none;
  border: 0;
  font-size: 1.2rem;
  width: 2.4rem;
  height: 2.4rem;
  color: var(--ink-soft);
}

.unit {
  margin: 1.25rem 0 2rem;
}
.unit-head {
  border: 1px solid var(--line);
  padding: 0.85rem 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  position: sticky;
  /* Overlap the top bar's border by 1px so nothing shows between them. */
  top: calc(var(--topbar-h) + var(--safe-t) - 1px);
  z-index: 5;
  background: var(--paper);
}
.unit-head.current {
  background: var(--blue);
  border-color: var(--blue-deep);
  color: var(--on-accent);
}
.unit-head.current .kicker {
  color: var(--on-accent);
  opacity: 0.85;
}
.unit-head .t {
  flex: 1 1 auto;
  min-width: 0;
}
.unit-head h2 {
  margin: 0.1rem 0 0.15rem;
}
.unit-head p {
  margin: 0;
  font-size: 0.85rem;
  opacity: 0.9;
}
.unit-head .guide-btn {
  flex: 0 0 auto;
  min-height: 2.6rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}
.unit-head.current .guide-btn {
  background: var(--blue);
  color: var(--on-accent);
  border-color: var(--on-accent);
  box-shadow: 0 3px 0 var(--blue-deep);
}

.path {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  /* Room for the bobbing START bubble above a unit's first lesson. */
  padding: 3.2rem 0 0.4rem;
}
.node-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.node {
  width: 4.6rem;
  height: 4.4rem;
  border-radius: 50%;
  border: 2px solid var(--blue-deep);
  background: var(--blue);
  color: var(--on-accent);
  font-weight: 800;
  font-size: 1.45rem;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 0 var(--blue-deep);
  margin-bottom: 6px;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.node:active {
  transform: translateY(6px);
  box-shadow: 0 0 0 var(--blue-deep);
}
.node.done {
  background: var(--paper);
  color: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 6px 0 var(--blue);
}
.node.done:active {
  box-shadow: 0 0 0 var(--blue);
}
.node.locked {
  background: var(--paper-2);
  color: var(--ink-faint);
  border: 2px dashed var(--line-soft);
  box-shadow: 0 6px 0 var(--line-soft);
}
.node.review {
  border-radius: 0;
  width: 4.4rem;
  font-size: 2.3rem;
}
.node.review:active {
  transform: translateY(6px);
}
.node-label {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  max-width: 9rem;
  text-align: center;
  line-height: 1.2;
}
/* The START bubble floats above the node; give it room so it never sits on
   the previous node's label. */
.node-wrap.current {
  margin-top: 1.4rem;
}
.path > .node-wrap.current:first-child {
  margin-top: 0;
}
.node-wrap.current::before {
  content: '';
  position: absolute;
  top: -7px;
  width: 5.6rem;
  height: 5.6rem;
  border-radius: 50%;
  border: 2px solid var(--blue);
  opacity: 0.45;
  animation: halo 2.2s ease-in-out infinite;
  pointer-events: none;
}
.node-wrap.current.is-review::before {
  border-radius: 0;
}
.start-bubble {
  position: absolute;
  top: -2.35rem;
  white-space: nowrap;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--blue);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.55rem;
  animation: bob 1.6s ease-in-out infinite;
  pointer-events: none;
}
.start-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 10px;
  height: 10px;
  background: var(--paper);
  border-right: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}
@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}
@keyframes halo {
  0%,
  100% {
    transform: scale(0.96);
    opacity: 0.25;
  }
  50% {
    transform: scale(1.06);
    opacity: 0.6;
  }
}

.popover {
  margin-top: 0.7rem;
  width: min(19rem, calc(100vw - 2rem));
  border: 2px solid var(--line);
  background: var(--paper);
  padding: 0.85rem;
  text-align: left;
  position: relative;
  z-index: 4;
  animation: pop 0.14s ease-out;
}
.popover::before {
  content: '';
  position: absolute;
  top: -8px;
  left: calc(50% + var(--arrow, 0px));
  width: 12px;
  height: 12px;
  background: var(--paper);
  border-left: 2px solid var(--line);
  border-top: 2px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}
.popover h3 {
  margin: 0 0 0.25rem;
  text-decoration: none;
  font-weight: 800;
}
.popover p {
  margin: 0 0 0.7rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
@keyframes pop {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
}

.course-end {
  text-align: center;
  color: var(--ink-soft);
  padding: 1rem 0 2rem;
  font-size: 0.85rem;
}

/* ───────────────────────────── Lesson screen ───────────────────────────── */

.lesson {
  position: fixed;
  inset: 0;
  /* Set from window.visualViewport while a lesson runs, so the on-screen
     keyboard shrinks the lesson instead of covering Check. */
  top: var(--vvt, 0px);
  bottom: auto;
  height: var(--vvh, 100%);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  z-index: 40;
}
.lesson-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: calc(0.7rem + var(--safe-t)) 1rem 0.7rem;
  max-width: var(--col);
  width: 100%;
  margin: 0 auto;
}
.icon-btn {
  width: 2.6rem;
  height: 2.6rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0;
}
.bar {
  flex: 1 1 auto;
  height: 0.95rem;
  border: 1.5px solid var(--line);
  background: var(--paper);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--blue);
  transition: width 0.35s ease;
}
.hearts {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--terra-ink);
  font-weight: 800;
  min-width: 2.6rem;
  justify-content: flex-end;
}
.hearts svg {
  width: 1.3rem;
  height: 1.3rem;
}
.hearts.hit {
  animation: shake 0.35s;
}
.hearts.infinite {
  color: var(--ink-faint);
}

.lesson-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.lesson-inner {
  max-width: var(--col);
  margin: 0 auto;
  padding: 0.5rem 1rem 1.5rem;
}
.ex-kicker {
  margin: 0.3rem 0 0.4rem;
}
.ex-kicker.again {
  color: var(--terra-ink);
}
.prompt {
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 0.9rem;
}
.prompt code {
  font-weight: 600;
}

.lesson-foot {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: var(--paper);
  padding: 0.9rem 1rem calc(0.9rem + var(--safe-b));
}
.lesson-foot .inner {
  max-width: var(--col);
  margin: 0 auto;
}

/* Feedback sheet: replaces the footer, slides up from the thumb. */
.feedback {
  border-top: 2px solid var(--blue);
  background: var(--blue-tint);
  animation: rise 0.18s ease-out;
  max-height: 66vh;
  max-height: 66dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* The text scrolls; Continue never leaves the screen. */
.feedback .inner {
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}
.feedback .fb-scroll {
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.feedback.wrong {
  border-top-color: var(--terra);
  background: var(--terra-tint);
}
.feedback h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.4rem;
  color: var(--blue-deep);
  font-size: 1.2rem;
}
:root[data-theme='dark'] .feedback h2,
:root[data-theme='dark'] .feedback .answer-label {
  color: var(--blue);
}
.feedback.wrong h2 {
  color: var(--terra-deep);
}
:root[data-theme='dark'] .feedback.wrong h2 {
  color: var(--terra);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .feedback h2 {
    color: var(--blue);
  }
  :root:not([data-theme='light']) .feedback.wrong h2 {
    color: var(--terra);
  }
}
.feedback .mark {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--blue);
  color: var(--on-accent);
  font-size: 1.05rem;
}
.feedback.wrong .mark {
  background: var(--terra);
}
.feedback .answer-label {
  font-weight: 700;
  margin: 0.4rem 0 0.2rem;
}
.feedback .explain {
  margin: 0.4rem 0 0.75rem;
  font-size: 0.92rem;
}
.feedback .code {
  background: var(--paper);
}
.feedback .links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
}
.feedback .links a {
  display: inline-block;
  padding: 0.55rem 0;
  color: var(--blue-ink);
}
.feedback .links a.report {
  color: var(--ink-soft);
}
.feedback .btn.primary {
  margin-top: 0.2rem;
}
.feedback.wrong .btn.primary {
  background: var(--terra-ink);
  border-color: var(--terra-deep);
  box-shadow: 0 var(--press) 0 var(--terra-deep);
}
.feedback.wrong .btn.primary:active {
  box-shadow: 0 0 0 var(--terra-deep);
}
@keyframes rise {
  from {
    transform: translateY(30%);
    opacity: 0.4;
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* ───────────────────────────── Code & goals ───────────────────────────── */

.code {
  display: block;
  margin: 0.6rem 0;
  padding: 0.7rem 0.8rem;
  background: var(--code-bg);
  border: 1px solid var(--line-soft);
  white-space: pre;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.55;
  tab-size: 2;
  -webkit-overflow-scrolling: touch;
}
@media (max-width: 360px) {
  .code {
    font-size: 0.8rem;
    padding: 0.6rem 0.65rem;
  }
}
.code .kw {
  font-weight: 700;
}
.code .tac {
  color: var(--blue-ink);
  font-weight: 600;
}
.code .com {
  color: var(--ink-soft);
  font-style: italic;
}
.code .str {
  color: var(--terra-ink);
}
.code .num {
  color: var(--terra-ink);
}
.code .sorry {
  color: var(--terra-ink);
  font-weight: 700;
}
.code .hl {
  background: var(--blue-tint);
  outline: 1px solid var(--blue);
  font-weight: 700;
}

.goal {
  margin: 0.6rem 0;
  border: 1px solid var(--line);
  font-size: 0.86rem;
}
.goal-head {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0.25rem 0.6rem;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--paper-2);
}
.goal pre {
  margin: 0;
  padding: 0.6rem 0.8rem;
  font-family: var(--font);
  white-space: pre;
  overflow-x: auto;
  line-height: 1.55;
}
.goal .hyp {
  color: var(--blue-ink);
  font-weight: 600;
}
.goal .ts {
  color: var(--blue-ink);
  font-weight: 800;
}
.goal .case {
  color: var(--ink-soft);
  font-style: italic;
}

/* ───────────────────────────── Exercises ───────────────────────────── */

.options {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin: 0.5rem 0 0;
}
.option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  min-height: 3.3rem;
  padding: 0.6rem 0.8rem;
  border: 2px solid var(--line-soft);
  background: var(--paper);
  box-shadow: 0 3px 0 var(--line-soft);
  margin-bottom: 3px;
  transition: transform 0.05s, box-shadow 0.05s, border-color 0.12s, background 0.12s;
}
.option:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--line-soft);
}
.option .key {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  border: 1.5px solid var(--line-soft);
  font-size: 0.75rem;
  color: var(--ink-soft);
}
.option .txt {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.option[aria-checked='true'] {
  border-color: var(--blue);
  background: var(--blue-tint);
  box-shadow: 0 3px 0 var(--blue);
}
.option[aria-checked='true'] .key {
  border-color: var(--blue);
  color: var(--blue-ink);
}
.option.is-right {
  border-color: var(--blue);
  background: var(--blue-tint);
  box-shadow: 0 3px 0 var(--blue);
}
.option.is-wrong {
  border-color: var(--terra);
  background: var(--terra-tint);
  box-shadow: 0 3px 0 var(--terra);
}
.locked-ui .option,
.locked-ui .tile,
.locked-ui .slot {
  pointer-events: none;
}

.tile {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.35rem 0.75rem;
  border: 2px solid var(--line-soft);
  background: var(--paper);
  box-shadow: 0 3px 0 var(--line-soft);
  margin-bottom: 3px;
  font-weight: 600;
  white-space: pre;
  transition: transform 0.05s, box-shadow 0.05s;
}
.tile:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--line-soft);
}
.tile.used {
  visibility: hidden;
}
.tile-ghost {
  display: inline-block;
  background: var(--paper-2);
}
.bank {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
  margin: 1rem 0 0;
}
.bank .slotwrap {
  background: var(--paper-2);
  display: inline-flex;
}

/* Blank: the gaps sit in the code itself. */
.code .slot {
  position: relative;
  display: inline-block;
  min-width: 4.5ch;
  min-height: 1.6em;
  vertical-align: middle;
  margin: 0.1em 0.1em;
  padding: 0 0.4ch;
  border: 0;
  border-bottom: 2px solid var(--ink-soft);
  background: var(--paper);
  font: inherit;
  font-weight: 700;
  color: var(--blue);
  line-height: 1.5;
}
.code .slot::after {
  content: '';
  position: absolute;
  inset: -8px -3px;
}
.code .slot.next {
  border-bottom-color: var(--blue);
  background: var(--blue-tint);
}
.code .slot.filled {
  border: 1.5px solid var(--blue);
  border-bottom-width: 3px;
}

/* Order (Parsons): the learner's proof grows in a ruled box. */
.given {
  margin-bottom: 0;
  border-bottom: 0;
}
.build {
  border: 2px dashed var(--line-soft);
  min-height: 7.5rem;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--paper);
}
.given + .build {
  border-top-style: solid;
}
.build:empty::before {
  content: 'Tap lines below to build the proof';
  color: var(--ink-faint);
  font-size: 0.85rem;
  padding: 0.6rem;
  text-align: center;
}
.build .tile,
.order-bank .tile {
  justify-content: flex-start;
  width: 100%;
  font-size: 0.86rem;
  min-height: 2.6rem;
  overflow-x: auto;
}
.order-bank {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}
.order-bank .tile.used {
  visibility: hidden;
}

/* Match */
.match {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.match .col {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.match .tile {
  width: 100%;
  justify-content: center;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  min-height: 3.2rem;
}
.match .tile[aria-pressed='true'] {
  border-color: var(--blue);
  background: var(--blue-tint);
  box-shadow: 0 3px 0 var(--blue);
}
.match .tile.ok {
  border-color: var(--line-soft);
  color: var(--ink-faint);
  box-shadow: none;
  background: var(--paper-2);
  transform: translateY(3px);
  pointer-events: none;
}
.match .tile.ok code {
  background: transparent;
}
.match .tile.bad {
  border-color: var(--terra);
  background: var(--terra-tint);
  animation: shake 0.3s;
}

/* Type */
.type-in {
  width: 100%;
  min-height: 3.2rem;
  padding: 0.6rem 0.8rem;
  border: 2px solid var(--line);
  background: var(--paper);
  font-family: var(--font);
  /* 16px or more: iOS Safari zooms the page into any smaller input on focus. */
  font-size: max(16px, 1rem);
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}
.type-in:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-tint);
}
.symbar {
  /* One scrolling row, like a keyboard's accessory bar: with the phone
     keyboard up there is no room for four rows of symbols. */
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 0.35rem;
  margin: 0.6rem -1rem 0;
  padding: 0 1rem 5px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.symbar::-webkit-scrollbar {
  display: none;
}
.symbar button {
  flex: 0 0 auto;
  min-width: 2.6rem;
  height: 2.5rem;
  border: 1.5px solid var(--line-soft);
  background: var(--paper);
  box-shadow: 0 2px 0 var(--line-soft);
  font-size: 1rem;
  padding: 0 0.3rem;
}
.symbar button:active {
  transform: translateY(2px);
  box-shadow: none;
}
.hint {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.5rem;
}

/* Learn card */
.learn h1 {
  margin: 0.3rem 0 0.6rem;
}
.learn .md {
  font-size: 1rem;
}

/* ───────────────────────────── End screens ───────────────────────────── */

.done-screen {
  text-align: center;
  padding-top: 2rem;
}
.done-screen .qed {
  font-size: 4.5rem;
  line-height: 1;
  color: var(--blue);
  animation: qed 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.done-screen.failed .qed {
  color: var(--terra);
}
.done-screen h1 {
  font-size: 1.5rem;
  margin: 0.8rem 0 0.3rem;
}
@keyframes qed {
  from {
    transform: scale(0.2) rotate(-30deg);
    opacity: 0;
  }
}
.tiles3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin: 1.5rem 0;
}
.tiles3 > div {
  border: 2px solid var(--line);
  text-align: center;
}
.tiles3 .lbl {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 800;
  padding: 0.25rem;
  background: var(--ink);
  color: var(--paper);
}
.tiles3 .val {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  padding: 0.55rem 0.2rem;
}
.tiles3 .xp .lbl {
  background: var(--blue);
  color: var(--on-accent);
}
.tiles3 .xp {
  border-color: var(--blue);
  color: var(--blue);
}
.streak-note {
  color: var(--terra-ink);
  font-weight: 700;
}

/* ───────────────────────────── Other tabs ───────────────────────────── */

.page-title {
  margin: 1.1rem 0 0.4rem;
  font-size: 1.3rem;
}
.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 1rem 0;
}

.search {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 2px solid var(--line);
  background: var(--paper);
  font-size: max(16px, 1rem);
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  margin: 0.5rem 0 0.25rem;
}
.cheat {
  border-top: 1px solid var(--line-soft);
  padding: 0.7rem 0;
}
.cheat:first-of-type {
  border-top: 0;
}
.cheat .name {
  font-weight: 800;
  /* Mathlib names such as tendsto_one_div_add_atTop_nhds_zero_nat have no break
     points; let them wrap rather than push the page sideways on a narrow phone. */
  overflow-wrap: anywhere;
}
.cheat .use {
  display: block;
  margin: 0.3rem 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}
.cheat p {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
}
.abbr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.2rem, 1fr));
  gap: 0.3rem 0.8rem;
  font-size: 0.9rem;
}
.abbr-grid span b {
  display: inline-block;
  min-width: 1.4em;
  color: var(--blue);
}

.statgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin: 0.9rem 0;
}
.statgrid > div {
  border: 1px solid var(--line);
  padding: 0.6rem 0.75rem;
}
.statgrid b {
  display: block;
  font-size: 1.35rem;
}
.statgrid span {
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.4rem;
  align-items: end;
  height: 7rem;
  margin: 0.8rem 0 0.2rem;
  position: relative;
}
.week .col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 0.2rem;
}
.week .b {
  width: 100%;
  max-width: 2rem;
  background: var(--blue);
  min-height: 2px;
}
.week .b.zero {
  background: var(--line-soft);
}
.week .v {
  font-size: 0.68rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.week .d {
  font-size: 0.7rem;
  color: var(--ink-soft);
}
.week .col.today .d {
  color: var(--ink);
  font-weight: 800;
}
.week .goal-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1.5px dashed var(--terra);
  pointer-events: none;
}
.seg {
  display: flex;
  border: 2px solid var(--line);
  margin: 0.4rem 0 0.2rem;
}
.seg button {
  flex: 1 1 0;
  min-height: 2.6rem;
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--paper);
  font-size: 0.82rem;
  padding: 0.2rem;
}
.seg button:first-child {
  border-left: 0;
}
.seg button[aria-pressed='true'] {
  background: var(--blue);
  color: var(--on-accent);
  font-weight: 700;
}
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line-soft);
}
.toggle:first-of-type {
  border-top: 0;
}
.toggle small {
  display: block;
  color: var(--ink-soft);
  font-size: 0.78rem;
}
.switch {
  flex: 0 0 auto;
  width: 3.3rem;
  height: 1.9rem;
  border: 2px solid var(--line);
  background: var(--paper-2);
  position: relative;
  padding: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.35rem;
  height: 1.35rem;
  background: var(--ink-soft);
  transition: transform 0.15s ease;
}
.switch[aria-checked='true'] {
  background: var(--blue);
  border-color: var(--blue-deep);
}
.switch[aria-checked='true']::after {
  background: var(--on-accent);
  transform: translateX(1.4rem);
}
.name-in {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--line);
  background: var(--paper);
  font-size: max(16px, 1rem);
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}
textarea.name-in {
  min-height: 5rem;
}

.guide-sec {
  margin: 1.2rem 0;
}
.guide-sec h2 {
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.3rem;
}
.back {
  display: inline-block;
  margin: 0.9rem 0 0;
  font-weight: 700;
}

/* ───────────────────────────── Sheets & toast ───────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.15s ease-out;
}
.sheet {
  width: 100%;
  max-width: var(--col);
  background: var(--paper);
  border-top: 2px solid var(--line);
  padding: 1.1rem 1rem calc(1rem + var(--safe-b));
  animation: rise 0.18s ease-out;
}
@media (min-width: 600px) {
  .scrim {
    align-items: center;
  }
  .sheet {
    border: 2px solid var(--line);
  }
}
.sheet h2 {
  margin: 0 0 0.4rem;
}
.sheet .row {
  margin-top: 1rem;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 1rem);
  transform: translateX(-50%) translateY(1rem);
  z-index: 70;
  background: var(--ink);
  color: var(--paper);
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100vw - 2rem);
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

/* Storage-blocked warning on the Learn tab. */
.box.warn {
  border-color: var(--terra);
  background: var(--terra-tint);
  font-size: 0.9rem;
}

/* ───────────────────────────── Account & class ───────────────────────────── */

/* Sheets can hold more than a screen (a student's summary in the class view). */
.sheet {
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.acct-form {
  margin: 1rem 0 0.6rem;
}
.field {
  margin: 0 0 0.85rem;
}
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}
.field input[readonly] {
  background: var(--paper-2);
  color: var(--ink-soft);
}
.show-pw {
  margin: -0.4rem 0 0.4rem -0.8rem;
}
.form-msg {
  color: var(--terra-ink);
  font-size: 0.9rem;
  margin: 0.2rem 0 0.8rem;
}
.form-msg.good {
  color: var(--blue-ink);
}
.form-msg:empty {
  margin: 0; /* kept in the page, so the alert region exists before a message */
}
.fine {
  font-size: 0.8rem;
  margin: 0.9rem 0;
}
.acct-email {
  overflow-wrap: anywhere;
}
.acct-id {
  font-size: 0.78rem;
  margin: 0.9rem 0 0.1rem;
}
.acct-id code {
  word-break: break-all;
}

.class-bar {
  justify-content: space-between;
  margin: 0.2rem 0 0.8rem;
  font-size: 0.85rem;
}
.class-bar > .btn {
  flex: 0 0 auto;
}
.class-list {
  display: grid;
  gap: 0.6rem;
}
.student {
  display: grid;
  gap: 0.35rem;
  width: 100%;
  text-align: left;
  padding: 0.75rem 0.85rem;
  border: 2px solid var(--line);
  background: var(--paper);
  box-shadow: 0 var(--press) 0 var(--line);
  margin-bottom: var(--press);
}
.student:active {
  transform: translateY(var(--press));
  box-shadow: none;
}
.st-top {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: baseline;
}
.st-top strong {
  overflow-wrap: anywhere;
}
.st-top .muted {
  font-size: 0.8rem;
  flex: 0 0 auto;
}
.st-bar {
  display: block;
  height: 0.5rem;
  background: var(--paper-2);
  border: 1px solid var(--line-soft);
}
.st-bar > span {
  display: block;
  height: 100%;
  background: var(--blue);
}
.st-meta {
  font-size: 0.8rem;
}
.hard {
  margin: 0.6rem 0 0;
  padding-left: 1.3rem;
}
.hard li {
  margin: 0 0 0.85rem;
}
.hard .md {
  margin: 0.15rem 0;
  overflow-wrap: anywhere;
}
.hard small {
  font-size: 0.78rem;
}
.summary {
  white-space: pre-wrap;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0.3rem 0 0.6rem;
  overflow-wrap: anywhere;
}
.student-sheet h3 {
  margin-top: 0.8rem;
}

/* Classes: the code students type, big enough to read out in a room. */
.class-code {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  margin: 0.3rem 0 0.4rem;
  color: var(--blue-ink);
}
.class-card h2 {
  margin: 0.2rem 0 0;
}
.class-bar .btn + .btn {
  margin-left: 0;
}
.class-head {
  margin: 1.4rem 0 0.6rem;
}
.code-in {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.code-in::placeholder {
  text-transform: none;
  letter-spacing: normal;
}
.acct-class {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

/* ───────────────────────────── December ───────────────────────────── */

/* From 1 to 31 December (app.js, applySeason) the app turns snowy:
   snow behind the Learn path, snow on the lesson circles, an ice crystal by the
   name, and the December calendar. Secular on purpose: no reds and greens, just
   the site's blue as frost. */
:root {
  --snow: #a7bfd6;
  --snow-alpha: 0.85;
  --frost: #eef4f9;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --snow: #dbe5ee;
    --snow-alpha: 0.55;
    --frost: #16202a;
  }
}
:root[data-theme='dark'] {
  --snow: #dbe5ee;
  --snow-alpha: 0.55;
  --frost: #16202a;
}

/* The snow layer sits under everything (z-index −1 in the root stacking
   context), so the body must not paint over it; html keeps the paper colour.
   Cards and headers stay opaque, so snow shows only between them. */
body.december {
  background: transparent;
}
.snow {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  display: none;
}
body[data-view='learn'] .snow {
  display: block;
}
body.in-lesson .snow {
  display: none;
}
.snow i {
  position: absolute;
  top: -12px;
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: var(--snow);
  opacity: var(--snow-alpha);
  animation: snowfall var(--t) linear var(--d) infinite;
  will-change: transform;
}
@keyframes snowfall {
  to {
    transform: translate3d(var(--w), calc(100vh + 24px), 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .snow,
  body[data-view] .snow {
    display: none;
  }
}
body.december .welcome {
  background: var(--paper);
}

/* Snow on every lesson circle, and a flat layer on the square review nodes. */
body.december .node {
  position: relative;
}
body.december .node::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -6px;
  width: 3.7rem;
  height: 1.35rem;
  transform: translateX(-50%);
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 22'%3E%3Cpath d='M3 13.5C3 6 15 1.2 32 1.2S61 6 61 13.5c0 2.4-2.6 3-3.8 1.1-.9 3.8-5.6 4-6.4.5-1.5 1.9-4.5 1.8-5.4-.3-1.2 5.2-6.8 5.4-7.8.3-1.8 1.7-5.3 1.7-6.9-.1-1.1 3.6-5.6 3.8-6.8.3-1.4 1.6-4.4 1.6-5.6-.2-1.1 2.8-5 2.8-6.1.1C5.6 16.2 3 15.8 3 13.5z' fill='%23fbfdff' stroke='%2393abc2' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E")
    center top / 100% 100% no-repeat;
}
body.december .node.review::before {
  top: -7px;
  width: calc(100% + 6px);
  height: 1.05rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 16' preserveAspectRatio='none'%3E%3Cpath d='M1.5 6C1.5 2.5 3 1.2 6 1.2h52c3 0 4.5 1.3 4.5 4.8v2.6c0 2.2-2.7 2.6-3.6.9-1 3.4-5.4 3.6-6.2.3-1.6 1.6-4.4 1.6-5.4-.2-1.2 4.4-6.6 4.6-7.6.2-1.8 1.4-5.2 1.4-6.8 0-1.2 3-5.6 3.2-6.8.2-1.4 1.4-4.3 1.4-5.5-.2-1.1 2.4-4.9 2.4-6-.1-1.4 1.4-4.2 1-4.2-1.2z' fill='%23fbfdff' stroke='%2393abc2' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* The ice crystal after the name: a link to the calendar, with a dot while
   today's door is closed. The negative margins keep a 44px target without
   widening the top bar. */
.dec-link {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  margin: 0 -0.7rem 0 -0.55rem;
  color: var(--blue);
}
a.dec-link:hover {
  border-bottom: 0;
  color: var(--blue-deep);
}
.dec-link .flake {
  width: 1.05rem;
  height: 1.05rem;
}
.dec-link .dot {
  display: none;
  position: absolute;
  top: 9px;
  right: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--terra);
  box-shadow: 0 0 0 2px var(--paper);
}
.dec-link.waiting .dot {
  display: block;
}
.dec-link.waiting .flake {
  animation: twirl 5s linear infinite;
}
body.in-lesson .dec-link {
  display: none;
}
/* At 320px a long streak and five-digit XP would push the bar off the screen
   once the crystal is there; tighten it below 375px. */
@media (max-width: 374px) {
  body.december .topbar {
    gap: 0.35rem;
  }
  body.december .stats {
    gap: 0.5rem;
  }
  body.december .brand {
    font-size: 0.86rem;
  }
  .dec-link {
    margin: 0 -0.8rem 0 -0.75rem;
  }
  /* Doors are too small for a knob beside a two-digit number. */
  .door::before {
    display: none;
  }
}

/* The card at the top of the Learn tab. */
.dec-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1rem 0 calc(0.5rem + var(--press));
  padding: 0.85rem 1rem;
  border: 2px solid var(--line);
  background: var(--frost);
  color: var(--ink);
  box-shadow: 0 var(--press) 0 var(--line);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
a.dec-card:hover {
  color: var(--ink);
  border-bottom: 2px solid var(--line);
}
.dec-card:active {
  transform: translateY(var(--press));
  box-shadow: 0 0 0 var(--line);
}
.dec-card.fresh,
a.dec-card.fresh:hover {
  border-color: var(--blue-deep);
  box-shadow: 0 var(--press) 0 var(--blue-deep);
}
.dec-card.fresh:active {
  box-shadow: 0 0 0 var(--blue-deep);
}
.dec-card .flake {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  color: var(--blue);
}
/* Six-fold symmetric, so a turn of 60° loops without a jump. */
.dec-card.fresh .flake {
  animation: twirl 5s linear infinite;
}
@keyframes twirl {
  to {
    transform: rotate(60deg);
  }
}
.dec-card .t {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.dec-card strong {
  font-size: 1.02rem;
}
.dec-card small {
  color: var(--ink-soft);
  font-size: 0.8rem;
}
.dec-card .go {
  flex: none;
  font-weight: 800;
  font-size: 1.2rem;
}

/* The calendar: 31 doors scattered over a 5 × 7 grid. */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 1rem 0 0.6rem;
  padding: 0.6rem 0.6rem calc(0.6rem - 3px);
  border: 2px solid var(--line);
  /* A light fall of snow on frost. */
  background:
    radial-gradient(circle, var(--snow) 0.8px, transparent 1.3px) 3px 5px / 23px 19px,
    radial-gradient(circle, var(--snow) 1.1px, transparent 1.6px) 13px 2px / 31px 37px,
    var(--frost);
}
.door {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-bottom: 3px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-weight: 800;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 0 var(--line);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
/* A knob, so a door looks like a door. */
.door::before {
  content: '';
  position: absolute;
  right: 7%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin-top: -2px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}
.door.open::before {
  display: none;
}
.door:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--line);
}
.door .flake {
  display: none;
}
.door.today {
  background: var(--blue);
  color: var(--on-accent);
  border-color: var(--blue-deep);
  box-shadow: 0 3px 0 var(--blue-deep);
}
.door.ready.today {
  animation: knock 2.2s ease-in-out infinite;
}
@keyframes knock {
  50% {
    box-shadow: 0 3px 0 var(--blue-deep), 0 0 0 5px var(--blue-tint);
  }
}
.door.shut {
  border-style: dashed;
  border-color: var(--line-soft);
  background: var(--paper-2);
  color: var(--ink-faint);
  box-shadow: 0 3px 0 var(--line-soft);
}
.door.open {
  background: var(--blue-tint);
  color: var(--blue-ink);
  border-color: var(--blue);
  box-shadow: 0 3px 0 var(--blue);
}
.door.open .num {
  font-size: 0.85rem;
  line-height: 1;
}
.door.open .flake {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.2rem;
}
/* On first opening, the closed face (copied by app.js into --face*) swings
   away on its hinge, revealing the open door beneath. */
.door.opening::after {
  content: attr(data-n);
  position: absolute;
  inset: -2px;
  display: grid;
  place-items: center;
  border: 2px solid var(--face-line);
  background: var(--face);
  color: var(--face-ink);
  font-size: 1.15rem;
  transform-origin: left center;
  animation: swing 0.48s ease-in forwards;
}
@keyframes swing {
  to {
    transform: perspective(420px) rotateY(-110deg);
    opacity: 0;
  }
}
.cal-deco {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
}
.cal-deco .koch {
  width: 74%;
  height: 74%;
  fill: none;
  stroke: var(--blue);
  stroke-width: 0.05;
  stroke-linejoin: round;
}
.cal-foot {
  font-size: 0.78rem;
  margin: 0.4rem 0 2rem;
}
.door-kicker {
  display: block;
  margin: -0.1rem 0 0.7rem;
}
.door-link {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
}
