/* Design 1 · Ryokan study
   A contained tatami room set into a warm plaster wall, framed in substantial
   hinoki: a deep lintel, two square posts and a sill. The navigation is
   written on the plaster outside the room, small and quiet; the room itself
   holds only the board or a page. The mats keep their true proportions
   (half-mat units square) wherever the window allows. */

.d-study {
  --plaster: #d8c8aa;
  --ink: #2a2017;
  --ink-2: #4b3c31;
  --vermilion: #9a4a33;
  --margin: clamp(12px, 6vw, 110px);
  --head-h: clamp(64px, 10vh, 96px);
  --foot-h: clamp(64px, 10vh, 96px);
  --lintel: 46px;
  --post: 32px;
  --sill: 26px;
  --max-ratio: 1.667;  /* width / height of the floor: 5:3, half-mat units square */
  color: var(--ink);
  font-family: var(--serif);
  background-color: var(--plaster);
  /* warm clay plaster: a fine sand grain and a faint trowelled unevenness,
     both static and drawn once */
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='s'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.36 0 0 0 0 0.28 0 0 0 0 0.18 0 0 0 0.5 -0.18'/></filter><rect width='100%' height='100%' filter='url(%23s)'/></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='640' height='640'><filter id='t'><feTurbulence type='fractalNoise' baseFrequency='0.006 0.01' numOctaves='3' seed='8' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.42 0 0 0 0 0.33 0 0 0 0 0.22 0 0 0 0.22 -0.06'/></filter><rect width='100%' height='100%' filter='url(%23t)'/></svg>"),
    radial-gradient(ellipse 80% 70% at 30% 20%, rgba(255, 246, 228, 0.35), transparent 70%);
}

.d-study .app {
  container-type: inline-size;
  min-height: var(--vh);
  display: grid;
  grid-template-rows: var(--head-h) auto var(--foot-h);
  align-content: center;
}

/* ---------- Header: the name and three places, on the plaster ---------- */
.st-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 var(--margin);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 44px;
  padding: 0 6px 0 0;
  text-decoration: none;
  color: var(--ink);
  border-radius: 2px;
  -webkit-tap-highlight-color: transparent;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 2px;
  background: var(--vermilion);
  color: #f6ecdd;
  font-family: var(--serif);
}
.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand-mark text { fill: currentColor; font-size: 15px; }
.brand-name { font-size: 18px; letter-spacing: 0.28em; }

.st-nav { display: flex; gap: clamp(4px, 1.6vw, 22px); }
.st-nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  font-size: 15px;
  letter-spacing: 0.14em;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: 2px;
  -webkit-tap-highlight-color: transparent;
}
.st-nav a:hover { color: var(--ink); }
.st-nav a[aria-current="page"] { color: var(--ink); }
.st-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: calc(10px + 0.14em);
  bottom: 8px;
  height: 1.5px;
  background: var(--vermilion);
}

.d-study :focus-visible { outline: 2px solid #6b3a26; outline-offset: 3px; }

/* ---------- The room ---------- */
.st-room {
  --avail-w: calc(100cqw - 2 * var(--margin) - 2 * var(--post));
  --avail-h: calc(var(--vh) - var(--head-h) - var(--foot-h) - var(--lintel) - var(--sill));
  display: grid;
  justify-items: center;
  padding: 0 var(--margin);
  min-width: 0;
}

.st-frame {
  position: relative;
  padding: var(--lintel) var(--post) var(--sill);
  /* a narrow shadowed reveal (chiri) where the plaster meets the timber */
  box-shadow: 0 0 0 1px rgba(60, 40, 24, 0.28), 0 0 0 4px rgba(120, 96, 66, 0.16), 0 18px 40px -24px rgba(40, 26, 14, 0.55);
}

.tatami {
  --tat-w: min(var(--avail-w), calc(var(--avail-h) * var(--max-ratio)));
  --tat-h: min(var(--avail-h), calc(var(--tat-w) * 3 / 5));
  --unit: calc((var(--tat-w) / 5 + var(--tat-h) / 3) / 2);  /* mean half-mat side, 0.91 m */
  --pad-x: clamp(12px, calc(var(--tat-w) * 0.05), 64px);
  --pad-y: clamp(10px, calc(var(--tat-h) * 0.05), 40px);
}

/* Hinoki timber: the owner's planks, shown at their real size against the
   mats (a plank is about 145 mm, a half-mat 910 mm), warmed and gently
   shaded so each member reads as a rounded square section. Nothing of it
   falls on the mats: the frame is drawn round them, not over them. */
.st-timber {
  --plank: calc(var(--unit) * 145 / 910);
  --tint: rgb(226, 184, 132);
  position: absolute;
  pointer-events: none;
  background:
    linear-gradient(var(--shade-dir, 180deg), rgba(255, 236, 205, 0.16), rgba(40, 22, 10, 0.04) 40%, rgba(30, 16, 6, 0.3)),
    linear-gradient(var(--tint), var(--tint)),
    url("../core/assets/hinoki-planks-1536.webp") 0 var(--plank-y, 0) / calc(var(--plank) * 13) calc(var(--plank) * 13) repeat;
  background-blend-mode: normal, multiply, normal;
}
@media (max-width: 860px) {
  .st-timber { background-image:
    linear-gradient(var(--shade-dir, 180deg), rgba(255, 236, 205, 0.16), rgba(40, 22, 10, 0.04) 40%, rgba(30, 16, 6, 0.3)),
    linear-gradient(var(--tint), var(--tint)),
    url("../core/assets/hinoki-planks-1024.webp"); }
}

/* lintel and sill run between the posts; one plank each, centred on it */
.st-lintel, .st-sill { left: var(--post); right: var(--post); }
.st-lintel {
  top: 0;
  height: var(--lintel);
  --plank: calc(var(--lintel) * 1.12);
  --plank-y: calc(var(--plank) * -3 - (var(--plank) - var(--lintel)) / 2);
  box-shadow: inset 0 -1px 0 rgba(30, 16, 6, 0.45), inset 0 1px 0 rgba(255, 236, 205, 0.18);
}
.st-sill {
  bottom: 0;
  height: var(--sill);
  --plank: calc(var(--sill) * 1.2);
  --plank-y: calc(var(--plank) * -8 - (var(--plank) - var(--sill)) / 2);
  --tint: rgb(214, 170, 120);
  box-shadow: inset 0 1px 0 rgba(255, 236, 205, 0.22), inset 0 -1px 0 rgba(30, 16, 6, 0.4);
}
/* posts: one upright plank, the full height of the opening */
.st-post {
  top: 0;
  bottom: 0;
  width: var(--post);
  --shade-dir: 90deg;
  background:
    linear-gradient(90deg, rgba(255, 236, 205, 0.12), rgba(40, 22, 10, 0.02) 35%, rgba(30, 16, 6, 0.34)),
    linear-gradient(rgb(218, 174, 124), rgb(218, 174, 124)),
    url("../core/assets/hinoki-post.webp") 50% 0 / var(--post) calc(var(--post) * 15.36) repeat-y;
  background-blend-mode: normal, multiply, normal;
  box-shadow: inset 1px 0 0 rgba(255, 236, 205, 0.16), inset -1px 0 0 rgba(30, 16, 6, 0.4);
}
.st-post-l { left: 0; }
.st-post-r { right: 0; transform: scaleX(-1); }

/* ---------- Footer: where you are, and the board's two tools ---------- */
.st-foot {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 var(--margin);
}
.st-where { margin: 0; font-size: 13px; letter-spacing: 0.12em; color: var(--ink-2); }
.st-where [data-title] { color: var(--ink); }
.st-version { margin: 0; justify-self: end; font-family: var(--sans); font-size: 11px; letter-spacing: 0.08em; color: var(--ink-2); }
.st-tools { display: flex; gap: 10px; justify-content: center; }
.d-study:not([data-work="board"]) .st-tools,
.d-study:not([data-view="work"]) .st-tools { visibility: hidden; }

.st-btn, .st-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid rgba(42, 32, 23, 0.55);
  border-radius: 2px;
  background: rgba(246, 238, 224, 0.4);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.12em;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 160ms, border-color 160ms;
}
.st-btn:hover, .st-button:hover { background: rgba(250, 244, 233, 0.75); border-color: var(--ink); }
.st-btn:active { transform: translateY(1px); }
.st-btn-quiet { border-color: transparent; background: transparent; }

/* ---------- Chooser: two paper cards on the mats ---------- */
.chooser { display: flex; flex-direction: column; align-items: center; gap: clamp(14px, 3vh, 28px); }
.st-chooser-title { /* the footer already says it; kept for screen readers */
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.choices { gap: clamp(14px, 2.4vw, 32px); }
.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: clamp(220px, 22vw, 300px);
  padding: 26px 20px 22px;
  border: 1px solid rgba(90, 66, 44, 0.35);
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.5), rgba(255, 252, 245, 0) 40%),
    #efe6d4;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 14px 30px -16px rgba(0, 0, 0, 0.7);
  color: var(--ink);
  transition: transform 180ms, box-shadow 180ms, border-color 180ms;
}
.choice:hover, .choice:focus-visible { transform: translateY(-2px); border-color: rgba(154, 74, 51, 0.7); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 20px 36px -18px rgba(0, 0, 0, 0.75); }
.choice:focus-visible { outline: 2px solid #6b3a26; outline-offset: 3px; }
.choice-art { height: 76px; margin-bottom: 6px; }
.choice-art svg { height: 58px; max-width: 100%; }
.choice-art .art-frame { fill: rgba(70, 48, 28, 0.08); stroke: #8b6a49; }
.choice-art .art-beam { stroke: #8b6a49; }
.choice-art line:not(.art-beam) { stroke: rgba(110, 86, 62, 0.6); }
.choice-art rect:not(.art-frame) { fill: #6e4f37; }
.choice-name { font-size: 18px; letter-spacing: 0.12em; }
.choice-meta { font-family: var(--sans); font-size: 12.5px; letter-spacing: 0.06em; color: var(--ink-2); }

/* ---------- Pages on the mats: a sheet of washi ---------- */
.st-page { align-self: center; justify-self: center; width: min(860px, 100%); padding: var(--pad-y) var(--pad-x); }
.st-paper {
  padding: 26px clamp(18px, 4vw, 40px) 30px;
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.6), rgba(255, 253, 248, 0) 30%),
    #f1e9d9;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 20px 44px -22px rgba(0, 0, 0, 0.75);
}
.st-page-title { margin: 0 0 14px; font-weight: 400; font-size: 22px; letter-spacing: 0.22em; }
.st-note { margin: 0 0 18px; max-width: 46em; font-size: 15px; line-height: 1.7; color: var(--ink-2); }
.lessons .lesson-list { margin: 0 0 22px; border-top: 1px solid rgba(60, 42, 28, 0.22); }
.lessons .lesson { padding: 14px 2px; border-bottom: 1px solid rgba(60, 42, 28, 0.22); font-size: 16px; letter-spacing: 0.08em; }
.lessons .lesson-state { font-family: var(--sans); font-size: 12px; letter-spacing: 0.1em; color: var(--ink-2); }
.st-button { border-color: rgba(42, 32, 23, 0.45); }


/* ---------- Tablet and phone ---------- */
@media (orientation: portrait) {
  .tatami {
    --tat-w: min(var(--avail-w), calc(var(--avail-h) * 0.78));
    --tat-h: min(var(--avail-h), calc(var(--tat-w) * 5 / 3));
    --unit: calc((var(--tat-w) / 3 + var(--tat-h) / 5) / 2);
  }
}
@media (max-width: 860px) {
  .d-study { --head-h: 64px; --foot-h: 68px; --lintel: 24px; --post: 14px; --sill: 14px; }
}
@media (max-width: 640px) {
  .d-study { --margin: 6px; --head-h: 54px; --foot-h: 62px; --lintel: 14px; --post: 8px; --sill: 9px; }
  .tatami { --pad-x: 8px; --pad-y: 12px; }
  .st-head { padding: 0 6px 0 10px; }
  .brand { gap: 10px; }
  .brand-name { font-size: 15px; letter-spacing: 0.2em; }
  .st-nav { gap: 0; }
  .st-nav a { padding: 0 9px; font-size: 14px; letter-spacing: 0.08em; }
  .st-nav a[aria-current="page"]::after { left: 9px; right: calc(9px + 0.08em); }
  .st-foot { grid-template-columns: 1fr auto; padding: 0 10px; }
  .st-where { display: none; }
  .st-tools { justify-content: flex-start; }
  .st-btn { padding: 0 14px; font-size: 13.5px; letter-spacing: 0.08em; }
  .choices { flex-direction: column; align-items: stretch; width: min(320px, 100%); }
  .choice { width: auto; padding: 16px 14px; }
  .choice-art { height: 58px; }
  .choice-art svg { height: 46px; }
  .st-page { padding: 10px 8px; }
  .st-paper { padding: 18px 14px 20px; }
}
@media (max-width: 380px) {
  .brand-name { display: none; }
}
/* phones on their side: a slim header and footer, the floor as wide as the screen */
@media (orientation: landscape) and (max-height: 500px) {
  .d-study { --head-h: 48px; --foot-h: 52px; --lintel: 10px; --post: 8px; --sill: 8px; --margin: 8px; }
  .tatami { --tat-w: var(--avail-w); --tat-h: var(--avail-h); --pad-x: 12px; --pad-y: 8px; }
  .choices { flex-wrap: nowrap; }
  .choice { width: 220px; padding: 12px 14px; }
  .choice-art { height: 46px; margin-bottom: 0; }
  .choice-art svg { height: 38px; }
  .st-foot { grid-template-columns: 1fr auto; }
  .st-where { display: none; }
}
/* the full board never goes below 18px rods: on the narrowest phones the
   room widens to hold it and the page scrolls sideways a little */
.d-study[data-rods="17"][data-work="board"][data-view="work"] .tatami { min-width: calc(326.2px + 2 * var(--pad-x)); }
.stage[data-rods="17"] { min-width: 326.2px; }

@media (prefers-reduced-motion: reduce) {
  .choice, .st-btn, .st-button { transition: none; }
  .choice:hover, .choice:focus-visible { transform: none; }
}

/* ======================================================================
   UI refinements (2026-10-28, owner-approved): softer rounded panels and
   buttons, slightly larger and firmer page text, and Settings laid out
   compactly inside the very box the board uses. Page controls and text
   only: the board, its beads, the mats and the timber are untouched.
   ====================================================================== */

/* One tatami footprint for Board, Lessons and Settings. While a page is
   open, whatever the room was showing (the board or the chooser) stays in
   the layout, invisible and inert, so the floor keeps exactly its size and
   place; the page lies over the floor and never sizes it. */
.d-study[data-work="board"]:not([data-view="work"]) .stage[hidden],
.d-study[data-work="chooser"]:not([data-view="work"]) .chooser[hidden] {
  display: flex !important;
  visibility: hidden;
}
.d-study[data-rods="17"][data-work="board"] .tatami { min-width: calc(326.2px + 2 * var(--pad-x)); }
.d-study .st-page {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: auto;
  align-self: stretch;
  justify-self: stretch;
  display: grid;
  place-items: center;
  overflow: auto; /* only if a page truly cannot fit; nothing is clipped */
  overscroll-behavior: contain;
}
/* the full board on the narrowest phones widens the floor past the window
   (and the page scrolls sideways to it); a page keeps to the floor's usual
   width, which is the part of it on screen */
.d-study[data-rods="17"][data-work="board"] .st-page { right: auto; width: var(--tat-w); }

/* ---------- Rounded, slightly translucent panels on the mats ---------- */
.d-study .st-paper {
  width: min(860px, 100%);
  max-height: 100%;
  overflow: auto;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.5), rgba(255, 253, 248, 0) 30%),
    rgba(241, 233, 217, 0.92);
}
.d-study .choice {
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 252, 245, 0.45), rgba(255, 252, 245, 0) 40%),
    rgba(239, 230, 212, 0.88);
}

/* ---------- Rounded buttons ---------- */
.st-btn, .st-button { border-radius: 12px; }
.st-btn-quiet { border-radius: 12px; }
.st-nav a, .brand { border-radius: 10px; }

/* ---------- Slightly larger, firmer page text (not the board) ---------- */
.brand-name { font-size: 19px; font-weight: 500; }
.st-nav a { font-size: 16px; font-weight: 500; }
.st-where { font-size: 14px; font-weight: 500; }
.st-version { font-size: 12px; font-weight: 500; }
.st-btn, .st-button { font-size: 15px; font-weight: 500; }
.choice-name { font-size: 19px; font-weight: 500; }
.choice-meta { font-size: 13.5px; font-weight: 500; }

/* ---------- Pages: Settings and Lessons (simplified 2026-10-29, owner-approved) ----------
   Two small sheets of washi, each sized to its contents and centred on the
   floor; the floor itself never changes (see above). Plain, readable text:
   a modest centred title, then the content.
   Settings: for each board its name, then two lines, Bead shape and Bead
   colour, each a pair of named options (radio buttons drawn as pills with a
   radio dot). The chosen pill has a filled vermilion dot, a vermilion edge
   and a warm hinoki ground; keyboard focus adds the page's dark ring; every
   pill is a 44px target. Each label sits beside its pair, above it on
   phones; on a short wide floor (a phone on its side) the two boards sit
   side by side. The page is a size container (the floor
   less its margins). */
.d-study .st-page { container-type: size; }
.d-study .settings-panel,
.d-study .lessons .st-paper { width: auto; max-width: 100%; padding: 18px 22px 20px; }
.settings .settings-title.st-page-title,
.lessons .st-page-title { margin: 0 0 12px; font-size: 19px; font-weight: 500; letter-spacing: 0.2em; text-align: center; }

.settings .settings-body { display: flex; flex-direction: column; gap: 16px; }
.settings .setting-group { display: grid; grid-template-columns: auto auto; align-items: center; gap: 8px 14px; }
.settings .setting-group legend { padding: 0 0 4px; font-size: 16px; font-weight: 500; letter-spacing: 0.1em; color: var(--ink); }
.settings .setting-group legend span { margin-left: 6px; font-family: var(--sans); font-size: 12.5px; font-weight: 500; letter-spacing: 0.04em; color: var(--ink-2); }
.settings .setting-label { font-family: var(--sans); font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.settings .wood-options { flex-wrap: nowrap; gap: 6px; }
.settings .wood-option { display: block; }
.settings .wood-card {
  flex-direction: row;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px 0 12px;
  border: 1px solid rgba(60, 42, 28, 0.26);
  border-radius: 10px;
  background: rgba(255, 252, 246, 0.55);
  transition: border-color 160ms, background-color 160ms;
}
.settings .wood-card::before { /* the radio dot */
  content: "";
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid rgba(60, 42, 28, 0.5);
}
.settings .wood-option:hover .wood-card { border-color: rgba(60, 42, 28, 0.45); background-color: rgba(255, 252, 246, 0.85); }
.settings .wood-option input:checked ~ .wood-card { border-color: var(--vermilion); background-color: rgba(226, 184, 132, 0.3); }
.settings .wood-option input:checked ~ .wood-card::before { border-color: var(--vermilion); background: var(--vermilion); box-shadow: inset 0 0 0 2px #f6eddd; }
.settings .wood-option input:focus-visible ~ .wood-card { outline: 2px solid #6b3a26; outline-offset: 2px; }
.settings .wood-name { font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--ink); white-space: nowrap; }
/* "Selected" stays in the label for screen readers; the dot shows it */
.settings .wood-check { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* phones: each label above its pair */
@container (max-width: 420px) {
  .d-study .settings-panel, .d-study .lessons .st-paper { padding: 14px 16px 16px; }
  .settings .setting-group { grid-template-columns: auto; row-gap: 4px; }
  .settings .setting-label { font-size: 13px; }
  .settings .wood-options + .setting-label { margin-top: 4px; }
}
/* a short, wide floor (a phone on its side): the two boards side by side */
@container (max-height: 320px) and (min-width: 600px) {
  .d-study .settings-panel { padding: 10px 12px 14px; }
  .settings .settings-title.st-page-title { margin-bottom: 6px; }
  .settings .settings-body { flex-direction: row; gap: 0; }
  .settings .setting-group { column-gap: 10px; row-gap: 6px; padding: 0 14px; }
  .settings .setting-group + .setting-group { border-left: 1px solid rgba(60, 42, 28, 0.16); }
  .settings .setting-label { font-size: 13px; white-space: nowrap; }
  .settings .wood-card { padding: 0 11px 0 10px; gap: 7px; }
}
/* the narrowest phones */
@container (max-width: 300px) {
  .d-study .settings-panel, .d-study .lessons .st-paper { padding: 12px 10px 14px; }
  .settings .settings-title.st-page-title, .lessons .st-page-title { margin-bottom: 8px; }
  .settings .settings-body { gap: 10px; }
  .settings .setting-group { row-gap: 2px; }
  .settings .setting-group legend { padding-bottom: 2px; }
  .settings .wood-options + .setting-label { margin-top: 2px; }
  .settings .wood-card { min-height: 42px; padding: 0 10px 0 9px; gap: 7px; }
  .settings .wood-name { font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) { .settings .wood-card { transition: none; } }

/* Lessons: the note, the three lessons and the way back, compact */
.d-study .lessons .st-paper { width: min(420px, 100%); }
.lessons .st-note { margin: 0 0 12px; font-size: 14.5px; font-weight: 500; line-height: 1.55; }
.lessons .lesson-list { margin: 0 0 14px; }
.lessons .lesson { padding: 9px 2px; font-size: 15.5px; font-weight: 500; letter-spacing: 0.06em; }
.lessons .lesson-state { font-size: 12px; font-weight: 500; }
.lessons .st-button { display: flex; width: fit-content; margin: 0 auto; }
/* a short, wide floor: the three lessons side by side */
@container (max-height: 320px) and (min-width: 600px) {
  .d-study .lessons .st-paper { width: min(600px, 100%); padding: 10px 20px 14px; }
  .lessons .st-page-title { margin-bottom: 6px; }
  .lessons .st-note { margin-bottom: 8px; }
  .lessons .lesson-list { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 10px; }
  .lessons .lesson { flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; }
}

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  .brand-name { font-size: 15.5px; }
  .st-nav a { padding: 0 6px; font-size: 14.5px; } /* the larger text keeps the header within a 390px screen */
  .st-nav a[aria-current="page"]::after { left: 6px; right: calc(6px + 0.08em); }
  .st-btn { font-size: 14.5px; }
  .d-study .st-page { padding: 8px; }
}
/* phones on their side: the page fills the first screen of the floor */
@media (orientation: landscape) and (max-height: 500px) {
  .d-study .st-page { bottom: auto; height: var(--tat-h); padding: 6px var(--pad-x); }
}
