/* MICMAC — single stylesheet, no external dependency.

   Built on the one written for MICMAC Bichat, so the two applications read as
   siblings: same tokens, same lollipop, same two themes. What is new here is
   the MIC distribution band on the left of every row. */

:root {
  color-scheme:    light;
  --bg:            #f4f6f8;
  --surface:       #ffffff;
  --surface-2:     #f8fafb;
  --band:          #eceff2;   /* alternating rows, the grey84 of the original */
  --ink:           #10161c;
  --ink-2:         #48545f;
  --ink-3:         #6d7a85;
  --line:          #dbe1e6;
  --line-strong:   #c3ccd3;
  --accent:        #00589a;   /* the blue of the MICMAC wordmark */
  --accent-ink:    #ffffff;
  --accent-soft:   #e4eef6;
  --warn:          #8a5300;
  --warn-bg:       #fdf3e2;
  --danger:        #a12020;
  /* The reading key's grey. Deliberately outside the ramp: the specimen shows
     how to read a row, it is not a result and must not look like one. */
  --key-mark:      #a9b4bd;
  /* Susceptibility ramp, identical to the Shiny application. Defined here and
     nowhere else: the chart reads it from the CSS, so one definition serves
     both themes and nothing can drift. */
  --ramp-0:        #8b0000;   /* red4 */
  --ramp-25:       #e46726;
  --ramp-50:       #fabb00;
  --ramp-100:      #548b54;   /* palegreen4 */
  /* MIC panel: dashed gridlines, and the two breakpoint inks — grey25 for a
     species breakpoint, grey60 for a PK/PD one. */
  --grid:          #cbd3da;
  --bp:            #404040;
  --bp-soft:       #999999;
  --radius:        10px;
  --radius-sm:     7px;
  --shadow:        0 1px 2px rgba(16, 22, 28, .06), 0 4px 16px rgba(16, 22, 28, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* The dark palette is not behind a media query: theme.js resolves "auto" into
   light or dark before the first paint and sets data-theme on <html>. One
   palette to describe, whatever the number of states offered. */
:root[data-theme="dark"] {
  color-scheme:  dark;
  --bg:          #10151a;
  --surface:     #171d23;
  --surface-2:   #1c232a;
  --band:        #212931;
  --ink:         #e8edf1;
  --ink-2:       #adb8c2;
  --ink-3:       #8e9ca8;
  --line:        #2a333c;
  --line-strong: #3a4650;
  --accent:      #4d9fe0;
  --accent-ink:  #08121b;
  --accent-soft: #17293a;
  --warn:        #f0b866;
  --warn-bg:     #2e2413;
  --danger:      #f08a8a;
  --key-mark:    #55636f;
  /* Same progression, lifted in lightness: on a dark ground the original tones
     sink towards olive, and the upper range — where most values sit — ends up
     looking uniformly yellow. */
  --ramp-0:      #d4544f;
  --ramp-25:     #e8813c;
  --ramp-50:     #eec245;
  --ramp-100:    #63c187;
  --grid:        #333d47;
  --bp:          #cdd6de;
  --bp-soft:     #7d8b97;
  --shadow:      0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.25rem; margin: 0 0 .2em; letter-spacing: -.01em; }
p  { margin: 0 0 .6em; }
.muted { color: var(--ink-2); }

.skip { position: absolute; left: -9999px; top: 0; z-index: 10;
        background: var(--accent); color: var(--accent-ink); padding: .6em 1em; }
.skip:focus { left: .5rem; top: .5rem; }

:where(button, select, input, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem clamp(.8rem, 3vw, 1.6rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .65rem; }
.brand .title { font-size: 1.15rem; letter-spacing: .06em; display: block; }
.brand .tagline {
  display: block; font-style: normal; font-size: .72rem; color: var(--ink-3);
  letter-spacing: .01em;
}
/* Without an outlined logo yet, the mark is logo/icon.svg beside the name. */
.mark { display: block; width: 30px; height: 30px; flex: none; }

/* Logo et barre du haut — bloc commun aux applications (Notion : « Modèle
   d'application »). static/logo.svg (clair) et static/logo_dark.svg (sombre),
   copiés depuis logo/ par ./<application> logo, hauteur fixe, largeur d'après
   les proportions. --barre est la hauteur de la barre : ce qui colle sous elle
   (onglets, panneau de filtres) s'y cale, au lieu d'un nombre de rem à deviner. */
:root { --logo-h: 56px; --sous-titre: 1.05rem; --barre: calc(var(--logo-h) + var(--sous-titre) + 1.5rem + 1px); }
@media (max-width: 480px) { :root { --logo-h: 36px; --sous-titre: .85rem; } }
.topbar { box-sizing: border-box; min-height: var(--barre); padding-top: .75rem; padding-bottom: .75rem; }
.logo { display: block; height: 56px; width: auto; max-width: 62vw; object-fit: contain; object-position: left center; flex: none; }
.logo.sombre { display: none; }
:root[data-theme="dark"] .logo.clair { display: none; }
:root[data-theme="dark"] .logo.sombre { display: block; }
@media (max-width: 480px) { .logo { height: 36px; } }
/* Subtitle: aligned with the wordmark, not the icon, and drawn up against
   its foot. Geometry read from static/logo.png (1104 × 168 after ./micmac logo):
   the wordmark starts at 223/168 of the logo height, its foot at 144/168. If
   the logo changes proportions, revisit those two ratios. The theme switch sits
   on the logo's row, leaving the subtitle the full width.
   width: 0 keeps the subtitle from widening the brand: on a phone it runs on
   beneath the theme switch instead of pushing it off screen. */
.lockup { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.sous-titre {
  display: block; box-sizing: border-box;
  height: var(--sous-titre); line-height: var(--sous-titre);
  margin-top: calc(var(--logo-h) * -24 / 168 + .3rem);
  padding-left: calc(var(--logo-h) * 223 / 168);
  font-size: .93rem; font-weight: 500; letter-spacing: .015em; color: var(--ink-2);
  white-space: nowrap; width: 0; overflow: visible;
}
.topbar .theme { align-self: flex-start; margin-top: calc((var(--logo-h) - 1.75rem - 2px) / 2); }
@media (max-width: 480px) { .sous-titre { font-size: .8rem; letter-spacing: .005em; } }

/* Theme choice: three states, "auto" following the device. Discreet by
   default; only the state in force is inked. */
.theme {
  display: flex; flex: none;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2);
}
.theme label { display: flex; }
.theme input { position: absolute; opacity: 0; pointer-events: none; }
.theme span {
  display: grid; place-items: center; cursor: pointer;
  width: 2rem; height: 1.75rem; color: var(--ink-3);
  border-left: 1px solid var(--line-strong);
}
.theme label:first-child span { border-left: 0; }
.theme span:hover { color: var(--ink-2); background: var(--surface); }
.theme input:checked + span { color: var(--accent); background: var(--accent-soft); }
.theme input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ------------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

button.ghost, button.preset {
  font: inherit; cursor: pointer; border-radius: var(--radius-sm);
  padding: .4em .9em; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink-2);
}
button.ghost:hover, button.preset:hover { background: var(--surface); color: var(--ink); }
/* The preset last clicked stays inked until the selection is touched by hand —
   the behaviour of the four buttons in the Shiny sidebar (server.R:20-70). */
button.preset.on {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}

/* ------------------------------------------------------------------ layout */

.layout {
  display: grid;
  grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr);
  gap: clamp(.8rem, 2vw, 1.4rem);
  align-items: start;
  padding: clamp(.8rem, 2vw, 1.4rem);
  max-width: 92rem; margin: 0 auto;
}

/* --------------------------------------------------------------- selection */

/* The panel stays in view while the chart scrolls. It carries no overflow of
   its own — that would clip the organism list, which has to be able to hang
   below the card — so it is the antibiotic list underneath that scrolls. */
.filters { padding: .35rem .9rem .9rem; position: sticky; top: calc(var(--barre) + .6rem); }
.filters fieldset { border: 0; margin: 1rem 0 0; padding: 0; }
.filters legend, .field > span {
  font-size: .78rem; font-weight: 600; letter-spacing: .02em;
  text-transform: uppercase; color: var(--ink); padding: 0;
}
.field { display: grid; gap: .3rem; margin-top: 1rem; }

.segmented {
  display: flex; margin-top: .35rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden;
}
.segmented label { flex: 1; display: flex; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  flex: 1; text-align: center; padding: .42em .3em; font-size: .86rem;
  cursor: pointer; color: var(--ink-2); background: var(--surface-2);
  border-left: 1px solid var(--line-strong); white-space: nowrap;
}
.segmented label:first-child span { border-left: 0; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.disclosure { display: none; }

/* -------------------------------------------------------------- combo box */

/* 250 organisms is far past what a plain menu can serve, on a phone above all:
   the field filters as you type and the list is navigable from the keyboard. */
.combo { position: relative; }
.combo input {
  font: inherit; width: 100%; padding: .5em 1.9em .5em .6em;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink);
}
.combo input::placeholder { color: var(--ink-3); }
.combo .clear {
  position: absolute; right: .1rem; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--ink-3); cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: .2rem .45rem;
}
.combo .clear:hover { color: var(--ink); }
.combo ul {
  position: absolute; z-index: 6; left: 0; right: 0; top: calc(100% + 3px);
  margin: 0; padding: .25rem; list-style: none; max-height: 17rem; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.combo ul[hidden] { display: none; }
.combo li {
  padding: .32em .5em; border-radius: 5px; cursor: pointer; font-size: .92rem;
}
.combo li[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.combo .none { color: var(--ink-3); cursor: default; }

/* --------------------------------------------------- antibiotic selection */

.presets { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.coverage { display: flex; align-items: stretch; margin-top: .45rem; }
.coverage button { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.coverage .box {
  display: flex; align-items: center; gap: .15em;
  border: 1px solid var(--line-strong); border-left: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-2); color: var(--ink-2); padding: 0 .55em; font-size: .9rem;
}
.coverage input {
  font: inherit; width: 2.6em; text-align: right; border: 0; padding: 0;
  background: none; color: var(--ink); -moz-appearance: textfield;
}
.coverage input::-webkit-outer-spin-button,
.coverage input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Bounded and scrolled inside the card rather than running the panel off the
   screen: the organism field and the four presets must stay reachable while a
   long list is being worked through. The rule above it says where it starts. */
.ab-panel {
  margin-top: .9rem; padding-top: .6rem; border-top: 1px solid var(--line);
  max-height: 52vh; overflow-y: auto; scrollbar-width: thin;
  overscroll-behavior: contain;
}

/* Only exists where the list has to fold — see the phone block below. */
.ab-toggle { display: none; }
.ab-panel .grp {
  font-style: italic; font-size: .82rem; color: var(--ink-3);
  margin: .7rem 0 .15rem;
}
.ab-panel .grp:first-child { margin-top: 0; }
.ab-panel label {
  display: flex; gap: .45em; align-items: baseline;
  padding: .07rem 0 .07rem .55rem; font-size: .87rem; cursor: pointer;
  line-height: 1.3;
}
.ab-panel label:hover { color: var(--accent); }
.ab-panel input { margin: 0; accent-color: var(--accent); flex: none; position: relative; top: .12em; }

/* ---------------------------------------------------------------- result */

.result { min-width: 0; }
.result > .card { padding: clamp(.9rem, 2.2vw, 1.4rem); }
.empty { color: var(--ink-2); }
.empty h1 { color: var(--ink); }

.result-head { display: flex; align-items: baseline; justify-content: space-between;
               gap: 1rem; flex-wrap: wrap; }
.result-head h1 { font-size: 1.4rem; }
.result-head h1 em { font-style: italic; }

/* The MIC / susceptibility switch only exists where both cannot be shown at
   once, so it is hidden on a wide screen. */
.viewswitch { display: none; flex: none; }

.notice {
  margin: 1rem 0 0; padding: .7em .9em; border-radius: var(--radius-sm);
  background: var(--warn-bg); color: var(--warn); font-size: .9rem;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}

/* ------------------------------------------------------------------ chart */

/* Positioned, so the hover guide and its readout can be laid over the whole
   band of rows rather than inside any one of them. */
.chart { margin-top: 1rem; position: relative; }

/* The dilution under the pointer, lit across every row at once. */
.mic-guide {
  position: absolute; top: 0; bottom: 0; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-left: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 2px;
}
.mic-guide[hidden] { display: none; }

.mic-readout {
  position: absolute; pointer-events: none; z-index: 4;
  padding: .18em .55em; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--bg);
  font-size: .78rem; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow);
}
.mic-readout[hidden] { display: none; }
.mic-readout b { font-weight: 700; }

/* One grid, shared by the heading, the ruler and every row, so the four bands
   line up exactly: MIC distribution, molecule, susceptibility, count. */
.chart-head, .ruler-row, .ab-row {
  display: grid;
  grid-template-columns:
    minmax(0, 1.35fr) minmax(6.5rem, 11rem) minmax(0, 1fr) 5.2rem;
  align-items: center;
  gap: .3rem 1rem;
}

.chart-head[hidden], .legend[hidden] { display: none; }

.chart-head {
  font-size: .74rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-3);
  padding: 0 .45rem .1rem;
}
.chart-head .h-mic  { grid-column: 1; text-align: center; }
.chart-head .h-sus  { grid-column: 3; text-align: center; }

/* The dilution ruler, drawn once, in the distribution band's own column. */
.ruler-row { padding: 0 .45rem; }
.ruler { grid-column: 1; position: relative; height: 1.1rem; }
.ruler span {
  position: absolute; top: 0; transform: translateX(-50%);
  font-size: .68rem; color: var(--ink-3); font-variant-numeric: tabular-nums;
}

.ab-class {
  font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3);
  padding: 1rem 0 .3rem;
  border-bottom: 1px solid var(--line-strong);
  margin-bottom: .12rem;
}

.ab-row { padding: .28rem .45rem; border-radius: 5px; --rowbg: var(--surface); }
.ab-row.band { background: var(--band); --rowbg: var(--band); }

.ab-name { font-size: .88rem; line-height: 1.25; text-align: center; }

.ab-n {
  font-size: .78rem; color: var(--ink-3); text-align: right;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ab-n.low { color: var(--warn); font-weight: 600; }
.ab-n.low::before { content: "⚠ "; }

/* --------------------------------------------------- MIC distribution band */

.ab-mic { position: relative; height: 30px; }
.ab-mic svg { display: block; width: 100%; height: 100%; }
/* The bars carry the colour; the gridlines and breakpoints are strokes kept at
   one physical pixel however far the band is stretched. The rules are not tied
   to .ab-mic so that the reading key can reuse the same marks. */
.mic-grid { stroke: var(--grid); stroke-width: 1; stroke-dasharray: 3 3; }
.mic-bp        { stroke: var(--bp); stroke-width: 1.6; }
.mic-bp.pk     { stroke: var(--bp-soft); }
.mic-bp.dash   { stroke-dasharray: 4 3; }

/* ----------------------------------------------------- susceptibility band */

/* The 0–100 % scale stops short of a gutter that holds the knob and the
   percentage, so nothing can be clipped, not even at 100 %. The gutter is the
   same in both modes: that is what makes the scale absolute, so a given
   percentage always falls in the same place. */
.lane { position: relative; height: 22px; --gutter: 5.6rem; }
.lane.dual { --gutter: 6.9rem; }
.scale { position: absolute; inset: 0 var(--gutter) 0 0; }

.fill {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 5px; border-radius: 999px;
}
.knob {
  position: absolute; top: 50%; width: 11px; height: 11px; border-radius: 50%;
  transform: translate(-50%, -50%); background: var(--c);
}
/* S+I in dual mode: an opaque tint (the colour half blended into the row's
   background) rather than .5 opacity. The link can then run to the knob's
   centre without a darker overlap; stopped at the knob's edge, it left a thin
   gap before the knob. */
.fill.soft, .knob.ghost { background: color-mix(in srgb, var(--c) 50%, var(--rowbg, var(--surface))); }

/* Transparency carries ONE meaning in this chart: the translucent mark is the
   S+I value, the solid one is S. server.R:311 also drew a percentage obtained
   through an interpretive rule at half opacity, which made the two meanings
   collide — in double mode such a row came out translucent throughout and read
   as if every mark on it were an S+I mark. Interpretive rules are marked by the
   asterisk on the label alone, which the reading key explains. A deliberate
   departure, and the reason it is one. */

.val {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: .95rem; font-weight: 600; color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  margin-left: 1.05rem;
}
.val .sep { font-weight: 400; color: var(--line-strong); margin: 0 .24em; }
.val .sec { font-weight: 400; }

/* The compact form used on a phone beside the distribution: the mark and the
   number, without the 0–100 % track. */
.ab-dot { display: none; align-items: center; gap: .3rem; justify-content: flex-end; }
.ab-dot .knob { position: static; transform: none; flex: none; }
.ab-dot .num {
  font-size: .88rem; font-weight: 600; color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ab-dot .num .sep { font-weight: 400; color: var(--line-strong); margin: 0 .2em; }
.ab-dot .num .sec { font-weight: 400; }

/* ---------------------------------------------------------------- legend */

.legend {
  margin-top: 1.8rem; padding: .85rem 1rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}
.key { margin: 0; display: grid; gap: .3rem; justify-items: start; align-content: start; }
.key[hidden] { display: none; }
.key figcaption {
  font-size: .7rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3);
}

.key-grid {
  display: inline-grid; align-items: center; justify-items: center;
  grid-template-columns: auto auto; row-gap: .1rem;
}
.key-grid.dual { grid-template-columns: auto auto auto auto; }
.key-spec { position: relative; width: 7rem; height: 12px; margin-right: 1.05rem; }
.key-fill {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 74%; height: 5px; border-radius: 999px; background: var(--key-mark);
}
.key-link {
  position: absolute; left: 74%; top: 50%; transform: translateY(-50%);
  width: 18%; height: 5px; border-radius: 999px;
  background: color-mix(in srgb, var(--key-mark) 50%, var(--surface));
}
.key-knob {
  position: absolute; top: 50%; left: 74%; width: 11px; height: 11px;
  border-radius: 50%; transform: translate(-50%, -50%); background: var(--key-mark);
}
.key-knob.ghost { left: 92%; background: color-mix(in srgb, var(--key-mark) 50%, var(--surface)); }
.key-spec.single .key-fill { width: 92%; }
.key-spec.single .key-knob { left: 92%; }

.k-num { font-size: .95rem; font-weight: 600; color: var(--ink-2);
         font-variant-numeric: tabular-nums; }
.k-num.sec { font-weight: 400; }
.k-sep { font-weight: 400; color: var(--line-strong); margin: 0 .24em; }
.k-tick { width: 1px; height: .32rem; background: var(--line-strong); }
.k-lbl { font-size: .72rem; font-weight: 700; letter-spacing: .04em; color: var(--ink-3); }
.key-def { font-size: .8rem; color: var(--ink-3); margin: .35rem 0 0; }
.key-def b { color: var(--ink-2); font-weight: 600; }

/* The MIC key: a specimen band with its two kinds of breakpoint line. */
.key-mic { display: grid; gap: .35rem; justify-items: start; }
.key-mic .spec { width: 9rem; height: 22px; }
.key-mic .spec svg { display: block; width: 100%; height: 100%; }

.footnotes { margin-top: 1.1rem; font-size: .84rem; color: var(--ink-2); }
.footnotes p { margin: 0 0 .4em; }
.footnotes a { color: var(--accent); }

/* Pied de page — bloc commun aux applications : grandes marges (celles de
   MICMAC), même police, même taille, même gris ; les intitulés en encre pleine,
   les liens à l'accent. Seule la largeur suit la grille de chaque page. */
.colophon {
  max-width: 68rem; margin: 0 auto;
  padding: 1.5rem clamp(.8rem, 3vw, 1.6rem) 3rem;
  font-size: .84rem; line-height: 1.55; color: var(--ink-2);
}
.colophon p { margin: 0 0 .55em; }
.colophon strong { font-weight: 600; color: var(--ink); }
.colophon a { color: var(--accent); }

/* --------------------------------------------------- narrow, then phone */

/* Two thresholds, because they answer two different questions. Below 900 px
   there is no room for a column of controls beside the chart, so the panel
   becomes a fold-away header. The chart itself holds up rather longer: it is
   only below 780 px that the two bands can no longer sit side by side. */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: .7rem; }
  .filters { position: static; padding: 0; }
  /* Nested scrolling is unpleasant on a touch screen: the list runs on and the
     page carries it. */
  .ab-panel { max-height: none; overflow: visible; }

  .disclosure {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; font: inherit; font-weight: 600; cursor: pointer;
    padding: .8rem .9rem; background: none; border: 0; color: var(--ink-2);
  }
  .chev {
    width: .5rem; height: .5rem; border-right: 2px solid var(--ink-3);
    border-bottom: 2px solid var(--ink-3); transform: rotate(45deg);
    transition: transform .18s ease; margin-bottom: .2rem;
  }
  .disclosure[aria-expanded="true"] .chev { transform: rotate(-135deg); margin-bottom: -.2rem; }
  .filters-body { display: none; padding: 0 .9rem 1rem; }
  .filters-body.open { display: block; }
  .filters fieldset:first-child, .filters-body > .field:first-child { margin-top: 0; }

}

@media (max-width: 780px) {
  .viewswitch { display: block; width: 100%; }
  .viewswitch .segmented { margin-top: .6rem; }

  /* Two bands cannot sit side by side at this width. The name and the count
     take the first line; the second holds either the distribution and a mark
     carrying the percentage, or the full lollipop — never both. */
  .ruler-row, .ab-row {
    grid-template-columns: minmax(0, 1fr) 5.2rem;
    gap: .1rem .7rem;
  }
  /* The headings stop being columns and become a caption spanning the pair.
     Without them the marks on the right are percentages of nothing. Small, but
     both fit on one line at this size — measured, not hoped. */
  .chart-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: .5rem; font-size: .6rem; padding: 0 .45rem .3rem;
    /* Clear of the tabs above: two small uppercase labels sitting straight
       under a segmented control read as part of it. */
    margin-top: 1.1rem;
  }
  .chart-head .h-mic, .chart-head .h-sus { grid-column: auto; text-align: left; }
  .chart-head .h-sus { text-align: right; }

  .ruler-row .ruler { grid-area: 1 / 1; }
  .ab-row { padding: .45rem .45rem .5rem; }
  .ab-name { grid-area: 1 / 1; text-align: left; font-weight: 500; }
  .ab-n    { grid-area: 1 / 2; }
  .ab-mic  { grid-area: 2 / 1; }
  .ab-dot  { grid-area: 2 / 2; display: flex; }
  .ab-lane { grid-area: 2 / 1 / 3 / -1; }
  .lane, .lane.dual { --gutter: 6.3rem; }

  .mode-mic  .ab-lane { display: none; }
  /* The distribution's heading, ruler and bars leave together; the tab name
     already says what is left. */
  .mode-lane .ab-mic,
  .mode-lane .ab-dot,
  .mode-lane .ruler-row,
  .mode-lane .chart-head { display: none; }

  /* The presets stay in view. The list itself folds, so choosing an organism
     does not push the chart off the bottom of the screen. */
  .ab-toggle {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; margin-top: .8rem; font: inherit; font-size: .87rem;
    font-weight: 600; cursor: pointer; color: var(--ink);
    background: var(--surface-2); border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); padding: .55rem .7rem;
  }
  .ab-toggle .chev { margin-bottom: .2rem; }
  .ab-toggle[aria-expanded="true"] .chev { transform: rotate(-135deg); margin-bottom: -.2rem; }
  .ab-panel { display: none; margin-top: .6rem; padding-top: 0; border-top: 0; }
  .ab-panel.open { display: block; }
}

/* -------------------------------------------------------------- touch input */

/* Safari on iOS zooms the whole page when a text field it is about to focus is
   set below 16 px, and does not zoom back out afterwards: tap the organism
   field and the carefully fitted layout is left magnified and scrolling
   sideways. The two text fields are therefore given 16 px wherever the pointer
   is a finger. The body stays at 15 px; only what can be focused grows.

   The alternative — user-scalable=no in the viewport tag — would also stop the
   zoom, by taking pinch-zoom away from everyone. Not a trade worth making, and
   iOS has ignored it since version 10 in any case. */
@media (hover: none) and (pointer: coarse) {
  .combo input,
  .coverage input,
  .coverage .box { font-size: 16px; }
}

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