/* Phone density (PLAN_MOBILE_DENSITY_20261204, user 2026-12-04: information density too low, too much wasted space).
   Loaded after saafe.css; every rule is phone-only. Targets, checked by tests/test_mobile_all.py:
   list: first record ≤ 110 px from the top, ≥ 6 records in view; card ≤ 84 px (≤ 104 px with an amount line);
   record page: ≥ 8 field values in the first screen. */
@media (max-width: 640px) {
  /* ---- list toolbar: one row (search | Filter | New | …), it stays under the top bar while the list scrolls */
  .main > .toolbar { flex-wrap: nowrap; gap: 6px; position: sticky; top: var(--topbar-h); z-index: 5; background: var(--bg);
    padding: 6px 0; margin: -6px 0 0; }
  .toolbar .search { flex: 1 1 auto; min-width: 0; max-width: none; position: static; padding: 0; background: none; }
  .toolbar .search .btn-icon { display: none; } /* Enter and typing search already */
  .toolbar .search { min-width: 120px; }
  .toolbar .search input { height: var(--hit); min-width: 0; }
  .toolbar .filter-toggle { flex: none; width: var(--hit); height: var(--hit); padding: 0; justify-content: center; position: relative; }
  .toolbar .filter-toggle > span:not(.btn-badge) { display: none; }
  .toolbar .filter-toggle .btn-badge { top: 2px; right: 2px; }  /* inside the button: a list opened with filters in effect */
  .toolbar .filter-toggle .ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
  .toolbar > .btn-primary, .toolbar > .btn-danger { flex: none; height: var(--hit); padding: 0 14px; }
  .toolbar .toolbar-more { flex: none; width: var(--hit); height: var(--hit); }
  .list-chips:empty { display: none; }

  /* ---- cards: a few lines of text, nothing else */
  .card-list.compact { gap: 6px; }
  .card-list.compact .dcard-head { align-items: center; gap: 8px; padding: 7px 12px 1px; min-height: 0; background: none; border-bottom: 0; }
  .card-list.compact .dcard-heading { flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; }
  .card-list.compact .dcard-title { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 15px; line-height: 1.35; }
  /* the whole card is the tap target: the title link drops the 44 px link box it gets elsewhere on a phone */
  #main .card-list.compact .dcard a { display: inline; min-height: 0; padding: 0; line-height: inherit; white-space: nowrap; }
  .card-list.compact .dcard-lines { gap: 1px; padding: 0 12px 7px; font-size: 14px; line-height: 1.35; }
  .card-list.compact .dcard-line-main.inline { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--text); }
  .card-list.compact .dcard-line-main.inline > * { display: inline; }
  .card-list.compact .dcard-line-main.inline .dcard-value { display: inline; -webkit-line-clamp: unset; }
  .card-list.compact .dcard-line-main.inline .cell-under { display: none; }
  .card-list.compact .dcard-line-main.inline div { display: inline; } /* stacked cells (dates over counts) flow in the line */
  .list-notice { padding: 2px 4px; font-size: 12px; }
  /* declared lines (card_lines) too: one line each, cut with an ellipsis (§2.2: a card is a few lines of text) */
  .card-list.compact .dcard-line-main .dcard-value { display: block; -webkit-line-clamp: unset; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; }
  .card-list.compact .dcard-labelled .dcard-value { display: inline; } /* "Departure 2027-09-12" on one line */
  .card-list.compact .dcard-line-main.inline .thumb { height: 32px; max-width: 56px; vertical-align: middle; }
  .card-list.compact .dcard-sep { margin: 0 5px; color: var(--text-faint); }
  .card-list.compact .dcard-inline-label { font-size: 12px; color: var(--text-muted); margin-right: 3px; }
  .card-list.compact .dcard-labelled { display: inline; }
  .card-list.compact .dcard-tag { font-size: 12px; }
  .card-list.compact .dcard-total { font-size: 14px; font-weight: 600; color: var(--text-strong); }
  .card-list.compact .dcard .pick { width: var(--hit); height: var(--hit); margin: -12px 0 -12px -12px; flex: none; }
  .card-list.compact .dcard.clickable:active { background: var(--row-hover); }
}

/* ---- record page (PLAN_MOBILE_DENSITY §2.3) */
@media (max-width: 640px) {
  /* the record head's actions and save state live in the bottom bar on a phone: with no title and no summary the
     head is an empty 28 px strip (plus its gap), so it goes */
  .page-head:has(> .head-title[hidden]):has(> .record-summary:empty):not(:has(> .page-back:not(:empty))) { display: none; }
  .phone-form .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
  .phone-form .form-grid > .field:not(.half) { grid-column: 1 / -1; }
  /* a half-width field's input shrinks to its column (a date input's own minimum is wider with Linux fonts) */
  .phone-form .form-grid > .field.half, .phone-form .form-grid > .field.half > * { min-width: 0; max-width: 100%; }
  .phone-form .form-grid > .field.half :is(input, select, textarea) { min-width: 0; width: 100%; box-sizing: border-box; }
  .phone-form .field { row-gap: 2px; }
  .phone-form .field > label { font-size: 12px; line-height: 15px; color: var(--text-muted); }
  .phone-form .form-card { padding: 8px 12px 10px; }
  .phone-form .form-card h3 { margin-bottom: 6px; }
  .phone-form .form-column { gap: 8px; }
  /* a value that cannot be changed reads as text, not as a greyed-out box (§2.3 item 3) */
  /* (an autosave "edit in a dialog" field is read-only too, but a tap on its box opens the dialog: it stays a box) */
  .phone-form .field:not(.dialog-edit) input[readonly], .phone-form .field:not(.dialog-edit) textarea[readonly],
  .phone-form .field:not(.dialog-edit) select:disabled,
  .phone-form .field:not(.dialog-edit) input:disabled:not([type=checkbox]):not([type=radio]) {
    border-color: transparent; background: transparent; box-shadow: none; padding-left: 0; padding-right: 0; height: auto;
    min-height: 22px; color: var(--text); opacity: 1; -webkit-text-fill-color: var(--text); appearance: none; }
  .phone-form .field textarea[readonly] { resize: none; }
  .phone-form .dialog-edit-btn { display: none; } /* the whole box opens the dialog; a 20 px pencil is no tap target */
  /* a bar without a primary action keeps only its … (a round button bottom-right), the page gets the strip back */
  .bottom-bar.lean { left: auto; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: auto; padding: 0; border: 0;
    background: transparent; box-shadow: none; }
  .bottom-bar.lean .bbar-status { display: none; }
  .bottom-bar.lean .bbar-more { width: var(--hit); height: var(--hit); border-radius: 50%; box-shadow: var(--shadow-lg); background: var(--surface); }
  body.has-bottom-bar:has(.bottom-bar.lean) .main { padding-bottom: 64px; }
  /* radio choices: rows touch (each option keeps its 44 px), no extra gap between the rows */
  .phone-form .radio-row { row-gap: 0; column-gap: 16px; }
  /* a text box is as tall as its text (two lines at least, 40 % of the screen at most), not a fixed 88 px */
  .phone-form textarea { field-sizing: content; min-height: 64px; max-height: 40vh; }
  /* four or more choices sit in two even columns: by their own widths a long label took a row of its own (3410's
     seven interaction types made five rows, four now) */
  .phone-form .radio-row:has(> :nth-child(4)) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 8px; }
  .phone-form .radio-row:has(> :nth-child(4)) > * { min-width: 0; white-space: normal; line-height: 1.2; font-size: 14px; }
  /* the 44 px tap box of the circle overlaps its own blank sides, so the name gets the room (words never split) */
  .phone-form .radio-row:has(> :nth-child(4)) .radio-opt input { margin: -11px -8px -11px -10px; }
  /* a record with tabs: the sections after the first fold under one "Details (n)" line (form_phone.js) */
  .phone-form .details-fold-card { padding: 0 12px; }
  .phone-form .details-fold { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: var(--hit);
    border: 0; background: transparent; color: var(--heading); font-size: 12px; font-weight: 600; letter-spacing: 0.6px;
    text-transform: uppercase; cursor: pointer; padding: 0; }
  .phone-form .details-fold .hf-caret { color: var(--primary); font-weight: 700; }
  .phone-form .details-fold-body { display: flex; flex-direction: column; gap: 8px; }
  .phone-form .details-fold-body[hidden] { display: none; }
  /* empty tab / section: one line of grey text */
  .pane-body .empty, .detail-empty { padding: 8px 12px; min-height: 0; }

  /* ---- a detail tab's side facets (6110 Lines): one line per group that scrolls sideways; a group with a single
     value cannot narrow anything and goes */
  .detail-with-facets > .detail-facets { display: flex; flex-direction: column; flex-wrap: nowrap; gap: 4px; }
  .detail-with-facets > .detail-facets .facet-group { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px;
    overflow-x: auto; scrollbar-width: none; }
  .detail-with-facets > .detail-facets .facet-group.single { display: none; }
  .detail-with-facets > .detail-facets .facet-title { flex: none; flex-basis: auto; font-size: 12px; margin-right: 2px; }
  .detail-with-facets > .detail-facets .facet-value { flex: none; }

  /* ---- the tour's Hotel / Land Order tabs (orders_tab.js draws cards on a phone): the land filter bar is one line
     per group that scrolls sideways, not a 190 px column stacked over the list (REVIEW_UX_MOBILE_TABS_20261205) */
  .orders-facets, .orders-facets.collapsed { flex: none; display: flex; flex-direction: column; gap: 4px; width: auto;
    border: 0; padding: 0 0 4px; background: none; overflow: visible; }
  .orders-facets .facet-head { display: none; }
  .orders-facets .facet-group, .orders-facets.collapsed .facet-group { display: flex; flex-wrap: nowrap; align-items: center;
    gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .orders-facets .facet-title { flex: none; font-size: 12px; margin-right: 2px; }
  .orders-facets .facet-value { flex: none; width: auto; border: 1px solid var(--border); border-radius: 999px; padding: 0 12px; }
  .orders-facets .facet-value .lbl { overflow: visible; }
  .order-list.phone-cards { overflow: visible; }
  .orders-split { align-items: stretch; }
  .orders-split > .orders, .orders-split > .orders-facets { min-width: 0; max-width: 100%; }
  .orders-filters input[type="text"] { width: auto; flex: 1 1 140px; min-width: 0; }
  .orders-filters { flex-wrap: wrap; gap: 6px; }
  .orders-filters > [hidden] { display: none; }
  .orders-chips { flex: 1 1 100%; display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .orders-chips > * { flex: none; }
  .orders-chips .legend { display: flex; flex-wrap: nowrap; gap: 6px; }
  .orders-chips .legend-chip { white-space: nowrap; }
  .orders-filters .order-summary { flex: 1 1 100%; font-size: 12px; }
  .dcard .dcard-tag[class*=" st-"] { background: var(--st-bg); color: var(--st); }
  .dcard.st-cxl { opacity: 0.6; }
  .card-list .card-day { padding: 6px 4px 0; font-size: 12px; font-weight: 600; color: var(--heading); }
  .dcard .bad { color: var(--danger, #b42318); font-weight: 600; }
  .dcard-line.sub { color: var(--text-muted); }

  /* ---- guest list / rooming list cards (guest_rooms.js): a guest a line; removed struck through, new marked */
  .guest-room-cards .gr-line.off { text-decoration: line-through; color: var(--text-faint); }
  .guest-room-cards .gr-line.new { color: var(--primary); font-weight: 600; }
  /* ---- itinerary day cards (itinerary.js): the text is the point, so its lines wrap whole */
  .card-list.compact.itin-cards .dcard-line-main.inline { white-space: normal; overflow: visible; }
  .itin-cards .itin-title { font-weight: 600; }
  .itin-cards .itin-h { font-weight: 600; color: var(--heading); }
  .itin-cards .dcard-line.off { color: var(--text-faint); }
  /* ---- mail cards (mail_tab.js): search, one sideways line per filter group, the cards */
  .mail-phone-view { display: flex; flex-direction: column; gap: 6px; }
  .mail-phone-view .mail-search { margin: 0; width: 100%; box-sizing: border-box; min-height: var(--hit); font-size: 16px; }
  .mail-facets.phone { display: flex; flex-direction: column; gap: 4px; flex: none; margin: 0; }
  .mail-facets.phone[hidden] { display: none; }
  .mail-facets.phone .facet-group { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .mail-facets.phone .facet-title { flex: none; font-size: 12px; margin-right: 2px; }
  .mail-facets.phone .facet-value, .mail-facets.phone .facet-more { flex: none; width: auto; border: 1px solid var(--border);
    border-radius: 999px; padding: 0 12px; }
  .mail-facets.phone .facet-value .lbl { overflow: visible; }

  /* ---- rich text: the formatting buttons stay on one line that scrolls sideways */
  .rt-toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .rt-toolbar > * { flex: none; }
}
