/* Phones and narrow windows: a compact header, a wider ☰ menu, bigger targets. Loaded last: it overrides. */
@media (max-width: 860px) {
    header { padding: env(safe-area-inset-top) calc(var(--s3) + env(safe-area-inset-right)) 0 calc(var(--s3) + env(safe-area-inset-left)); height: calc(var(--header-h) + env(safe-area-inset-top)); }
    header .brand-name { display: none; }
    header:has(#h-page:empty) .brand-name { display: inline; }
    header .trail { font-size: var(--fs-l); }
    header .trail > .page { font-weight: 600; }
    /* The page above shrinks to a back arrow (its name stays its accessible text); the page's own name gets the room. */
    header .trail > a { font-size: 0; min-width: 0; flex: none; padding: 6px 4px; }
    header .trail > a::before { content: '‹'; font-size: 22px; line-height: 1; margin: 0; color: #c9cfd2; }
    header .trail > a:not([hidden]) ~ .page::before { content: none; }
    /* Signed in, Blog and Documentation move into the ☰ menu (its .rail-phone links). */
    body:not(.signed-out) .h-link { display: none; }
    /* Signed out they stay, smaller, so Sign in fits beside them. */
    #h-blog, #h-docs { padding: 6px; font-size: var(--fs-s); }
    header { gap: var(--s2); }
    body.signed-out header .brand-name, body.signed-out header:has(#h-page:empty) .brand-name { display: none; }   /* the mark alone, so Sign in fits */
    #rail .rail-phone { display: block; }
    /* Floating over the page, nearly the screen's width. */
    #rail {
        top: calc(var(--header-h) + env(safe-area-inset-top) + var(--s1));
        left: calc(var(--s2) + env(safe-area-inset-left)); right: calc(var(--s2) + env(safe-area-inset-right)); width: auto;
        max-height: calc(100vh - var(--header-h) - env(safe-area-inset-top) - var(--s4));
    }
    #rail a { padding: var(--s3); font-size: var(--fs-l); }
    #actions { padding: 12px calc(var(--s3) + env(safe-area-inset-right)) calc(var(--s4) + env(safe-area-inset-bottom)) calc(var(--s3) + env(safe-area-inset-left)); }
    .log { font-size: var(--fs-xs); }

    /* 16px stops iOS zooming into a field on focus; 40px+ targets for thumbs. */
    input[type=text], input[type=password], input[type=number], textarea, select { font-size: var(--fs-l); padding: var(--s2); }
    button, a.button { min-height: 40px; padding: var(--s2) var(--s4); }
    button.small { min-height: 36px; padding: var(--s2) var(--s3); }
    .seg button { min-height: 36px; }
    label.check { font-size: var(--fs-l); min-height: 32px; }
    label.check input { width: 20px; height: 20px; }
    .grid3 { grid-template-columns: 1fr 1fr; }
    .grid2 { grid-template-columns: 1fr; }
    .lora-row { grid-template-columns: 1fr 76px 40px; }
    .form-actions button[type=submit] { flex: 1; }
    details > summary { font-size: var(--fs-m); padding: var(--s2) 0; }
    .cmd { font-size: var(--fs-xs); }
    .rowline .meta.opt { display: none; }
    /* Rows wrap rather than clip: status stays on screen, the summary takes its own line. */
    /* Three lines, the same in every list: the name (and its version), what it is, then when and how it stands.
       The summary sits between them and takes a whole line, so it is also the break; the whole row is the link. */
    .rowline { flex-wrap: wrap; row-gap: var(--s1); padding: var(--s3); }
    .rowline .title { white-space: normal; overflow-wrap: anywhere; min-width: 0; }
    .rowline .grow:not(.title) { flex-basis: 100%; white-space: normal; overflow-wrap: anywhere; }
    .rowline .grow:not(.title):empty { height: 0; margin-top: calc(-1 * var(--s1)); }
    .rowline > [aria-hidden=true] { display: none; }
    /* A cover beside the lines, not above them. */
    .rowline:has(> .lead) { display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: var(--s3); row-gap: var(--s0); align-items: start; }
    .rowline:has(> .lead) > .lead { grid-row: 1 / span 4; align-self: center; }
    .rowline:has(> .lead) > :not(.lead) { grid-column: 2; }
    .rowline:has(> .lead) > .chip { justify-self: start; }
    /* A page's main list (rows.big): the same lines, a little more room around them. */
    .rows.big .rowline { min-height: 0; padding: var(--s3) var(--s4); gap: var(--s1) var(--s2); }
    .rows.big .rowline:has(> .lead) { column-gap: var(--s3); row-gap: var(--s0); }
    .rows.big .ex-group-runs > .rowitem > .rowline { min-height: 0; padding-left: calc(var(--s4) + 1.5em); }
    .rows.big .row-actions { padding-right: var(--s4); }
    /* colList(): each row stacks, the name (and what it is) then its cells on one line; no header. */
    .chead { display: none !important; }
    .crow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) 10px; padding: 14px var(--s4); min-height: 0; }
    .crow .who { flex: 1 1 calc(100% - 30px); padding: 0; }
    .crow.block .who { flex-basis: 100%; }
    .crow.block .go { display: none; }
    .crow .go { width: 16px; text-align: right; }
    .crow .cell { order: 2; }
    .crow .cell.opt { display: none; }
    .crow .name { white-space: normal; overflow-wrap: anywhere; }
    .crow .cell.end { margin-left: auto; }
    .crow .cell:empty { display: none; }
    /* A list's tools: the search takes a line, the actions follow. */
    .env-facts { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
    .env-facts dd { margin-bottom: var(--s2); }
    .toolbar > .spacer { display: none; }
    .toolbar > .spacer + * { margin-left: auto; }
    .toolbar > input[type=search].search { flex: 1 1 100%; }
    input[type=search].search { flex: 1; font-size: var(--fs-l); padding: var(--s2); }
    /* A table becomes blocks: each value on its own line, named. */
    table.data, table.data tbody, table.data tr, table.data td { display: block; }
    table.data thead { display: none; }
    table.data tr { padding: var(--s2) 0; border-bottom: 1px solid var(--line); }
    table.data td { display: flex; gap: var(--s3); border: 0; padding: var(--s0) var(--s3); }
    table.data td::before { content: attr(data-label); color: var(--dim); flex: none; width: 84px; }
    table.data td:empty { display: none; }
    table.data.datasets td { min-width: 0; max-width: none; }
    /* The version picker gets its own line above the tabs, so they keep their room. */
    .tabrow { flex-direction: column-reverse; align-items: stretch; gap: var(--s2); border-bottom: 0; }
    .tabrow > .tabbar { border-bottom: 1px solid var(--line); }
    .tabrow > .page-version { max-width: none; }
}
