/* DN Robotics V7 mobile experience
   Desktop keeps the established identity; this layer turns narrow screens into a
   touch-first interface and gives operations pages a dedicated mobile workspace. */

:root {
  --mobile-gutter: clamp(16px, 4.5vw, 24px);
  --mobile-bar-height: 72px;
  --site-logo-height: 52px;
}

.admin-mobile-nav,
.mobile-ops-hero { display: none; }
/* 상단 언어 버튼이 숨겨지는 폭에서만 메뉴 안에 보인다(아래 390px 규칙). */
.nav-lang { display: none; }

/* 공개·회원·운영 화면에서 헤더 로고 크기를 하나로 유지한다. */
.wordmark { flex: 0 0 auto; }
.wordmark .logo {
  width: auto;
  height: var(--site-logo-height);
  aspect-ratio: 642 / 452;
}

.stat .num small {
  margin-left: 3px;
  font-size: .48em;
  font-weight: 500;
  color: var(--steel);
}

@media (max-width: 880px) {
  body { font-size: 16px; line-height: 1.65; overflow-x: hidden; }
  .wrap { width: 100%; padding-left: var(--mobile-gutter); padding-right: var(--mobile-gutter); }

  header .wrap {
    min-height: 66px;
    padding-top: 9px;
    padding-bottom: 9px;
    flex-wrap: nowrap;
  }
  .wordmark .logo { width: auto; height: var(--site-logo-height); }
  .header-actions { gap: 7px; }
  .header-actions .lang { min-width: 40px; padding: 6px 8px; text-align: center; }
  .theme-switch .sw { width: 42px; height: 24px; }
  .theme-switch .knob { width: 18px; height: 18px; }
  .theme-switch[aria-checked="true"] .knob { left: 19px; }

  header nav {
    width: min(88vw, 360px);
    padding: 76px 20px 28px;
    gap: 0;
  }
  header nav a {
    min-height: 52px;
    padding: 13px 8px;
    display: flex;
    align-items: center;
    font-size: 17px;
  }
  header nav a[aria-current] { color: var(--ink); background: var(--safety-soft); padding-left: 14px; }

  .app-main { min-height: calc(100vh - 180px); }
  .breadcrumb { padding-top: 18px; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .breadcrumb::-webkit-scrollbar { display: none; }
  .title-row { align-items: flex-start; padding-top: 22px; }
  .title-row .actions { width: 100%; }
  .title-row .actions .btn { flex: 1 1 auto; }
  .page-title { font-size: clamp(27px, 8vw, 36px); }
  .desc { font-size: 14px; line-height: 1.65; }

  .box { padding: 20px; border-radius: 14px; }
  .cols, .cols.even, .cols.side-left { gap: 14px; }
  .value-grid, .card-grid { gap: 14px; }
  .value-card, .menu-card, .item, .mini-item { border-radius: 14px; }

  input, select, textarea { min-height: 48px; font-size: 16px !important; }
  textarea { min-height: 140px; }
  input[type="checkbox"], input[type="radio"] { min-height: 0; }
  .btn { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; }
  .btn.small { min-height: 42px; }
  .bottom-actions { flex-wrap: wrap; }
  .bottom-actions > .btn, .bottom-actions > form { flex: 1 1 140px; }
  .bottom-actions > form .btn { width: 100%; }

  .filters {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
  }
  .filters input, .filters select, .filters input[type="search"] { flex: 1 1 100%; min-width: 0; width: 100% !important; }
  .filters .btn { flex: 1 1 120px; }
  .filters .count { width: 100%; margin-left: 0; text-align: right; }

  dialog.modal, dialog.modal.wide { max-width: calc(100vw - 20px); margin: auto; }
  .modal-box { max-height: calc(100dvh - 20px); padding: 22px 18px 18px; border-radius: 18px; }
  .modal-actions .btn { flex: 1 1 110px; }

  .article-nav { gap: 8px; }
  .article-nav a { padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
  footer { margin-top: 48px; }
  footer .wrap { gap: 14px; }
  footer .links { gap: 10px 16px; }

  /* Operations shell */
  body:has(.admin-page) { padding-bottom: calc(var(--mobile-bar-height) + env(safe-area-inset-bottom)); }
  body:has(.admin-page) footer { display: none; }
  .admin-page { padding-bottom: 36px; }
  .admin-page .page-head { margin-bottom: 4px; }

  .admin-mobile-nav {
    position: fixed;
    z-index: 22;
    left: 10px;
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    min-height: 62px;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    padding: 6px;
    border: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
    border-radius: 18px;
    background: color-mix(in srgb, var(--card) 94%, transparent);
    box-shadow: 0 10px 35px rgba(8, 16, 24, .2);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }
  .admin-mobile-nav a {
    min-width: 54px;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 3px;
    border-radius: 12px;
    color: var(--steel);
    text-decoration: none;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
  }
  .admin-mobile-nav a span { font-size: 19px; line-height: 1; }
  .admin-mobile-nav a[aria-current="page"] { background: var(--ink); color: var(--bg); }

  .mobile-ops-hero {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 16px;
    margin-top: 18px;
    padding: 22px;
    border-radius: 18px;
    background: var(--ink);
    color: var(--bg);
  }
  .mobile-ops-hero::after {
    content: "";
    position: absolute;
    width: 130px;
    height: 130px;
    right: -52px;
    top: -66px;
    border: 24px solid var(--safety);
    border-radius: 50%;
    opacity: .9;
  }
  .mobile-ops-hero > * { position: relative; z-index: 1; }
  .mobile-ops-hero .eyebrow { color: var(--safety); font-size: 11px; font-weight: 700; letter-spacing: .14em; }
  .mobile-ops-hero h2 { margin-top: 5px; font-size: 21px; line-height: 1.35; }
  .mobile-ops-hero p:not(.eyebrow) { margin-top: 6px; color: color-mix(in srgb, var(--bg) 72%, transparent); font-size: 12px; }
  .mobile-alert-shortcut {
    min-width: 76px;
    padding: 12px 9px;
    border: 1px solid color-mix(in srgb, var(--bg) 24%, transparent);
    border-radius: 14px;
    background: color-mix(in srgb, var(--bg) 10%, transparent);
    color: var(--bg);
    text-align: center;
    text-decoration: none;
  }
  .mobile-alert-shortcut strong { display: block; color: var(--safety); font-size: 25px; line-height: 1; }
  .mobile-alert-shortcut span { display: block; margin-top: 5px; font-size: 10px; white-space: nowrap; }

  .admin-dashboard .stat-row {
    display: flex;
    gap: 10px;
    margin-left: calc(var(--mobile-gutter) * -1);
    margin-right: calc(var(--mobile-gutter) * -1);
    padding: 2px var(--mobile-gutter) 8px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .admin-dashboard .stat-row::-webkit-scrollbar { display: none; }
  .admin-dashboard .stat {
    min-width: 132px;
    padding: 16px;
    border-radius: 14px;
    scroll-snap-align: start;
    box-shadow: none;
  }
  .admin-dashboard .stat.attention { border-color: var(--safety); background: var(--highlight); }
  .admin-dashboard .stat .num { font-size: 27px; }
  .admin-dashboard .sub-head { margin-top: 26px; }
  .admin-dashboard .sub-head h2 { font-size: 19px; }
  .admin-dashboard .menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .admin-dashboard .menu-card { min-height: 154px; padding: 16px; }
  .admin-dashboard .menu-card h3 { font-size: 15px; }
  .admin-dashboard .menu-card p { font-size: 12px; line-height: 1.5; }
  .admin-dashboard .menu-card .btn { width: 100%; margin-top: 6px; }
  .admin-dashboard .cols { margin-top: 0; }
  .admin-dashboard .mini-item { padding: 14px 15px; }

  /* Dashboard tables become readable cards, other admin tables remain swipeable. */
  .dashboard-table, .dashboard-table tbody, .dashboard-table tr, .dashboard-table td { display: block; width: 100%; }
  .dashboard-table { min-width: 0 !important; }
  .dashboard-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .dashboard-table tbody { display: grid; gap: 10px; }
  .dashboard-table tr { padding: 13px 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
  .dashboard-table td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 8px;
    padding: 5px 0 !important;
    border: 0 !important;
    white-space: normal;
  }
  .dashboard-table td::before { content: attr(data-label); color: var(--steel); font-size: 12px; font-weight: 500; }
  .dashboard-table td:first-child { padding-top: 0 !important; font-weight: 700; }
  .dashboard-table td:last-child { padding-bottom: 0 !important; }

  .admin-page .table-wrap:not(:has(.dashboard-table)) {
    margin-left: calc(var(--mobile-gutter) * -1);
    margin-right: calc(var(--mobile-gutter) * -1);
    padding: 0 var(--mobile-gutter) 8px;
    border-radius: 0;
    scroll-padding-left: var(--mobile-gutter);
  }
  .admin-page .table-wrap:not(:has(.dashboard-table)) table.data { min-width: 680px; }
  .admin-page .table-wrap:not(:has(.dashboard-table)) th:first-child,
  .admin-page .table-wrap:not(:has(.dashboard-table)) td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--card);
    box-shadow: 8px 0 14px -12px rgba(0, 0, 0, .45);
  }
  .admin-page .table-wrap:not(:has(.dashboard-table)) thead th:first-child { z-index: 2; background: var(--bg); }
  .admin-page .scroll-hint { margin-top: 7px; font-size: 11px; }

  .admin-page .perm-grid { grid-template-columns: 1fr; }
  .admin-page .dropzone { min-height: 150px; }
  .admin-page .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  :root { --mobile-gutter: 16px; }
  .nav-toggle { min-width: 42px; min-height: 42px; padding: 8px 10px; }
  .title-row .actions { display: grid; grid-template-columns: 1fr; }
  .box { padding: 18px 16px; }
  .auth-box { border-radius: 18px; }
  .home-hero .wrap { padding-top: 18px; padding-bottom: 52px; }
  .home-hero h1, .hero-text h1 { font-size: clamp(35px, 11vw, 52px); }
  .home-section .wrap, .home-cta .wrap { padding-top: 48px; padding-bottom: 52px; }
  .cta .btn { flex: 1 1 100%; }
  .article-nav { grid-template-columns: 1fr; }
  .article-nav .next { text-align: left; }
  .profile-card { text-align: left; }
  .profile-card .big-avatar { margin-left: 0; }
  .item { padding: 15px 16px; }
  .item .side { width: 100%; justify-content: space-between; }

  .mobile-ops-hero { grid-template-columns: 1fr; align-items: start; }
  /* 오른쪽 위의 원 장식이 제목 글자를 덮지 않게 자리를 비운다 */
  .mobile-ops-hero::after { width: 84px; height: 84px; border-width: 18px; right: -46px; top: -58px; }
  .mobile-ops-hero > div:first-child { padding-right: 60px; }
  .mobile-alert-shortcut { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 10px 13px; }
  .mobile-alert-shortcut strong, .mobile-alert-shortcut span { display: inline; margin: 0; }
  .admin-dashboard .menu-grid { grid-template-columns: 1fr 1fr; }
  .admin-dashboard .menu-card { min-height: 148px; }
}

@media (max-width: 390px) {
  .header-actions .lang { display: none; }
  #site-nav .nav-lang { display: flex; }
  .admin-mobile-nav { left: 6px; right: 6px; }
  .admin-mobile-nav a { min-width: 0; font-size: 9px; }
  .admin-dashboard .menu-grid { grid-template-columns: 1fr; }
  .admin-dashboard .menu-card { min-height: 0; }
  .admin-page .info-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .admin-dashboard .stat-row { scroll-behavior: auto; }
}

@media print {
  .admin-mobile-nav, .mobile-ops-hero { display: none !important; }
  body:has(.admin-page) { padding-bottom: 0; }
}
