:root {
  /* Verified straight from delugecommunity.com's own hardware-control icons
     (decoded from the site's inline SVGs): gold encoder fill/stroke/label,
     the neutral "Select" encoder colors, and the cyan "turn" indicator. The
     page chrome itself uses Starlight's default blue, but that's just the
     doc-framework theme -- these hardware colors are the site's actual
     Deluge-specific visual identity, so they're what this app matches. */
  --bg: #17181a;
  --panel: #1c1d20;
  --panel-2: #232427;
  --border: #34363d;
  --text: #ecebe8;
  --text-dim: #9a9ba2;
  --gold: #ad7309;
  --gold-stroke: #e2ad5d;
  --gold-text: #ffecd2;
  --select-fill: #1e1e1e;
  --select-stroke: #949494;
  --select-text: #d0d0d0;
  --cyan: #00ffca;
  --accent: #e2ad5d;
  --accent-soft: #3a2d13;
  --accent-2: #00ffca;
  --changed: #f0d000;
  --changed-soft: #3d3406;
  --danger: #ff5a5a;
  --danger-soft: #3d1414;
  --done: #55565d;
  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 18px; margin: 0; letter-spacing: 0.02em; }

.topbar-controls { display: flex; align-items: center; gap: 20px; }

.deluge-connect { display: flex; align-items: center; gap: 8px; }
.deluge-connect .btn-secondary { width: auto; padding: 6px 12px; font-size: 12px; }
.deluge-status { font-size: 12px; color: var(--text-dim); }
.deluge-status.connected { color: var(--cyan); }

/* Set apart from the functional device-connectivity group with its own
   left border -- reference material (rarely needed once you know the app),
   not another action in that row. See topbar-controls' own comment for the
   full left-to-right ordering rationale. */
.topbar-help { padding-left: 20px; border-left: 1px solid var(--border); }

.mode-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.mode-label { font-size: 13px; color: var(--text-dim); }
.mode-toggle input { display: none; }
.mode-toggle .slider {
  width: 38px; height: 20px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: relative;
  transition: background .15s;
}
.mode-toggle .slider::before {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  top: 2px; left: 2px;
  transition: transform .15s, background .15s;
}
.mode-toggle input:checked + .slider { background: var(--accent-soft); }
.mode-toggle input:checked + .slider::before {
  transform: translateX(18px);
  background: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100% - 53px);
}

.library {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Only meaningful on a landscape phone (see the `orientation: landscape`
   media query below) -- a short, wide viewport where a side-by-side layout
   makes sense but the preset list still shouldn't permanently eat width
   the guide needs. Hidden everywhere else so it never appears on desktop
   or the portrait-mobile stacked layout, where this problem doesn't exist. */
.library-collapse-toggle { display: none; }

.loader { padding: 18px; }
.loader p { color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.or-divider { text-align: center; margin: 10px 0; color: var(--text-dim); font-size: 12px; }

.btn-primary, .btn-secondary {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #0d1410; font-weight: 600; border-color: var(--accent); }
.btn-secondary { background: var(--panel-2); color: var(--text); }
.btn-link {
  background: none; border: none; color: var(--accent-2);
  font-size: 12px; cursor: pointer; padding: 0;
}

.load-status { font-size: 12px; color: var(--accent); min-height: 16px; }

.library-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  /* Flex items default to min-height: auto, which lets this column's
     natural (content) height win over `flex: 1` and the ancestor .library's
     max-height/overflow:hidden cap -- the preset-tree below then renders at
     its full content height instead of being clipped to a scrollable box,
     so most of the list becomes invisible and unclickable rather than
     scrollable. Needed for the mobile .library { max-height: 40vh } cap in
     the breakpoint below to actually produce a scrollable list instead of
     silently-clipped, unreachable content. */
  min-height: 0;
  padding: 12px;
  gap: 8px;
}
/* Same author-vs-user-agent cascade gotcha the .modal-overlay[hidden] rule
   above already has a comment for: this class selector and the UA's
   `[hidden] { display: none }` rule are equal specificity, so origin order
   (author beats user-agent) lets `display: flex` above win and keeps this
   panel visibly (if emptily) rendered before any folder is loaded, instead
   of actually being hidden -- found via this session's mobile pass, where
   the now-more-compact mobile library made the stray empty search box +
   filter row visible above the loader's own buttons. Needs the same
   higher-specificity override. */
.library-body[hidden] { display: none; }

#searchBox {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
}

/* Library filter chips: a compact row per group (engine / oscillator
   source / other flags), sized and colored like the existing mini-toggle
   pills used above the step list, but as click-to-select/toggle buttons
   instead of checkboxes -- reads better at this width than a row of
   labeled sliders would for 3-4 mutually-exclusive-or-not options each. */
.library-filters {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.filter-chip {
  background: var(--panel-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 9px;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s, border-color .15s;
}
.filter-chip:hover { color: var(--text); border-color: var(--text-dim); }
.filter-chip.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.preset-count { font-size: 11px; color: var(--text-dim); }

.preset-tree { overflow-y: auto; flex: 1; min-height: 0; }

.pack-group { margin-bottom: 4px; }
.pack-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  padding: 6px 4px 4px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}
.pack-header:hover { color: var(--text); }

.preset-item {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preset-item:hover { background: var(--panel-2); }
.preset-item.active { background: var(--accent); color: #0d1410; font-weight: 600; }
.preset-item .done-badge {
  float: right; font-size: 11px; color: var(--accent);
}
.preset-item.active .done-badge { color: #0d1410; }

.guide {
  overflow-y: auto;
  padding: 26px 40px 60px;
}

.guide-empty {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 60px;
  text-align: center;
}

.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
  margin-bottom: 20px;
}
.guide-pack { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
#guideTitle { margin: 2px 0 0; font-size: 24px; }
.guide-progress { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
#completedText { display: block; font-size: 12px; color: var(--accent); }
.guide-progress .btn-link { margin-left: 12px; }

/* Guide-level action buttons: Glossary / Print, above the tab bar. */
.guide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 4px;
}
.guide-actions .btn-secondary { width: auto; padding: 7px 14px; font-size: 12.5px; }

/* Idea 7: Compare tab */
.compare-picker { margin-bottom: 14px; font-size: 13px; color: var(--text-dim); }
.compare-picker select {
  margin-left: 6px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
}
/* Session 4/5: two full Signal Path diagrams, stacked one above the other
   (see the comment above renderCompareTab() in app.js) -- the whole
   comparison now, no separate flag-table summary alongside them. */
.compare-diagrams { display: flex; flex-direction: column; gap: 28px; }
.compare-col-title { margin: 0 0 8px; font-size: 13px; color: var(--text-dim); text-align: center; font-weight: 600; }

/* Idea 8: glossary modal */
.glossary-list { display: flex; flex-direction: column; gap: 14px; max-height: 55vh; overflow-y: auto; }
.glossary-term { font-weight: 700; color: var(--accent-2); font-size: 13.5px; margin-bottom: 3px; }
.glossary-body { font-size: 13px; color: var(--text-dim); line-height: 1.55; }

/* User Guide modal: same term+body shape as the glossary above, just with
   richer bodies (multiple <p>s, kbd()/shift() badges, lists) instead of one
   plain-text line each -- see userGuideSections() in app.js. */
.user-guide-box { width: min(680px, 92vw); }
.user-guide-list { display: flex; flex-direction: column; gap: 18px; max-height: 65vh; overflow-y: auto; padding-right: 2px; }
.user-guide-title { font-weight: 700; color: var(--accent-2); font-size: 14px; margin-bottom: 5px; }
.user-guide-body { font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.user-guide-body p { margin: 0 0 8px; }
.user-guide-body p:last-child { margin-bottom: 0; }
.user-guide-body b { color: var(--text); }
.user-guide-body code {
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 12px;
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 4px;
}

/* Idea 2: WebAudio demo modal */
.audio-demo-note { font-size: 11.5px; color: var(--text-dim); margin: 0 0 12px; line-height: 1.5; }
.demo-controls { display: flex; flex-direction: column; gap: 10px; }
.demo-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); }
.demo-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  /* The visible track stays thin, but the element's own box (and so its
     touch hit area) is taller -- makes the slider comfortably draggable
     with a fingertip instead of just a mouse pointer. */
  min-height: 28px;
}
.demo-row select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 6px; font-size: 12.5px;
}
.demo-val { min-width: 54px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.step-ref.step-demo { margin-top: 8px; }
.demo-open-btn { font-size: 12px; }

/* Session 3: ADSR demo's live envelope-shape curve, drawn as inline SVG for
   visual consistency with buildSignalPathSvg()'s diagrams elsewhere in this
   app (see .signal-diagram-wrap / .sd-* above) rather than a second visual
   language (e.g. canvas). */
.demo-envelope-svg-wrap { margin-top: 2px; }
.demo-envelope-svg { display: block; width: 100%; max-width: 280px; margin: 0 auto; }
.env-baseline { stroke: var(--border); stroke-width: 1; }
.env-curve-path { fill: none; stroke: var(--accent-2); stroke-width: 2; }
.env-playhead { fill: var(--accent); }

/* Per-guide toolbar: Show manual reference / Show tips -- small pill
   toggles, visually distinct from (and lighter-weight than) the page-level
   Beginner/Expert switch. */
.guide-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 16px;
}
.mini-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
  color: var(--text-dim);
}
.mini-toggle input { display: none; }
.mini-toggle .mini-slider {
  width: 30px; height: 16px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  position: relative;
  transition: background .15s;
  flex-shrink: 0;
}
.mini-toggle .mini-slider::before {
  content: "";
  position: absolute;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--text-dim);
  top: 1.5px; left: 1.5px;
  transition: transform .15s, background .15s;
}
.mini-toggle input:checked + .mini-slider { background: var(--accent-soft); }
.mini-toggle input:checked + .mini-slider::before {
  transform: translateX(14px);
  background: var(--accent);
}
.mini-toggle input:checked ~ span:last-child { color: var(--text); }

/* "Show sources" / "Show tips" captions under a step's instruction text. */
.step-ref {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-top: 6px;
  padding-left: 2px;
}
.step-ref b { color: var(--text-dim); font-weight: 600; }
.step-ref a { color: var(--accent-2); text-decoration: none; }
.step-ref a:hover { text-decoration: underline; }
.step-ref.step-tip { color: var(--text-dim); border-left: 2px solid var(--border); padding-left: 8px; }
.step-ref.step-source-community { color: var(--changed); }
.step-ref.step-source-community a { color: var(--changed); }

.section-block { margin-bottom: 26px; }
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.step {
  display: flex;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
/* A step that only makes sense as a follow-on to the one right before it
   (e.g. a cable's chained depth-modulation step, which depends on that
   cable already being connected) -- indented with a connecting rule so the
   dependency reads visually instead of the two looking like independent
   peers. The step right before it loses its usual bottom margin so the
   connector reads as one continuous line rather than jumping a gap. */
.step:has(+ .step.step-indent) { margin-bottom: 2px; }
.step.step-indent {
  margin-left: 28px;
  border-left: 2px solid var(--border);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
.step-body { flex: 1; }
.step-title { font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.step-text { font-size: 13.5px; color: var(--text-dim); line-height: 1.5; }
.kbd {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 1em;
  line-height: 1.6;
  white-space: nowrap;
}
.kbd:has(svg) { padding-left: 3px; }
.kbd svg { display: block; flex-shrink: 0; }
.step-text .value {
  color: var(--text);
  font-weight: 600;
}
.step-text ul { margin: 6px 0 0; padding-left: 18px; }
.step-text table { border-collapse: collapse; margin-top: 6px; font-size: 12.5px; }
.step-text td, .step-text th { padding: 2px 8px 2px 0; text-align: left; color: var(--text-dim); }
.step-text th { color: var(--text); }

/* Tab bar: Steps / Mod Matrix / Signal Path */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 18px 0 20px;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--cyan); border-bottom-color: var(--cyan); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Shared reference-table style, used by the mod matrix tab */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.data-table th {
  text-align: left;
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.is-default td { color: var(--text-dim); }
.data-table .amount-bar {
  display: inline-block;
  width: 70px;
  height: 6px;
  background: var(--panel-2);
  border-radius: 3px;
  position: relative;
  vertical-align: middle;
  margin-right: 8px;
}
.data-table .amount-bar > span {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 3px;
}
.empty-note { color: var(--text-dim); font-size: 13px; padding: 20px 0; }

/* Shared pinch-zoom/pan wrapper for the Mod Matrix table and the Signal
   Path / Compare SVG diagrams -- see initZoomViewport()/makeZoomable() in
   app.js. touch-action:pan-x pan-y (not the "auto" default) hands the pinch
   gesture over to that JS instead of letting the browser try to zoom the
   whole page at the same time. Height only gets capped while actually
   zoomed (.is-zoomed, toggled by the JS) -- unzoomed, these stay exactly as
   tall as their natural content and just let the page scroll past them,
   like before this existed. */
.zoom-toolbar { display: flex; justify-content: flex-end; margin-bottom: 6px; }
/* Collapse the toolbar's own spacing to nothing while its only child (the
   reset button) is hidden, i.e. whenever this diagram/table isn't zoomed --
   otherwise every Mod Matrix/Signal Path/Compare render would carry a
   permanent empty gap above it. */
.zoom-toolbar:has(.zoom-reset-btn[hidden]) { margin-bottom: 0; }
.zoom-reset-btn {
  padding: 5px 10px;
  font-size: 11.5px;
  background: var(--panel-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.zoom-reset-btn:hover { color: var(--text); }
.zoom-viewport {
  position: relative;
  overflow-x: auto;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}
.zoom-viewport.is-zoomed { overflow-y: auto; max-height: min(70vh, 620px); }
.zoom-spacer { position: relative; }
.zoom-content { position: absolute; top: 0; left: 0; }

/* Mod matrix cross-tab: sources across the top, destinations down the side */
/* table-layout:auto (not fixed) + width:auto lets columns size to their
   natural content instead of being force-squeezed into 100% width -- that
   squeeze (min-width on th is ignored by table-layout:fixed) let cell text
   overflow its box uncontained and visually overlap neighboring cells on
   any preset with enough mod-matrix columns to not fit a narrow screen.
   min-width:100% still fills the panel when content is narrow enough to
   allow it; when it isn't, the table grows past 100% and .zoom-viewport's
   horizontal scroll (now also pinch-zoomable) takes over instead. */
.matrix-grid { table-layout: auto; width: auto; min-width: 100%; }
.matrix-grid .mm-corner {
  min-width: 160px;
  font-size: 10px;
  background: var(--panel-2);
}
.matrix-grid th:not(.mm-corner) { text-align: center; min-width: 84px; }
.matrix-grid .mm-rowhead {
  text-align: left;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.matrix-grid .mm-cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 12.5px;
}
.matrix-grid .mm-cell.is-default { color: var(--text-dim); font-weight: 400; background: transparent; }
/* Yellow border = this routing differs from the init patch's own cables. */
.matrix-grid .mm-cell:not(.is-default) { color: var(--changed); background: var(--changed-soft); box-shadow: inset 0 0 0 1.5px var(--changed); }
.matrix-grid .mm-empty { text-align: center; color: var(--border); }
.matrix-grid .amount-bar { display: block; width: 90%; margin: 4px auto 0; height: 4px; }
/* A synthetic column for a cable's own modulation depth being itself
   modulated by a second source (see cablesOf()'s own comment, a "double
   mod") -- shaded so it visually reads as "not an ordinary destination"
   even though its cell otherwise looks like any other depth number. */
.matrix-grid .mm-depth-col { background: var(--panel-2); color: var(--cyan); cursor: help; }
.matrix-grid .mm-depth-cell { box-shadow: inset 0 0 0 1.5px var(--cyan); color: var(--cyan); background: transparent; }

/* Signal path diagram */
.signal-diagram-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  overflow-x: auto;
  /* Smooth momentum scrolling for the horizontal drag on iOS Safari (the
     diagram is wider than the viewport on phones); overflow-x:auto alone
     scrolls fine but without this the drag can feel stiff/steppy on older
     iOS versions. Harmless on Chromium/desktop, where it's ignored. */
  -webkit-overflow-scrolling: touch;
}
.signal-diagram-wrap svg { display: block; margin: 0 auto; }
.sd-box { fill: var(--panel-2); stroke: var(--border); stroke-width: 1.5; }
/* Yellow border = this box's value differs from the init patch. */
.sd-box.changed { stroke: var(--changed); stroke-width: 2; }
.sd-box.bypassed { opacity: 0.4; }
/* Modulation-source lane boxes: cyan, matching the dashed cyan mod lines. */
.sd-box.lane { stroke: var(--src-color, var(--cyan)); fill: var(--panel); }
/* Session 4/5, Compare tab: this box differs BETWEEN the two Compare
   diagrams. Same yellow the Signal Path tab already uses for "differs
   from this preset's own init patch" (.changed above) -- one color for
   "this box isn't at its default" everywhere in the app, rather than a
   second color the user has to separately learn. Set by
   flagCompareDifferences(), never by buildSignalPathSvg() itself. */
.sd-box.compare-differs { stroke: var(--changed); stroke-width: 2; }
.sd-hoverable { cursor: default; }
.sd-label { fill: var(--text); font-size: 12px; font-family: "Segoe UI", Helvetica, Arial, sans-serif; }
.sd-sublabel { fill: var(--text-dim); font-size: 10px; font-family: "Segoe UI", Helvetica, Arial, sans-serif; }
.sd-arrow { stroke: var(--text-dim); stroke-width: 1.5; fill: none; marker-end: url(#sd-arrowhead); }
/* Modulation lines are drawn as curves whose tangent at the endpoint doesn't
   reliably point at the target, so an auto-oriented arrowhead marker on them
   often ends up pointing the wrong way. No marker at all reads better than
   one that's frequently backwards -- the dashed cyan styling and matching
   source/target color already make the connection clear without it. */
.sd-arrow.mod { stroke: var(--cyan); stroke-dasharray: 3 3; marker-end: none; }
.sd-mod-label { fill: var(--cyan); font-size: 9.5px; font-family: "SFMono-Regular", Consolas, Menlo, monospace; }

/* Custom hover tooltip for signal-path nodes (native SVG <title> is
   unreliable for markup injected via innerHTML, especially in Safari). */
.svg-tooltip {
  position: fixed;
  z-index: 1000;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: pre-line;
  pointer-events: none;
  max-width: 260px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Generic modal overlay: reused for the Deluge file picker and the check
   settings panel. */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
/* An author rule of equal specificity to the UA stylesheet's [hidden] rule
   wins the cascade (author beats user-agent origin regardless of order),
   so `display: flex` above was overriding `hidden` and leaving this
   full-screen overlay showing -- and eating every click -- from first
   paint. Needs its own, higher-specificity override. */
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  width: min(480px, 90vw);
  max-height: 80vh;
  overflow-y: auto;
}
.modal-box h3 { margin: 0 0 14px; font-size: 15px; }
.modal-box p { margin: 0 0 14px; font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.modal-checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 16px; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-celebrate h3 { color: var(--accent); text-align: center; font-size: 18px; }
.modal-celebrate p { text-align: center; }
.modal-celebrate .modal-actions { justify-content: center; }

.midi-monitor-box { width: min(640px, 92vw); }
.midi-monitor-box p { margin: 0 0 4px; }
.midi-monitor-warn { color: var(--changed); }
.midi-monitor-toolbar { display: flex; justify-content: flex-end; margin: 6px 0 8px; }
.midi-monitor-log {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 45vh;
  overflow-y: auto;
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 11.5px;
}
.midi-monitor-row {
  display: flex;
  gap: 10px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.midi-monitor-row:last-child { border-bottom: none; }
.midi-monitor-time { color: var(--text-dim); flex-shrink: 0; }
.midi-monitor-ch { color: var(--text-dim); flex-shrink: 0; }
.midi-monitor-detail { overflow: hidden; text-overflow: ellipsis; white-space: normal; }
.midi-monitor-dim { color: var(--text-dim); }
.midi-monitor-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--changed-soft);
  color: var(--cyan);
  border: 1px solid var(--cyan);
}
.modal-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; max-height: 50vh; overflow-y: auto; }
.modal-list-item {
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
  word-break: break-all;
}
.modal-list-item:hover { border-color: var(--accent-2); }
/* Plain (non-folder, non-search-result) file rows get a name + optional
   category hint span once the device-side "Categorize this folder…"
   feature has read one -- lay those two out like the folder row already
   does, without touching that row's own .modal-list-folder rule. */
.modal-list-item:not(.modal-list-folder) { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal-item-category { font-size: 10.5px; color: var(--accent); flex-shrink: 0; white-space: nowrap; }

/* Device-side (experimental) category filter chips + "Categorize this
   folder…" opt-in button, inside the "Load from connected Deluge" file
   picker modal only -- reuses .library-filters/.filter-chip/.filter-group
   from the local library filter panel for visual consistency. */
.modal-device-filters { margin-bottom: 8px; }
.modal-categorize-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.modal-categorize-btn { width: auto; padding: 6px 12px; font-size: 12px; }
.modal-categorize-status { font-size: 11.5px; color: var(--text-dim); }
/* Chips start disabled -- every file's category is unknown until
   Categorize has actually run, so a clickable-looking chip that quietly
   does nothing would read as broken rather than "not yet". */
.filter-chip:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

.modal-search {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  box-sizing: border-box;
}

.modal-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin-bottom: 10px;
  font-size: 12px;
}
.modal-breadcrumb-item {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 3px;
  font-size: 12px;
}
.modal-breadcrumb-item:last-of-type { color: var(--text); font-weight: 600; }
.modal-breadcrumb-item:hover { color: var(--accent-2); }
.modal-breadcrumb-sep { color: var(--text-dim); }

.modal-list-folder {
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-folder-icon { flex-shrink: 0; }
.modal-item-name { flex: 1; text-align: left; word-break: break-all; }
.modal-item-count { font-size: 11px; color: var(--text-dim); flex-shrink: 0; }

.modal-list-search-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}
.modal-list-search-item .modal-item-path {
  font-size: 11px;
  color: var(--text-dim);
  word-break: break-all;
}

.modal-empty { font-size: 12.5px; color: var(--text-dim); padding: 8px 2px; }

/* Live-device check: guide + entry point, above the step list. Sticky so it
   stays reachable (and the live/check-pending status stays visible) while
   scrolling through a long step list -- `.guide` (its scrolling ancestor)
   has its own top padding, which position:sticky's `top: 0` correctly
   accounts for on its own; the panel only starts pinning once scrolled
   past where that padding would have placed it. */
.device-check-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 22px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.4);
}
.device-check-desc {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.55;
  max-width: 560px;
  margin: 0;
}
.device-check-desc code {
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 11.5px;
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 4px;
}
.device-check-desc strong { color: var(--text); }
.device-check-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.btn-check { width: auto; padding: 10px 18px; white-space: nowrap; }

.device-check-status { font-size: 11.5px; color: var(--text-dim); text-align: right; max-width: 220px; }
/* Beginner-mode-only affordance: click the "X / Y fields match" status
   line to see exactly which fields still don't match -- see
   showMissingFieldsModal()'s own comment for why this is gated to
   Beginner mode. */
.device-check-status.clickable-status { cursor: pointer; text-decoration: underline dotted; }
.device-check-status.clickable-status:hover { color: var(--text); }
.missing-fields-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); margin: 14px 0 4px; }
.missing-fields-group-title:first-child { margin-top: 0; }
.missing-fields-row { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.missing-fields-row:last-child { border-bottom: none; }
.missing-field-label { flex: 1; }
.missing-field-status { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 8px; border: 1px solid currentColor; }
.missing-field-status.check-changed { color: var(--changed); }
.missing-field-status.check-unexpected { color: var(--danger); }
.missing-field-status.check-untouched { color: var(--text-dim); }
.missing-field-how { font-size: 11.5px; color: var(--text-dim); flex-basis: 100%; }

/* Live-device check status, applied directly to a step in the checklist
   below (see stepCheckStatus() in app.js) -- no separate results list. */
.step.check-ok { border-color: var(--cyan); }
.step.check-changed { border-color: var(--changed); }
.step.check-unexpected { border-color: var(--danger); }

/* Colors an individual instruction fragment in place (e.g. the literal
   text "SHIFT+ATTACK 31") once a device check has data for it -- see ck()
   and the [data-check-path] pass in renderGuide() in app.js. On a
   multi-value step like an envelope's A/D/S/R, each fragment gets its own
   color instead of one status for the whole step. "untouched" (still at
   the init value) intentionally gets no styling -- it should read as
   ordinary text, not be highlighted. */
/* The kbd()/val() spans nested inside a fragment (".kbd", ".value") carry
   their own explicit color, which would otherwise win over the wrapper's
   color by specificity -- so the status color is repeated onto them
   directly rather than relying on inheritance. */
.check-value.check-ok,
.check-value.check-ok .value,
.check-value.check-ok .kbd { color: var(--cyan); }
.check-value.check-changed,
.check-value.check-changed .value,
.check-value.check-changed .kbd { color: var(--changed); }
.check-value.check-unexpected,
.check-value.check-unexpected .value,
.check-value.check-unexpected .kbd { color: var(--danger); }

/* Live-only: which way to turn the physical knob (see applyLiveSpanVisuals()
   in app.js) -- shown right after a live check-value fragment whenever it's
   not (or no longer) a match. hidden by default; app.js only unhides it
   with a real direction, never inserts/removes the element itself (so it
   doesn't reflow the surrounding text on every CC message). */
.live-arrow {
  display: inline-block;
  margin-left: 2px;
  font-size: 10px;
  line-height: 1;
  vertical-align: super;
}
/* An author rule of equal specificity beats the UA stylesheet's [hidden]
   rule regardless of source order -- same fix as .modal-overlay[hidden]
   above, needed for the same reason: the plain .live-arrow rule's
   `display: inline-block` would otherwise override `hidden` and leave a
   stale arrow showing. */
.live-arrow[hidden] { display: none; }
.live-arrow-up,
.live-arrow-down { color: var(--text-dim); }

/* MIDI Follow live steps (see isLiveStep()/liveStepStatus() in app.js):
   same border-color language as .step.check-ok/-changed/-unexpected above,
   plus a small badge next to the step title identifying WHY it's colored
   without a "Check now" click -- and a distinct dim/dashed state for "live,
   but nothing's arrived from the device for this yet" so that's never
   confused with "untouched" (which, for a live step, would incorrectly
   suggest we'd actually checked and it matched the init value). */
.step-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
}
.step-badge-live { background: var(--changed-soft); color: var(--cyan); border: 1px solid var(--cyan); }
.step-badge-pending { background: transparent; color: var(--text-dim); border: 1px solid var(--border); text-transform: none; }
.step.step-live-waiting { border-style: dashed; }

/* Flags device-side changes with no step of their own to be colored in --
   a parameter the target patch never uses (e.g. bitcrush on a patch that
   never touched it) or an extra patch cable the target didn't ask for.
   See findUnexpectedChanges() in app.js. */
.unexpected-changes {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 22px;
  font-size: 12.5px;
}
.unexpected-title { font-weight: 700; color: var(--danger); margin-bottom: 6px; }
.unexpected-changes ul { margin: 0; padding-left: 18px; color: var(--text-dim); }
/* Idea 6: "did you mean to...?" teaching note under a flagged unexpected
   change, shown when "Show tips" is on -- reuses the same PARAM_CONCEPTS
   copy the Steps tab shows, so learning why a parameter matters isn't
   limited to only the steps this specific preset happens to use. */
.unexpected-note { color: var(--text-dim); font-size: 11.5px; margin-top: 2px; line-height: 1.5; }
/* Always shown (not gated behind "Show tips" like .unexpected-note above)
   -- the actual fix (what value + which shortcut), not an optional
   teaching aside. Brighter than the dim why-note since it's the
   actionable part of this item, not background context. */
.unexpected-reset { color: var(--text); font-size: 11.5px; margin-top: 2px; line-height: 1.5; }

/* Minimal styling for deluge-check-settings.js's own generated markup. */
.deluge-check-settings { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.deluge-check-settings__row { display: flex; align-items: center; }
.deluge-check-settings input[type="number"] {
  width: 70px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 3px 6px;
  margin-left: 4px;
}
.deluge-check-settings__overrides { display: flex; flex-direction: column; gap: 6px; padding-top: 6px; border-top: 1px solid var(--border); }

@media (max-width: 800px) {
  /* --- Structural fix -----------------------------------------------------
     Desktop is a fixed-viewport-height, two-pane app: .layout is pinned to
     `calc(100% - topbar)` and .library/.guide each scroll *independently*
     inside that fixed box. That's the right call with a mouse and a tall
     window -- it's also exactly what made the app feel broken on a phone:
     everything past the first screenful (every actual tab's content) lived
     inside a small nested scroll region that a normal page-scroll gesture
     never reaches, and Playwright's own full-page capture confirmed it --
     scrolling the *page* barely moved past the topbar+loader. Below this
     width, switch to one normal, continuously-scrolling document instead. */
  body { overflow-x: hidden; } /* safety net -- see .topbar fix below for the actual source of the overflow */
  .layout { grid-template-columns: 1fr; height: auto; }
  /* `overflow-y: auto` (desktop's value) has a side effect this relies on:
     per spec, a grid/flex item's automatic min-width is its content's
     min-content size UNLESS the item itself has overflow other than
     `visible`, in which case that automatic minimum is 0 instead. Desktop's
     `overflow-y: auto` quietly gets that exemption "for free", which is the
     only reason wide content (the Signal Path/Compare SVGs, hundreds of px
     wider than the guide column) never forced `.guide`'s grid track wider
     than the desktop layout intends. Switching to `overflow-y: visible`
     above removes that exemption, so it has to be restated explicitly here
     -- otherwise the SVGs force this grid item (and so the whole page)
     wider than the viewport instead of scrolling inside their own
     .signal-diagram-wrap, reintroducing page-level horizontal overflow. */
  .guide { overflow-y: visible; min-width: 0; padding: 18px 16px 48px; }

  /* The preset library becomes a normal block above the guide instead of a
     side column, with its own bounded, internally-scrollable list (see the
     .library-body/.preset-tree `min-height: 0` fix above this breakpoint --
     without it this max-height clips the list instead of scrolling it, so
     most presets were both invisible AND unclickable). Bounding it keeps a
     long library from pushing the actual guide far down the page. */
  .library { border-right: none; border-bottom: 1px solid var(--border); max-height: 58vh; }

  /* #loaderPanel (the "Choose synths folder / individual files / connected
     Deluge" block) never gets hidden once a library is loaded -- by design,
     so you can always load a different folder -- but its full ~340px of
     buttons and copy is a flex sibling of #libraryBody competing for the
     same capped height, and (being ordinary block content) it can't
     actually shrink below its own content size the way the preset list
     can. Left alone it simply wins the space, squeezing the preset list --
     the thing you actually came here for -- down to a sliver. Once a
     library IS loaded, collapse it to just the "load a different folder"
     button + status line so the list gets the room. */
  #loaderPanel:has(~ #libraryBody:not([hidden])) { padding: 10px 18px 8px; }
  #loaderPanel:has(~ #libraryBody:not([hidden])) > p:first-of-type,
  #loaderPanel:has(~ #libraryBody:not([hidden])) .or-divider,
  #loaderPanel:has(~ #libraryBody:not([hidden])) #pickFilesBtn,
  #loaderPanel:has(~ #libraryBody:not([hidden])) #loadFromDelugeBtn {
    display: none;
  }

  .device-check-panel { flex-direction: column; align-items: stretch; }
  .device-check-actions { align-items: stretch; }
  .btn-check { width: 100%; }

  /* Topbar: "Connect Deluge…" + status text + the Beginner/Expert toggle no
     longer fit in one row next to the title at phone widths -- the "Expert"
     label was being clipped clean off the edge of the screen (the actual
     source of the page's horizontal scroll), not just tight. Wrap onto a
     second row instead of overflowing. */
  .topbar { flex-wrap: wrap; row-gap: 8px; padding: 12px 16px; }
  .topbar h1 { font-size: 16px; }
  .topbar-controls { flex-wrap: wrap; row-gap: 8px; }
  /* A left border only makes sense when .topbar-help trails the other
     groups on the same line -- once things wrap, it can just as easily
     land first on its own row, where a stray border reads as a mistake. */
  .topbar-help { padding-left: 0; border-left: none; }

  /* Filter chips: 3px/9px padding at 11px font is a mouse-era target, well
     under the ~28-44px phones expect for a reliable tap. */
  .library-filters { gap: 8px; }
  .filter-group { gap: 8px; }
  .filter-chip { padding: 7px 12px; font-size: 12.5px; }

  /* Tab bar: at phone width "Mod Matrix" and "Signal Path" each wrapped
     their own label onto two lines (the row itself stayed one line --
     `gap: 4px` flex with no flex-wrap -- but the buttons were squeezed
     narrower than their label's natural width first). Two-line tab labels
     ate a lot of vertical space and read as broken. Keep every label on one
     line and let the row scroll horizontally instead -- a well-understood
     mobile pattern, and every tab is still one tap away either way. */
  .tab-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 14px 0 16px; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; padding: 8px 12px; font-size: 12.5px; }

  .guide-toolbar { gap: 10px 18px; margin-bottom: 12px; }
  .guide-actions { margin: 10px 0 4px; }
  .guide-actions .btn-secondary { padding: 8px 12px; }

  /* Modals: don't nest a second independently-scrolling region inside the
     already-scrollable .modal-box -- one scroll gesture should reach every
     glossary term instead of two different boxes each capturing part of
     the touch-drag. */
  .glossary-list { max-height: none; }
  .user-guide-list { max-height: none; }
  .modal-box { padding: 16px; }

  .step.step-indent { margin-left: 14px; } /* narrower than desktop's 28px -- less width to spare here */
}

/* Landscape phone (short, wide viewport): the portrait breakpoint above
   turns the whole page into one long scrolling document, which is exactly
   right when height is the scarce resource -- but in landscape, WIDTH is
   the scarce-ish resource instead and there's plenty of height for a
   proper two-pane layout again. So landscape mobile goes back to
   desktop's side-by-side grid (own comment above .layout in the portrait
   block explains why `overflow-y: auto`/independent scroll panes need to
   come back too, not just the column split) -- but a permanently-visible
   ~210px preset list still eats a big share of a phone's landscape width
   from the guide content, which is what's actually being read/interacted
   with most of the time. A collapse toggle (visible only in this exact
   breakpoint, see `.library-collapse-toggle` above) lets that width be
   reclaimed on demand instead of either wasting it constantly or hiding
   the list outright. Cascade note: rules here share exact selectors with
   the portrait block above and win via source order (this block comes
   later), not extra specificity -- keep new landscape rules appended
   after this comment, not inserted earlier in the file, or they'll lose.

   Gated on max-height, not max-width: a width cap (originally 900px) let
   wider-but-still-short phones fall through untouched -- an iPhone 15 Pro
   Max is 932px wide in landscape but only 430px tall, so it matched
   neither this block nor the portrait one and got bare desktop CSS with
   no loader-collapse and no scrollable library-body, reproducing the
   exact 0px-tall preset-tree bug this block exists to fix. What actually
   causes the squeeze is limited vertical space, which max-height targets
   directly regardless of how wide the phone is; a landscape tablet (e.g.
   iPad, ~1024px+ wide but 700px+ tall) correctly stays out since it has
   height to spare. */
@media (max-height: 500px) and (orientation: landscape) {
  .layout { grid-template-columns: 240px 1fr; height: calc(100% - 53px); }
  .guide { overflow-y: auto; min-width: 0; padding: 18px 20px 40px; }
  .library { max-height: none; border-right: 1px solid var(--border); border-bottom: none; }

  /* Bug found after shipping the collapse toggle: the preset list was
     rendering at 0px tall and totally unreachable. Root cause was relying
     on #presetTree alone (flex:1; min-height:0) to be the library's only
     scrollable region while #searchBox/.library-filters/#presetCount sat
     above it at a fixed (non-shrinking) height -- at this column's ~240px
     width the 3 filter-chip rows wrap across multiple lines (measured up
     to ~300px tall on a real iPhone SE), which alone can exceed this
     breakpoint's ~320-430px of total available height, so the tree's
     flexible share got squeezed to nothing before a single preset ever
     had room to render. Making the whole body scroll as one unit (like
     the portrait breakpoint already does for the whole page) means
     search/filters/tree share one scrollbar instead of the tree alone
     being squeezed out by its fixed-height siblings. */
  .library-body { overflow-y: auto; min-height: 0; }
  .preset-tree { overflow-y: visible; flex: none; }

  /* The portrait breakpoint's #loaderPanel-collapse-once-loaded rule (see
     above) only fires below 800px, so it silently never applied to
     landscape phones wider than that (e.g. a real iPhone 13/14, 844px
     landscape) -- the ~350-425px-tall uncollapsed loader panel alone could
     eat this breakpoint's entire height budget. Restate unconditionally
     for every width this landscape breakpoint covers. */
  #loaderPanel:has(~ #libraryBody:not([hidden])) { padding: 10px 12px 8px; }
  #loaderPanel:has(~ #libraryBody:not([hidden])) > p:first-of-type,
  #loaderPanel:has(~ #libraryBody:not([hidden])) .or-divider,
  #loaderPanel:has(~ #libraryBody:not([hidden])) #pickFilesBtn,
  #loaderPanel:has(~ #libraryBody:not([hidden])) #loadFromDelugeBtn {
    display: none;
  }

  /* Filter chips at this narrower column: shrink further than the portrait
     breakpoint's already-touch-sized version so fewer of them wrap, which
     directly shrinks how much height the filter block competes for. */
  .library-filters { gap: 4px; }
  .filter-group { gap: 4px; }
  .filter-chip { padding: 5px 9px; font-size: 11.5px; }

  .library-collapse-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 9px 8px;
    background: var(--panel-2);
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .library-collapse-toggle:hover { color: var(--text); }
  .library-collapse-icon { transition: transform 0.15s; font-size: 15px; line-height: 1; }

  /* Collapsed: the sidebar grid track shrinks to just fit the toggle
     (turned into a full-height vertical strip, arrow flipped to point the
     other way), and everything else in .library disappears -- loader
     buttons or the preset-body, whichever is currently showing. Toggling
     is session-only (see the comment on the click listener in app.js). */
  body.sidebar-collapsed .layout { grid-template-columns: 34px 1fr; }
  body.sidebar-collapsed .library > *:not(.library-collapse-toggle) { display: none; }
  body.sidebar-collapsed .library-collapse-toggle { flex-direction: column; height: 100%; padding: 10px 4px; border-bottom: none; border-right: 1px solid var(--border); }
  body.sidebar-collapsed .library-collapse-icon { transform: rotate(180deg); }
  body.sidebar-collapsed .library-collapse-label {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
  }
}
