/* =====================================================================
   반응형: 화면(또는 아티팩트 창)이 작아지면 작업 표시줄·독·바탕화면 아이콘·위젯·연결 막대·큰 카드의
   크기와 간격이 함께 줄어든다. 셸 CSS 다음에 읽히므로 같은 선택자를 덮어쓴다.
   단계: 1100px 이하(좁은 창), 900px 이하(아티팩트 창 정도), 720px 이하(창은 최대화), 560px 이하(아주 좁음)
   ===================================================================== */

/* ----- 큰 카드·엔딩: 글자 크기를 화면 너비에 맞춘다 ----- */
.chapter-card-title { font-size: clamp(22px, 5vw, 40px); }
.chapter-card-goal { font-size: clamp(12px, 1.8vw, 15px); max-width: min(520px, 90vw); }
.ending-inner { max-width: min(640px, 92vw); }
.ending-title { font-size: clamp(24px, 5vw, 40px); }

/* ----- 원격 조사 연결 막대 ----- */
.remote-bar { max-width: calc(100vw - 24px); }
.rb-target { overflow: hidden; text-overflow: ellipsis; max-width: 48vw; }

/* ===== 1100px 이하 ===== */
@media (max-width: 1100px) {
  html[data-shell="windows"] .tb-pinned { gap: 2px; }
  html[data-shell="windows"] .tb-tasks { gap: 2px; }
  .todo-widget { width: 240px; }
}

/* ===== 900px 이하 (아티팩트 창 정도) ===== */
@media (max-width: 900px) {
  /* Windows 작업 표시줄: 단추 36px, 아이콘 22px */
  html[data-shell="windows"] .tb-start,
  html[data-shell="windows"] .tb-pin,
  html[data-shell="windows"] .tb-task { width: 36px; height: 36px; }
  html[data-shell="windows"] .tb-start svg { width: 18px; height: 18px; }
  html[data-shell="windows"] .tb-pin svg,
  html[data-shell="windows"] .tb-task svg,
  html[data-shell="windows"] .tb-task-icon,
  html[data-shell="windows"] .tb-task-icon svg { width: 22px; height: 22px; }
  html[data-shell="windows"] .tb-clock { padding: 0 8px; font-size: 11px; }
  /* 시계 자리를 비워 두고, 창이 많으면 실행 중인 창 단추만 옆으로 밀린다 */
  html[data-shell="windows"] .taskbar { padding: 0 84px 0 4px; }
  html[data-shell="windows"] .tb-pinned { flex: 0 0 auto; }
  html[data-shell="windows"] .tb-tasks { flex: 0 1 auto; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }

  /* mac 독: 아이콘 44px */
  html[data-shell="mac"] .tb-pin,
  html[data-shell="mac"] .tb-task { width: 50px; height: 54px; }
  html[data-shell="mac"] .tb-pin svg,
  html[data-shell="mac"] .tb-task svg,
  html[data-shell="mac"] .tb-task-icon,
  html[data-shell="mac"] .tb-task-icon svg { width: 42px; height: 42px; }

  /* 바탕화면 아이콘: 72px 칸, 그림 40px */
  .desktop-icons { gap: 2px 4px; }
  .desktop-icon { width: 72px; padding: 4px 2px 3px; }
  .desktop-icon-image { width: 40px; height: 40px; }
  .desktop-icon-label { font-size: 11px; max-width: 70px; }

  .todo-widget { width: 220px; }

  .rb-rec { display: none; }
  .remote-bar { font-size: 11.5px; gap: 8px; height: 28px; }

  /* 앱 안쪽: 옆 칸을 줄인다 */
  .cl-side { flex-basis: 180px; }
  .cl-detail { flex-basis: 300px; }
  .ml-side { flex-basis: 170px; }
  .ml-list { flex-basis: 240px; }
  .cb-side { flex-basis: 200px; }
  .ms-sidebar { flex-basis: 220px; }
}

/* ===== 720px 이하: 창은 최대화된다 (window-manager). 작업 표시줄은 더 촘촘히 ===== */
@media (max-width: 720px) {
  html[data-shell="windows"] .tb-start,
  html[data-shell="windows"] .tb-pin,
  html[data-shell="windows"] .tb-task { width: 34px; height: 34px; }
  html[data-shell="windows"] .tb-tray { flex: 0 0 auto; }
  html[data-shell="windows"] .tb-clock { padding: 0 6px; }
  html[data-shell="mac"] .todo-widget { bottom: calc(var(--taskbar-h) + 8px); }

  .desktop-icon { width: 64px; }
  .desktop-icon-image { width: 36px; height: 36px; }
  .desktop-icon-label { font-size: 10.5px; max-width: 62px; }

  .cl-detail { flex-basis: 260px; }
  .ml-side { flex-basis: 140px; }
  .ml-account-addr { display: none; }
  .cb-side { flex-basis: 170px; }
  .cb-main { padding: 14px 16px 24px; }
  .rm-table th:nth-child(3), .rm-table td:nth-child(3) { display: none; }
}

/* ===== 560px 이하: 날짜를 숨기고 아이콘만 ===== */
@media (max-width: 560px) {
  html[data-shell="windows"] .tb-date { display: none; }
  html[data-shell="windows"] .tb-start,
  html[data-shell="windows"] .tb-pin,
  html[data-shell="windows"] .tb-task { width: 32px; height: 32px; }
  html[data-shell="windows"] .tb-pin svg,
  html[data-shell="windows"] .tb-task svg,
  html[data-shell="windows"] .tb-task-icon,
  html[data-shell="windows"] .tb-task-icon svg { width: 20px; height: 20px; }
  html[data-shell="mac"] .taskbar { height: 50px; }
  html[data-shell="mac"] .tb-pin,
  html[data-shell="mac"] .tb-task { width: 38px; height: 44px; }
  html[data-shell="mac"] .tb-pin svg,
  html[data-shell="mac"] .tb-task svg,
  html[data-shell="mac"] .tb-task-icon,
  html[data-shell="mac"] .tb-task-icon svg { width: 30px; height: 30px; }
  html[data-shell="windows"] .taskbar { padding-right: 60px; }

  .todo-widget { display: none; }
  .rb-target { max-width: 40vw; }
}

/* ===== 480px 이하 (폰 너비): 단추를 더 줄여 시계와 겹치지 않게 ===== */
@media (max-width: 480px) {
  html[data-shell="windows"] .taskbar { justify-content: flex-start; padding: 0 56px 0 2px; }
  html[data-shell="windows"] .tb-start { margin: 4px 0; }
  html[data-shell="windows"] .tb-start,
  html[data-shell="windows"] .tb-pin,
  html[data-shell="windows"] .tb-task { width: 28px; height: 32px; }
  html[data-shell="windows"] .tb-pinned, html[data-shell="windows"] .tb-tasks { gap: 0; margin-left: 0; }
  html[data-shell="windows"] .tb-tray { padding: 0 2px; }
  html[data-shell="windows"] .tb-pin svg,
  html[data-shell="windows"] .tb-task svg { width: 18px; height: 18px; }
  .remote-bar { gap: 4px; padding: 0 6px; }
  .rb-label { display: none; }
  .rb-target { max-width: 34vw; }
  .rb-btn { padding: 0 6px; }
}

/* ===== 낮은 화면 (높이 600px 이하): 바탕화면 아이콘 세로 간격과 위젯 ===== */
@media (max-height: 600px) {
  .desktop-icons { gap: 0 4px; }
  .desktop-icon { padding: 2px 2px 2px; }
}

/* ===== 앱 안 배치: 창 너비를 기준으로 (컨테이너 쿼리) =====
   앱 CSS 와 위 미디어 쿼리를 덮어써야 하므로 이 파일 맨 끝에 둔다. 셸 CSS(html[data-shell="mac"] .x)도 이기도록 선택자 앞에 html[data-shell] 을 붙인다.
   좁아져도 메뉴·목록으로 가는 길은 없애지 않는다: 옆 칸을 지우지 않고 위로 올린다. */
@container win (max-width: 760px) {
  html[data-shell] .ml-toolbar .ml-tb:nth-child(3), html[data-shell] .ml-toolbar .ml-tb:nth-child(4) { display: none; }
  html[data-shell] .ml-subject { font-size: 15px; }
}
@container win (max-width: 680px) {
  html[data-shell] .ex-sidebar { display: none; }
  html[data-shell] .ex-col-date { display: none; }
  html[data-shell] .ex-search { flex-basis: 150px; }
  html[data-shell] .xl-ribbon-body, html[data-shell] .wd-ribbon-body { display: none; }
  html[data-shell] .rm-table th:nth-child(3), html[data-shell] .rm-table td:nth-child(3) { display: none; }

  /* 캘린더: 캘린더 고르기를 위 띠로, 일정 상세는 아래로 */
  html[data-shell] .cl-app { flex-direction: column; }
  html[data-shell] .cl-side { flex: 0 0 auto; max-height: 92px; border-right: none; border-bottom: 1px solid #e1e5ea; }
  html[data-shell] .cl-brand, html[data-shell] .cl-mini { display: none; }
  html[data-shell] .cl-cals, html[data-shell] .cl-group { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
  html[data-shell] .cl-main { flex: 1 1 0; min-height: 0; }
  html[data-shell] .cl-detail { flex: 0 0 45%; border-left: none; border-top: 1px solid #e1e5ea; }
  html[data-shell] .cl-head .cl-btn-history { display: none; }

  html[data-shell] .ml-side { flex-basis: 150px; }
  html[data-shell] .ml-account-addr { display: none; }
  html[data-shell] .ml-list { flex-basis: 230px; }
  html[data-shell] .ms-sidebar { flex-basis: 170px; }
  html[data-shell] .ms-thread-snippet { display: none; }

  /* ERP: 하위 메뉴를 위 탭으로 (예약 이력·조직도 등으로 가는 길) */
  html[data-shell] .erp-main { flex-direction: column; }
  html[data-shell] .erp-subnav { flex: 0 0 auto; display: flex; padding: 0; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--erp-line); scrollbar-width: none; }
  html[data-shell] .erp-subnav-title { display: none; }
  html[data-shell] .erp-subnav-item { flex: 0 0 auto; width: auto; padding: 8px 12px; border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; }
  html[data-shell] .erp-subnav-item.is-active { border-bottom-color: var(--erp-teal); }
  html[data-shell] .erp-subnav-count { margin-left: 6px; }
  html[data-shell] .erp-content { flex: 1 1 0; min-height: 0; }
  html[data-shell] .erp-fields { grid-template-columns: 100px 1fr; }
  html[data-shell] .erp-field-v.is-wide { grid-column: 2 / 3; }

  html[data-shell] .cb-side { flex-basis: 180px; }
  html[data-shell] .cb-main { padding: 14px 16px 24px; }
}
@container win (max-width: 620px) {
  html[data-shell] .pdf-page { width: calc(100% - 16px); min-height: 0; padding: 36px 24px 48px; }
  html[data-shell] .wd-ribbon-tabs { overflow-x: auto; scrollbar-width: none; }
  html[data-shell] .wd-ribbon-tab { flex: 0 0 auto; }
  html[data-shell] .ex-address { overflow-x: auto; scrollbar-width: none; }
}
@container win (max-width: 560px) {
  html[data-shell] .erp-user-name { display: none; }
  html[data-shell] .ph-main { flex-direction: column; }
  html[data-shell] .ph-list { flex: 0 0 auto; max-height: 40%; border-right: none; border-bottom: 1px solid #e1e5ea; }
  html[data-shell] .ph-detail { flex: 1 1 0; min-height: 0; }
}
@container win (max-width: 520px) {
  html[data-shell] .ex-col-type { display: none; }
  html[data-shell] .ex-search { flex-basis: 110px; }

  /* 메일: 폴더·검색을 위 띠로, 목록과 본문은 번갈아 (본문에 [목록] 단추) */
  html[data-shell] .ml-app { flex-direction: column; }
  html[data-shell] .ml-side { flex: 0 0 auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border-right: none; border-bottom: 1px solid #e1e5ea; }
  html[data-shell] .ml-account, html[data-shell] .ml-compose { display: none; }
  html[data-shell] .ml-search { flex: 1 1 100%; margin: 0; }
  html[data-shell] .ml-folders { flex-direction: row; padding: 0; overflow-x: auto; scrollbar-width: none; }
  html[data-shell] .ml-folder { flex: 0 0 auto; }
  html[data-shell] .ml-list { flex: 1 1 0; min-height: 0; border-right: none; }
  html[data-shell] .ml-read { display: none; flex: 1 1 0; min-height: 0; }
  html[data-shell] .ml-app.is-reading .ml-list { display: none; }
  html[data-shell] .ml-app.is-reading .ml-read { display: flex; }
  html[data-shell] .ml-back { display: inline-block; }

  /* 한빛톡: 대화방은 얼굴만 남긴 좁은 칸으로 */
  html[data-shell] .ms-sidebar { flex-basis: 56px; }
  html[data-shell] .ms-me { justify-content: center; padding: 10px 4px; }
  html[data-shell] .ms-thread { justify-content: center; margin: 2px; padding: 8px 0; }
  html[data-shell] .ms-thread-name, html[data-shell] .ms-thread-time, html[data-shell] .ms-me-body { display: none; }

  html[data-shell] .erp-menu-item { padding: 0 8px; font-size: 12px; }
  html[data-shell] .erp-user-dept, html[data-shell] .erp-user-logout { display: none; }

  /* 수첩: 사건 목록을 위로 */
  html[data-shell] .cb-app { flex-direction: column; }
  html[data-shell] .cb-side { flex: 0 0 auto; max-height: 42%; border-right: none; border-bottom: 1px solid #d9cfb4; }
  html[data-shell] .cb-me { padding: 8px 12px; }
  html[data-shell] .cb-me-plan, html[data-shell] .cb-me-next { display: none; }
  html[data-shell] .cb-main { flex: 1 1 0; min-height: 0; }
}
@container win (max-width: 400px) {
  html[data-shell] .ex-col-size { display: none; }
  html[data-shell] .cl-seg { display: none; }
  html[data-shell] .erp-logo-text, html[data-shell] .erp-user-name { display: none; }
}
