@charset "UTF-8";
/* ==========================================================================
   기억이음(Memory-Link) 2026 — 통합 반응형 & 클라우드 PWA 마스터 안전망 (responsive-master.css)
   대상 해상도: 스마트폰(360~430px) · 태블릿(768~1024px) · 노트북(1280~1440px) · 대형 모니터(1920px+)
   목표: 전 구간 가로 잘림(0px overflow) 원천 차단, iOS 자동 확대 방지, 동적 뷰포트 및 듀얼 X-Ray 최적화
   ========================================================================== */

/* 1. 전역 가로 오버플로우 원천 차단 & 한글 줄바꿈 폴리시 */
html,
body {
  overflow-x: clip;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

/* 그리드 및 플렉스 자식 요소의 최소 폭 잠금 해제 (중첩 카드 내부 가로 삐져나감 방지) */
.um-card,
.ml-card,
.ml-card-elevated,
#user-service-left-pane,
#main-view-container {
  min-width: 0;
  max-width: 100%;
}

/* 네이티브 셀렉트 및 접속자 스위처 가로 삐져나감 원천 차단 */
#user-actor-switcher,
#global-actor-select,
#current-active-actor-label {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  #global-actor-select {
    max-width: calc(100vw - 150px);
  }
}

/* 사용자 헤더 우측 액션 버튼 바 가로 스와이프 스크롤 폴리시 */
.user-header-right {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.user-header-right::-webkit-scrollbar {
  display: none;
}

/* 2. 모바일(<=768px) iOS Safari 입력창 터치 시 자동 화면 확대(Auto-zoom) 원천 차단 */
@media (max-width: 768px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea {
    font-size: max(16px, 1em) !important;
  }
}

/* 3. 모바일(<=768px) 아버지와의 대화(#user-chat-section .chat-container) 동적 뷰포트 높이 보정 및 상단 컴팩트화 */
@media (max-width: 768px) {
  #user-chat-section .chat-container {
    height: calc(100vh - 210px) !important;
    height: calc(100dvh - 210px) !important;
    min-height: 460px !important;
    max-height: calc(100dvh - 130px) !important;
  }

  /* 채팅 상단 프로필·보이스 설정 바 패딩 축소 및 버튼 1줄 가로 스와이프화 */
  #user-chat-section .chat-container > div:first-child {
    padding: 10px 12px !important;
    gap: 8px !important;
  }

  #user-chat-section .chat-container > div:first-child > div.ml-auto {
    width: 100%;
    margin-left: 0 !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  #user-chat-section .chat-container > div:first-child > div.ml-auto::-webkit-scrollbar {
    display: none;
  }

  #user-chat-section .chat-container > div:first-child > div.ml-auto > * {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  /* 캐릭터 학습도(Lv.1~Lv.4) 바 모바일 슬림화 */
  #user-chat-section .chat-container > div:nth-child(2) {
    padding: 8px 12px !important;
  }

  #user-chat-section .chat-container > div:nth-child(2) > div:first-child > div:last-child {
    width: 100%;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  #user-chat-section .chat-container > div:nth-child(2) > div:first-child > div:last-child::-webkit-scrollbar {
    display: none;
  }

  #user-chat-section .chat-container > div:nth-child(2) > div:first-child > div:last-child > button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  #chat-learning-tier-banner {
    display: none !important;
  }

  /* 대화 메시지 본문 스크롤 영역 최소 높이 항상 넉넉히 확보 */
  #chat-messages-container {
    min-height: 220px !important;
    padding: 12px 14px !important;
  }

  #chat-welcome-guide {
    padding: 10px 4px !important;
  }

  #user-chat-section .chat-input-bar {
    padding: 8px 10px !important;
    gap: 6px !important;
  }
}

/* 4. 실시간 듀얼 X-Ray 드로어(#live-xray-drawer) 모바일·태블릿(<1280px) 슬라이드업 바텀시트 스타일 */
#live-xray-drawer.xray-mobile-sheet {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  top: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  z-index: 9650 !important;
  max-height: 80dvh !important;
  border-radius: 24px 24px 0 0 !important;
  border-left: none !important;
  border-top: 2px solid #D4AF37 !important;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px)) !important;
  overflow-y: auto !important;
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.55) !important;
}

@media (max-width: 1279px) {
  #live-xray-drawer:not(.hidden) {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    z-index: 9650 !important;
    max-height: 80dvh !important;
    border-radius: 24px 24px 0 0 !important;
    border-left: none !important;
    border-top: 2px solid #D4AF37 !important;
    padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px)) !important;
    overflow-y: auto !important;
    box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.55) !important;
    display: flex !important;
    flex-direction: column;
    gap: 12px;
  }

  /* 태블릿·모바일에서는 좌측 서비스 본문이 찌그러지지 않도록 항상 100% 폭 보장 */
  #user-mode main.user-content {
    display: block !important;
  }

  #user-service-left-pane {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* 5. 관리자·특허 콘솔(#admin-mode) 모바일·태블릿(<1024px) 사이드바 가로 스크롤 탭 스트립 최적화 */
@media (max-width: 1023px) {
  #admin-mode > div.grid {
    padding: 14px 12px 28px !important;
    gap: 14px !important;
  }

  #admin-mode aside:not(#right-inspector-panel) {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
  }

  /* 7개 모듈 네비게이션 카드를 컴팩트 가로 스와이프 탭 바로 변환 */
  #admin-mode aside:not(#right-inspector-panel) > .ml-card:first-child {
    padding: 10px 12px !important;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    align-items: center;
  }

  #admin-mode aside:not(#right-inspector-panel) > .ml-card:first-child::-webkit-scrollbar {
    display: none;
  }

  #admin-mode aside:not(#right-inspector-panel) > .ml-card:first-child > *:not(.ml-nav-item) {
    display: none !important;
  }

  #admin-mode aside:not(#right-inspector-panel) > .ml-card:first-child > .ml-nav-item {
    flex: 0 0 auto;
    width: auto !important;
    margin-top: 0 !important;
    padding: 8px 12px !important;
    gap: 8px !important;
    border-radius: 12px !important;
    white-space: nowrap;
    transform: none !important;
  }

  #admin-mode aside:not(#right-inspector-panel) > .ml-card:first-child > .ml-nav-item > div:first-child {
    width: 28px !important;
    height: 28px !important;
    border-radius: 8px !important;
  }

  #admin-mode aside:not(#right-inspector-panel) > .ml-card:first-child > .ml-nav-item > div:last-child > div:last-child {
    display: none;
  }

  /* 세 문 규칙 방화벽 카드(#sidebar-three-door-card) 슬림 정돈 */
  #sidebar-three-door-card {
    padding: 10px 12px !important;
  }

  #sidebar-three-door-card > * + * {
    margin-top: 8px !important;
  }

  #sidebar-three-door-card > div.space-y-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
    gap: 6px;
  }

  #sidebar-three-door-card > div.space-y-2 > div {
    margin-top: 0 !important;
    padding: 6px 8px !important;
  }

  #sidebar-three-door-card #three-door-reason-text {
    padding: 8px 10px !important;
    font-size: 11.5px !important;
  }

  #sidebar-three-door-card #global-view-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  #sidebar-three-door-card #global-view-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* 6. 듀얼 X-Ray 활성(body.xray-split-open) 시 노트북(1280px~1535px) 좌측 창 과밀 그리드 자동 완화 */
@media (min-width: 1280px) and (max-width: 1535px) {
  body.xray-split-open #user-service-left-pane .lg\:grid-cols-7,
  body:has(#live-xray-drawer:not(.hidden)) #user-service-left-pane .lg\:grid-cols-7 {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }

  body.xray-split-open #user-service-left-pane .lg\:grid-cols-6,
  body:has(#live-xray-drawer:not(.hidden)) #user-service-left-pane .lg\:grid-cols-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}
