/* YouTuber Supporter 스타일 — CSS 변수 기반 다크 테마 */
:root {
  --bg: #14161c;
  --panel: #1d212b;
  --panel-2: #262b38;
  --text: #e8eaf0;
  --muted: #98a0b3;
  --primary: #4f7cff;
  --primary-d: #3a63d8;
  --publish: #1faa6b;
  --draft: #f2c94c;      /* 게시 전 = 노란색 */
  --published: #ffffff;  /* 게시 완료 = 흰색 */
  --danger: #e25555;
  --border: #333a49;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); }

/* ── 버튼 ── */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;   /* 좁은 폭에서 글자단위로 깨지지 않도록 */
}
.btn:hover { filter: brightness(1.1); }
a.btn { text-decoration: none; }   /* 링크형 버튼(나가기 등) 밑줄 제거 */
.btn.primary { background: var(--primary); border-color: var(--primary-d); }
.btn.publish { background: var(--publish); border-color: var(--publish); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; display: block; text-align: center; }
.btn.small { padding: 5px 10px; font-size: 12px; }

/* ── 인증 화면 ── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card {
  background: var(--panel); padding: 32px; border-radius: 14px;
  width: 360px; border: 1px solid var(--border);
}
.auth-card h1 { margin-top: 0; font-size: 22px; }
.auth-card label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.auth-card input {
  width: 100%; padding: 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
}
.auth-card .btn { margin-top: 18px; width: 100%; }
.req { color: var(--danger); }
/* ── 소셜 로그인 ── */
.social-login { margin-top: 18px; }
.social-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 8px 0 12px; }
.social-divider::before, .social-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
/* 소셜 버튼 — 로고 + 규정 문구. 각 브랜드 가이드 색상 */
.social-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; margin-top: 8px; padding: 11px 14px; border-radius: 10px;
  font-size: 14px; font-weight: 600; text-decoration: none; position: relative;
  border: 1px solid transparent;
}
.social-btn .social-ic { display: inline-flex; align-items: center; }
.social-btn .social-label { line-height: 1; }
.social-google { background: #fff; color: #1f1f1f; border-color: #dadce0; }
.social-naver { background: #03c75a; color: #fff; }
.social-kakao { background: #fee500; color: #191600; }
.social-btn:hover { filter: brightness(0.97); }
.error { color: var(--danger); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }

/* ── 앱 레이아웃 ── */
.layout { display: flex; height: 100vh; height: 100dvh; }
.sidebar {
  width: 260px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar-full { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.sidebar-head { padding: 14px; }
.sidebar-head-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }

/* 최소화 레일 — 기본 숨김, 접힘 상태에서만 노출 */
.sidebar-rail { display: none; }
.layout.sidebar-collapsed .sidebar { width: 56px; }
.layout.sidebar-collapsed .sidebar-full { display: none; }
.layout.sidebar-collapsed .sidebar-rail {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding: 14px 0;
}
.content-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; }
.content-item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer; margin-bottom: 4px;
  font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.content-item:hover { background: var(--panel-2); }
.content-item[data-active="1"] { background: var(--panel-2); }
.content-item.draft .title { color: var(--draft); }       /* 게시 전 노란색 */
.content-item.published .title { color: var(--published); } /* 게시 완료 흰색 */
/* 항목 전체를 감싸는 링크(프롬프터 사이드바) — 색/밑줄을 상속해 앱의 평문 항목과 동일 */
.content-item .row-link { display: block; color: inherit; text-decoration: none; }
.sidebar-foot {
  padding: 12px 14px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-foot .user { font-size: 13px; color: var(--muted); }
.foot-actions { display: flex; align-items: center; gap: 8px; }
/* 톱니(icon-btn 32px)와 로그아웃 버튼 높이 일치 */
.foot-actions .btn { height: 32px; display: inline-flex; align-items: center; }
.foot-actions form { display: flex; }

/* 사이드바 카테고리 */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 0; }
.cat { margin-bottom: 6px; }
.cat-head {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px 4px; font-size: 12px; font-weight: 700;
  color: var(--muted); text-transform: none; letter-spacing: .2px;
}
.cat-head .cat-ic { color: var(--primary); flex: 0 0 auto; }
.cat-empty { padding: 4px 16px 8px; font-size: 12px; color: #6b7280; list-style: none; }

/* 아이콘 버튼(톱니 등) */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { filter: brightness(1.15); }

/* ── 모달 ── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
/* hidden 속성이 .modal 의 display:flex 보다 우선하도록 명시 — 닫힘 상태 보장 */
.modal[hidden] { display: none; }
.modal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  width: 420px; max-width: 92vw; max-height: 88vh; overflow-y: auto; padding: 20px 22px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-tabs { display: flex; gap: 8px; margin: 16px 0 12px; border-bottom: 1px solid var(--border); }
.tab-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 8px 4px; font-size: 14px; border-bottom: 2px solid transparent;
}
.tab-btn[data-active="1"] { color: var(--text); border-bottom-color: var(--primary); }
.modal-pane label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.modal-pane input[type="text"], .modal-pane input[type="email"],
.modal-pane input[type="url"] {
  width: 100%; padding: 9px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
}
.modal-pane input[type="range"], .modal-pane input[type="color"] { width: 100%; }
.modal-pane input:disabled { opacity: .6; }
.modal-pane .btn { margin-top: 16px; }
.modal-pane .muted { display: block; margin-top: 8px; }

/* ── 캔버스 ── */
.canvas { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.canvas-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-bottom: 1px solid var(--border);
}
.title-input {
  background: transparent; border: none; color: var(--text);
  font-size: 18px; font-weight: 600; flex: 0 1 320px; padding: 6px;
}
.title-input:focus { outline: 1px solid var(--border); border-radius: 6px; }
.spacer { flex: 1; }

.scene-area { flex: 1; overflow-y: auto; padding: 18px; }
.empty-hint { color: var(--muted); text-align: center; margin-top: 80px; }

/* 콘티 장면 카드 */
.scene-card {
  display: grid; grid-template-columns: 320px 1fr; gap: 16px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin-bottom: 16px; position: relative;
}
.scene-card .duration {
  position: absolute; top: 10px; right: 12px;
  background: var(--panel-2); padding: 3px 8px; border-radius: 20px;
  font-size: 12px; color: var(--muted);
}
.scene-left .scene-img {
  width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 8px;
  background: var(--panel-2);
}
.scene-guide { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.scene-guide b { color: var(--text); }
.scene-right { display: flex; flex-direction: column; }
.scene-right .dialogue {
  flex: 1; min-height: 90px; width: 100%; resize: vertical;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px; font-size: 15px; line-height: 1.6;
}
.scene-right .scene-actions { margin-top: 8px; display: flex; gap: 8px; }

/* 하단 프롬프트 바 */
.prompt-bar {
  display: flex; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border);
  background: var(--panel);
}
.prompt-bar textarea {
  flex: 1; min-width: 0; resize: none; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; padding: 12px; font-size: 15px; line-height: 1.5;
}

/* 사이드바 팝업 */
.item-popup {
  position: absolute; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px; z-index: 50; min-width: 130px;
}
.item-popup button {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); padding: 8px 12px; cursor: pointer; border-radius: 6px; font-size: 14px;
}
.item-popup button:hover { background: var(--panel); }
/* hidden 속성이 display:block 보다 우선하도록 — 프롬프터 생성 메뉴 숨김 보장 */
.item-popup button[hidden] { display: none; }
.item-popup button.danger { color: var(--danger); }

/* ── 프롬프터 ── */
.prompter-page { background: #000; }
.prompter-setup {
  max-width: 460px; margin: 8vh auto; background: var(--panel);
  padding: 28px; border-radius: 14px; border: 1px solid var(--border);
}
.prompter-setup label { display: block; margin: 16px 0 6px; color: var(--muted); }
.prompter-setup .btn { margin-top: 18px; margin-right: 8px; }

/* 프롬프터 레이아웃 — 최소화 레일 + 본문 (dvh: 모바일 브라우저 크롬 제외 높이) */
.prompter-layout { display: flex; height: 100vh; height: 100dvh; }
.prompter-rail {
  width: 56px; flex: 0 0 56px; background: var(--panel);
  border-right: 1px solid var(--border);
}
.prompter-rail .sidebar-rail {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 0;
}
.prompter-wrap { flex: 1; min-width: 0; }

.prompter-stage {
  height: 100dvh; max-height: 100dvh; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
/* 상단 여백 최소화(과거 30vh → 상단 2vh), 하단 40vh 여유.
   overflow-y:auto 로 대사가 잘리지 않고 스크롤 가능(자동/수동 추종 공용). */
.scroll-area { flex: 1; min-height: 0; overflow-y: auto; padding: 2vh 8vw 40vh; scroll-behavior: smooth; }
/* '텍스트만 노출' 체크박스 */
.text-only-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; white-space: nowrap; }
.scroll-area.text-only .p-image { display: none; }
.p-scene { margin-bottom: 8vh; }
.scroll-area.with-scene .p-scene { display: grid; grid-template-columns: 40% 1fr; gap: 4vw; align-items: center; }
.p-image img { width: 100%; border-radius: 10px; }
.no-image { color: #555; }
.p-line {
  font-size: 48px; line-height: 1.5; color: #fff; transition: background .3s;
  padding: 4px 8px; border-radius: 6px;
}
/* 현재까지 읽은 부분 배경 강조 */
.p-line.read { background: rgba(79,124,255,.35); }
.p-line.current { background: rgba(79,124,255,.18); }
.prompter-controls {
  display: flex; gap: 10px; align-items: center; padding: 12px 18px;
  background: var(--panel); border-top: 1px solid var(--border);
  flex-wrap: wrap;     /* 좁은 폭에서 줄바꿈 — 컨트롤 항상 보이도록 */
  flex-shrink: 0;      /* 본문이 줄어도 컨트롤은 잘리지 않음 */
}
/* 가로/낮은 높이 화면 — 컨트롤 공간 확보 위해 본문 폰트·여백 축소 */
@media (max-height: 500px) {
  .p-line { font-size: 28px; }
  .scroll-area { padding: 2vh 6vw 30vh; }
  .prompter-controls { padding: 8px 12px; }
}

/* ── 로고/브랜드 ── */
.brand { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 4px 2px 12px; }
.brand-logo { flex: 0 0 auto; }
.brand-logo-img { height: 22px; width: auto; max-width: 100%; border-radius: 8px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }

/* ── 장면 넘버링 ── */
.scene-no {
  position: absolute; top: 10px; left: 12px;
  background: var(--primary); color: #fff; font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px;
}
.scene-card .scene-left { padding-top: 6px; }

/* ── 이미지 플레이스홀더(생성중) ── */
.scene-img.placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--muted); font-size: 13px; gap: 6px;
  border: 1px dashed var(--border);
}
.ph-timer { font-size: 12px; color: var(--primary); }

/* ── 생성 상태 배너 ── */
.gen-status {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 16px; color: var(--text); font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.spinner {
  width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  display: inline-block; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 첨부 ── */
.prompt-bar-wrap { border-top: 1px solid var(--border); background: var(--panel); }
.prompt-bar-wrap .prompt-bar { border-top: none; }
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 18px 0; }
.attach-chips:empty { padding: 0; }
.chip {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 16px;
  padding: 3px 10px; font-size: 12px; color: var(--muted);
}
.chip.err { color: var(--danger); }
.attach-btn {
  display: flex; align-items: center; justify-content: center;
  width: 42px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel-2); cursor: pointer; font-size: 18px;
}
.attach-btn:hover { filter: brightness(1.15); }

/* ── 참고영상 목록 ── */
.ref-video { margin-top: 8px; }
.ref-video-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.ref-video-row {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 6px;
}
/* min-width:0 필수 — flex item 기본 min-width:auto 가 긴 파일명만큼 폭 강제(가로 오버플로우) */
.ref-video-row > a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-video-del { color: var(--danger); }
.ref-video-play { color: var(--primary); }
/* 참고영상 재생 모달 — 와이드 카드 */
.video-modal-card { width: 720px; max-width: 94vw; }

/* ── 모바일 반응형 (≤768px) ── */
@media (max-width: 768px) {
  /* 사이드바: 좁은 화면에서 기본 최소화(레일) — 펼치면 오버레이 */
  .sidebar { width: 56px; flex: 0 0 56px; }
  .sidebar .sidebar-full { display: none; }
  .sidebar .sidebar-rail {
    display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 0;
  }
  .layout:not(.sidebar-collapsed) .sidebar {
    position: fixed; top: 0; left: 0; height: 100dvh; width: 78vw; max-width: 300px;
    z-index: 80; box-shadow: 0 0 0 100vmax rgba(0,0,0,.5);
  }
  .layout:not(.sidebar-collapsed) .sidebar .sidebar-full { display: flex; }
  .layout:not(.sidebar-collapsed) .sidebar .sidebar-rail { display: none; }

  /* 캔버스 툴바: 줄바꿈 허용, 제목은 한 줄 차지 */
  .canvas-toolbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .title-input { flex: 1 1 100%; font-size: 16px; }
  .canvas-toolbar .spacer { display: none; }
  .btn.small, .btn { font-size: 13px; padding: 7px 10px; }

  /* 가로 오버플로우 차단(긴 콘텐츠가 viewport 밖으로 새는 것 방지) */
  body { overflow-x: hidden; }
  .canvas, .scene-area { max-width: 100%; overflow-x: hidden; }

  /* 씬 카드: 이미지 위 / 대사 아래 단일 열 */
  .scene-card { grid-template-columns: 1fr; gap: 12px; padding: 12px; min-width: 0; }
  .scene-left, .scene-right { min-width: 0; }
  .scene-left .scene-img { aspect-ratio: 16/9; }

  /* 프롬프트 입력 바 */
  .prompt-bar { padding: 10px 12px; gap: 8px; }
  .attach-chips { padding: 8px 12px 0; }

  /* 프롬프터: 본문 폭 여유 */
  .scroll-area { padding: 2vh 5vw 40vh; }
  .scroll-area.with-scene .p-scene { grid-template-columns: 1fr; gap: 2vh; }
  .p-line { font-size: 32px; }
}
