/* Phone mode (data-phone="on"): drugbook. Every rule here is prefixed :root[data-phone="on"] so nothing leaks to desktop. */

/* The Drug Book on a phone (2026-09-24): the list, then the card with an "All drugs"
   back. A vet at the kennel checks one dose or one interaction and puts the phone away,
   so the card is one column, the species chips sit on one row, and everything tappable
   is at least 44px. These selectors carry :root[data-phone] and so outrank the page's
   scoped .drugbook-*[b-xxx] rules (0,3,0 against 0,2,0). Tokens only; micro type
   consumes the comfort floor, as in the scoped sheet. */

/* ── One pane at a time ──────────────────────────────────────────────────────── */
:root[data-phone="on"] .drugbook-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
}

:root[data-phone="on"] .drugbook-page--open .drugbook-list { display: none; }
:root[data-phone="on"] .drugbook-page:not(.drugbook-page--open) .drugbook-mono { display: none; }

:root[data-phone="on"] .drugbook-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin: -0.35rem 0 0.1rem;
    padding: 0 0.25rem 0 0;
}

/* The card loses its frame: the article already has one, and a bordered panel inside
   a 375px gutter spent 30px of every line on chrome. */
:root[data-phone="on"] .drugbook-mono {
    padding: 0.4rem 0 0;
    border: 0;
    background: transparent;
}

:root[data-phone="on"] .drugbook-title {
    font-size: 1.6rem;
    line-height: 1.1;
}

/* ── Header controls ─────────────────────────────────────────────────────────── */
:root[data-phone="on"] .drugbook-mode { flex: 0 0 auto; }

:root[data-phone="on"] .drugbook-mode-btn {
    min-height: 44px;
    padding-inline: 1rem;
}

:root[data-phone="on"] .drugbook-search { min-height: 44px; font-size: 1rem; }

/* Dog / Cat / All on one row, each an equal share of the width. */
:root[data-phone="on"] .drugbook-species {
    flex-wrap: nowrap;
    gap: 0.4rem;
}

:root[data-phone="on"] .drugbook-species-chip {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    font-size: 0.95rem;
}

/* ── Facts ───────────────────────────────────────────────────────────────────── */
/* Block padding only. This selector outranks the scoped ones, so a shorthand here beat
   .drugbook-fact--flag's padding-left and sat a flagged row's text on its accent bar
   (review, 2026-09-24). The two lists that set their own rhythm get phone twins. */
:root[data-phone="on"] .drugbook-fact { padding-block: 0.4rem; }
:root[data-phone="on"] .drugbook-facts--mech .drugbook-fact { padding-block: 0; }
:root[data-phone="on"] .drugbook-facts--compact .drugbook-fact { padding-block: 0.18rem; }

:root[data-phone="on"] .drugbook-line { line-height: 1.5; }

/* The source icon keeps its small look but gets a thumb-sized target. The negative
   block margin hands the extra height back, so a one-line fact stays one line tall. */
:root[data-phone="on"] .drugbook-src {
    min-width: 44px;
    min-height: 44px;
    margin: -0.8rem -0.6rem -0.8rem 0;
    font-size: 1.05em;
}

:root[data-phone="on"] .drugbook-fold-btn {
    min-height: 44px;
    width: 100%;
}

:root[data-phone="on"] .drugbook-fold-what { display: none; }

/* Review controls wrap under the text rather than squeezing it. */
:root[data-phone="on"] .drugbook-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.3rem 0 0;
}

:root[data-phone="on"] .drugbook-icon-btn {
    width: 44px;
    height: 44px;
    font-size: 1.05rem;
}

:root[data-phone="on"] .drugbook-approve-section,
:root[data-phone="on"] .drugbook-approve-drug .btn,
:root[data-phone="on"] .drugbook-actions .btn {
    min-height: 44px;
}

:root[data-phone="on"] .drugbook-actions .btn { flex: 1 1 auto; }

:root[data-phone="on"] .drugbook-check {
    font-size: 0.92rem;
    padding: 0.5rem 0.65rem;
}

:root[data-phone="on"] .drugbook-tag,
:root[data-phone="on"] .drugbook-sp {
    font-size: max(0.75rem, var(--ed-fs-floor, 0rem));
}

/* The "Other sources" toggle is a thumb target like every other control on the card. */
:root[data-phone="on"] .drugbook-other-btn {
    min-height: 44px;
}

/* ── Typed in by a reviewer (round 6, 2026-09-27) ───────────────────────────── */
/* The one-row, equal-share chips above would squeeze "Dog and cat" into a quarter of the
   width: the form's four chips wrap and size to their words instead. 1rem inputs keep iOS
   from zooming the page on focus, as the search box does. */
:root[data-phone="on"] .drugbook-add-species { flex-wrap: wrap; }
:root[data-phone="on"] .drugbook-add-species .drugbook-species-chip { flex: 1 1 auto; }

:root[data-phone="on"] .drugbook-add .form-control,
:root[data-phone="on"] .drugbook-add .form-select {
    min-height: 44px;
    font-size: 1rem;
}

:root[data-phone="on"] .drugbook-add-btn,
:root[data-phone="on"] .drugbook-add-fact-btn { min-height: 44px; }

/* ── Dose calculator (workflow helpers F2, 2026-09-27) ─────────────────────────── */
/* "Calculate" stays in the line but is a thumb target. The panel's rows already wrap;
   at 360px each box sits under its label.
   1rem inputs keep iOS from zooming the page on focus, as the search box does. */
:root[data-phone="on"] .drugbook-calc-btn {
    min-height: 44px;
    padding-inline: 0.9rem;
    font-size: 0.9rem;
}

:root[data-phone="on"] .drugbook-calc {
    padding: 0.6rem 0.7rem;
    font-size: 0.95rem;
}

:root[data-phone="on"] .drugbook-calc-weight,
:root[data-phone="on"] .drugbook-calc-dose,
:root[data-phone="on"] .drugbook-calc-unit,
:root[data-phone="on"] .drugbook-calc-strength {
    min-height: 44px;
    font-size: 1rem;
}

/* ── The quick look over Medications (DrugBookPeek; QoL 2026-10-04, phone#8) ─────── */
/* A 778px box holding 1,460-1,950px of card: after Side effects Close had scrolled away,
   and the way out was a 17px strip of backdrop. The head sticks at the box's top edge:
   top is minus the box's 1.1rem top padding, which a sticky box otherwise stops below,
   and the head's own padding (handed back by its margin) is the room above the title
   once it is stuck. inherit is the dialog's surface in either theme. */
:root[data-phone="on"] .drugbook-peek-head {
    position: sticky;
    top: -1.1rem;
    z-index: 1;
    margin-top: -0.6rem;
    padding: 0.6rem 0 0.45rem;
    background: inherit;
    border-bottom: 1px solid var(--ed-hairline);
}

/* The scoped 2.2rem floors (0,2,0) beat the 44px .btn floor: Close and the Dog/Cat/All
   chips were 37px, the link icons 27px. The icon hands its extra height back, as the
   full card's does, so a one-line fact stays one line tall. */
:root[data-phone="on"] .drugbook-peek-close,
:root[data-phone="on"] .drugbook-peek-chip {
    min-height: 44px;
}

:root[data-phone="on"] .drugbook-peek-src {
    min-width: 44px;
    min-height: 44px;
    margin: -0.8rem -0.6rem -0.8rem 0;
}

/* ── 2026-11-15: the floating bar and a reviewer's whole-drug tools ───────────── */
/* The bar is sticky from the scoped sheet; on a phone it is the page's own row under the
   masthead, so it loses its side padding's worth of width to nothing and stays compact. */
:root[data-phone="on"] .drugbook-bar {
    flex-wrap: nowrap;
    align-items: center;
    padding-block: 0.4rem;
    gap: 0.35rem 0.5rem;
}

:root[data-phone="on"] .drugbook-bar > span {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

:root[data-phone="on"] .drugbook-bar .tool-header-actions {
    width: auto;
    flex: 0 0 auto;
    flex-wrap: nowrap;
}

/* A desk job (it re-reads the files that ship with the app): not on a phone. */
:root[data-phone="on"] .drugbook-batch-btn { display: none; }

:root[data-phone="on"] .drugbook-drug-tools .btn,
:root[data-phone="on"] .drugbook-source-change-actions .btn,
:root[data-phone="on"] .drugbook-cap-rule {
    min-height: 44px;
}

:root[data-phone="on"] .drugbook-cap-rule { width: 100%; }

/* ── 2026-11-29: the redesigned card (Brad) ──────────────────────────────────── */
/* Phone mode can be on at any width, so the stacked dose table and single-column pairs
   are repeated here rather than left to the media queries of the scoped sheet. */
:root[data-phone="on"] .drugbook-mono--cards { padding: 0.4rem 0 0; gap: 0.75rem; }

:root[data-phone="on"] .dbc-title { font-size: 2rem; }

:root[data-phone="on"] .dbc-seg { width: 100%; }

:root[data-phone="on"] .dbc-card { padding: 0.9rem 0.85rem; }

:root[data-phone="on"] .dbc-pair { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }

:root[data-phone="on"] .dbc-item { padding-block: 0; }

:root[data-phone="on"] .dbc-row-sum { flex-wrap: wrap; gap: 0.3rem 0.6rem; }
:root[data-phone="on"] .dbc-row-text { flex-basis: 100%; }
:root[data-phone="on"] .dbc-row-tags { max-width: 100%; justify-content: flex-start; }

:root[data-phone="on"] .dbc-dose thead { position: absolute; left: -9999px; }

:root[data-phone="on"] .dbc-dose,
:root[data-phone="on"] .dbc-dose tbody,
:root[data-phone="on"] .dbc-dose tr,
:root[data-phone="on"] .dbc-dose td { display: block; width: 100%; }

:root[data-phone="on"] .dbc-dose-row { padding: 0.6rem 0; border-top: 1px solid var(--ed-hairline); }

:root[data-phone="on"] .dbc-dose td {
    display: grid;
    grid-template-columns: 6rem minmax(0, 1fr);
    gap: 0.5rem;
    padding: 0.2rem 0;
    border-top: 0;
    white-space: normal;
}

:root[data-phone="on"] .dbc-dose td[data-l]::before {
    content: attr(data-l);
    font-size: max(0.72rem, var(--ed-fs-floor, 0rem));
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding-top: 0.2rem;
}

:root[data-phone="on"] .dbc-dose td.dbc-dose-calc { display: block; text-align: left; padding-top: 0.4rem; }
:root[data-phone="on"] .dbc-dose td.dbc-dose-calc:empty { display: none; }
:root[data-phone="on"] .dbc-calc-row td { display: block; }
:root[data-phone="on"] .dbc-calc-btn--solid { width: 100%; justify-content: center; }
