/* ===== Mandala V4 画面の土台：電話の幅と狭い幅（640px 以下・980px 以下）（phone.css）=====
   もとは impl-kit/ui/parts.css（部品の担当、2026-11-16）。置き場の表 impl-kit/LAYOUT.md に合わせて分けた（2026-11-16）。
   色・角・影・動きは tokens/tokens.css と motion/motion.css の名前だけを使う（値を直に書かない。要件 I-08）。
   読み込みの順：tokens/tokens.css → motion/motion.css → components/base/base.css → components/extra/extra.css → frame/layouts/layouts.css → phone/phone.css */

/* ---------- 幅の狭い PC・タブレット ---------- */
@media (max-width:980px){
  /* 言語の切替は、980px 以下では上の帯に出さない（本人のメニューにだけ出す。S222） */
  .mx-top-tools .mx-lang{display:none}
  .mx-ring{width:min(86vw,60vh)}
  .mx-search{min-width:0}
  .mx-search-text{display:none}
  /* 保存の状態は短い文（長い文は読み上げにだけ残す。見た目だけ 1px に縮めて切る） */
  .mx-save-long{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
  .mx-save-short{display:inline}
}

/* ---------- いまの場所（breadcrumb）----------
   幅に合わせる形（nav.mx-crumb-fit。ResizeObserver が在るとき）は、部品が前の階層から省く（base.css）。ここの決まりは使わない。
   ResizeObserver が無い環境だけ：900px より狭いと最後の 2 つ、640px 以下は最後の 1 つだけを見せる。
   隠した階層は読み上げに残す（見た目だけ 1px に縮めて切る。.mx-sr と同じ形）。Tab で来たときは見せる */
@media (max-width:899.98px){
  .mx-crumb:not(.mx-crumb-fit) li.mx-crumb-far{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
  .mx-crumb:not(.mx-crumb-fit) li.mx-crumb-far:focus-within{position:static;width:auto;height:auto;margin:0;clip:auto}
  .mx-crumb:not(.mx-crumb-fit) li.mx-crumb-far+li:not(.mx-crumb-far)::before{display:none}
}
@media (max-width:640px){
  .mx-crumb:not(.mx-crumb-fit) li.mx-crumb-prev{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
  .mx-crumb:not(.mx-crumb-fit) li.mx-crumb-prev:focus-within{position:static;width:auto;height:auto;margin:0;clip:auto}
  .mx-crumb:not(.mx-crumb-fit) li.mx-crumb-prev+li::before{display:none}
}

/* ---------- スマートフォン（640px 以下）：1 列、押せる部分は 44px 以上 ---------- */
@media (max-width:640px){
  html,body{max-width:100%;overflow-x:hidden}
  .mx-btn,.mx-btn.sm,.mx-seg,.mx-tabs [role="tab"],.mx-pitem,.mx-search,.mx-input,.mx-toast-undo,.mx-save-retry,.mx-attach-name,.mx-conflict-opt,.mx-cal-day,.mx-lfig-fold summary{min-height:44px}
  .mx-ibtn,.mx-ibtn.sm,.mx-toast-x{width:44px;height:44px}
  /* 上の帯：2 段。上の段は 窓口の名前・検索・保存の状態・本人（と actions）、下の段は いまの場所の 1 行（第6巻 shell.menu の phone_note）。
     見た目の切替（.mx-top-tools）は帯に出さない（枠が本人のメニューの板の中に出す）。帯の中身が 375px に収まる */
  .mx-top{flex-wrap:wrap;gap:4px 8px;height:auto;min-height:56px;padding:6px 12px}
  .mx-top-tools{display:none}
  .mx-kbd{display:none}
  .mx-brand{flex:1 1 0;gap:8px;letter-spacing:.08em;min-height:44px}
  .mx-brand:has(.mx-brand-console) .mx-brand-name{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
  .mx-brand small{font-size:13px;color:var(--ink)}
  .mx-top-crumb{order:10;flex:1 0 100%;min-width:0}
  .mx-crumb ol{font-size:12px}
  .mx-search{width:44px;padding:0;justify-content:center;color:var(--ink)}
  .mx-top>.mx-save{min-width:0}
  .mx-save-short{min-width:0;max-width:6em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  /* ring_nav：輪をやめて、指で選べる札の並び */
  .mx-ring{width:100%;aspect-ratio:auto}
  .mx-ring-disc{height:auto;display:grid;gap:12px}
  .mx-orb,.mx-beam{display:none}
  .mx-ring-core{position:relative;inset:auto;border-radius:var(--r);padding:14px;aspect-ratio:auto}
  .mx-ring-core::before{display:none}
  .mx-ring-list{position:static;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  .mx-node{position:relative;left:auto;top:auto;width:auto;aspect-ratio:auto;margin:0;min-height:72px;border-radius:var(--r2);padding:8px 4px}
  .mx-node:hover,.mx-node:focus-visible,.mx-node.hot{transform:none}
  .mx-node .mx-badge{top:4px;right:4px}
  /* list・table：札にする */
  .mx-row{grid-template-columns:10px minmax(0,1fr) auto;min-height:52px}
  .mx-row .mx-tag,.mx-row .mx-row-marks{grid-column:2}
  .mx-row-thumb{width:36px;height:36px}
  .mx-row-value{grid-column:3;grid-row:1}
  .mx-row:hover{transform:none}
  .mx-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
  .mx-table,.mx-table tbody,.mx-table tr,.mx-table td{display:block;width:100%}
  .mx-table tr{margin-bottom:10px;padding:8px 10px;border:1px solid var(--line);border-radius:var(--r2);background:var(--glass)}
  .mx-table td{display:grid;grid-template-columns:minmax(6em,40%) minmax(0,1fr);gap:8px;border-bottom:0;padding:4px 0;text-align:left}
  .mx-table td::before{content:attr(data-label);color:var(--muted);font-size:11px;font-weight:700}
  .mx-table .r{text-align:left}
  .mx-conflict-table th[scope="row"]{display:block;padding:4px 0;font-weight:700;border-bottom:0}
  /* filter_bar：引き出し */
  .mx-filter-open{display:inline-flex}
  .mx-filter-body{display:none;width:100%;flex-direction:column;align-items:stretch}
  .mx-filter.open .mx-filter-body{display:flex}
  .mx-filter-body select.mx-input,.mx-filter-body input.mx-input{width:100%;min-width:0}
  .mx-filter-range{display:grid;gap:6px}
  .mx-filter-pair{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);width:100%}
  .mx-tabs{width:100%}
  .mx-tabs [role="tab"]{flex:1}
  /* metrics：3 つまで横に、図は隠す */
  .mx-metrics{grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
  .mx-metric{display:block;padding:10px}
  .mx-metric-value{font-size:20px}
  .mx-metric .mx-spark{display:none}
  /* detail_pane：全画面 */
  .mx-detail{position:fixed;inset:0;z-index:40;border-radius:0;overflow:auto;padding:12px 12px 24px}
  /* 重ねる小窓・知らせ */
  dialog.mx-pal{margin:8px auto auto}
  .mx-pbox,.mx-mbox{width:calc(100vw - 16px)}
  .mx-macts .mx-btn{flex:1}
  .mx-toasts{left:8px;right:8px;bottom:8px;justify-items:stretch}
  /* 知らせは下から入る（右から入ると、出る間・消える間に右の端の外へはみ出す） */
  .mx-toast{max-width:none;transform:translateY(12px)}
  /* 本人のメニューの板（dialog.mx-sheet）：画面の下に付く全幅の板。上の角だけ丸い。下からせり上がる（動きを減らす設定では motion.css が止める） */
  dialog.mx-dlg.mx-sheet{margin:auto 0 0;width:100%;max-width:100%}
  dialog.mx-sheet .mx-mbox{width:100%;max-height:85vh;overflow:auto;padding:20px 16px 16px;border-radius:var(--r) var(--r) 0 0;border-bottom:0;transform:translateY(100%);opacity:1;transition:transform var(--t) var(--ease)}
  dialog.mx-sheet.in .mx-mbox{transform:none}
  dialog.mx-sheet .mx-macts{justify-content:stretch}
  /* calendar：文を隠して件数だけ */
  .mx-cal-grid{border-spacing:2px}
  .mx-cal-grid td{height:auto;min-height:48px}
  .mx-cal-evs,.mx-cal-more{display:none}
  .mx-cal-dots{display:inline}
  .mx-cal-day{flex-direction:column;gap:0;padding:4px 0}
  .mx-attach-row{grid-template-columns:minmax(0,1fr) auto auto}
  .mx-attach-size{display:none}
  .mx-wizard-acts .mx-btn{flex:1}
  .mx-form-acts .mx-btn{flex:1}
  .mx-rail{flex-direction:row;overflow-x:auto}
  .mx-rail button{min-width:58px}
  .mx-rail-div{border-top:0;border-left:1px solid var(--line);margin:4px 2px;padding:8px 6px 0}
  .mx-nmatch-value{font-size:44px}
}

/* ---------- 枠と型（640px 以下）：1 列、detail_pane は全画面、よく使う操作は下の帯（第6巻 6 章、要件 I-11・I-13） ---------- */
@media (max-width:640px){
  .mx-body,.mx-dev-main,.mx-shell.has-detail .mx-body,.mx-shell.has-detail .mx-dev-main{grid-template-columns:minmax(0,1fr);padding:12px}
  .mx-dev{grid-template-columns:minmax(0,1fr)}
  .mx-grid,.mx-facts{grid-template-columns:minmax(0,1fr)}
  .mx-board{grid-auto-flow:row;grid-auto-columns:auto}
  .mx-page{padding-bottom:72px}
  .mx-page-acts .mx-phone-bottom{position:fixed;left:12px;right:12px;bottom:12px;z-index:30;min-height:48px}
  .mx-phone-hide{display:none!important}
  .mx-phone-only{display:block}
  .mx-row-acts .mx-btn,.mx-page-acts .mx-btn{min-height:44px}
}
