/* ============================================================================
   PHRASE  (#phraseRoot, body.phrase-mode). Loaded with the engine (core/app.js
   ENGINES row), so nothing here reaches another chart.
   One memorable thing: the staircase. The passage's own words run down the
   page one phrase to a line, each set in under the phrase it hangs on, with a
   fine guide for every level, so the eye can follow a line back up to what it
   hangs on. The main line is bold and flush; the joining words are marked in
   the accent; each movement has its own colored spine. On a phone the indent
   step shrinks to fit the deepest line (the JS sets --step), the guides carry
   the levels, long lines wrap with a hanging indent, and the note opens as a
   bottom sheet.
   Hues for movements and repeated words are the engine's own six (gold, teal,
   rose, green, orange, violet), each with a dark and a light value; everything
   else comes from the palette.
   ============================================================================ */

@font-face { font-family: "Fraunces"; src: url("../fonts/fraunces.woff2") format("woff2");
             font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("../fonts/source-serif-4.woff2") format("woff2");
             font-weight: 200 900; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("../fonts/source-serif-4-italic.woff2") format("woff2");
             font-weight: 200 900; font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/ibm-plex-sans-400.woff2") format("woff2");
             font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("../fonts/ibm-plex-sans-600.woff2") format("woff2");
             font-weight: 600; font-display: swap; }

body.phrase-mode #phraseRoot {
  /* Hues, dark values (dark mode, every palette). */
  --ph-h0: #e3c15a;
  --ph-h1: #5cc2cf;
  --ph-h2: #f09ab6;
  --ph-h3: #8ccf8f;
  --ph-h4: #f0955f;
  --ph-h5: #b9a3f2;
  --ph-wash: 12%;              /* a repeated word's tint, over --ph-wash-base; the underline carries the hue */
  --ph-wash-on: 18%;           /* the picked-out group's tint */
  --ph-wash-base: transparent;
  --ph-guide: color-mix(in srgb, var(--text-dim) 42%, transparent);
  --ph-sel: color-mix(in srgb, var(--accent) 16%, transparent);
  --ph-up: color-mix(in srgb, var(--accent) 7%, transparent);
  --ph-card: var(--bg-haze);
  --ph-display: "Fraunces", var(--font-display);
  --ph-read: "Source Serif 4", Georgia, "Times New Roman", serif;
  --ph-ui: "IBM Plex Sans", var(--font);
  display: block; position: relative; min-height: 100vh; min-height: 100dvh;
  background: var(--bg-1); color: var(--text);
  font-family: var(--ph-read); font-size: 18px; line-height: 1.55;
  padding: 0 24px 96px; overflow-x: clip;
}
:root[data-mode="light"] body.phrase-mode #phraseRoot {
  --ph-h0: #7a5c00;
  --ph-h1: #136776;
  --ph-h2: #a2305a;
  --ph-h3: #2d6a35;
  --ph-h4: #a03e15;
  --ph-h5: #5a3ea8;
  --ph-wash: 10%;              /* light: tints lean toward white, so the accent ink keeps 4.5:1 */
  --ph-wash-on: 14%;
  --ph-wash-base: #fff;
  --ph-guide: color-mix(in srgb, var(--text-dim) 38%, transparent);
  --ph-sel: color-mix(in srgb, var(--accent) 14%, #fff);
  --ph-up: color-mix(in srgb, var(--accent) 7%, #fff);
  --ph-card: var(--bg-haze);
}

#phraseMain { max-width: 1180px; margin: 0 auto; padding-top: 72px; }
#phraseBack { position: absolute; }
#phraseCredit { margin-top: 40px; }
#phraseRoot :focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
#phraseRoot [lang="grc"] { font-family: "Gentium Plus", "Gentium", "Palatino Linotype", "Book Antiqua", "Times New Roman", "Noto Serif", serif; }
#phraseRoot a:not(.lib-link) { color: var(--accent-ink); text-underline-offset: 3px; }
#phraseRoot [data-mv="0"], #phraseRoot [data-g="0"] { --h: var(--ph-h0); }
#phraseRoot [data-mv="1"], #phraseRoot [data-g="1"] { --h: var(--ph-h1); }
#phraseRoot [data-mv="2"], #phraseRoot [data-g="2"] { --h: var(--ph-h2); }
#phraseRoot [data-mv="3"], #phraseRoot [data-g="3"] { --h: var(--ph-h3); }
#phraseRoot [data-mv="4"], #phraseRoot [data-g="4"] { --h: var(--ph-h4); }
#phraseRoot [data-mv="5"], #phraseRoot [data-g="5"] { --h: var(--ph-h5); }

/* ---- Title and opening ------------------------------------------------- */
.ph-head { max-width: 760px; }
.ph-eyebrow { margin: 0; font: 600 12px/1.2 var(--ph-ui); letter-spacing: .14em; text-transform: uppercase; color: var(--accent-ink); }
.ph-head h1 { margin: 8px 0 8px; font: 600 clamp(32px, 5.6vw, 52px)/1.06 var(--ph-display); color: var(--ink); text-wrap: balance; }
.ph-sub { margin: 0; font-size: 20px; color: var(--text-dim); text-wrap: pretty; }
.ph-facts { margin: 14px 0 0; font: 400 14px/1.4 var(--ph-ui); color: var(--text-dim); letter-spacing: .02em; }
.ph-intro { margin: 20px 0 4px; }
.ph-intro p { margin: 0 0 12px; text-wrap: pretty; }
.ph-error { font: 600 16px/1.4 var(--ph-ui); color: var(--ink); }

/* ---- Toolbar (sticky: the pills scroll away above it) ------------------- */
.ph-tools {
  position: sticky; top: 0; z-index: 6; margin: 18px -24px 0; padding: 10px 24px 10px;
  background: var(--bg-1); border-bottom: 1px solid var(--line);
}
.ph-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.ph-tog {
  display: inline-flex; align-items: center; gap: 9px; min-height: 40px; padding: 0 16px 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--bg-haze); color: var(--text);
  font: 600 14px/1 var(--ph-ui); cursor: pointer; white-space: nowrap;
}
.ph-tog:hover { border-color: var(--accent-ink); }
.ph-tog-box {
  width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid var(--text-dim); flex: none;
  display: grid; place-items: center;
}
.ph-tog[aria-pressed="true"] { border-color: var(--accent); }
.ph-tog[aria-pressed="true"] .ph-tog-box { background: var(--accent); border-color: var(--accent); }
.ph-tog[aria-pressed="true"] .ph-tog-box::after {
  content: ""; width: 8px; height: 4px; margin-top: -2px; border: solid var(--on-accent); border-width: 0 0 2px 2px; transform: rotate(-45deg);
}
.ph-legend { margin-top: 10px; }
.ph-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ph-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px 0 10px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text);
  font: 400 14px/1 var(--ph-ui); cursor: pointer; white-space: nowrap;
}
.ph-chip-sw { width: 14px; height: 14px; border-radius: 4px; background: color-mix(in srgb, var(--h) 40%, transparent); box-shadow: inset 0 -3px 0 var(--h); }
.ph-chip-n { font-weight: 600; color: var(--text-dim); }
.ph-chip[aria-pressed="true"] { border-color: var(--h); box-shadow: inset 0 0 0 1px var(--h); background: color-mix(in srgb, var(--h) 12%, var(--ph-wash-base)); }
.ph-legend-note, .ph-mainnote, .ph-taphint { margin: 8px 0 0; font: 400 14px/1.45 var(--ph-ui); color: var(--text-dim); }
.ph-taphint { display: none; }

/* ---- Layout: the diagram, and the note beside it ------------------------ */
.ph-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: 40px; align-items: start; margin-top: 8px; }
.ph-col { min-width: 0; }

/* Movements: a colored spine, a numeral, a title and what the text shows. */
.ph-mv { margin: 28px 0 0; padding-left: 16px; border-left: 3px solid var(--h); }
.ph-mv-head { display: flex; gap: 14px; align-items: flex-start; margin: 0 0 12px; }
.ph-mv-num { margin: 0; min-width: 1.4em; font: 600 30px/1 var(--ph-display); color: var(--h); }
.ph-mv-head h2 { margin: 2px 0 4px; font: 600 22px/1.2 var(--ph-display); color: var(--ink); }
.ph-mv-ref {
  display: inline-block; margin-right: 10px; padding: 3px 8px; border-radius: 6px; vertical-align: 3px;
  font: 600 12px/1.2 var(--ph-ui); letter-spacing: .04em; color: var(--text); border: 1px solid var(--h);
}
.ph-mv-lead { margin: 0; font-size: 16px; line-height: 1.5; color: var(--text-dim); max-width: 64ch; }
.ph-mv-lead strong { color: var(--text); }

/* ---- The lines ---------------------------------------------------------- */
.ph-lines { list-style: none; margin: 0; padding: 0; }
.ph-diagram { --step: 24px; }
.ph-row { position: relative; padding-left: calc(var(--lvl, 0) * var(--step)); transition: padding-left .32s cubic-bezier(.3, .7, .2, 1); }
.ph-row[hidden] { display: none; }
/* One fine guide per level, centered in each step, and an elbow into the line. */
.ph-guides {
  position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--lvl, 0) * var(--step)); pointer-events: none;
  background-image: linear-gradient(to right, var(--ph-guide) 0 1px, transparent 1px);
  background-size: var(--step) 100%; background-repeat: repeat-x;
  background-position: calc(var(--step) / 2) 0;
  transition: width .32s cubic-bezier(.3, .7, .2, 1);
}
.ph-guides::after {
  content: ""; position: absolute; top: 1.05em; right: 2px; width: calc(var(--step) / 2 - 2px); height: 1px; background: var(--ph-guide);
}
.ph-row.is-root .ph-guides::after { display: none; }
.ph-row.is-up .ph-guides, .ph-row.is-parent .ph-guides, .ph-row.is-sel .ph-guides { --ph-guide: color-mix(in srgb, var(--accent-ink) 60%, transparent); }

.ph-line {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: baseline;
  width: 100%; min-height: 34px; margin: 0; padding: 4px 10px 4px 8px; border: 0; border-radius: 8px;
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.ph-line:hover { background: var(--ph-up); }
.ph-text { display: block; padding-left: 1.1em; text-indent: -1.1em; text-wrap: pretty; }
.ph-row.is-main .ph-text { font-weight: 650; color: var(--ink); }
.ph-row.is-root .ph-text { font-size: 1.08em; }
.ph-rel { display: none; font: 600 12px/1.3 var(--ph-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); white-space: nowrap; }
.ph-show-conn .ph-rel { display: block; }
.ph-show-conn .ph-conn { color: var(--accent-ink); font-weight: 700; }
.ph-v {
  font: 600 12px/0 var(--ph-ui); color: var(--accent-ink); margin: 0 .3em 0 .05em; vertical-align: .55em; text-indent: 0;
}
.ph-two {
  display: inline-block; margin-left: .55em; padding: 2px 8px; border-radius: 999px; border: 1px dashed var(--accent-ink);
  font: 600 12px/1.25 var(--ph-ui); letter-spacing: .02em; color: var(--accent-ink); text-indent: 0; vertical-align: .12em; white-space: nowrap;
}
.ph-row.is-alt .ph-two { border-style: solid; }
.ph-row.is-alt .ph-two::before { content: "↷ "; }
.ph-row.is-sel .ph-line { background: var(--ph-sel); box-shadow: inset 3px 0 0 var(--accent); }
.ph-row.is-parent .ph-line { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-ink) 55%, transparent); }
.ph-row.is-up .ph-line { background: var(--ph-up); }
/* A set-back line names the word its pronoun points to; that word carries a
   dotted underline, solid when the line pointing to it is chosen. */
.ph-ptag {
  display: inline-block; margin-left: .55em; padding: 1px 0; text-indent: 0; vertical-align: .12em;
  font: 600 12px/1.3 var(--ph-ui); letter-spacing: .02em; color: var(--text-dim);
  border-bottom: 1px dotted var(--accent-ink);
}
.ph-row.is-sel .ph-ptag { color: var(--accent-ink); }
.ph-show-conn .ph-diagram .ph-pt { text-decoration: underline 1px dotted var(--accent-ink); text-underline-offset: 4px; }
.ph-pt.on, .ph-show-conn .ph-pt.on { text-decoration: underline 2px solid var(--accent-ink); text-underline-offset: 4px; }

/* Repeated words: a tint and an underline in the group's hue; the text keeps its own ink. */
.ph-show-rep .ph-rep { background: color-mix(in srgb, var(--h) var(--ph-wash), var(--ph-wash-base)); box-shadow: inset 0 -2px 0 var(--h); border-radius: 3px; }
.ph-show-rep .ph-diagram:not([data-focus=""]) .ph-rep { background: none; box-shadow: none; }
.ph-show-rep .ph-diagram[data-focus="0"] .ph-rep[data-g="0"],
.ph-show-rep .ph-diagram[data-focus="1"] .ph-rep[data-g="1"],
.ph-show-rep .ph-diagram[data-focus="2"] .ph-rep[data-g="2"],
.ph-show-rep .ph-diagram[data-focus="3"] .ph-rep[data-g="3"],
.ph-show-rep .ph-diagram[data-focus="4"] .ph-rep[data-g="4"],
.ph-show-rep .ph-diagram[data-focus="5"] .ph-rep[data-g="5"] {
  background: color-mix(in srgb, var(--h) var(--ph-wash-on), var(--ph-wash-base)); box-shadow: inset 0 -3px 0 var(--h);
}

/* ---- The note panel ------------------------------------------------------ */
.ph-panel {
  position: sticky; top: calc(var(--ph-bar, 72px) + 14px); margin-top: 28px;
  max-height: calc(100vh - var(--ph-bar, 72px) - 32px); max-height: calc(100dvh - var(--ph-bar, 72px) - 32px); overflow: auto;
  padding: 18px 20px 20px; border-radius: 16px; background: var(--ph-card); border: 1px solid var(--card-border);
  font-size: 16px; line-height: 1.55; overscroll-behavior: contain;
}
.ph-panel:focus { outline: none; }
.ph-panel:focus-visible { outline: 2px solid var(--accent-ink); }
.ph-pn-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ph-pn-ref { margin: 0; font: 600 13px/1.3 var(--ph-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
.ph-pn-close {
  display: none; flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg-1); color: var(--text); font: 400 24px/1 var(--ph-ui); cursor: pointer;
}
#phraseRoot.ph-open .ph-pn-close { display: grid; place-items: center; }
.ph-pn-line { margin: 10px 0 8px; font: 600 21px/1.35 var(--ph-read); color: var(--ink); }
.ph-pn-rel, .ph-pn-pt { margin: 0 0 6px; font: 400 14px/1.45 var(--ph-ui); color: var(--text-dim); }
.ph-pn-rel q, .ph-pn-pt q { color: var(--text); }
.ph-pn-relw { font-weight: 600; color: var(--text); }
.ph-pn-note { margin-top: 12px; }
.ph-pn-note p { margin: 0; }
.ph-pn-note strong { color: var(--ink); }
.ph-pn-lab { display: block; margin: 0 0 6px; font: 600 12px/1.2 var(--ph-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); }
.ph-pn-greek { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--bg-1); }
.ph-pn-greek [lang="grc"] { font-size: 17px; color: var(--text); }
.ph-pn-refs { margin-top: 16px; }
.ph-quote { margin: 0 0 12px; padding: 0 0 0 12px; border-left: 2px solid var(--accent); }
.ph-quote p { margin: 0; font-style: italic; }
.ph-quote cite { display: block; margin-top: 2px; font: normal 600 12px/1.3 var(--ph-ui); letter-spacing: .03em; color: var(--accent-ink); }
.ph-reads { margin: 14px 0 0; padding: 12px; border-radius: 12px; border: 1px dashed var(--accent-ink); }
.ph-reads-t { margin: 0 0 8px; font: 600 12px/1.2 var(--ph-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-ink); }
.ph-read {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; min-height: 44px; margin: 6px 0 0; padding: 8px 10px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg-1); color: var(--text);
  font: 400 14px/1.4 var(--ph-ui); text-align: left; cursor: pointer;
}
.ph-read-k {
  flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--text-dim); font-weight: 600; font-size: 12px;
}
.ph-read[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ph-read[aria-pressed="true"] .ph-read-k { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ph-pn-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.ph-pn-nav[hidden] { display: none; }
.ph-pn-step {
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent;
  color: var(--text); font: 600 14px/1 var(--ph-ui); cursor: pointer;
}
.ph-pn-step:disabled { opacity: .45; cursor: default; }

/* The key, shown before a line is chosen. */
.ph-key-title { margin: 0 0 10px; font: 600 19px/1.2 var(--ph-display); color: var(--ink); }
.ph-key ul { list-style: none; margin: 0; padding: 0; font: 400 14px/1.45 var(--ph-ui); color: var(--text); }
.ph-key li { display: grid; grid-template-columns: 94px 1fr; gap: 10px; align-items: center; margin: 0 0 10px; }
.ph-key-demo { justify-self: start; font-family: var(--ph-read); font-size: 16px; }
.ph-key-demo .ph-conn { color: var(--accent-ink); font-weight: 700; }
.ph-key-demo .ph-two, .ph-key-demo .ph-ptag { margin: 0; }
.ph-key-demo .ph-ptag { white-space: nowrap; }
.ph-key-lvl {
  width: 72px; height: 30px;
  background:
    linear-gradient(var(--ph-guide), var(--ph-guide)) 10px 0 / 1px 100% no-repeat,
    linear-gradient(var(--ph-guide), var(--ph-guide)) 10px 15px / 12px 1px no-repeat,
    linear-gradient(var(--text-dim), var(--text-dim)) 26px 12px / 44px 6px no-repeat;
  border-radius: 2px;
}
.ph-key-tap { margin: 14px 0 0; font: 600 14px/1.4 var(--ph-ui); color: var(--accent-ink); }

/* ---- Closing and sources ------------------------------------------------- */
.ph-closing, .ph-sources { max-width: 760px; margin-top: 56px; }
.ph-closing { padding: 24px 26px; border-radius: 16px; background: var(--ph-card); border: 1px solid var(--card-border); }
.ph-closing h2, .ph-sources h2 { margin: 0 0 12px; font: 600 26px/1.2 var(--ph-display); color: var(--ink); }
.ph-closing p { margin: 0 0 12px; }
.ph-closing p:last-child { margin-bottom: 0; }
.ph-sources p, .ph-sources li { font: 400 15px/1.5 var(--ph-ui); color: var(--text-dim); }
.ph-sources ul { margin: 0; padding-left: 1.2em; }
.ph-sources li { margin: 0 0 6px; }

@media (prefers-reduced-motion: reduce) { .ph-row, .ph-guides { transition: none; } }
body.low-power .ph-row, body.low-power .ph-guides { transition: none; }

/* ---- Between phone and desktop: the note goes under the diagram's header.  */
@media (max-width: 980px) and (min-width: 641px) {
  .ph-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; }
  .ph-rel { display: none !important; }
}

/* ---- Touch ---------------------------------------------------------------- */
@media (pointer: coarse) {
  .ph-line { min-height: 40px; }
  .ph-tog, .ph-chip { min-height: 44px; }
}

/* ---- Phones, upright and sideways: tighter page, one-row toolbar ----------- */
@media (max-width: 640px), (max-height: 500px) {
  body.phrase-mode #phraseRoot { padding: 0 14px 72px; font-size: 17px; }
  #phraseMain { padding-top: 60px; }
  .ph-sub { font-size: 18px; }
  .ph-facts { font-size: 13px; }
  .ph-tools { margin: 14px -14px 0; padding: 8px 14px; }
  /* One row each, scrolling sideways, with a fade at the cut edge. */
  .ph-bar, .ph-chips {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -14px; padding-right: 28px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }
  .ph-bar::-webkit-scrollbar, .ph-chips::-webkit-scrollbar { display: none; }
  .ph-tog, .ph-chip { flex: none; }
  .ph-legend-note { font-size: 13px; }
  .ph-taphint { display: block; font-size: 13px; margin-top: 6px; }
  .ph-rel { display: none !important; }
  .ph-mv { padding-left: 9px; margin-top: 22px; }
  .ph-mv-head { gap: 10px; }
  .ph-mv-num { font-size: 24px; min-width: 1.2em; }
  .ph-mv-head h2 { font-size: 20px; }
  .ph-mv-lead { font-size: 15px; }
  .ph-line { padding: 5px 4px 5px 4px; grid-template-columns: minmax(0, 1fr); }
  .ph-text { padding-left: .9em; text-indent: -.9em; }
  .ph-row.is-root .ph-text { font-size: 1.04em; }
  .ph-closing { padding: 20px 18px; }
  .ph-closing h2, .ph-sources h2 { font-size: 23px; }
}

/* ---- Upright phone: one column, the note as a bottom sheet ---------------- */
@media (max-width: 640px) {
  body.phrase-mode #phraseRoot.ph-open { padding-bottom: calc(var(--ph-sheet, 50vh) + 24px); }
  .ph-layout { display: block; }
  .ph-panel {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; top: auto; margin: 0;
    max-height: 70vh; max-height: 70dvh; border-radius: 18px 18px 0 0;
    padding: 0 18px max(18px, env(safe-area-inset-bottom));
    border-width: 1px 0 0; box-shadow: 0 -14px 34px rgba(0, 0, 0, .35);
    transform: translateY(105%); visibility: hidden;
    transition: transform .28s cubic-bezier(.3, .7, .2, 1), visibility 0s linear .28s;
  }
  #phraseRoot.ph-open .ph-panel { transform: none; visibility: visible; transition: transform .28s cubic-bezier(.3, .7, .2, 1); }
  .ph-pn-top { position: sticky; top: 0; z-index: 1; margin: 0 -18px; padding: 10px 18px 8px; background: var(--ph-card); border-bottom: 1px solid var(--line); }
  .ph-pn-line { font-size: 19px; }
  body.low-power .ph-panel, body.low-power #phraseRoot.ph-open .ph-panel { transition: none; }
}
@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
  .ph-panel, #phraseRoot.ph-open .ph-panel { transition: none; }
}

/* ---- Sideways phone: 390 px of height. The toolbar stays in the page (not
   stuck over the lines) and the note sits beside the diagram, as on a desktop,
   so both show at once. -------------------------------------------------- */
@media (max-height: 500px) and (min-width: 641px) {
  .ph-tools { position: static; }
  .ph-taphint { display: none; }
  .ph-panel { top: 12px; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); }
  .ph-layout { gap: 18px; }
}
