/* ============================================================
   모바일(폭 760px 이하) — 사장 지시 2026-11-02 "모바일에선 볼 수가 없네".
   좁은 화면에서도 왼쪽 메뉴가 156px 고정 칸을 차지해 본문이 200px 남짓으로 눌리던 것을
   ☰ 버튼으로 여는 서랍 메뉴로 바꾸고, 본문은 화면 폭을 다 쓴다.
   데스크톱(761px 이상)은 이 파일의 어떤 규칙도 타지 않는다.
   ============================================================ */
.nav-toggle,
.nav-backdrop,
.msg-back {
  display: none;
}

@media (max-width: 760px) {
  /* --- 뼈대: 한 칸, 메뉴는 서랍 --- */
  .app {
    grid-template-columns: minmax(0, 1fr);
  }
  .app > .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 84vw);
    height: 100vh;
    height: 100dvh;
    z-index: 40;
    padding: 20px 12px 14px;
    background: var(--surface);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    visibility: hidden;
  }
  .app.nav-open > .sidebar {
    transform: none;
    visibility: visible;
    box-shadow: 0 0 48px rgba(0, 0, 0, 0.45);
  }
  .app.nav-open > .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 39;
    border: 0;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.5);
  }
  /* 620px 규칙이 좁은 칸에 맞춰 줄여 둔 메뉴 글씨·로고·프로필을 서랍 폭에 맞게 되돌린다. */
  .brand {
    display: flex;
    gap: 6px;
    padding: 0 10px 8px;
  }
  .sidebar-caption,
  .nav-group-trigger {
    padding-left: 10px;
    padding-right: 10px;
  }
  .nav-tab {
    min-height: 44px;
    font-size: 14px;
  }
  .mini-profile {
    display: grid;
  }

  /* --- 상단바: ☰ · 제목 · 테마 · 알림 한 줄 --- */
  .topbar {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-height: 58px;
    padding: 9px 12px;
  }
  .nav-toggle {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
  }
  .header-title {
    flex: 1;
    min-width: 0;
  }
  .header-title .crumb,
  .title-sub {
    display: none;
  }
  .title {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-actions {
    flex-shrink: 0;
    gap: 6px;
  }
  .admin-session {
    display: none;
  }
  .notification-button,
  .theme-toggle {
    width: 40px;
    height: 40px;
  }
  /* 알림 목록 — 화면 폭에 맞추고, 뒤 카드 글씨가 비쳐 겹쳐 보이지 않게 불투명하게. */
  .notification-dropdown {
    position: fixed;
    top: 62px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
    background: var(--surface);
  }
  .account-dropdown {
    width: auto;
  }

  /* --- 본문 --- */
  .content {
    padding: 14px 12px 56px;
  }

  /* 대시보드 7칸 — 데스크톱처럼 한 줄은 유지하되 좁으면 옆으로 밀어 본다. */
  .dashboard-cards {
    display: grid;
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(104px, 1fr);
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .dashboard-cards::-webkit-scrollbar {
    display: none;
  }
  .dashboard-cards .metric-card {
    padding: 10px 10px;
    scroll-snap-align: start;
  }
  .dashboard-cards .metric-card .label {
    font-size: 11.5px;
  }
  .dashboard-cards .metric-card .value {
    font-size: 17px;
  }

  /* 조회 줄 — 입력칸·선택칸은 한 줄씩 꽉 차게. */
  .toolbar,
  .inline-form {
    padding: 10px;
    gap: 8px;
  }
  .toolbar > input:not([type="checkbox"]):not([type="radio"]),
  .toolbar > select,
  .inline-form > input:not([type="checkbox"]):not([type="radio"]),
  .inline-form > select {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }
  /* 퀀타 로그 '관리자·테스트 계정 포함' — 입력칸 규칙(폭 100%·높이 46px)을 받아 큰 네모가 되던 것. */
  .inline-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 0;
    flex: none;
  }

  /* 표 — 감싸개 없이 바로 놓인 표는 패널 밖으로 삐져나가던 것을 옆으로 밀어 보게 한다.
     감싸개(.table-wrap) 안 표는 머리글이 글자 단위로 세로로 꺾이지 않게 한 줄로 둔다. */
  :not(.table-wrap) > table.data-table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }
  .table-wrap th {
    white-space: nowrap;
  }
  /* 공모전 위쪽 칸 — 그리드 칸이 안의 넓은 표 폭만큼 늘어나 화면 밖으로 밀리던 것. */
  .contest-top-grid > * {
    min-width: 0;
  }
  /* 입력 묶음(라벨+칸) — 날짜·파일·긴 선택지 칸이 제 기본 폭을 고집해 패널 밖으로 나가던 것. */
  .form-field {
    min-width: 0;
  }
  .form-field > input:not([type="checkbox"]):not([type="radio"]),
  .form-field > select,
  .form-field > textarea {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .inline-form > .form-field {
    flex: 1 1 100%;
  }
  .contest-mini-fields {
    grid-template-columns: minmax(0, 1fr);
  }
  .file-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }
  .file-row input[type="file"] {
    max-width: 100%;
  }

  /* 작가 메시지 — 목록과 대화를 한 화면씩. 작품을 고르면 대화, ← 로 목록. */
  /* 높이 = 화면 − (상단바 + 위쪽 조회 줄 + 여백). 대화 입력칸이 첫 화면 안에 들어오게. */
  .msg-layout {
    grid-template-columns: minmax(0, 1fr);
    height: calc(100dvh - 226px);
    min-height: 380px;
  }
  .msg-layout:has(.msg-thread-head) > .msg-list,
  .msg-layout:not(:has(.msg-thread-head)) > .msg-thread {
    display: none;
  }
  .msg-back {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    margin: -6px 0 -6px -6px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    align-self: center;
  }
  .msg-thread-head {
    align-items: center;
  }
  .msg-line {
    max-width: 86%;
  }

  /* 운영 지표 · 유입·도달 — 큰 숫자가 칸 밖으로 넘치던 3칸을 2칸으로, 단계 줄은 이름·숫자 / 막대 / 전환율. */
  .ins-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ins-kpi {
    padding: 12px;
  }
  .ins-kpi > b {
    font-size: 22px;
  }
  .ins-step {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
  }
  .ins-step-bar,
  .ins-step-conv,
  .ins-step-act {
    grid-column: 1 / -1;
    text-align: left;
  }
  .ins-step-bar {
    order: 3;
  }
  .ins-step-conv {
    order: 4;
  }
  .ins-step-act {
    order: 5;
  }
  .ins-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* 상세 슬라이드 창은 화면 전체로. 화면을 다 덮으니 뒤 목록이 비치지 않게 불투명하게. */
  .detail-modal .panel {
    width: 100vw;
    background: var(--surface);
  }
}
