/* =========================================================
   브레인와이어 · 쇼츠 공장 (shorts/) — 모바일 전용 CSS
   mobile.css — body.mobile-layout 일 때 적용
   =========================================================
   핵심 원칙:
   - 뷰포트 100vw 엄격 제한 및 가로 스크롤(overflow-x) 방지
   - 탭바 하단 고정 (iOS Safe Area 지원)
   - 플로팅 토스트/액션바가 탭바를 가리지 않도록 Safe Bottom Offset 유지
   - 단일 열(Single Column) 카드 레이아웃 & 터치 친화적 인터랙션
   ========================================================= */

/* ── 모바일 감지 클래스 (JS가 <body>에 추가) ── */
@media (max-width: 767px) {
  html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  body.mobile-layout {
    padding: 0 !important;
    margin: 0 !important;
    min-height: 100vh;
    display: block;
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
  }

  /* 📐 full-bleed 컨테이너 + 균일한 좌우 패딩 */
  body.mobile-layout #app {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: calc(10px + env(safe-area-inset-top)) 14px calc(85px + env(safe-area-inset-bottom)) 14px !important;
    overflow-x: hidden !important;
  }

  /* ── 상호 교차 배너 ── */
  body.mobile-layout .cross-nav-bar {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    margin: 0 0 12px 0;
    border-radius: 10px;
    font-size: 11px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }
  body.mobile-layout .cross-nav-link {
    font-size: 10px;
    padding: 4px 8px;
  }

  /* ── 헤더 ── */
  body.mobile-layout .header {
    width: 100%;
    padding: 6px 0 12px;
    margin: 0;
    text-align: center;
  }
  body.mobile-layout .header .live-badge {
    font-size: 10px;
    padding: 3px 10px;
    margin-bottom: 6px;
  }
  body.mobile-layout .header h2 {
    font-size: 17px;
    line-height: 1.35;
  }

  /* ── 스티키 네비 → 하단 고정 탭바 ── */
  body.mobile-layout .tabs {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    z-index: 9990 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    border-top: 1px solid rgba(255, 255, 255, 0.12) !important;
    padding: 6px env(safe-area-inset-right) calc(6px + env(safe-area-inset-bottom)) env(safe-area-inset-left) !important;
    background: rgba(9, 13, 22, 0.97) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    display: flex !important;
    justify-content: space-around !important;
    gap: 4px !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.6) !important;
  }
  body.mobile-layout .tab-btn {
    flex: 1;
    font-size: 11px !important;
    padding: 8px 4px !important;
    min-height: 42px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
    white-space: nowrap;
  }

  /* ── 수익화 툴바 ── */
  body.mobile-layout .monetize-toolbar {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin: 0 0 12px 0;
    border-radius: 10px;
    font-size: 11px;
  }
  body.mobile-layout .monetize-toolbar > div {
    font-size: 11px !important;
  }
  body.mobile-layout .btn-monetize-setting {
    font-size: 11px;
    padding: 6px 10px;
  }

  /* ── 주간 명예의 전당 배너 & 가치관 박스 ── */
  body.mobile-layout .weekly-hall-banner,
  body.mobile-layout .card-box {
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 14px 0 !important;
    padding: 12px 14px !important;
    border-radius: 12px !important;
  }
  body.mobile-layout .weekly-hall-banner h3 {
    font-size: 13px;
  }
  body.mobile-layout .weekly-hall-banner p {
    font-size: 11px;
  }

  /* ── AI 자연어 피드백 섹션 ── */
  body.mobile-layout .user-feedback-section {
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 14px 0 !important;
    padding: 12px !important;
    border-radius: 10px !important;
  }
  body.mobile-layout .user-feedback-section > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  body.mobile-layout #userDirectFeedbackInput {
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    font-size: 13px !important;
    padding: 10px 12px !important;
  }
  body.mobile-layout #btnSubmitFeedback {
    width: 100% !important;
    min-height: 40px !important;
    padding: 10px !important;
    font-size: 13px !important;
    text-align: center;
    justify-content: center;
  }

  /* ── 필터 툴바 & 카테고리 스크롤 ── */
  body.mobile-layout .filter-toolbar {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }
  body.mobile-layout .category-scroll {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0 10px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
  }
  body.mobile-layout .cat-chip {
    padding: 6px 12px;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* ── 바이럴 카드 그리드 ── */
  body.mobile-layout .viral-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 14px !important;
    width: 100% !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }
  body.mobile-layout .viral-card {
    width: 100% !important;
    box-sizing: border-box !important;
    border-radius: 14px !important;
    overflow: hidden !important;
  }
  body.mobile-layout .card-media {
    height: 220px !important;
    width: 100% !important;
  }
  body.mobile-layout .card-body {
    padding: 12px !important;
  }
  body.mobile-layout .card-title {
    font-size: 14px !important;
    min-height: auto !important;
    line-height: 1.35;
  }
  body.mobile-layout .price-tag {
    font-size: 15px !important;
  }

  /* ── 서사 검색 박스 ── */
  body.mobile-layout .narrative-search-box {
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 14px 0;
    padding: 14px;
    border-radius: 12px;
  }
  body.mobile-layout #narrative-input {
    font-size: 14px;
    padding: 12px;
  }
  body.mobile-layout .preset-pill {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* ── 구독 칩 ── */
  body.mobile-layout .subscribed-topics-box {
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 14px 0;
    padding: 12px 14px;
    border-radius: 12px;
  }

  /* ── 숏츠 스튜디오 (3단계) ── */
  body.mobile-layout #tab-create [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  body.mobile-layout [style*="display:grid; grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ── 폼 요소 iOS 줌 방지 ── */
  body.mobile-layout input[type="text"],
  body.mobile-layout textarea,
  body.mobile-layout input[type="url"],
  body.mobile-layout select {
    font-size: 16px !important; /* iOS 자동 줌 방지 */
  }

  /* ── 작업 바구니 액션 버튼 ── */
  body.mobile-layout #tab-basket [style*="display:flex"][style*="gap:8px"]:not(.narrative-presets):not(.subscribed-chips):not(.feed-foot) {
    flex-direction: column;
    width: 100%;
  }
  body.mobile-layout #tab-basket button {
    width: 100%;
    justify-content: center;
  }

  /* ── 모달 ── */
  body.mobile-layout .modal-overlay {
    align-items: flex-end; /* 바텀 시트 형태 */
    padding: 0;
  }
  body.mobile-layout .modal-card {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 85vh;
    overflow-y: auto;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  }

  /* ── 플로팅 토스트 & 일괄 액션바 (하단 탭바 위에 안전하게 배치) ── */
  body.mobile-layout .shorts-toast,
  body.mobile-layout #shorts-dismiss-toast,
  body.mobile-layout #batch-action-bar {
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
    max-width: 94vw !important;
    font-size: 12px !important;
    padding: 10px 14px !important;
    z-index: 99999 !important;
    box-sizing: border-box !important;
  }
}

/* ── 틴더 스와이프 전용 스타일 ── */
.tinder-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #131b2e;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  will-change: transform;
  transform-origin: 50% 100%;
}
.tinder-card:active {
  cursor: grabbing;
}
.tinder-stamp {
  position: absolute;
  top: 28px;
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 30px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
}
.tinder-stamp-like {
  left: 16px;
  border: 3px solid #10b981;
  color: #10b981;
  transform: rotate(-15deg);
  background: rgba(16, 185, 129, 0.2);
}
.tinder-stamp-nope {
  right: 16px;
  border: 3px solid #ef4444;
  color: #ef4444;
  transform: rotate(15deg);
  background: rgba(239, 68, 68, 0.2);
}
.tinder-ctrl-btn {
  border-radius: 50%;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.tinder-ctrl-btn:active {
  transform: scale(0.9);
}
.tinder-ctrl-btn.btn-undo {
  background: #1e293b;
  color: #f59e0b;
  border: 1px solid #475569;
  width: 40px;
  height: 40px;
  font-size: 15px;
}
.tinder-ctrl-btn.tinder-btn-nope {
  background: #1e293b;
  color: #ef4444;
  border: none;
  width: 60px;
  height: 60px;
  font-size: 26px;
  font-weight: 700;
  position: static;
  opacity: 1;
}
.tinder-ctrl-btn.btn-note {
  background: #1e293b;
  color: #c4b5fd;
  border: none;
  width: 40px;
  height: 40px;
  font-size: 16px;
}
.tinder-ctrl-btn.tinder-btn-like {
  background: #1e293b;
  color: #10b981;
  border: none;
  width: 60px;
  height: 60px;
  font-size: 26px;
  position: static;
  opacity: 1;
}
.tinder-ctrl-btn .ctrl-label {
  display: none;
}
.tinder-preset-chip {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(139, 92, 246, 0.35);
  color: #cbd5e1;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.tinder-preset-chip:hover,
.tinder-preset-chip:active {
  background: rgba(139, 92, 246, 0.4);
  color: #fff;
  border-color: #8b5cf6;
}

/* ── 틴더 카드 v2 (2026-09-04): 썸네일·제목 크게, 원본재생/예상금액 제거 ── */
.tinder-thumb {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  background: linear-gradient(135deg, #1e293b, #0b1120);
}
.tinder-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tinder-thumb.broken img { display: none; }
.tinder-thumb.broken::after {
  content: "▶  영상 보기";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  font-weight: 800;
  font-size: 15px;
  background: linear-gradient(135deg, #312e81, #1e1b4b);
}
.tinder-views {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: #fde68a;
  font-weight: 800;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 20px;
}
.tinder-foot {
  padding: 14px 16px 16px;
  background: linear-gradient(180deg, #1b2438 0%, #0d1424 100%);
}
.tinder-chan {
  font-size: 12px;
  color: #a78bfa;
  font-weight: 700;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tinder-tt {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tinder-hint {
  margin-top: 9px;
  font-size: 10px;
  color: #64748b;
}

/* ── 모바일 전용 플로팅 스와이프 퀵 런처 ── */
.mobile-only-fab {
  display: none;
}
@media (max-width: 767px) {
  body.mobile-layout .mobile-only-fab {
    position: fixed;
    bottom: calc(68px + env(safe-area-inset-bottom));
    right: 14px;
    background: linear-gradient(135deg, #ff3b5c, #f59e0b);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    padding: 9px 15px;
    border-radius: 30px;
    box-shadow: 0 8px 24px rgba(255, 59, 92, 0.45);
    z-index: 9980;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(255, 255, 255, 0.2);
  }
}/* ── UI Enhancement: Thumbnail, Views, Like/Nope ── */

/* ── Thumbnail Display Enhancement ── */
.viral-card .card-media {
  width: 100%;
  height: 180px !important;
  object-fit: cover !important;
  border-radius: 12px 12px 0 0 !important;
  transition: transform 0.3s ease, box-shadow 0.3s ease !important;
}

.viral-card .card-media:hover {
  transform: scale(1.02) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3) !important;
}

/* ── View Count Badge ── */
.viral-stat {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 255, 170, 0.8);
  color: #000;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(4px);
  z-index: 10;
  white-space: nowrap;
}

/* ── Feedback Overlay ── */
.feedback-overlay {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 100%);
}

.feedback-overlay:hover {
  opacity: 1;
}

/* ── Feedback Buttons ── */
.btn-like, .btn-nope {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.viral-card:hover .feedback-overlay .btn-like,
.viral-card:hover .feedback-overlay .btn-nope {
  opacity: 1;
}

/* ── Buttons ── */
.btn-like {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn-like:hover { transform: scale(1.05); }

.btn-nope {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s;
}

.btn-nope:hover { transform: scale(1.05); }

/* ── Floating Tags ── */
.floating-tag {
  position: fixed;
  padding: 8px 16px;
  background: #ef4444;
  color: white;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  z-index: 10000;
  animation: float 5s infinite ease-in-out;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  line-height: 1.4;
  pointer-events: none;
}

.floating-tag.like {
  background: #3b82f6;
}

@keyframes float {
  0%, 100% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-20px) translateX(10px); }
}

/* ── Grid Layout Density ── */
body.mobile-layout .viral-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px !important;
  padding: 12px !important;
}

body.mobile-layout .viral-card {
  background: #1e293b;
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s ease;
}

body.mobile-layout .viral-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.4);
}
