/* ════════════════════════════════════════════════════════════
   제이씨드 v2 · 반응형 + 모바일웹앱 + 다크모드 + 밀도
   ════════════════════════════════════════════════════════════ */

/* iOS PWA safe-area 적용 */
@supports (padding: max(0px)) {
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* 아이패드 (721~1100) */
@media (max-width: 1100px) and (min-width: 721px) {
  .topbar-inner { gap: 14px; padding: 12px 20px; }
  .nav-link { padding: 7px 11px; font-size: 14px; }
  .search-box { display: none; }
  .btn { padding: 9px 16px; font-size: 13.5px; }
  .hero-title { font-size: clamp(28px, 4.6vw, 40px); }
  .banner h3 { font-size: 30px; }
  .page { padding: 24px 20px 64px; }
  .video-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .counter-v { font-size: 26px; }
  .hero-side { flex-direction: row; overflow-x: auto; }
  .hero-side > * { min-width: 240px; flex: 1; }
  .pf-hero { padding: 28px 30px; }
  .pf-total { font-size: 32px; }
}

/* 모바일 (≤720) — 토스 모바일웹앱 톤 */
@media (max-width: 720px) {
  html { font-size: 15px; }
  body { font-size: 14.5px; }

  .topbar { padding-top: env(safe-area-inset-top); }
  .topbar-inner { padding: 12px 16px; gap: 10px; }
  .nav-links { display: none; } /* 모바일은 하단탭으로 */
  .btn { padding: 9px 15px; font-size: 13.5px; }
  .search-box { display: none; }
  .logo span { display: inline; font-size: 16px; }

  .page { padding: 20px 16px 96px; }

  /* 히어로 — 모바일 풀폭 */
  .hero { gap: 12px; margin-bottom: 36px; }
  .hero-title { font-size: clamp(22px, 6.4vw, 28px); line-height: 1.2; }
  .hero-thumb-content { padding: 22px 20px; }
  .hero-play { width: 56px; height: 56px; }
  .hero-play svg { width: 22px; height: 22px; }
  .hero-sub { font-size: 13.5px; }
  .hero-meta { font-size: 12.5px; gap: 12px; flex-wrap: wrap; }

  .hero-side { flex-direction: column; }
  .hero-card-title { font-size: 16px; }
  .hero-card { padding: 16px 18px; }

  .counter-strip { padding: 8px 0; margin-bottom: 36px; }
  .counter { padding: 14px 18px; }
  .counter-v { font-size: 22px; }
  .counter-l { font-size: 11px; margin-top: 4px; }

  .section-head h2 { font-size: 19px; }
  .section-head { margin: 32px 0 14px; }

  .banner { padding: 28px 22px; border-radius: 18px; margin: 36px 0; }
  .banner h3 { font-size: 24px; }
  .banner p { font-size: 14px; }
  .banner-ctas { flex-wrap: wrap; }
  .banner-ctas .btn { flex: 1; min-width: 0; }

  .video-grid { grid-template-columns: repeat(2, 1fr); gap: 14px 10px; }
  .youtube-embed-card { grid-template-columns: 1fr; padding: 14px; gap: 14px; border-radius: 18px; }
  .youtube-embed-copy { min-height: auto; padding: 18px; }
  .youtube-embed-copy h3 { font-size: 19px; }
  .youtube-frame-wrap { min-height: 0; }
  .video-title { font-size: 13.5px; }
  .video-meta { font-size: 11.5px; }
  .video-duration { font-size: 10px; padding: 2px 5px; }

  .watch-widget h3 { font-size: 15px; margin: 12px 16px 6px; }
  .watch-row { padding: 12px 16px; gap: 10px; }
  .watch-ticker { display: none; }
  .watch-name { font-size: 14px; }
  .watch-price { min-width: 88px; }
  .watch-price .p { font-size: 14px; }
  .watch-price .c { font-size: 12.5px; }

  .col-side { padding: 18px 18px; }
  .col-item-title { font-size: 14px; }

  /* 포트폴리오 */
  .pf-hero { padding: 24px 22px; border-radius: 18px; gap: 22px; }
  .pf-total { font-size: 28px; }
  .pf-donut-wrap svg { width: 180px; height: 180px; }
  .pf-ctas { flex-direction: column; align-items: stretch; }
  .pf-ctas .btn { text-align: center; }
  .pf-hd-row { padding: 14px 14px; gap: 10px; grid-template-columns: 30px 1.4fr 0.7fr 1fr; font-size: 12.5px; }
  .pf-hd-row > *:nth-child(5) { display: none; }
  .pf-hd-head { grid-template-columns: 30px 1.4fr 0.7fr 1fr; }

  /* 클래스 */
  .page > div[style*="2fr 1fr"] { grid-template-columns: 1fr !important; gap: 16px !important; }
  .player-title { font-size: 18px; top: 18px; left: 18px; right: 18px; }
  .player-controls { padding: 14px 14px; gap: 10px; }
  .lesson-list-item { padding: 12px 12px; }
  .ll-title { font-size: 13.5px; }

  /* 커뮤니티 */
  .proof-grid { grid-template-columns: 1fr; gap: 12px; }
  .proof-rate { font-size: 30px; }

  /* 칼럼 */
  .column-card { padding: 20px 20px; }
  .column-title { font-size: 17px; }

  /* 푸터 */
  .footer { padding: 36px 0 calc(80px + env(safe-area-inset-bottom)); margin-top: 64px; }
  .footer-inner { grid-template-columns: 1fr 1fr; gap: 24px; padding: 0 16px; }
  .footer-bottom { flex-direction: column; gap: 10px; padding: 20px 16px 0; font-size: 11.5px; }

  /* 회의방 */
  .crit-toggle { bottom: calc(76px + env(safe-area-inset-bottom)); right: 14px; padding: 11px 18px; font-size: 12.5px; }
  .crit-panel { width: 100vw; }

  /* 모달 — 바텀시트 */
  .modal { border-radius: 18px 18px 0 0; position: fixed; bottom: 0; left: 0; right: 0; width: 100%; max-height: 92vh; overflow-y: auto; animation: slideUpModal 0.28s ease-out; padding-bottom: env(safe-area-inset-bottom); }
  @keyframes slideUpModal { from { transform: translateY(100%); } to { transform: translateY(0); } }
  .modal-backdrop { align-items: flex-end; }
}

/* ── 모바일 하단 탭바 (토스앱 시그니처) ─────────────── */
.tabbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--t-50);
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 40;
  justify-content: space-around;
}
.tabbar-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px;
  border: none; background: transparent; cursor: pointer;
  font-size: 10.5px; font-weight: 600; color: var(--t-300);
  border-radius: 10px;
  transition: color 0.12s;
}
.tabbar-item.active { color: var(--t-900); }
.tabbar-item svg { width: 22px; height: 22px; }

@media (max-width: 720px) {
  .tabbar { display: flex; }
}

/* Tweak 패널 */
[class*="tweaks-panel"], .tweaks-panel { left: 24px !important; right: auto !important; }
@media (max-width: 720px) {
  [class*="tweaks-panel"], .tweaks-panel { left: 14px !important; bottom: calc(76px + env(safe-area-inset-bottom)) !important; }
}

/* 포커스 접근성 */
button:focus-visible, input:focus-visible, textarea:focus-visible, .nav-link:focus-visible {
  outline: 2px solid var(--t-900);
  outline-offset: 2px;
}

/* 스크롤바 */
.crit-messages::-webkit-scrollbar, .lesson-list::-webkit-scrollbar { width: 6px; }
.crit-messages::-webkit-scrollbar-thumb, .lesson-list::-webkit-scrollbar-thumb {
  background: var(--t-100); border-radius: 3px;
}

/* 다크 테마 — 토스 다크 톤 */
body.theme-dark {
  --bg:        #17181C;
  --bg-soft:   #1E1F23;
  --bg-mute:   #26282E;
  --bg-card:   #1E1F23;

  --t-900:     #F2F4F6;
  --t-700:     #D1D6DB;
  --t-500:     #B0B8C1;
  --t-400:     #8B95A1;
  --t-300:     #6B7684;
  --t-200:     #4E5968;
  --t-100:     #333D4B;
  --t-50:      #26282E;

  --brand-tint: #2A2715;
  --brand-soft: #3A3520;

  --up-bg:   #2A1A1C;
  --down-bg: #14253D;
}
body.theme-dark .topbar { background: rgba(23,24,28,0.92); }
body.theme-dark .tabbar { background: rgba(23,24,28,0.96); }

/* 밀도 */
body.density-cozy .page { padding: 40px 28px 80px; }
body.density-compact .page { padding: 20px 20px 64px; }
body.density-compact .section-head { margin: 28px 0 12px; }
body.density-compact .video-grid { gap: 12px; }

/* 모바일웹앱 standalone 모드 — 노치/홈인디케이터 대응 */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
  .topbar { padding-top: env(safe-area-inset-top); }
}
