/* page-mobile: 폰 폭(640px 이하) 공통 틀 — 아래 메뉴(탭바)·조회 첫 화면·내 정보·시트·전체 화면 입력·모션.
   컴퓨터 화면(641px 이상)에는 영향이 없다: 모든 규칙이 @media (max-width: 640px) 안에 있다(탭바는 기본 숨김).
   색은 --ps-* 토큰만 쓴다. 시안: 모바일 시안 12장(달력·메모·조회·내 정보). 터치 영역 48px 이상. */

.tabbar { display: none; }
.m-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 640px) {
  /* ---- 틀: 왼쪽·위쪽 메뉴는 숨기고 아래 메뉴만. 본문은 아래 메뉴(64px + 안전 영역)에 가리지 않게 비운다 ---- */
  .nav { display: none; }
  .main { padding: 14px 16px calc(88px + env(safe-area-inset-bottom)); }
  body[data-page="calendar"] .main, body[data-page="memo"] .main, body[data-page="view"] .main, body[data-page="me"] .main { padding: 0 0 calc(80px + env(safe-area-inset-bottom)); }
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }

  /* ---- 아래 메뉴: 5칸, 높이 64px, 위 2px 선, 켜진 칸은 위 3px 주황 선 + 글자 밝게 ---- */
  body.m-ready .tabbar { display: grid; position: fixed; left: 0; right: 0; bottom: 0; z-index: 100; grid-template-columns: repeat(5, minmax(0, 1fr)); height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--ps-bg); border-top: 2px solid var(--ps-rule); font-family: "Pretendard Variable", Pretendard, "Malgun Gothic", system-ui, sans-serif; }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 48px; margin-top: -2px; border-top: 3px solid transparent; color: var(--ps-muted); font-size: 13px; line-height: 1.2; text-decoration: none; -webkit-tap-highlight-color: transparent; transition: transform 144ms, opacity 144ms; }
  .tabbar a.on { color: var(--ps-text); border-top-color: var(--ps-ac); }
  .tabbar a:active { transform: scale(.96); opacity: .7; }
  .tabbar a:focus-visible { outline: 2px solid var(--ps-text); outline-offset: -4px; }
  .tabbar svg { stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

  /* ---- 화면 전환: 페이드 + 미세 이동(opacity·transform 만, 180ms) ---- */
  .page.on { animation: m-fade 324ms ease-out; }
  .m-root { animation: m-rise 324ms ease-out; }
  @keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }
  @keyframes m-rise { from { transform: translateY(6px); } to { transform: none; } }

  /* ---- 공통 부품 ---- */
  .m-ic { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
  .m-root { color: var(--ps-text); font-variant-numeric: tabular-nums; }
  .m-root :focus-visible, .m-layer :focus-visible { outline: 2px solid var(--ps-text); outline-offset: 2px; }
  .m-top { padding: 16px 16px 10px; }
  .m-top h1 { margin: 0; font-size: 24px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.25; }
  .m-sub { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--ps-muted); }
  .m-dot { width: 8px; height: 8px; background: var(--ps-ac); display: inline-block; flex: none; }
  .m-body { padding: 0 16px; }
  .m-sec { border-top: 2px solid var(--ps-rule); padding-top: 10px; margin-top: 14px; }
  .m-sec h2 { margin: 0 0 6px; font-size: 15px; font-weight: 500; display: flex; justify-content: space-between; align-items: baseline; }
  .m-sec h2 span { font-size: 12px; color: var(--ps-muted); font-weight: 400; }
  .m-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--ps-hair); background: transparent; color: var(--ps-text); text-align: left; text-decoration: none; font: inherit; -webkit-tap-highlight-color: transparent; transition: transform 144ms, opacity 144ms; }
  .m-row[hidden] { display: none; }
  a.m-row:active, button.m-row:active { opacity: .7; transform: scale(.99); }
  .m-row .grow { flex: 1; min-width: 0; }
  .m-row .t { display: block; font-size: 15px; }
  .m-row .s { display: block; font-size: 12px; color: var(--ps-muted); }
  button.m-row > .s { flex: none; }
  .m-row .t.big { font-size: 18px; }
  .m-chev { color: var(--ps-muted); display: inline-flex; }
  .m-acc { color: var(--ps-ac-ink); flex: none; font-size: 14px; }
  .m-warnrow { margin-top: 4px; padding: 0 10px; background: color-mix(in srgb, var(--ps-brand) 13%, transparent); outline: 2px solid var(--ps-brand); outline-offset: -2px; border-bottom-color: transparent; }
  .m-who { border-top: 2px solid var(--ps-rule); min-height: 72px; margin-top: 4px; }
  .m-foot { padding-top: 20px; }
  .m-btn, .m-btn2 { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 16px; border-radius: 2px; font: inherit; -webkit-tap-highlight-color: transparent; transition: transform 144ms, opacity 144ms; }
  .m-btn { background: var(--ps-brand); color: var(--ps-btn-ink); border: 0; font-size: 16px; font-weight: 500; }
  .m-btn2 { background: transparent; color: var(--ps-text); border: 1px solid var(--ps-rule); font-size: 15px; }
  .m-btn:active, .m-btn2:active { transform: scale(.98); opacity: .75; }
  .m-btn.m-danger { background: var(--ps-bad); color: var(--ps-bg); }
  .m-btn2.m-danger { color: var(--ps-bad); border-color: var(--ps-bad); }
  .m-btn[disabled], .m-btn2[disabled] { opacity: .5; }
  .m-in { display: block; width: 100%; min-height: 48px; padding: 0 12px; background: var(--ps-panel); color: var(--ps-text); border: 1px solid var(--ps-rule); border-radius: 2px; font: inherit; font-size: 16px; }
  textarea.m-in { padding: 10px 12px; min-height: 88px; line-height: 1.5; resize: none; }
  .m-in:focus { outline: 2px solid var(--ps-text); outline-offset: 0; border-color: var(--ps-text); }
  .m-lbl { display: block; margin: 14px 0 6px; font-size: 12px; color: var(--ps-muted); }

  /* ---- 시트(아래에서 위로 올라옴) · 전체 화면 입력(아래에서 위로 덮음) ---- */
  .m-layer { position: fixed; inset: 0; z-index: 500; font-family: "Pretendard Variable", Pretendard, "Malgun Gothic", system-ui, sans-serif; color: var(--ps-text); font-size: 15px; line-height: 1.5; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
  .m-layer * { box-sizing: border-box; }
  .m-back { position: absolute; inset: 0; background: color-mix(in srgb, #000 50%, transparent); animation: m-back-in 360ms ease-out; }
  .m-layer .m-panel { outline: none; }
  .m-sheet-l .m-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 86dvh; overflow-y: auto; background: var(--ps-panel); border-top: 2px solid var(--ps-box); padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: m-up 360ms cubic-bezier(.16, 1, .3, 1); }
  .m-full-l .m-panel { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--ps-bg); overflow: hidden; animation: m-up 360ms cubic-bezier(.16, 1, .3, 1); }
  .m-full-l.m-vv { inset: auto; left: 0; right: 0; top: var(--m-vvt, 0); height: var(--m-vvh, 100%); }      /* 키보드가 화면을 줄이지 않는 브라우저에서 보이는 영역에 맞춤(mobile.js fitToVisual) */
  .m-layer.out .m-panel { animation: m-down 270ms ease-in forwards; }
  .m-layer.out .m-back { animation: m-back-out 270ms ease-in forwards; }
  @keyframes m-up { from { transform: translateY(100%); } to { transform: none; } }
  @keyframes m-down { from { transform: none; } to { transform: translateY(100%); } }
  @keyframes m-back-in { from { opacity: 0; } to { opacity: 1; } }
  @keyframes m-back-out { from { opacity: 1; } to { opacity: 0; } }
  .m-sheet-t { margin: 0 0 8px; font-size: 17px; font-weight: 500; }
  .m-sheet-p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--ps-text2); word-break: keep-all; }
  .m-sheet-act { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
  .m-opts { display: flex; flex-direction: column; }
  .m-opt { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--ps-hair); background: transparent; color: var(--ps-text); font: inherit; text-align: left; transition: opacity 144ms; }
  .m-opt:active { opacity: .7; }
  .m-opt[aria-checked="true"] { font-weight: 500; }
  .m-opt-s { flex: 1; font-size: 12px; color: var(--ps-muted); font-weight: 400; }
  .m-fab { position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 90; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 2px; background: var(--ps-brand); color: var(--ps-btn-ink); transition: transform 144ms, opacity 144ms; -webkit-tap-highlight-color: transparent; }
  .m-fab:active { transform: scale(.94); opacity: .8; }

  /* 비밀번호 바꾸기 같은 기존 대화창(<dialog>)도 폰에서는 아래에서 올라오는 모양으로 */
  .au-host dialog.ui-dialog { position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; max-height: 90dvh; border: 0; border-top: 2px solid var(--ps-box); padding: 0; background: var(--ps-panel); color: var(--ps-text); animation: m-up 360ms cubic-bezier(.16, 1, .3, 1); }
  .au-host dialog.ui-dialog::backdrop { background: color-mix(in srgb, #000 50%, transparent); }
  .au-host .ui-dialog-head { padding: 14px 16px 6px; }
  .au-host .ui-dialog-body { padding: 4px 16px calc(16px + env(safe-area-inset-bottom)); }
  .au-host .ui-input, .au-host .ui-btn { min-height: 48px; font-size: 16px; }

  /* ---- 조회 첫 화면·내 정보 군더더기 정리(모바일J, 2026-10-06): 제목 줄 오른쪽에 점+날짜 하나 · 줄은 이름 + 오른쪽 값 한 줄 ---- */
  .m-top.mj-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 56px; padding: 8px 16px 4px; }
  .mj-top .m-sub { margin: 0; flex: none; font-size: 13px; font-variant-numeric: tabular-nums; }
  .mj-top .m-sub[hidden] { display: none; }
  .m-sec.mj-sec { padding-top: 0; margin-top: 12px; }
  .m-row.mj-mrow { min-height: 52px; padding: 4px 0; }
  .m-row.mj-mrow .t { font-size: 16px; }
  .mj-v { flex: none; max-width: 64%; font-size: 15px; line-height: 1.3; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ps-text2); }
  .mj-v.mj-acc { color: var(--ps-ac-ink); }
  .mj-v.mj-warn { color: var(--ps-warn-ink); font-weight: 500; }      /* 발주 N: 주황 글자(기호 없이 글자와 색) */
  .m-warnrow .t[data-k="wt"] { color: var(--ps-warn-ink); font-weight: 500; }      /* 오늘 안 받은 자료 N개: 주황 글자 + 주황 테두리 띠 */
  .mj-v.mj-bad { color: var(--ps-bad); font-weight: 500; }
  .mj-v.mj-mut { color: var(--ps-muted); }
  .mj-optl { flex: 1; min-width: 0; }

  /* 달력의 되돌리기 알림 등은 아래 메뉴 위에 뜬다 */
  .toast { left: 12px; right: 12px; transform: none; bottom: calc(76px + env(safe-area-inset-bottom)); justify-content: space-between; min-height: 52px; font-size: 14px; }
  .toast .cal-btn { min-height: 44px; padding: 0 14px; white-space: nowrap; flex: none; }
  .toast .kbd { display: none; }
}

/* 움직임 줄이기 설정이면 모두 멈춘다 */
@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
  .page.on, .m-root, .m-back, .m-layer .m-panel, .m-layer.out .m-panel, .m-layer.out .m-back, .au-host dialog.ui-dialog { animation: none !important; }
  .tabbar a, .m-row, .m-btn, .m-btn2, .m-fab, .m-opt { transition: none !important; }
  .tabbar a:active, a.m-row:active, button.m-row:active, .m-btn:active, .m-btn2:active, .m-fab:active { transform: none; }
}
