/* ================================================================
   MOBILE — the pocket instrument. body.m is JS-synced to ≤1023px.
   Same glass and light, rebuilt for a thumb: a one-line header that
   slides away while you scroll down → one tab of panels → a slim
   commit strip → three-tab bar. Modals become bottom sheets; the
   year's cards become full-bleed swipeable pages.
   ================================================================ */

body.m { height: 100dvh; }
body.m .btn, body.m .action-row, body.m .menu-item, body.m .m-tab,
body.m .diet-select, body.m .card, body.m .profile-card, body.m .orl-item { touch-action: manipulation; }

/* -- shell frame -- */
.m-shell { position: relative; display: flex; flex-direction: column; height: 100%; min-height: 0; --mtop: calc(54px + env(safe-area-inset-top, 0px)); }
/* the header floats over the page, so sliding it away moves nothing */
.m-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  height: var(--mtop); box-sizing: border-box;
  display: flex; align-items: center;
  padding: env(safe-area-inset-top, 0px) 10px 0 12px;
  background: linear-gradient(180deg, rgba(20, 31, 48, 0.97), rgba(11, 18, 29, 0.95));
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: transform 260ms var(--ease-out), box-shadow 260ms var(--ease-out);
}
.m-shell.hdr-away .m-top { transform: translateY(-100%); box-shadow: none; }
.m-top-line { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; }
.m-year { font: 700 calc(22px * var(--text-scale))/1 var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; color: #fff; text-shadow: 0 0 20px rgba(47, 227, 203, 0.3); }
.m-sub { font: 600 calc(11.5px * var(--text-scale))/1 var(--font-sans); color: var(--text-2); white-space: nowrap; }
.m-sys { appearance: none; background: var(--well); border: 1px solid var(--line); cursor: pointer; font: 700 18px/1 var(--font-sans); color: var(--text-2); width: 36px; height: 34px; border-radius: 10px; flex: none; }
.m-sys:active { background: var(--hover-2); }
.m-chips { display: flex; gap: 5px; margin-left: auto; min-width: 0; }
.m-chip { font: 600 calc(12px * var(--text-scale))/1.4 var(--font-mono); padding: 4px 9px; gap: 5px; }
@media (max-width: 380px) { .m-top .logo { display: none; } .m-chip { padding: 4px 7px; } }

/* -- the page: one tab's panels, flowing and scrollable -- */
.m-page { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--mtop) + 12px) 12px 20px; scrollbar-width: none; }
.m-page::-webkit-scrollbar { display: none; }
.m-page > * { margin-bottom: 12px; }
.m-page > *:last-child { margin-bottom: 0; }
.m-page > .panel { animation: panel-in 460ms var(--ease-out) backwards; }
.m-page > .panel:nth-child(2) { animation-delay: 60ms; }
.m-page > .panel:nth-child(3) { animation-delay: 120ms; }
body.m .panel-fill { flex: none; display: block; overflow: visible; min-height: 0; }
body.m .bio-panel { max-height: none; }
body.m .bio-scroll, body.m .list-scroll { flex: none; overflow: visible; -webkit-mask-image: none; mask-image: none; }
body.m .queue-foot { display: none; } /* budget + End Year live in the commit strip */
body.m .q-list { max-height: none; }
body.m .bio-row { padding: 7px 6px 7px 12px; }
body.m .action-row { padding: 10px 8px; }
/* a row you can afford shows its +; one you can't, a hollow one */
body.m .a-add { opacity: 1; transform: none; }
body.m .a-row.disabled .a-add { background: transparent; color: var(--text-4); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
body.m .a-row .row-name { white-space: normal; align-items: flex-start; line-height: 1.35; }
body.m .a-row .path-dot { margin-top: 5px; }
body.m .a-row .why, body.m .a-row .brings { padding-left: 0; }
body.m .a-row .costs { flex-direction: column; align-items: flex-end; gap: 3px; }
body.m .sup-row { align-items: flex-start; }
body.m .sup-row .row-cost { font-size: calc(10.5px * var(--text-scale)); text-align: right; max-width: 76px; white-space: normal; }
body.m .q-x { opacity: 1; }

/* the body, pocket-size: no figure on the tab (the Body view has it) */
body.m .body-panel { min-height: 0; }
body.m .organ-list { grid-template-columns: repeat(5, minmax(0, 1fr)); }

/* -- commit strip (always reachable, on every tab): the year's state, its money, End -- */
.m-commit { display: flex; align-items: center; gap: 10px; background: linear-gradient(180deg, rgba(14, 38, 44, 0.96), rgba(11, 18, 29, 0.98)); border-top: 1px solid rgba(47, 227, 203, 0.25); padding: 7px 10px 7px 12px; z-index: 2; }
.m-commit-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.m-flag { display: flex; align-items: center; gap: 5px; min-width: 0; font: 650 calc(12.5px * var(--text-scale))/1.2 var(--font-sans); color: var(--teal-ink); }
.m-flag > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-flag .ico { flex: none; }
.m-flag.over { color: var(--danger-ink); }
.m-flag.idle { color: var(--c-energy-ink); }
.m-money { display: flex; align-items: center; gap: 4px; min-width: 0; font: 500 calc(11px * var(--text-scale))/1.2 var(--font-mono); white-space: nowrap; overflow: hidden; }
.m-money .ico { color: var(--c-money-ink); flex: none; }
.m-money b { color: var(--c-money-ink); font-weight: 650; }
.m-commit .btn { white-space: nowrap; }
.m-end { flex: none; min-width: 0; height: 44px; padding: 0 14px 0 16px; gap: 8px; border-radius: 13px; font: 700 calc(15.5px * var(--text-scale))/1 var(--font-display); }
.m-end.blocked { filter: saturate(0.25) brightness(0.8); }

/* -- tab bar -- */
.m-tabbar { display: flex; background: rgba(6, 11, 19, 0.98); border-top: 1px solid var(--line-soft); padding: 4px 8px calc(6px + env(safe-area-inset-bottom, 0px)); }
.m-tab {
  flex: 1; appearance: none; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-transform: uppercase; letter-spacing: 0.12em;
  font: 700 calc(10px * var(--text-scale))/1 var(--font-sans);
  color: var(--text-3); padding: 9px 0 8px; position: relative; border-radius: 10px;
  transition: color 160ms var(--ease-out);
}
.m-tab:active { background: var(--hover); }
.m-tab.active { color: #fff; }
.m-tab.active .ico { color: var(--tabc); filter: drop-shadow(0 0 6px var(--tabc)); }
.m-tab.active::after { content: ''; position: absolute; top: 1px; left: 50%; transform: translateX(-50%); width: 26px; height: 3px; border-radius: 2px; background: var(--tabc, var(--accent)); box-shadow: 0 0 10px var(--tabc, var(--accent)); animation: pop-in 280ms var(--ease-spring); }

/* -- controls grow to thumb size -- */
body.m .btn { padding: 11px 16px; }
body.m .btn-sm { padding: 8px 13px; }
body.m .btn-lg { padding: 14px 22px; }
body.m .step-btn { width: 40px; height: 38px; padding: 0; }
body.m .diet-select { font-size: 16px; padding: 10px 34px 10px 14px; } /* ≥16px: no iOS focus zoom */
body.m .field { padding: 12px 0; grid-template-columns: minmax(0, 1fr) auto; }
body.m .field .field-bar { grid-column: 1 / -1; grid-row: 2; }
body.m .stepper .val { min-width: 74px; }

/* -- modals become bottom sheets -- */
body.m .modal-layer { align-items: flex-end; justify-content: stretch; }
body.m .modal {
  width: 100%; min-width: 0; max-width: none;
  border: none; border-top: 1px solid var(--line-strong);
  border-radius: 22px 22px 0 0;
  max-height: 90dvh;
  --mpx: 18px; --mpb: calc(24px + env(safe-area-inset-bottom, 0px));
  padding: 8px var(--mpx) var(--mpb);
  animation: sheet-up 380ms var(--ease-out);
}
body.m .modal.leaving { animation: sheet-down 220ms var(--ease-in-out) both; }
body.m .modal::before { content: ''; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 4px auto 14px; }
body.m .modal::after { left: 40px; right: 40px; }
@keyframes sheet-up { from { transform: translateY(60px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@keyframes sheet-down { to { transform: translateY(80px); opacity: 0; } }
body.m .modal-tech { height: 92dvh; max-height: 92dvh; padding-left: 12px; padding-right: 12px; }
body.m .modal-tech .modal-head { flex-wrap: wrap; }
body.m .modal-tech .mh-text { flex-basis: 100%; }
body.m .modal-tech .tech-filter { order: 2; }
body.m .modal-tech .modal-close { order: 3; margin-left: auto; }
body.m .m-idle { margin-top: 10px; color: var(--c-energy-ink); font-weight: 600; display: flex; align-items: center; gap: 5px; }
body.m .m-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); flex: none; }
body.m .m-over { margin-top: 10px; color: var(--danger-ink); font-weight: 650; }
body.m .m-bad { color: var(--danger-ink); font-weight: 700; }

/* the Body view, pocket-size: the organs, then the page you pick */
body.m .modal-anatomy { height: 94dvh; max-height: 94dvh; padding-left: 12px; padding-right: 12px; }
body.m .anat-head { gap: 8px; margin-bottom: 10px; }
body.m .anat-head .anat-summary { display: none; }
body.m .anat-head .modal-close { margin-left: auto; }
body.m .anat-body.pocket { display: block; overflow-y: auto; overscroll-behavior: contain; margin: 0 -4px; padding: 0 4px; }
body.m .anat-body.pocket .anat-left { margin-bottom: 10px; }
body.m .anat-body.pocket .anat-detail { overflow: visible; scroll-margin-top: 6px; }
body.m .anat-body.pocket .orl-item.on { border-color: var(--og); background: color-mix(in srgb, var(--og) 12%, transparent); }
body.m .ad-hero { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; }
body.m .ad-ring .org-ring { width: 96px; height: 96px; }
body.m .ad-step { display: none; }
body.m .watch-row { grid-template-columns: minmax(0, 1fr) auto; }
body.m .watch-row .wr-when { grid-column: 1 / -1; grid-row: 2; }
body.m .risk-row { grid-template-columns: minmax(0, 1fr) auto; }
body.m .risk-row .rk-basis { grid-column: 1 / -1; grid-row: 2; }
body.m .ol-row { grid-template-columns: 22px minmax(0, 1fr) 56px 44px; }
body.m .org-preview { grid-template-columns: 1fr; }

/* -- year-end cards: full-bleed pages, swipe to turn -- */
body.m #card-layer.active { align-items: stretch; justify-content: stretch; }
body.m .card { --cpx: 22px; width: 100%; max-width: none; height: 100%; max-height: none; border: none; border-radius: 0; }
body.m .card-top { padding-top: calc(10px + env(safe-area-inset-top, 0px)); padding-left: var(--cpx); gap: 10px; }
body.m .card-kind { min-width: 0; }
body.m .card-plate { height: clamp(150px, 27dvh, 240px); }
body.m .card-title { font-size: calc(24px * var(--text-scale)); }
body.m .card-prose { font-size: calc(16.5px * var(--text-scale)); }
body.m .card-nav { padding: 12px 22px calc(14px + env(safe-area-inset-bottom, 0px)); }
body.m .card-nav .btn { padding: 12px 20px; font-size: calc(14px * var(--text-scale)); }
body.m .card-datum { grid-template-columns: 1fr auto; }
body.m .datum-spark { display: none; }

/* -- year turning, pocket-size -- */
body.m .yt-years { font-size: calc(76px * var(--text-scale)); }
body.m .yt-steps { width: 90vw; }

/* -- menu -- */
body.m .menu-screen { padding: 7vh 20px 4vh; max-width: none; justify-content: flex-start; }
body.m .wordmark { font-size: calc(52px * var(--text-scale)); margin-top: 12px; }
body.m .menu-items { margin-top: 4vh; width: 100%; }
body.m .menu-item { padding: 12px 12px; }
body.m .mi-lead { display: none; }
body.m .mi-detail { margin-left: auto; font-size: calc(11px * var(--text-scale)); text-align: right; }
body.m .menu-item:hover, body.m .menu-item.focused { transform: none; }

/* -- character creation -- */
body.m .chargen { padding: 22px 16px 32px; }
body.m .cg-title { font-size: calc(30px * var(--text-scale)); }
body.m .profile-grid { grid-template-columns: 1fr; gap: 12px; }
body.m .cg-section { margin: 24px 0 10px; }
body.m .field-carry .carry-chips { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
body.m .cg-cols { grid-template-columns: 1fr; gap: 16px; }
body.m .cg-fields { padding: 4px 14px; }
body.m .field-habits .habit-togs { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
body.m .cg-readout { position: static; }
body.m .rd-body { height: 180px; }
body.m .cg-foot { position: sticky; bottom: -32px; background: linear-gradient(transparent, var(--bg-1) 16px); padding: 20px 0 16px; margin-bottom: -16px; flex-wrap: wrap; }
body.m .cg-sum { display: flex; }
body.m .profile-card { padding: 18px; }
body.m .profile-card:hover, body.m .profile-card.focused { transform: none; }

/* -- run summary -- */
body.m .summary-band { padding-top: 90px; }
body.m .summary-band-inner, body.m .summary-body-inner { padding-left: 18px; padding-right: 18px; }
body.m .summary-title { font-size: clamp(30px, 9vw, 42px); }
body.m .summary-cols { grid-template-columns: 1fr; gap: 34px; margin-top: 26px; }
body.m .summary-ledger { padding: 14px 16px; }

/* -- toast clears the commit strip + tab bar -- */
body.m .bp-conds { max-height: none; overflow: visible; }
body.m .toast { bottom: calc(128px + env(safe-area-inset-bottom, 0px)); max-width: calc(100vw - 40px); }

/* -- the dashboard's parts, pocket-size -- */
body.m .bio-flex { display: block; }
body.m .bio-row { grid-template-columns: minmax(0, 1fr) minmax(48px, 0.8fr) calc(92px * var(--text-scale)) calc(40px * var(--text-scale)); gap: 8px; }
body.m .bio-spark { display: none; }
body.m .atab { padding: 10px 4px; font-size: calc(11.5px * var(--text-scale)); }
body.m .atab .cnt, body.m .atab .ico { display: none; }
body.m .act-pill { padding: 9px 14px 9px 8px; }
body.m .act-pill .cost { font-size: calc(11px * var(--text-scale)); }
body.m .rt-item { padding: 8px 10px; }
body.m .rt-grid { grid-template-columns: 1fr 1fr; }
/* no keyboard on a phone: the key hints go */
body.m .m-shell kbd, body.m .modal kbd { display: none; }
body.m .modal-influence { width: 100vw; height: 94dvh; max-height: 94dvh; padding: 14px 12px 0; }
body.m .ins-title .t2 { font-size: calc(18px * var(--text-scale)); }
body.m .is-line .t5 { min-width: 0; }
body.m .rt-foot .rt-btns { width: 100%; }
body.m .rt-foot .rt-btns .btn { flex: 1 1 0; }

/* the biomarker header and rows, pocket-size */
body.m .bio-row { grid-template-columns: minmax(0, 1.3fr) minmax(56px, 1fr) auto; }
body.m .bio-delta { display: none; }

/* -- decisions and what you carry, pocket-size -- */
body.m .choice { grid-template-columns: 26px minmax(0, 1fr); padding: 14px 12px; }
body.m .choice .ch-go { display: none; }
body.m .ch-key { width: 26px; height: 26px; }
body.m .ch-key kbd { display: none; }
body.m .ch-key:not(:has(.ico))::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
body.m .ch-label { font-size: calc(15.5px * var(--text-scale)); }
body.m .choice:hover { transform: none; }
body.m .choice-confirm .btn-row .btn { flex: 1 1 0; white-space: normal; }
body.m .cond-chip { padding: 7px 11px 7px 9px; }
/* an adoption card's links: the button drops under its line on a phone */
body.m .op-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; row-gap: 10px; }
body.m .op-go { grid-column: 2; justify-self: start; }
