/* Phone layout fixes (loaded last). Found by the 360/390/412px audit in tests/mobile-layout.cjs. */
/* A long site name in a site picker must not widen the page (found with long fake names, 2026-11-27). */
select { max-width: 100%; }
label:has(> select) { max-width: 100%; min-width: 0; }
.flex.between > .flex { max-width: 100%; min-width: 0; }
@media (max-width: 640px) {
  /* 16px text stops iPhone from zooming in when a field is tapped; 44px is the minimum comfortable tap height. */
  input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]), select, textarea {
    font-size: 16px; min-height: 44px;
  }
  /* .dialog fields inherit 13px from the dialog; match that specificity. */
  .dialog input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]), .dialog select, .dialog textarea { font-size: 16px; }
  input[type=color] { min-height: 44px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  label:has(> input[type=checkbox]), label:has(> input[type=radio]) {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  }
  /* Free-text boxes in toolbar rows were squeezed to 60-80px; give them the full row. */
  .flex > input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]) {
    flex: 1 1 100%; min-width: 0;
  }
  /* Home list links and dialog close buttons were 26-37px tall. */
  .site-detail-link, .quote-amount-link, .detail-record { min-height: 44px; }
  .dialog .between > button, .dialog button[aria-label="닫기"] { min-width: 44px; min-height: 44px; }
  .actions button, .dialog .actions button { min-height: 44px; }
  /* Calendar task bars (26px) and site rows (29px) were hard to hit with a finger. */
  #calendarBody .bar { min-height: 36px; font-size: 12px; }
  #calendarBody .siteheader { min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 8px; overflow-wrap: anywhere; }
  #calendarBody .siteheader > span { flex: none; white-space: nowrap; }
  .quote-amount-link { min-width: 44px; }
  body > header { flex-wrap: wrap; gap: 4px 12px; padding: 14px 16px; }
  body > header #authModeLabel { flex-basis: 100%; }
  /* Consultation demo links (header + demo banner) were 19px tall. */
  .demo-open-link, #demoExit { display: inline-flex; align-items: center; min-height: 44px; }
  #demoBanner button { min-height: 44px; }
  /* Estimate table: one card per line on phones instead of an 8-column sideways table. */
  #estimate .tablewrap table, #estimate .tablewrap tbody, #estimate .tablewrap tr, #estimate .tablewrap td { display: block; width: 100%; }
  #estimate .tablewrap thead { display: none; }
  #estimate .tablewrap tr { border: 1px solid #e5e7eb; border-radius: 10px; padding: 8px; margin: 0 0 10px; background: #fff; }
  #estimate .tablewrap tr[hidden] { display: none; }
  #estimate .tablewrap td { border: 0; padding: 4px 0; display: grid; grid-template-columns: 56px minmax(0,1fr); align-items: center; gap: 8px; }
  #estimate .tablewrap td::before { content: attr(data-label); font-size: 13px; color: #52657c; }
  #estimate .tablewrap td input, #estimate .tablewrap td select { width: 100% !important; min-width: 0; }
  #estimate .tablewrap td.money { font-weight: 700; }
  #estimate .tablewrap td.estimate-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
  #estimate .tablewrap td.estimate-actions::before { content: none; }
  #estimate .tablewrap td.estimate-actions button { min-height: 44px; min-width: 44px; }
  #estimate .tablewrap td[colspan] { display: block; }
  #estimate .tablewrap td[colspan]::before { content: none; }
}
/* 2026-11-30 사장님 휴대폰 의견: 메뉴가 줄을 넘고 위치가 제각각 → 휴대폰은 아래쪽 고정 탭 4개, 현장 업무 메뉴는 한 줄(옆으로 밀기). */
@media (max-width: 720px) {
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  main.shell > nav.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: #fff; border-top: 1px solid #e2e8f0; box-shadow: 0 -4px 14px rgba(15,23,42,.08); }
  main.shell > nav.nav button { margin: 0; min-height: 52px; padding: 4px 2px; font-size: 12px; line-height: 1.25; white-space: normal; border-radius: 10px; }
  #workNavigation .site-work-links { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 6px; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  #workNavigation .site-work-links::-webkit-scrollbar { display: none; }
  #workNavigation .site-work-links button { flex: none; min-height: 44px; white-space: nowrap; }
  #workNavigation > .hint { display: none; }
  #workNavigation { position: sticky; top: 0; z-index: 20; }
  .today-chip:disabled { display: none; }
}
/* 손가락으로 끌어 옮기는 중 */
.touch-dragging { opacity: .55; outline: 2px dashed #2563eb; }
.touch-drop-target { outline: 2px solid #2563eb !important; background: #dbeafe !important; }
[draggable=true] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
/* 휴대폰 공정표: 시작 칸이 병합 선택·◀▶ 때문에 270px까지 넓어져 옆 날짜가 안 보였다. 휴대폰에서는 막대만(꾹 눌러 끌기, 눌러서 날짜 수정). */
@media (max-width: 720px) {
  .site-schedule-preview td label.schedule-merge-control.schedule-merge-control, .site-schedule-preview td span[role="button"][aria-label$="일 조정"] { display: none !important; }
  .site-schedule-preview .schedule-done-toggle { min-width: 30px; }
}
