/* ==========================================================================
   OrthoPlan Pro — phones and tablets (fix/mobile, 12 Nov 2026)
   ==========================================================================
   R11-MOB-01, R11-MOB-02, M11-05: docs/overhaul/mobile/AUDIT.md closed, row
   by row. Loaded last (after op-zz-design.css and op-zz-icons.css: the
   module files load in name order, OrthoPlan_Public::module_assets()), so
   these rules settle what the calm look leaves open on a phone, a tablet and
   a touch screen. Every rule is under `.op-ds`: with "New look" off (the
   kill switch) not one of them applies.

     1. Touch: 16 px in every field (no iOS zoom) and 44 px targets   §3 fix 3, 6
     2. The case strip: folds to one line, names the step and its
        sections; the bottom sheet they open                          fix 4, 5
     3. The bottom bar: one 60 px row below 1024, labels under the
        icons, Save in Next's place, toasts above it                  fix 4, 7, 9
     4. Tablets: a static topbar in the case, Photos in the bar (no
        edge tab over "Fold all"), "N pending" inside the screen,
        the lab table stacked                                         fix 9
     5. Screens: the Summary charts whole, the overdue instalment,
        Money and admin on a phone, the theme column                  fix 1, 2, 10
   ========================================================================== */

/* A list icon (Lucide "list") for "Sections". */
.op-ds {
    --op-ic-list: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12h.01' /%3E%3Cpath d='M3 18h.01' /%3E%3Cpath d='M3 6h.01' /%3E%3Cpath d='M8 12h13' /%3E%3Cpath d='M8 18h13' /%3E%3Cpath d='M8 6h13' /%3E%3C/svg%3E");
}
.op-ds .op-ic-list { --op-ic: var(--op-ic-list); }

/* ---- 1. Touch (AUDIT fix 3 and 6) ----------------------------------------------
   iOS zooms the page on focus into any field under 16 px: booking the next
   visit, Messages, the month filter, working hours, the admin's selects
   (rows 20, 25, 29, 31, 32). One rule for every field on a touch screen. */
@media (pointer: coarse) {
    .op-ds :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]):not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]), select, textarea) {
        font-size: 16px !important; min-height: 48px !important;
    }

    /* 44 px for every control a thumb aims at (Apple 44, Google 48). */
    .op-ds :is(.op-slot, .op-tab-pill, .op-seg-btn, .op-bite-tab, .op-mech-viewbtn, .op-mech-tab, .op-mech-pen, .op-tc-state,
               .op-dictate, .op-rail-tab, .op-help-inline, .op-usage-chip, .op-dock-tabbtn, .op-sidenav-link,
               .op-case-filter-chip, .op-tab-link, a.op-chip, .op-chip) {
        min-height: 44px !important; box-sizing: border-box;
    }
    .op-ds :is(.op-sequence .op-tab-link, .op-tab-link, .op-step-index-link, .op-tab-pill) { min-width: 44px; justify-content: center; }
    /* The floor is no ceiling: a step's primary action keeps its 52 px
       (spec 10.4); in the bottom bar Next and Save are 44, so the bar is 60. */
    .op-ds .op-btn:not(.op-btn-primary) { min-height: 44px !important; }
    .op-ds .op-btn-primary { min-height: 52px !important; }
    .op-ds .op-wizard-foot :is(.op-btn-primary, .op-bar-save) { min-height: 44px !important; }
    .op-ds .op-wizard-foot { padding-block: 7px; }
    /* Icon buttons: 44 × 44 (the bell was 36 × 40, Help 36 × 36; row 6). */
    .op-ds :is(.op-icon-btn, .op-bell-btn, .op-mini-delete, .op-visit-delete, .op-delete-att, .op-mech-remove,
               .op-modal-close, .op-dock-btn, .op-fold-btn) {
        min-width: 44px; min-height: 44px !important; box-sizing: border-box;
    }
    .op-ds .op-clinic-chip { height: auto; min-height: 44px !important; }
    /* A floor, so !important: the controls' own rules reach 40 px at
       specificities from (0,2,0) to (0,4,0), each written for a mouse. */
    /* 44 wide too: a one-word button ("Undo", "View", "لأ", "تعديل"), a
       short chip ("1", "C1") and the topbar's icons. Not a tooth: a tooth
       chart keeps its 32-36 px teeth and scrolls in its frame (R11-MOB-03),
       and the tooth picker's eight a row are 32. Next and the bar's Save
       keep their own, wider floors (96, 180 on a tablet). */
    .op-ds :is(.op-btn, .op-chip, .op-toggle-btn, .op-icon-btn, .op-bell-btn, .op-btn-icon):not(.op-tc-tooth, .op-wizard-next, .op-bar-save) { min-width: 44px; }
    .op-ds .op-topbar :is(.op-icon-btn, .op-bell-btn, .op-btn-icon, .op-topbar-signout, .op-topbar-consult) { min-width: 44px; min-height: 44px !important; }
    .op-ds .op-topbar .op-topbar-actions > .op-topbar-consult.op-btn-small { width: 44px; min-width: 44px; }
    .op-ds .op-topbar :is(.op-brand-link, .op-topbar-brand > a) { display: inline-flex; align-items: center; min-height: 44px !important; }
    /* The back link to My cases was 32 × 32 (row 5). */
    .op-ds .op-casebar .op-back-link { min-width: 44px; min-height: 44px !important; justify-content: center; }
    /* A link that stands on its own line is a target, not a word in a sentence. */
    .op-ds :is(a.op-goto-step, a.op-goto-agenda, .op-agenda-money-link, a.op-activity-case, .op-jline, .op-workarea > .op-jline,
               .op-table-cards td > a:not(.op-btn), .op-money-who, a.op-mono, .op-status-card, .op-admin-cases a, .op-pf-more) {
        display: inline-flex; align-items: center; min-height: 44px !important; min-width: 44px; box-sizing: border-box;
    }
    .op-ds .op-status-card { display: flex; }
    /* Tabs anywhere (the admin's case tabs, sign-in / register), a box
       ticked by its words, a phone number to call. */
    .op-ds :is(.op-tab-link, .op-auth-tabs a, .op-back-link, a[href^="tel:"]) {
        min-height: 44px !important; box-sizing: border-box; display: inline-flex; align-items: center;
    }
    /* A tick and its words are a row of their own (as every screen that
       styles one has it), so the row is the target even before its words
       are filled in: inline, Settings' "Also use it on my cases" shrank to
       its 26 px box. */
    .op-ds label.op-inline { min-height: 44px !important; box-sizing: border-box; display: flex; align-items: center; }
    .op-ds :is(.op-users-table select, select) { min-height: 44px !important; }
    /* Every <summary> a thumb opens (a 24 px one, row 19). */
    .op-ds summary { min-height: 44px !important; box-sizing: border-box; }
    .op-ds summary:not([class]) { display: flex; align-items: center; }
    .op-ds summary.op-summary-head { display: flex; flex-wrap: wrap; align-items: center; row-gap: 0; padding-block: 10px; height: auto; }
    .op-ds summary.op-summary-head * { white-space: normal; }

    /* (No id inside :is() above: it would lift the whole list over the
       primary action's 52 px.) The Functional shift button (row 36). */
    .op-ds #op-shift-toggle { min-height: 44px !important; }
    /* Photos: Rotate / Mirror / Crop at 44 × 44, 8 px apart (row 12), the
       photo's × too. */
    .op-ds .op-photo-tools { gap: 8px; flex-wrap: wrap; }
    .op-ds .op-photo-tool { width: 44px; min-width: 44px; min-height: 44px !important; }
    /* The crop window's corners: a 44 px hit round the 22 px handle (row 13). */
    .op-ds .op-crop-modal .op-crop-handle::before { content: ''; position: absolute; inset: -11px; border-radius: 50%; }
    /* …and its turn and mirror buttons, 44 × 44 (they were 40 × 44). */
    .op-ds .op-crop-modal .op-crop-turns .op-btn { min-width: 44px; min-height: 44px !important; }
    /* The segment buttons of Collected photos (row 14) and the photo sheet's tabs. */
    .op-ds .op-seg-btn { min-width: 44px; }

    /* The board (rows 16, 17): every pen, tab and × at 44; every TAD or hook
       site, placed or not, takes a tap 22 px round its centre — a 44 px
       circle (fix/board-touch; it was a 10 px circle 42 px from the next,
       "more than one try", then 36 px open and 26 placed). op-mech draws the
       circle with this radius (its own r, so no browser depends on the CSS
       `r` property). The sites stand 34-46 px apart: a tap where two circles
       overlap goes to the nearer site, and one no site on the open tab can
       take falls through to the tooth beneath (op-mech.js routeTap()), so a
       placed screw never hides the tooth beside it from an O-tie. The
       palate's sites are 36 units of a drawing scaled up: 49 px at 360. */
    .op-ds .op-mech-item { min-height: 44px !important; box-sizing: border-box; display: inline-flex; align-items: center; }
    .op-ds .op-mech-pens-small .op-mech-pen { min-height: 44px !important; }
    .op-ds .op-mech-overlay { --op-site-hit: 22; --op-site-hit-on: 22; }
    /* The tooth picker's teeth: at least 32 wide (fix/teeth18: the button is the target, its box smaller);
       fix/ceph24 (M24-13): 36 tall, "smaller still", above the acceptance's 32 px floor. */
    .op-ds .op-tpick .op-tpick-chip { min-height: 36px !important; min-width: 32px; }
    /* A visit's × stands 12 px clear of Edit (row 22). */
    .op-ds .op-visit-delete { margin-inline-start: 12px; }
    /* A lone radio whose label is elsewhere (the timeline's sessions). */
    .op-ds .op-session-radio { min-width: 24px; min-height: 24px; }
    /* The swipe hint under a tooth chart is read, not squinted at (row 15). */
    .op-ds .op-tc-board.is-scrollable + .op-tc-swipe { font-size: 13px; line-height: 18px; }
}

/* ---- 2. The case strip and its sheet (R11-MOB-01; AUDIT rows 1-3, 7, 8) --------- */
/* The strip's two buttons exist on every width; they show once the step bar
   is out of sight (op-shell.js sets op-mnav-on) and never on a desktop rail. */
.op-ds .op-mnav { display: none; }
/* What the strip gains or loses in height with them stays as margin under
   it (op-shell.js), so the page below does not move. */
.op-ds.op-mnav-on .op-casebar { margin-bottom: calc(var(--ds-sp-4) + var(--op-strip-give, 0px)); }
.op-ds.op-mnav-on .op-casebar > .op-mnav {
    display: flex; align-items: center; gap: 4px; flex: none; margin-inline-start: auto; order: 5;
}
.op-ds .op-mnav button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-sizing: border-box;
    min-height: 34px; padding: 0 10px; margin: 0; cursor: pointer;
    border: 1px solid var(--ds-line-strong); border-radius: var(--ds-r-md); background: var(--ds-surface);
    font: 500 var(--ds-fs-sm)/var(--ds-lh-sm) var(--ds-font); color: var(--ds-ink); white-space: nowrap;
}
.op-ds .op-mnav button:hover { background: var(--ds-n-50); }
.op-ds .op-mnav button[aria-expanded="true"] { background: var(--ds-brand-50); border-color: var(--ds-brand); color: var(--ds-brand-700); }
.op-ds .op-mnav button[hidden] { display: none; }
.op-ds .op-mnav .op-ic { color: var(--ds-icon); }
.op-ds .op-mnav-num {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    min-width: 20px; height: 20px; padding: 0 4px; box-sizing: border-box; border-radius: 10px;
    background: var(--ds-brand); color: var(--ds-n-0); font: 600 var(--ds-fs-xs)/20px var(--ds-font);
}
.op-ds .op-mnav-num:empty { display: none; }
.op-ds .op-mnav-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (pointer: coarse) { .op-ds .op-mnav button { min-height: 44px; } }
/* A tablet: the strip stays one row with its two buttons in it — Export
   PDF waits on Summary & Export, and "My cases" is its arrow. */
@media (min-width: 641px) and (max-width: 1279px) {
    .op-ds.op-mnav-on .op-casebar { flex-wrap: nowrap; }
    .op-ds.op-mnav-on .op-casebar .op-case-head-actions > .op-btn,
    .op-ds.op-mnav-on .op-casebar .op-back-label,
    .op-ds.op-mnav-on .op-casebar .op-case-subline { display: none; }
    .op-ds.op-mnav-on .op-casebar > .op-casebar-id { min-width: 0; }
    .op-ds.op-mnav-on .op-casebar h1 { min-width: 0; }
    .op-ds.op-mnav-on .op-casebar .op-case-head-actions { flex-wrap: nowrap; }
}
@media (min-width: 1280px) {
    /* The rail is sticky beside the step there: nothing to add. */
    .op-ds.op-app .op-casebar > .op-mnav { display: none; }
}

/* The strip folded on a phone: one line — the name and code, the step, Sections. */
@media (max-width: 640px) {
    .op-ds .op-casebar { transition: none; }
    .op-ds.op-strip-tight .op-casebar {
        flex-wrap: nowrap; gap: 8px; padding-block: 4px; min-height: 52px;
        margin-bottom: calc(var(--ds-sp-4) + var(--op-strip-give, 0px));
    }
    .op-ds.op-strip-tight .op-casebar > .op-casebar-id { flex: 1 1 auto; flex-basis: auto; min-width: 0; gap: 0; }
    .op-ds.op-strip-tight .op-casebar .op-back-link,
    .op-ds.op-strip-tight .op-casebar .op-case-head-actions { display: none; }
    .op-ds.op-strip-tight .op-casebar h1 {
        display: flex; flex-direction: column; align-items: flex-start; gap: 0; min-width: 0;
        font-size: var(--ds-fs-md); line-height: 18px; white-space: normal;
    }
    .op-ds.op-strip-tight .op-casebar-name {
        display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; max-width: 100%;
    }
    .op-ds.op-strip-tight .op-casebar-code { font-size: var(--ds-fs-xs); line-height: 16px; }
    .op-ds.op-strip-tight .op-casebar > .op-mnav { margin-inline-start: 0; max-width: 62%; }
    .op-ds.op-strip-tight .op-mnav-step { min-width: 0; flex: 0 1 auto; padding-inline: 8px; }
    /* A long step name ("Summary & Export") takes two lines, never an ellipsis. */
    .op-ds.op-strip-tight .op-mnav-name {
        white-space: normal; overflow: hidden; text-overflow: clip; line-height: 15px; text-align: start;
        display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
    }
    /* "Sections": the icon over its word, as the bar's tools are. */
    .op-ds .op-mnav-sections { flex-direction: column; gap: 1px; padding: 2px 6px; min-width: 52px; }
    .op-ds .op-mnav-label { font: 500 11px/13px var(--ds-font); }
}

/* The step bar on a phone: one row of 44 px discs that scrolls, the open one
   named and in the middle (op-shell.js); the others are named for a screen
   reader and a long press, not by a number only (row 7). */
@media (max-width: 640px) {
    .op-ds .op-sequence > .op-tabs-nav,
    [dir="rtl"] .op-ds .op-sequence > .op-tabs-nav {
        flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
        margin-inline: calc(-1 * var(--ds-gutter)); padding-inline: var(--ds-gutter); scroll-padding-inline: var(--ds-gutter);
        --end: right;
        -webkit-mask-image: linear-gradient(to var(--end), black calc(100% - 24px), transparent);
        mask-image: linear-gradient(to var(--end), black calc(100% - 24px), transparent);
    }
    [dir="rtl"] .op-ds .op-sequence > .op-tabs-nav { --end: left; }
    .op-ds .op-sequence > .op-tabs-nav::-webkit-scrollbar { display: none; }
    .op-ds .op-sequence .op-tab-link { flex: none; }
}

/* The sheet: the step's sections, or every step. A bottom sheet on a phone,
   a panel under the strip from 641 up. */
.op-ds .op-msheet[hidden] { display: none; }
.op-ds .op-msheet { position: fixed; inset: 0; z-index: 1000; }
.op-ds .op-msheet-scrim { position: absolute; inset: 0; background: var(--ds-scrim); }
.op-ds .op-msheet-panel {
    position: absolute; inset-inline: 0; inset-block-end: 0; max-height: 78vh; box-sizing: border-box;
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--ds-surface); border-radius: var(--ds-r-lg) var(--ds-r-lg) 0 0; box-shadow: var(--ds-shadow);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 641px) {
    .op-ds .op-msheet-panel {
        inset-block: var(--op-chrome-top, 120px) auto; inset-inline: auto var(--ds-gutter); width: min(420px, calc(100vw - 32px));
        max-height: calc(100vh - var(--op-chrome-top, 120px) - var(--op-wizard-h, 60px) - 16px); border-radius: var(--ds-r-lg);
    }
}
.op-ds .op-msheet-head {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px 0 var(--ds-gutter); flex: none;
}
[dir="rtl"] .op-ds .op-msheet-head { padding: 6px var(--ds-gutter) 0 8px; }
/* The grab line a bottom sheet has. */
@media (max-width: 640px) {
    .op-ds .op-msheet-head { position: relative; padding-top: 14px; }
    .op-ds .op-msheet-head::before {
        content: ''; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px;
        border-radius: 2px; background: var(--ds-line-strong);
    }
}
.op-ds .op-msheet-title { flex: 1; min-width: 0; margin: 0; font: 600 var(--ds-fs-lg)/var(--ds-lh-lg) var(--ds-font); color: var(--ds-ink); }
.op-ds .op-msheet-close {
    flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: var(--ds-r-md); background: none; color: var(--ds-icon); cursor: pointer;
}
.op-ds .op-msheet-close:hover { background: var(--ds-sunken); color: var(--ds-ink); }
.op-ds .op-msheet-close .op-ic { width: 20px; height: 20px; }
/* fix/shell18 (C17-MOB-01): no tabs — each button opens its own list; a line under the title. */
.op-ds .op-msheet-head { padding-bottom: 6px; border-bottom: 1px solid var(--ds-line); }
.op-ds .op-msheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 4px 0 12px; }
.op-ds .op-msheet-body[hidden] { display: none; }
.op-ds .op-msheet-list { display: flex; flex-direction: column; }
.op-ds .op-msheet-item {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; box-sizing: border-box;
    padding: 8px var(--ds-gutter); margin: 0; cursor: pointer; text-align: start;
    border: 0; border-inline-start: 3px solid transparent; background: none; border-radius: 0;
    font: 400 var(--ds-fs-md)/var(--ds-lh-md) var(--ds-font); color: var(--ds-ink);
}
.op-ds .op-msheet-item:hover { background: var(--ds-n-50); }
.op-ds .op-msheet-item.is-current { border-inline-start-color: var(--ds-brand); background: var(--ds-brand-50); color: var(--ds-brand-700); font-weight: 600; }
.op-ds .op-msheet-item[data-pillar]::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ds-pillar-skeletal); }
.op-ds .op-msheet-item[data-pillar="dental"]::before { background: var(--ds-pillar-dental); }
.op-ds .op-msheet-item:is([data-pillar="soft"], [data-pillar="extra"])::before { background: var(--ds-pillar-soft); }
.op-ds .op-msheet-text { flex: 1; min-width: 0; unicode-bidi: plaintext; text-align: start; }
.op-ds .op-msheet-num {
    flex: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%;
    background: var(--ds-sunken); color: var(--ds-ink-2); font: 600 var(--ds-fs-xs)/24px var(--ds-font);
}
.op-ds .op-msheet-item.is-current .op-msheet-num { background: var(--ds-brand); color: var(--ds-n-0); }
.op-ds .op-msheet-note { flex: none; font: 400 var(--ds-fs-xs)/var(--ds-lh-xs) var(--ds-font); color: var(--ds-ink-3); }
.op-ds .op-msheet-foldall, .op-ds .op-msheet-back {
    display: flex; align-items: center; gap: 8px; min-height: 48px; box-sizing: border-box; width: 100%;
    margin-top: 4px; padding: 0 var(--ds-gutter); border: 0; border-top: 1px solid var(--ds-line); background: none; cursor: pointer;
    font: 500 var(--ds-fs-md)/var(--ds-lh-md) var(--ds-font); color: var(--ds-brand) !important; text-decoration: none !important; text-align: start;
}
.op-ds .op-msheet-foldall[hidden], .op-ds .op-msheet-back[hidden] { display: none; }
.op-ds.op-msheet-open { overscroll-behavior: contain; }

/* ---- 3. The bottom bar (AUDIT rows 2, 9, 10, 18, 37) ------------------------------
   Below 1024: ONE row of 60 px — Prev · the tools · Next — on a phone and on
   a tablet (the tablet's was two rows, 123 px; 131 in Arabic). The tools
   show their word under the icon (touch never shows a title). */
@media (max-width: 1023px) {
    .op-ds.op-case-detail { --op-wizard-h: 60px; }
    .op-ds .op-wizard-foot,
    .op-ds.op-case-detail .op-wizard-foot {
        display: flex; flex-wrap: nowrap; align-items: center; gap: 2px; grid-template-columns: none; grid-template-areas: none;
        min-height: 60px; padding: 7px 8px; box-sizing: border-box;
    }
    .op-ds .op-wizard-mid { order: 0; flex: 0 1 auto; width: auto; min-width: 0; justify-content: center; gap: 0; }
    .op-ds .op-wizard-count { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .op-ds .op-wizard-tools { gap: 0; }
    .op-ds .op-wizard-foot .op-wizard-empty { display: none; }
    .op-ds .op-wizard-prev { flex: none; min-width: 44px; min-height: 44px; padding: 0 6px; justify-content: center; }
    .op-ds .op-wizard-next, .op-ds .op-bar-save {
        flex: 1 1 auto; min-width: 96px; min-height: 44px; height: auto; padding: 4px; justify-content: center;
    }
    .op-ds .op-wizard-foot:has(.op-wizard-next.op-wizard-empty) .op-wizard-prev { flex: 1 1 auto; justify-content: flex-start; }
    /* public.css's `.op-frontend .op-wizard-foot > .op-btn` (flex: 1 1 0,
       nowrap; 0,3,0) outranked the three lines above: Prev took half the
       spare room (an 84 px "<"), and the bar's Save kept 96 px and one line,
       so "Save clinical steps" ran past the screen (the page 397 wide at
       390; "حفظ الخطوات العلاجية" 405). Prev its own 44, the tools their
       own width, and what is left to Next or Save (basis 0, so a long
       name never pushes into the tools), whose words wrap to a second line. */
    .op-ds .op-wizard-foot > .op-btn.op-wizard-prev { flex: none; }
    .op-ds .op-wizard-foot:has(.op-wizard-next.op-wizard-empty) > .op-btn.op-wizard-prev { flex: 1 1 auto; }
    .op-ds .op-wizard-foot > .op-btn:is(.op-wizard-next, .op-bar-save) { flex: 1 1 0%; white-space: normal; overflow-wrap: anywhere; }
    .op-ds .op-wizard-foot > .op-wizard-mid { flex: none; }
    .op-ds .op-wizard-next .op-btn-text, .op-ds .op-bar-save {
        max-width: none; overflow: visible; text-overflow: clip; white-space: normal; line-height: 16px; text-align: center;
    }
    .op-ds :is(.op-tool-btn, .op-wizard-tools .op-notes-fab) {
        position: relative; flex-direction: column; justify-content: center; gap: 2px;
        width: auto; min-width: 44px; height: 44px; min-height: 44px; padding: 0 2px;
    }
    .op-ds :is(.op-tool-btn, .op-wizard-tools .op-notes-fab) :is(.op-tool-text, .op-notes-fab-text) {
        display: block; position: static; width: auto; height: auto; overflow: visible; clip: auto;
        font: 500 11px/13px var(--ds-font); white-space: nowrap;
    }
    .op-ds .op-tool-btn > .op-ic, .op-ds .op-notes-fab > .op-ic { width: 18px; height: 18px; }
    .op-ds .op-tool-badge { position: absolute; top: 0; inset-inline-end: 2px; transform: none; }
    .op-ds .op-notes-fab .op-tool-dot { position: absolute; top: 6px; inset-inline-end: 8px; }
    .op-ds .op-wizard-more { display: block; position: relative; }
    .op-ds .op-wizard-tools .op-wizard-more-btn { display: inline-flex; }
    .op-ds .op-wizard-more-menu {
        display: none; position: absolute; z-index: 50; inset-block-end: calc(100% + 8px); inset-inline-end: 0;
        min-width: 220px; padding: 8px; flex-direction: column; align-items: stretch; gap: 2px;
        background: var(--ds-surface); border: 1px solid var(--ds-line); border-radius: var(--ds-r-lg); box-shadow: var(--ds-shadow);
    }
    .op-ds .op-wizard-more.is-open .op-wizard-more-menu { display: flex; }
    .op-ds .op-wizard-more-menu .op-tool-btn { flex-direction: row; width: auto; justify-content: flex-start; padding: 0 12px; min-height: 44px; height: auto; gap: 8px; }
    .op-ds .op-wizard-more-menu .op-tool-btn .op-tool-text { font: 500 var(--ds-fs-md)/var(--ds-lh-md) var(--ds-font); }
    /* Next names the step; the button itself says "forward". */
    .op-ds .op-wizard-next .op-wizard-arrow { display: none; }
    .op-ds .op-wizard-prev .op-btn-text { display: none; }
}
@media (max-width: 374px) {
    /* A 360 px phone leaves Next or Save about 100 px: at 13 px "Save
       treatment" is one line, so the longest name is two ("Save treatment
       / plan") and the bar stays one 60 px row (at 14 px it took three). */
    .op-ds .op-wizard-foot > .op-btn:is(.op-wizard-next, .op-bar-save),
    .op-ds .op-wizard-foot > .op-btn.op-wizard-next .op-btn-text { font-size: 13px; padding-inline: 2px; }
}
/* Photos is in the bar below 1280 (the edge tab sat on "Fold all" and on
   the end of every row on an iPad, in both orientations; row 38). */
@media (max-width: 1279px) {
    .op-ds .op-wizard-tools .op-tool-photos:not([hidden]) { display: inline-flex; }
    .op-ds .op-dock-tab { display: none !important; }
}
@media (min-width: 641px) and (max-width: 1023px) {
    /* A tablet has the room to name the step Prev goes back to. */
    .op-ds .op-wizard-prev .op-btn-text { display: inline; }
    .op-ds .op-wizard-prev { justify-content: flex-start; max-width: 30%; }
    .op-ds .op-wizard-prev .op-btn-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .op-ds .op-wizard-mid { flex: 1 1 auto; }
    .op-ds .op-wizard-next { flex: 0 1 auto; min-width: 180px; }
    .op-ds .op-wizard-foot > .op-btn.op-wizard-prev { flex: 0 1 auto; }
    .op-ds .op-wizard-foot > .op-wizard-mid { flex: 1 1 auto; }
    .op-ds .op-wizard-foot > .op-btn:is(.op-wizard-next, .op-bar-save) { flex: 0 1 auto; min-width: 180px; }
}
/* Save in Next's place while the step has edits and its own Save is off
   screen: nothing floats over the step (rows 2, 21). */
.op-ds .op-bar-save[hidden] { display: none !important; }
@media (max-width: 1023px) {
    .op-ds.op-bar-save-on .op-float-save { display: none !important; }
    .op-ds.op-bar-save-on .op-wizard-next { display: none !important; }
}
@media (min-width: 1024px) {
    .op-ds .op-bar-save { display: none !important; }
}

/* Toasts above the bar, not over Next (row 10), and the board's Undo white
   and underlined on the dark toast (it was ink on ink, 1.2:1; row 18). */
@media (max-width: 1023px) {
    body:has(.op-ds.op-case-detail) #op-toast-host {
        inset-inline: 16px; bottom: calc(var(--op-wizard-h, 60px) + 12px + env(safe-area-inset-bottom, 0px));
        align-items: center;
    }
    body:has(.op-ds.op-case-detail) .op-toast { max-width: 100%; }
}
body:has(.op-ds) #op-toast-host .op-mech-undo-btn,
body:has(.op-ds) #op-toast-host .op-toast .op-btn-ghost {
    color: var(--ds-n-0) !important; background: none !important; border: 0 !important;
    text-decoration: underline !important; text-underline-offset: 3px; min-height: 44px; padding-inline: 8px; font-weight: 600;
}

/* ---- 4. Tablets (R11-MOB-02; AUDIT rows 37-40) ---------------------------------- */
/* The topbar scrolls away in the case below 1280: the strip carries the way
   back, and the screen goes to the work (277 px of chrome in portrait). */
@media (max-width: 1279px) {
    .op-ds.op-case-detail > .op-topbar { position: relative; top: auto; }
}
/* "N pending" opens inside the screen in both directions (it ran 92 px past
   an iPad in Arabic, row 39): a panel under the strip, the gutter each side. */
/*
 * fix/cephpolish (P13, the walk of 17 Nov): that panel was FIXED under the
 * strip, so a case with news opened it by itself and it stayed over the step
 * while he scrolled (358 × 320 px over the ceph card at 390) until he closed
 * it. It is in the page's flow now, under its line: it pushes the step down
 * instead of covering it, and scrolls away with the page. With news, the
 * line is moved to the top of the case (op-shell.js), so at first view it is
 * never at the fold under the bottom bar; it closes once he has scrolled past
 * it, or taps elsewhere.
 */
@media (max-width: 1023px) {
    .op-ds details.op-case-notices[open] { flex: 1 1 100%; width: 100%; min-width: 0; }
    .op-ds details.op-case-notices[open] .op-case-notices-panel {
        position: static; width: auto; max-width: 100%; max-height: none;
        margin: 4px 0 0 !important; box-shadow: none;
    }
    .op-ds details.op-case-notices.is-top { margin: 8px 0 12px; }
    .op-ds details.op-case-notices.is-top .op-case-notices-sum { min-height: 44px; }
    /* A news item's × a 44 px target for a finger (it was 32): it keeps its place, the row no taller. */
    .op-ds .op-case-notices .op-case-alert-close { width: 44px; height: 44px; margin: -12px -8px; }
}
/* The lab orders: stacked rows on a tablet, both orientations (the table
   was 900-1021 px in a 686 px box on an iPad, row 40; 1021, 1081 in Arabic,
   in a 926 px box in landscape). Up to 1179, where its columns first fit
   the Lab orders page and the case's Lab step in both directions. */
@media (min-width: 641px) and (max-width: 1179px) {
    .op-ds .op-lab-table-wrap { overflow: visible; }
    .op-ds .op-lab-table, .op-ds .op-lab-table tbody { display: block; width: 100%; min-width: 0; }
    .op-ds .op-lab-table thead { display: none; }
    .op-ds .op-lab-table tr {
        display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px;
        padding: 12px 0; border-bottom: 1px solid var(--ds-line);
    }
    .op-ds .op-lab-table td { display: block; padding: 0; border: 0; min-width: 0; }
    .op-ds .op-lab-table td[data-label]::before {
        content: attr(data-label); display: block; font: 400 var(--ds-fs-xs)/var(--ds-lh-xs) var(--ds-font); color: var(--ds-ink-3);
    }
    .op-ds .op-lab-table td:first-child, .op-ds .op-lab-table td:last-child { grid-column: 1 / -1; }
}
@media (min-width: 901px) and (max-width: 1179px) {
    /* Landscape: three figures a line, so a card is not mostly white. */
    .op-ds .op-lab-table tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---- 5. Screens ------------------------------------------------------------------ */
/* "Whole arch" under a tooth chart that scrolls on a phone (row 15): the
   whole mouth in the width, so both ends of a pair, an elastic or a chain
   are on screen together; pressed again, the 36 px teeth come back. */
.op-ds .op-tc-whole-btn { display: none; }
@media (max-width: 640px) {
    .op-ds .op-tc-board.is-scrollable ~ .op-tc-whole-btn,
    .op-ds .op-tc-whole .op-tc-whole-btn {
        display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin: 4px auto 0; padding: 0 12px;
        border: 1px solid var(--ds-line-strong); border-radius: var(--ds-r-md); background: var(--ds-surface); cursor: pointer;
        font: 500 var(--ds-fs-sm)/var(--ds-lh-sm) var(--ds-font); color: var(--ds-ink);
    }
    .op-ds .op-tc-whole-btn[aria-pressed="true"] { background: var(--ds-brand-50); border-color: var(--ds-brand); color: var(--ds-brand-700); }
    .op-ds .op-tc-whole .op-tc-board { overflow-x: hidden; -webkit-mask-image: none; mask-image: none; }
    .op-ds .op-tc-whole .op-tc-row { gap: 1px; min-width: 0; width: 100%; }
    .op-ds .op-tc-whole .op-tc-tooth { flex: 1 1 0; min-width: 0 !important; width: auto; padding: 0; }
    .op-ds .op-tc-whole .op-tc-tooth .op-tc-svg { width: 100%; }
    .op-ds .op-tc-whole .op-tc-swipe { display: none !important; }
    /* The mechanics board's drawing layer lies over the board, not over the
       694 px row it was last drawn on (it kept the board scrolling, half the
       mouth out of reach); op-mech repaints it to this width. */
    .op-ds .op-tc-whole .op-mech-overlay { width: 100%; inset-inline: 0; }
    /* Whole arch is an overview: its teeth are 15-21 px wide (under the 32 px
       floor of a chart that scrolls; assert-mobile holds them to 15 wide and
       44 tall). A TAD or hook site there takes a tap 9 px round its centre,
       about the gap between two teeth, so two sites never share a tap; a
       placed one keeps its 13 (op-mech reads both, as above). */
    .op-ds .op-tc-whole .op-mech-overlay { --op-site-hit: 9; --op-site-hit-on: 13; }
}

/* Summary: the read-only charts whole on a phone, in both directions (rows
   26, 27 — in Arabic teeth 23-28 and 33-38 could not be reached). The row
   is drawn left to right like every tooth chart and scaled to the width. */
.op-ds .op-summary-fig .tchart { direction: ltr; }
.op-ds .op-summary-fig > figcaption { direction: inherit; }
@media (max-width: 640px) {
    .op-ds .op-summary-fig { overflow: visible; }
    .op-ds .op-summary-fig .tchart-row { justify-content: center; gap: 1px; }
    .op-ds .op-summary-fig .tchart-t { flex: 1 1 0; min-width: 0; width: auto !important; }
    .op-ds .op-summary-fig .tchart-t > svg { width: 100%; height: auto; display: block; }
    .op-ds .op-summary-fig .tchart-mid { margin-inline-end: 3px; }
    /* fix/teeth18 (C17-PLN-06): drawn to the width, the chart is the width and the upper centrals stay the widest front teeth. */
    .op-ds .op-summary-fig .tchart { grid-template-columns: minmax(0, 1fr); }
    .op-ds .op-summary-fig .tchart-upper .tchart-central { flex-grow: 1.3; }
    .op-ds .op-summary-fig .tchart-n { font-size: 11px; }
    /* A tooth's note ("↔23", "Bypass") is wider than a 20 px tooth: it ran
       into the next tooth's number ("14↔23 12"). Here it is a dot under
       its tooth, out of the row's flow (no tooth moves), and the notes are
       said in full under the chart, each with its tooth (op-shell.js). */
    .op-ds .op-summary-fig.has-tnotes .tchart-t { position: relative; }
    .op-ds .op-summary-fig.has-tnotes .tchart-l {
        position: absolute; inset-inline-start: 50%; width: 6px; height: 6px; margin-inline-start: -3px;
        border-radius: 50%; background: var(--ds-ink-2); font-size: 0; line-height: 0; overflow: hidden; color: transparent;
    }
    .op-ds .op-summary-fig.has-tnotes .tchart-upper .tchart-l { top: 100%; margin-top: 1px; }
    .op-ds .op-summary-fig.has-tnotes .tchart-lower .tchart-l { bottom: 100%; margin-bottom: 1px; }
    .op-ds .op-summary-fig.has-tnotes .tchart-upper { padding-bottom: 8px; }
    .op-ds .op-summary-fig.has-tnotes .tchart-lower { padding-top: 11px; }
    .op-ds .op-tchart-notes {
        display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; margin: 6px 0 0;
        font: 500 var(--ds-fs-sm)/var(--ds-lh-sm) var(--ds-font); color: var(--ds-ink);
    }
    .op-ds .op-tchart-note { white-space: nowrap; }
    .op-ds .op-tchart-note::before {
        content: ''; display: inline-block; width: 6px; height: 6px; margin-inline-end: 6px; vertical-align: middle;
        border-radius: 50%; background: var(--ds-ink-2);
    }
}
/* From a tablet up the notes are under their teeth, as before. */
@media (min-width: 641px) {
    .op-ds .op-tchart-notes { display: none; }
}

/* The Treatment plan summary folded on a phone: its sentence on its own
   line, two lines at most, not "Treatment plan summary · Auto-generated ·
   St…" (row 19). Open, the whole sentence as before. */
@media (max-width: 640px) {
    .op-ds .op-summary-fold > summary.op-summary-head { flex-wrap: wrap; row-gap: 2px; }
    .op-ds .op-summary-fold .op-plan-headline { flex-basis: 100%; }
    .op-ds .op-summary-fold .op-plan-headline > bdi {
        display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; overflow: hidden;
    }
    .op-ds .op-summary-fold[open] .op-plan-headline > bdi { display: block; -webkit-line-clamp: none; }
}

/* The topbar's icons sit edge to edge on a phone (the clinic's name keeps
   its room); a tablet keeps the gap, so "Consultations" is not run into
   Help's icon. Working hours on a touch phone: "Morning" over its two
   times, each half the row, so a 16 px "10:00 AM" is not cut to "10:00 A". */
@media (pointer: coarse) and (max-width: 640px) {
    .op-ds .op-topbar .op-topbar-actions { gap: 0; }
    .op-ds .op-hours-shift { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); row-gap: 2px; }
    .op-ds .op-hours-shift::before { grid-column: 1 / -1; }
}

/* A visit card on a phone: its date on a line of its own ("2026-03-" over
   "02" when it shared one with Photos, Edit and ×), the buttons under it,
   × at the end of their row. */
@media (max-width: 640px) {
    .op-ds .op-visit-meta { flex-wrap: wrap; row-gap: 2px; }
    .op-ds .op-visit-meta > time { white-space: nowrap; flex: 1 0 100%; }
    /* The buttons from the start of their rows, not pushed to the end one by one. */
    .op-ds .op-visit-meta:has(.op-visit-instr, .op-visit-instr-write) { justify-content: flex-start; row-gap: 6px; }
}

/* A table drawn as cards on a phone (Money, Collected, the admin's lists):
   the first cell is the card's title, not a sticky column's grey band. */
@media (max-width: 640px) {
    .op-ds .op-table-wrap .op-table-cards :is(tbody, tfoot) :is(td, th):first-child { position: static; background: none; box-shadow: none; }
}

/* An overdue instalment: its lateness chip wraps inside its card ("8 شهور"
   ran past the chip's edge in Arabic). */
@media (max-width: 640px) {
    .op-ds .op-late { white-space: normal; max-width: 100%; height: auto; }
}

/* Money (row 24): a card per row on a phone (op-shell.js labels each cell
   with its column's heading): the patient first, then what is still to come. */
.op-ds .op-mcard-val { display: contents; }
@media (max-width: 640px) {
    .op-ds .op-mcards td { font-size: var(--ds-fs-md); }
    .op-ds .op-mcards td:first-child { order: -3; font-weight: 600; }
    .op-ds .op-mcards td[data-col="next"] { order: -2; }
    .op-ds .op-mcards tfoot { display: block; width: 100%; }
    .op-ds .op-mcards tfoot tr { display: flex; flex-direction: column; padding: 12px 16px; border-top: 1px solid var(--ds-line); }
    .op-ds .op-mcards tfoot :is(td, th) { display: grid; padding: 3px 12px; border: 0; text-align: start; }
    .op-ds .op-mcards tfoot :is(td, th)[data-label]::before { content: attr(data-label); font-size: 12px; color: var(--ds-ink-3); }
    .op-ds .op-mcards tfoot :is(td, th):empty { display: none; }
    /* "Total" is the card's title, not a sticky column's band. */
    .op-ds .op-mcards :is(tbody, tfoot) :is(td, th):first-child,
    .op-ds .op-table-wrap .op-mcards :is(tbody, tfoot) :is(td, th):first-child { position: static; background: none; box-shadow: none; }
    /* Label | figure: the label column wraps when its words are longer
       ("الصافي بعد المعمل" ran 28 px into its amount); the figure is one
       item (op-shell.js wraps it), its notes under it, wrapping inside the
       card ("تكلفة المعمل لسه مش معروفة" was cut at the edge). */
    .op-ds .op-mcards :is(tbody, tfoot) :is(td, th)[data-label] {
        grid-template-columns: minmax(0, 34%) minmax(0, 1fr); column-gap: 12px; white-space: normal;
    }
    .op-ds .op-mcards :is(td, th)[data-label]::before { white-space: normal; overflow-wrap: anywhere; min-width: 0; }
    .op-ds .op-mcards .op-mcard-val { display: block; grid-column: 2; min-width: 0; overflow-wrap: anywhere; }
    .op-ds .op-mcards .op-mcard-val > bdi { white-space: nowrap; }
    .op-ds .op-table-wrap:has(> .op-mcards) { overflow: visible; }
    .op-ds .op-table-wrap > .op-mcards { min-width: 0; }
}

/* The Money screen's seven tabs and the Settings tabs: every one on screen
   on a phone, in two rows (three of the seven were off the edge, row 24). */
@media (max-width: 640px) {
    .op-ds :is(.op-money-tabs, .op-tab-pills) { flex-wrap: wrap; overflow-x: visible; row-gap: 0; column-gap: 16px; }
}

/* Admin on a phone (row 30): the side menu's row fades at the end it can
   still scroll to, and opens on the page's own entry (op-shell.js). */
@media (max-width: 640px) {
    .op-ds .op-sidenav { --end: right; --start: left; }
    [dir="rtl"] .op-ds .op-sidenav { --end: left; --start: right; }
    .op-ds .op-sidenav.is-more-end:not(.is-more-start) {
        -webkit-mask-image: linear-gradient(to var(--end), black calc(100% - 32px), transparent);
        mask-image: linear-gradient(to var(--end), black calc(100% - 32px), transparent);
    }
    .op-ds .op-sidenav.is-more-start:not(.is-more-end) {
        -webkit-mask-image: linear-gradient(to var(--start), black calc(100% - 32px), transparent);
        mask-image: linear-gradient(to var(--start), black calc(100% - 32px), transparent);
    }
    .op-ds .op-sidenav.is-more-start.is-more-end {
        -webkit-mask-image: linear-gradient(to var(--end), transparent, black 32px, black calc(100% - 32px), transparent);
        mask-image: linear-gradient(to var(--end), transparent, black 32px, black calc(100% - 32px), transparent);
    }
}

/* The case inside a WordPress theme (the full-screen template off, row 35):
   the cards, the strip and the bar bleed by the gutter, so the root is padded
   by the gutter too (it kept the 3.0 template's 14 px: 2 px past a 390 px
   phone, 4 px in Arabic). In our own template the calm look does the same. */
@media (max-width: 1279px) {
    body .op-frontend.op-ds.op-case-detail:not(.op-app):not(.op-shell) { padding-inline: var(--ds-gutter); }
    body .op-frontend.op-ds.op-case-detail:not(.op-app):not(.op-shell) > .op-topbar { margin-inline: calc(-1 * var(--ds-gutter)); padding-inline: var(--ds-gutter); }
}
/* The front desk, the lab and the admin in Arabic (row 34): a line the
   catalogue does not cover yet keeps its own direction, so its full stop
   and "!" stay at its end ("!Nothing in the review queue. Great work"). */
[dir="rtl"] .op-ds:is(.op-admin, .op-lab, .op-secretary) :is(.op-empty, .op-empty p, p.op-muted, .op-field-hint, .op-page-sub) { unicode-bidi: plaintext; }
/* ---- end fix/mobile ---- */

/* ---- fix/look16 (16 Nov 2026, R16-06): the photo strip on a touch screen ----
   The strip is back on the phone and the tablet (op-zz-design.css, fix/look16):
   its fold and every button of its head are a thumb's 44 × 44 ("All" was 32
   wide on an iPad, the fold 32 high); a thumbnail is 72 × 54 and its caption,
   a 44 px target already. */
@media (pointer: coarse) {
    .op-ds .op-photo-rail .op-photo-rail-toggle { min-height: 44px; min-width: 44px; justify-content: center; }
    .op-ds .op-photo-rail .op-rail-tab { min-width: 44px; justify-content: center; }
}
/* ---- end fix/look16 ---- */

/* ---- walk of 16 Nov 2026 (R16-05 on a touch screen) ----
   "It is on today's plan list below: tick it there" takes him to its box
   (op-followup.js); on a touch screen it is a thumb's 44 px high. */
@media (pointer: coarse) {
    .op-ds .op-todo [data-todo-go] { min-height: 44px; display: inline-flex; align-items: center; text-align: start; }
}
/* ---- end walk of 16 Nov ---- */

/* ---- fix/shell18 (17 Nov 2026 call, C17-SHL-02): the step bar on a phone ----
   «لازم نظبط البروجرامنج بتاعه على الموبايل والتابلت زي بعض». The phone shows
   the four phases too, each boxed at the start of its own line with its
   steps after it (op-zz-design.css, fix/shell18), instead of one row of
   numbered discs that scrolled sideways: no sideways scroll, every step one
   tap (44 px), the open one still named. */
@media (max-width: 640px) {
    .op-ds { --ds-phase-w: 84px; }
    .op-ds .op-sequence > .op-tabs-nav,
    [dir="rtl"] .op-ds .op-sequence > .op-tabs-nav {
        flex-direction: column; flex-wrap: nowrap; overflow: visible; margin-inline: 0; padding-inline: 0;
        -webkit-mask-image: none; mask-image: none; gap: 4px;
    }
    .op-ds .op-step-group { padding-inline-start: calc(var(--ds-phase-w) + 6px); gap: 2px; }
    .op-ds .op-step-phase { padding: 0 8px; }
}
/* ---- end fix/shell18 ---- */
