/* The phone version of RADCAD (docs/MOBILE.md).  Every rule starts with html.m, the class static/mode.js sets from
   the person's choice or the screen: no phone layout lives in a media query, so the choice can go against the screen.
   Shared rules first, then one section per page. */

/* ---- on every screen: the menu button, the way back from a forced desktop page, the view option */
#m-menu-btn, #m-back-pill, #m-say { display: none; }
html.desk-on-phone #m-back-pill { display: block; position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 95;
  background: var(--accent, #1f6feb); color: #fff; border: 0; border-radius: 28px; padding: 18px 34px; font: 600 30px/1 -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.view-chooser { display: inline-flex; border: 1px solid var(--border, #2a323d); border-radius: 8px; overflow: hidden; vertical-align: middle; }
.view-chooser button { border: 0 !important; border-radius: 0 !important; background: transparent; color: var(--muted, #8b98a8); padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer; min-height: 0 !important; }
.view-chooser button.on { background: var(--accent, #1f6feb); color: #fff; }

/* ---- shared */
html.m { -webkit-text-size-adjust: 100%; }
html.m, html.m body { overscroll-behavior-x: none; }
html.m body { -webkit-tap-highlight-color: transparent; }
html.m input[type=text], html.m input[type=email], html.m input[type=password], html.m input[type=number], html.m input[type=search],
html.m input:not([type]), html.m textarea, html.m select { font-size: 16px !important; min-height: 42px; }   /* under 16 px iOS zooms the page */
html.m textarea { min-height: 64px; }
html.m button, html.m .btn { min-height: 40px; }
html.m .btn.small, html.m button.small { min-height: 36px; padding: 6px 12px; font-size: 13px; }
html.m input[type=checkbox], html.m input[type=radio] { width: 20px; height: 20px; min-height: 0; flex: none; }
html.m .toast { max-width: 92vw; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 96; }

/* the header: logo, the page's name, one main action, the menu */
html.m header { height: auto; min-height: 52px; gap: 8px; padding: 6px 10px; padding-top: calc(6px + env(safe-area-inset-top)); flex-wrap: nowrap; position: relative; }
html.m header > * { display: none !important; }
html.m header > .logo, html.m header > .spacer, html.m header > .title, html.m header > #m-menu-btn { display: block !important; }
html.m header > [data-m=keep]:not([hidden]) { display: inline-flex !important; align-items: center; flex: none; }
html.m header > .logo { flex: none; font-size: 17px; }
html.m header > .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.m header > #m-menu-btn { display: flex !important; flex-direction: column; justify-content: center; gap: 4px; width: 44px; height: 40px; padding: 0 11px; flex: none;
  background: var(--panel-2, #1c232c); border: 1px solid var(--border, #2a323d); border-radius: 8px; cursor: pointer; }
html.m header > #m-menu-btn { margin-left: auto; }
#m-menu-btn i { display: block; height: 2px; background: var(--text, #e6edf3); border-radius: 1px; }

/* sheets: the menu, and every dialog and floating panel */
.m-sheet { position: fixed; inset: 0; z-index: 97; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.m-sheet-card { width: 100%; max-width: 560px; max-height: 86vh; max-height: 86dvh; display: flex; flex-direction: column; background: var(--panel, #161b22); color: var(--text, #e6edf3);
  border: 1px solid var(--border, #2a323d); border-bottom: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.5); animation: m-up .16s ease-out; }
@keyframes m-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .m-sheet-card { animation: none; } }
.m-sheet-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 8px; font-size: 16px; }
.m-sheet-x { background: transparent; border: 0; color: var(--accent-2, #388bfd); font: inherit; font-size: 15px; padding: 6px 4px; cursor: pointer; }
.m-sheet-body { overflow: auto; padding: 0 10px calc(14px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.m-row { display: block; width: 100%; text-align: left; background: transparent; color: var(--text, #e6edf3); border: 0; border-top: 1px solid var(--border, #2a323d);
  border-radius: 0; padding: 14px 8px; font: inherit; font-size: 16px; cursor: pointer; min-height: 50px; }
.m-row:first-child { border-top: 0; }
.m-row.primary { color: var(--accent-2, #388bfd); font-weight: 600; }
.m-row:active { background: var(--panel-2, #1c232c); }
.m-note { display: block; color: var(--muted, #8b98a8); font-size: 13px; font-weight: 400; margin-top: 2px; }
.m-head { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted, #8b98a8); padding: 16px 8px 6px; border-top: 1px solid var(--border, #2a323d); }
html.m-sheet-open, html.m-sheet-open body { overflow: hidden; }

html.m #make-pop, html.m #share-pop, html.m #whatsnew, html.m #about-pop, html.m .limit-modal, html.m .sheet-host {
  align-items: flex-end !important; justify-content: center; padding: 0 !important; overflow: hidden !important; }
html.m #make-pop > .card, html.m #share-pop > .card, html.m #whatsnew > .card, html.m #about-pop > .card, html.m .limit-modal > div, html.m .sheet-host > .card {
  width: 100% !important; max-width: 100% !important; margin: 0 !important; border-radius: 16px 16px 0 0 !important; border-bottom: 0;
  max-height: 90vh; max-height: 90dvh; overflow: auto; padding: 16px 16px calc(18px + env(safe-area-inset-bottom)) !important; -webkit-overflow-scrolling: touch; }
html.m .acct-pop, html.m #fb-panel { position: fixed !important; left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: auto !important; max-width: none !important;
  max-height: 88vh; max-height: 88dvh; overflow: auto; border-radius: 16px 16px 0 0 !important; padding: 16px 16px calc(18px + env(safe-area-inset-bottom)) !important;
  z-index: 96 !important; box-shadow: 0 -10px 40px rgba(0,0,0,.6) !important; font-size: 14px; }
html.m .acct-pop button, html.m .limit-modal button { min-height: 40px; padding: 8px 14px; }
html.m #fb-fab { display: none !important; }                     /* it lay over Send: Feedback is in the menu */
html.m #fb-panel .mood { min-height: 36px; padding: 7px 12px; font-size: 13px; }

/* plain pages (page.css): terms, privacy, reset, admin, commons, guide */
html.m .page { padding: 16px 14px 60px; }
html.m .page h1 { font-size: 24px; }
html.m .page table { display: block; overflow-x: auto; max-width: 100%; }

/* ---- the design page (design.html) */
html.m body.design-page { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
html.m body.design-page #d-name { display: block !important; flex: 0 1 auto; min-width: 0; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; padding: 2px 0; }
html.m body.design-page header > .logo { font-size: 15px; letter-spacing: 0; }
html.m body.design-page #d-status { font-size: 10px; padding: 1px 6px; }
html.m body.design-page #make-btn, html.m body.design-page #remix-btn { min-height: 36px; padding: 5px 10px; white-space: nowrap; }
html.m #start { margin: 3vh auto 0; padding: 0 14px 24px; }
html.m #start h1 { font-size: 24px; }
html.m #start textarea { min-height: 120px; }
html.m #start .row { flex-wrap: wrap; } html.m #start .row .hint { flex-basis: 100%; }
html.m #start .row .btn { flex: 1; }
html.m #start .examples button { min-height: 38px; font-size: 13px; }
html.m body.design-page:not(.m-model):not(.m-chat):not(.m-panel) { overflow: auto; }      /* the start box scrolls */

html.m #ws { display: block; flex: 1; min-height: 0; height: auto; position: relative; }
html.m #ws > section { display: none !important; height: 100%; border: 0; }
html.m body.m-model #viewer-pane { display: block !important; }
html.m body.m-chat #chat { display: flex !important; }
html.m body.m-panel #panel { display: flex !important; }
html.m #mtabs { display: flex; border-top: 1px solid var(--border); background: var(--panel); padding-bottom: env(safe-area-inset-bottom); flex: none; }
html.m #mtabs[hidden] { display: none; }
html.m #mtabs button { flex: 1; border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 8px 4px 9px; font-size: 12px; border-top: 2px solid transparent;
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 54px; position: relative; }
html.m #mtabs button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
html.m #mtabs button.on { color: var(--text); border-top-color: var(--accent-2); }
html.m #mtabs button .new { position: absolute; top: 7px; left: calc(50% + 9px); width: 9px; height: 9px; border-radius: 50%; background: var(--accent-2); }

/* the model: one strip of tools, the reply card, the "change anything" bar */
html.m #viewer-tools { left: 0; right: 0; top: 0; padding: 8px; gap: 6px; flex-wrap: nowrap; overflow-x: auto; max-width: none; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  background: linear-gradient(rgba(11,14,18,.9), rgba(11,14,18,0)); }
html.m #viewer-tools::-webkit-scrollbar { display: none; }
html.m #viewer-tools .btn { flex: none; min-height: 36px; padding: 6px 12px; }
html.m #viewer-overlay { left: 10px; bottom: auto; top: 54px; font-size: 11px; }
html.m #headline { display: none !important; }
html.m #banner { left: 8px; right: 8px; top: 54px; flex-wrap: wrap; }
html.m #face-picks { top: 76px; left: 8px; max-width: 80%; }
html.m #viewer-empty { padding: 24px; }
html.m #viewer-hint { left: 8px; right: 8px; bottom: 64px; }
html.m #look-panel, html.m #measure-panel, html.m #motion-panel { position: absolute; left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 62%; overflow: auto; z-index: 8;
  border-radius: 16px 16px 0 0; border-bottom: 0; padding: 14px 14px 16px; font-size: 14px; box-shadow: 0 -10px 30px rgba(0,0,0,.5); background: rgba(22,27,34,.98); }
html.m #look-panel .lk-row button { min-height: 36px; font-size: 13px; padding: 6px 12px; }
html.m #section-panel { left: 8px; right: 8px; bottom: 64px; max-width: none; z-index: 6; padding: 8px; }
html.m #section-panel .btn { min-width: 40px; }

html.m body.m-model #m-say:not([hidden]) { display: flex; align-items: center; gap: 8px; position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 5; min-height: 46px;
  background: rgba(22,27,34,.96); border: 1px solid var(--border); border-radius: 23px; padding: 0 6px 0 16px; color: var(--muted); font-size: 15px; text-align: left; cursor: text; }
html.m #m-say .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.m #m-say .go { flex: none; background: var(--accent); color: #fff; border-radius: 18px; padding: 7px 14px; font-size: 13px; font-weight: 600; }
html.m body.m-model #m-last { display: block; position: absolute; left: 8px; right: 8px; bottom: 62px; z-index: 5; background: rgba(22,27,34,.96);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; font-size: 14px; max-height: 34%; overflow: auto; }
html.m body.m-model #m-last:empty { display: none; }
/* a tool's panel has the bottom of the screen to itself */
html.m #viewer-pane:has(#look-panel:not([hidden]), #measure-panel:not([hidden]), #motion-panel:not([hidden]), #section-panel:not([hidden])) #m-last,
html.m #viewer-pane:has(#look-panel:not([hidden]), #measure-panel:not([hidden]), #motion-panel:not([hidden])) #m-say { display: none !important; }
html.m #m-last .t { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
html.m #m-last a { font-size: 13px; display: inline-block; padding: 6px 0 0; }
html.m #m-last .x { float: right; margin: -6px -8px 0 8px; padding: 0 10px; font-size: 20px; line-height: 1; border: 0; background: transparent; color: var(--muted); min-height: 36px; }
html.m body.m-model #m-last.min { left: auto; right: 8px; padding: 0; background: transparent; border: 0; }
html.m #m-last .sugg button, html.m .sugg button { min-height: 36px; font-size: 13px; padding: 6px 12px; }
html.m #m-last .msg.verdict { margin-top: 8px; }

/* the chat */
html.m .msg { max-width: 100%; font-size: 15px; }
html.m .msg.change, html.m .msg.system { font-size: 13px; }
html.m #thread { padding: 10px; }
html.m #thread-bar { padding: 4px 10px; }
html.m #thread-bar label { min-height: 32px; font-size: 12px; }
html.m #compose { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
html.m body.m-chat #mtabs { padding-bottom: env(safe-area-inset-bottom); }
html.m #compose textarea { min-height: 56px; }
html.m #compose .row .hint { display: none; }
html.m #compose .row { justify-content: flex-end; }
html.m #compose #send { min-width: 96px; }
html.m #compose .row2 { font-size: 12px; }
html.m .rate .thumb { font-size: 18px; padding: 4px 8px; min-height: 36px; }
html.m .chip-r { padding: 6px 12px; font-size: 13px; }
html.m #tips, html.m #trouble { margin: 0 10px 8px; font-size: 14px; }

/* the details */
html.m #tabs { overflow-x: auto; scrollbar-width: none; flex: none; }
html.m #tabs::-webkit-scrollbar { display: none; }
html.m #tabs button { flex: 1 0 auto; padding: 12px 14px; font-size: 14px; white-space: nowrap; min-height: 46px; }
html.m #tab-body { padding: 12px 12px 24px; -webkit-overflow-scrolling: touch; }
html.m #tab-body table { font-size: 13px; }
html.m #tab-body td, html.m #tab-body th { padding: 6px 4px; }
html.m .param { grid-template-columns: 1fr 118px 34px 36px; gap: 6px; padding: 3px 0; font-size: 14px; }
html.m .param input { min-height: 40px; padding: 6px 8px; }
html.m .param .pin { font-size: 18px; padding: 6px 0; }
html.m .kv { font-size: 13px; }
html.m .req { font-size: 14px; padding: 8px 0; grid-template-columns: 20px 1fr 30px; }
html.m .rev-row, html.m .pdm-row { min-height: 44px; font-size: 14px; }
html.m .bi-tools { grid-template-columns: 1fr; gap: 0; font-size: 15px; }
html.m .bi-tools label { align-items: center; min-height: 40px; }
html.m .bi-field { grid-template-columns: 1fr; font-size: 14px; }
html.m .bi-row .btn { flex: 1 0 auto; }
html.m .lib-search .btn { flex: none; }
html.m #src { font-size: 12px !important; min-height: 55vh; }
html.m h3 .btn { min-height: 34px; }
html.m details.fold > summary { padding: 10px 0; font-size: 14px; }
html.m #ro-note { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }

/* get this made: a sheet, one column */
html.m #make-pop .grid { grid-template-columns: 1fr; }
html.m #make-pop .r { position: sticky; bottom: -18px; background: var(--panel); padding: 10px 0 2px; flex-wrap: wrap; }
html.m #make-pop .r .muted { flex-basis: 100%; }
html.m #make-pop .r .btn { flex: 1; min-height: 44px; font-size: 15px; }
html.m #make-pop label { font-size: 13px; margin-top: 10px; }
html.m #make-pop input, html.m #make-pop select { width: 100%; }
html.m .sh-inv, html.m .sh-link { flex-wrap: wrap; } html.m .sh-inv input, html.m .sh-link input { flex: 1 1 100%; }

/* ---- the library and the landing page (index.html) */
html.m #signin { padding: 22px 16px 24px; }
html.m #signin .hero h1 { font-size: 27px; }
html.m #signin .hero p { font-size: 16px; }
html.m #signin .cta .btn.big { width: 100%; min-height: 50px; font-size: 17px; }
html.m #signin .examples-row, html.m #signin .auth-grid, html.m #signin .demo-row { grid-template-columns: 1fr; }
html.m #signin .auth-grid input:not([type=checkbox]) { width: 100%; }   /* (a full-width checkbox pushed its label off the screen) */
html.m #signin .check input[type=checkbox] { width: 18px; height: 18px; }
html.m .starter { min-height: 38px; font-size: 14px; }
html.m footer.site-foot { line-height: 2.4; }
html.m #library { padding: 16px 12px 40px; }
html.m #library h1 { font-size: 22px; margin-bottom: 10px; }
html.m .box { padding: 12px; }
html.m .box .row { flex-wrap: wrap; }
html.m .box .row .hint { flex-basis: 100%; }
html.m #design-box .row .btn { flex: 1; }
html.m #design-box textarea { min-height: 96px; }
html.m #building-box .row .btn { flex: 1; text-align: center; display: flex; align-items: center; justify-content: center; }
html.m .new-row, html.m #lib-body { grid-template-columns: 1fr; display: grid; }
html.m #lib-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
html.m .commons-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
html.m .card .name { font-size: 13px; overflow: hidden; }
html.m .card .meta { font-size: 11px; }
html.m .card .actions .btn { min-height: 32px; padding: 4px 9px; font-size: 12px; }
html.m #lib-tree .node { min-height: 42px; }
html.m #lib-project-head .row { flex-wrap: wrap; }
html.m #feedback-box { left: 8px !important; right: 8px !important; width: auto !important; }
/* the older step-by-step workspace: usable, not redesigned */
html.m #workspace { height: calc(100vh - 53px); height: calc(100dvh - 53px); }
html.m #workspace #viewer-tools { position: absolute; }
html.m #status-line { left: 8px; right: 8px; top: 52px; max-width: none; }
html.m #prompt-bar { left: 6px; right: 6px; bottom: 6px; }
html.m body.flyout-open #viewer-pane { right: 0; }
html.m #flyout { width: min(92vw, 360px); z-index: 7; }
html.m body.flyout-open #flyout-tab { right: min(92vw, 360px); }

/* ---- the commons (commons.html) */
html.m .page > .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
html.m .bar { flex-wrap: wrap; }
html.m .bar input[type=search] { flex: 1 1 100%; }

/* ---- components (components.html): the list, then a part's details over the whole screen */
html.m body.components-page #page { display: block; height: calc(100% - 53px); overflow: auto; }
html.m #side { border-right: 0; border-bottom: 1px solid var(--border); padding: 8px 10px; overflow: visible; }
html.m #side h3 { display: none; }
html.m #upload-btn { width: auto; margin: 0 0 6px; }
html.m .scopes, html.m .cats { flex-direction: row; display: flex; gap: 6px; overflow-x: auto; white-space: nowrap; padding-bottom: 4px; scrollbar-width: none; }
html.m .scopes button, html.m .cats button { width: auto; flex: none; gap: 6px; border: 1px solid var(--border); border-radius: 18px; padding: 6px 12px; }
html.m body.components-page #main { overflow: visible; padding: 10px; }
html.m body.components-page #grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
html.m #detail { display: none; }
html.m body.detail-open #detail { display: flex; position: fixed; inset: 0; z-index: 30; border: 0; width: auto; }
html.m #d-close { display: block; position: sticky; top: 0; z-index: 2; padding: 14px; background: var(--panel); border-bottom: 1px solid var(--border); flex: none; }
html.m #view-wrap { height: min(300px, 45vh); }

/* ---- build instructions (guide.html) */
html.m .top img { width: 100%; }
html.m nav.toc { overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; scrollbar-width: none; margin: 10px -14px; padding: 8px 14px; }
html.m nav.toc a { flex: none; padding: 7px 12px; font-size: 14px; }
html.m nav.toc .grow { display: none; }
html.m label.tick { min-height: 36px; }
html.m .part, html.m .step { padding: 12px; }
html.m table.buy img.thumb { width: 48px; height: 48px; }

/* ---- the building designer (building.html) is a desktop tool: on a phone it shows the model (its own narrow rule) */

/* ---- admin: readable */
html.m nav.sections { overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; }
html.m .kpis { grid-template-columns: 1fr 1fr; }
html.m .breq .body { grid-template-columns: 1fr; }
