/* 뽑아줘잉 — 모바일 퍼스트 웹 */
:root {
  --bg: #0b0b0f;
  --fg: #f5f5f7;
  --muted: #a1a1aa;
  --accent: #ff2d55;
  --accent-2: #ffd60a;
  --card: #16161c;
  --line: #2a2a33;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* iOS: 폼 컨트롤 글자가 16px 미만이면 포커스 시 화면이 자동 확대됨 → 16px로 막는다. */
input, textarea, select { font-size: 16px; }

/* hidden 속성이 .btn 등 author의 display 규칙에 밀려 안 먹던 것 강제(녹화 UI 버튼 토글이 안 되던 원인). */
[hidden] { display: none !important; }

/* Topbar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6), rgba(0,0,0,0));
}
.topbar .brand { display: inline-flex; flex-direction: column; line-height: 1.15; }
.topbar .brand-name { font-weight: 800; font-size: 18px; letter-spacing: -0.5px; }
.topbar .brand-tagline { font-size: 11px; font-weight: 700; color: var(--accent-2); letter-spacing: -0.2px; }
.topbar .brand-desc { font-size: 11px; font-weight: 600; color: var(--muted); }
@media (max-width: 480px) { .topbar .brand-desc { display: none; } }
.topbar nav { display: flex; align-items: center; gap: 8px; }
.topbar .me { font-size: 13px; color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 999px; cursor: pointer;
  padding: 10px 16px; font-size: 15px; font-weight: 600;
  background: #2a2a33; color: var(--fg);
}
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-xs { padding: 4px 8px; font-size: 12px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: rgba(255,255,255,0.12); }
.btn-danger { background: #3a1014; color: #ff8a9a; }
.btn-link { background: none; color: var(--muted); padding: 4px 6px; }
.btn-action { flex-direction: column; background: rgba(0,0,0,0.35); border-radius: 16px; min-width: 56px; }

/* Vote */
.btn-vote { background: rgba(255,255,255,0.14); flex-direction: column; min-width: 64px; }
.btn-vote.voted { background: var(--accent); color: #fff; }
.btn-vote .vote-label { font-size: 13px; }
.btn-vote .vote-count { font-size: 18px; font-weight: 800; }

/* Feed: 한 화면 한 영상 세로 스냅 */
.feed {
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
}
.candidate {
  position: relative;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex; align-items: center; justify-content: center;
  background: #000;
  overflow: hidden;
}
.candidate-video { position: absolute; inset: 0; }
.candidate-video video {
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
}
.candidate-tap { position: absolute; inset: 0; z-index: 1; }

.candidate-overlay {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(0,0,0,0.75), rgba(0,0,0,0));
  pointer-events: none;
}
.candidate-overlay a, .candidate-overlay button, .candidate-overlay form { pointer-events: auto; }
.candidate-meta { max-width: 70%; }
.candidate-meta .category {
  display: inline-block; font-size: 12px; color: #000; background: var(--accent-2);
  border-radius: 6px; padding: 2px 8px; font-weight: 700; margin-bottom: 6px;
}
.candidate-meta .number { display: block; color: var(--muted); font-size: 13px; }
.candidate-meta .title { margin: 4px 0 0; font-size: 20px; font-weight: 800; line-height: 1.25; }
.candidate-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }

.feed-sentinel { height: 1px; }
.empty { padding: 40vh 24px; text-align: center; color: var(--muted); }

/* Detail */
.detail { max-width: 720px; margin: 0 auto; padding: 56px 0 40px; }
/* 유튜브/쇼츠처럼: 검은 박스에 영상을 가운데 정렬(레터박스), 박스 자체도 중앙. */
.detail-video {
  position: relative; background: #000;
  /* 9:16 영상을 화면 높이(최대 88dvh)에 꽉 차게: 폭은 그 높이에 맞춰 자동 제한, 모바일은 풀폭. */
  width: 100%; max-width: calc(88dvh * 9 / 16); margin: 0 auto;
  aspect-ratio: 9 / 16;
}
.detail-video video { display: block; width: 100%; height: 100%; object-fit: contain; }
.detail-meta { padding: 16px; }
.detail-meta .category {
  display: inline-block; font-size: 12px; color: #000; background: var(--accent-2);
  border-radius: 6px; padding: 2px 8px; font-weight: 700;
}
.detail-meta .title { font-size: 22px; margin: 8px 0; }
.detail-meta .byline { display: flex; gap: 12px; color: var(--muted); font-size: 13px; }
.detail-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* Comments */
.comments { padding: 16px; border-top: 1px solid var(--line); margin-top: 16px; }
.comments h2 { font-size: 16px; }
.comment { padding: 8px 0; border-bottom: 1px solid var(--line); }
.comment-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.comment-author { color: var(--accent-2); font-size: 13px; font-weight: 700; white-space: nowrap; }
.comment-body { flex: 1; }
.comment-form { display: flex; gap: 8px; margin-top: 12px; }
/* 대댓글 */
.replies { margin: 8px 0 0 16px; border-left: 2px solid var(--line); padding-left: 12px; }
.comment.reply { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.comment.reply:last-child { border-bottom: none; }
.comment.pinned { background: color-mix(in srgb, var(--accent) 8%, transparent); border-left: 3px solid var(--accent); padding-left: 8px; border-radius: 6px; }
.pin-badge { font-size: 11px; color: var(--accent); font-weight: 700; margin-bottom: 4px; letter-spacing: 0.02em; }
.reply-form-wrap { margin-top: 6px; }
.reply-form-wrap summary { display: inline-block; }
.reply-form { margin-top: 8px; }
.comment-form textarea { flex: 1; background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; padding: 8px; resize: none; }
.login-hint { color: var(--muted); }

/* Login */
.login { max-width: 420px; margin: 0 auto; padding: 80px 24px; text-align: center; }
.login h1 { font-size: 30px; }
.login .lede { color: var(--muted); }
.login-buttons { display: flex; flex-direction: column; gap: 10px; margin: 24px 0; }
.inapp-notice { background: var(--card); border: 1px solid var(--accent); border-radius: 12px; padding: 14px; margin: 16px 0 4px; text-align: left; }
.inapp-notice p { margin: 0 0 10px; font-size: 14px; line-height: 1.5; }
.inapp-notice .btn { width: 100%; }
.btn-google { background: #fff; color: #111; }
.btn-apple { background: #111; color: #fff; border: 1px solid var(--line); }
.dev-login { text-align: left; background: var(--card); border: 1px dashed var(--line); border-radius: 10px; padding: 12px; }
.dev-login summary { cursor: pointer; color: var(--muted); }
.dev-login label { display: block; margin: 10px 0; }
.dev-login input[type=number] { width: 100px; padding: 6px; }

/* New post (출마하기) */
.new-post { max-width: 480px; margin: 0 auto; padding: 70px 20px 40px; }
.new-post .field { margin-bottom: 16px; }
.new-post label { display: block; margin-bottom: 6px; font-weight: 600; }
.new-post input[type=text], .new-post select, .new-post input[type=file] {
  width: 100%; padding: 10px; background: var(--card); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px;
}
.recorder { background: #000; aspect-ratio: 9/16; border-radius: 14px; overflow: hidden; position: relative; }
/* 셀카처럼 좌우반전(거울) — 녹화 미리보기/재생 한정. 피드(.candidate-video)는 원본 그대로. */
.recorder video { width: 100%; height: 100%; object-fit: cover; }
.recorder[data-facing="user"] video { transform: scaleX(-1); } /* 셀카 미러 — 후면일 땐 미러 안 함 */
.recorder { position: relative; }
.flip-camera { position: absolute; top: 10px; right: 10px; z-index: 2; background: rgba(0,0,0,0.55); color: #fff; border: 1px solid rgba(255,255,255,0.25); border-radius: 999px; width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; }
.flip-camera:hover { background: rgba(0,0,0,0.75); }
.recorder-nocam { text-align: center; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px 18px; line-height: 1.5; }
.recorder .countdown {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 80px; font-weight: 900; color: #fff; text-shadow: 0 2px 20px rgba(0,0,0,0.6);
}
.recorder .rec-dot { position: absolute; top: 12px; left: 12px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); }
.recorder-controls { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.recorder-field { display: flex; flex-direction: column; gap: 10px; }
.recorder-status { color: var(--muted); font-size: 13px; text-align: center; margin: 0; }
.recorder .rec-dot { animation: rec-blink 1s steps(2, start) infinite; }
@keyframes rec-blink { to { opacity: 0; } }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.hidden { display: none !important; }

/* Report */
.report { display: inline-block; }
.report-form { display: flex; gap: 6px; margin-top: 6px; }
.report-form select { background: var(--card); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; }

/* Flash + login prompt */
.flash { position: fixed; top: 56px; left: 0; right: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.flash > div { background: #1f1f27; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; max-width: 90%; }
.flash-alert { color: #ff8a9a; }
.flash-notice { color: #8affc1; }

.login-prompt { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.login-prompt-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.login-prompt-card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; max-width: 320px; text-align: center; }
.login-prompt-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

/* 첫 방문 안내 (Onboarding) — 다단계 모달 */
.onboarding { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.78); padding: 24px; }
.onboarding-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 26px 22px 22px; max-width: 360px; width: 100%; text-align: center; }
.ob-step { animation: ob-fade 220ms ease-out; }
.ob-step h2 { margin: 0 0 10px; font-size: 22px; line-height: 1.3; }
.ob-step p { color: var(--fg); line-height: 1.55; margin: 0; font-size: 15px; }
.ot-big { font-size: 56px; line-height: 1; margin-bottom: 14px; }
.ob-dots { display: flex; gap: 6px; justify-content: center; margin: 20px 0 14px; }
.ob-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); transition: width 0.18s, background 0.18s; }
.ob-dot.active { background: var(--accent); width: 22px; border-radius: 4px; }
.ob-controls { display: flex; gap: 8px; }
.ob-controls .btn { flex: 1; }
@keyframes ob-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Not found (사퇴한 후보) */
.not-found { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 12px; }
.not-found .nf-emoji { font-size: 56px; margin: 0; }
.not-found h1 { margin: 0; font-size: 22px; }
.not-found .nf-sub { color: var(--muted); margin: 0 0 8px; }

/* Processing (영상 처리 중) */
.processing { display: flex; align-items: center; gap: 10px; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.25); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* 업로드 중 폼 비활성 + 스피너 */
form[aria-busy="true"] .upload-busy { display: inline-flex; }
.upload-busy { display: none; align-items: center; gap: 8px; color: var(--muted); margin-top: 10px; }

/* 업로드 진행 오버레이 (출사표 보내는 중) */
.upload-overlay { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,0.86); display: flex; align-items: center; justify-content: center; padding: 24px; }
.upload-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 22px 22px; max-width: 360px; width: 100%; text-align: center; }
.upload-emoji { font-size: 44px; line-height: 1; margin-bottom: 10px; animation: pulse 1.4s ease-in-out infinite; }
.upload-card h2 { margin: 0 0 6px; font-size: 19px; }
.upload-status { color: var(--muted); margin: 0 0 16px; font-size: 14px; min-height: 1.4em; }
.upload-bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.upload-bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 200ms ease; }
.upload-percent { margin: 0 0 14px; font-size: 15px; font-weight: 700; color: var(--accent); }
.upload-tip { color: var(--muted); margin: 0; font-size: 12px; }
@keyframes pulse { 0%,100% { opacity: 1; transform: none; } 50% { opacity: 0.6; transform: scale(0.96); } }
form[aria-busy="true"] [type="submit"] { opacity: 0.5; pointer-events: none; }
