:root {
  --bg: #0e0f12;
  --surface: #17191e;
  --surface-2: #22252c;
  --border: #2c3038;
  --text: #eceef2;
  --muted: #8d93a0;
  --accent: #3ee0a1;
  --accent-ink: #062016;
  --danger: #ff6b6b;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  background: rgba(14, 15, 18, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: -.5px; }
.logo-mark {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-size: 15px;
}
.logo .accent { color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
h1 { font-size: 22px; margin: 0 0 18px; }

/* 목록 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px 16px; }
.card { display: block; }
.thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2);
}
.thumb video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 32px; }
.badge {
  position: absolute; padding: 2px 6px; border-radius: 4px; font-size: 12px; font-weight: 700;
  background: rgba(0, 0, 0, .75);
}
.badge.rec { top: 8px; left: 8px; background: var(--surface-2); color: var(--accent); }
.badge.dur { right: 8px; bottom: 8px; }
.card:hover .thumb { outline: 2px solid var(--accent); }
.card-title { margin: 10px 0 2px; font-weight: 700; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { color: var(--muted); font-size: 13px; }

.empty { text-align: center; padding: 80px 16px; color: var(--muted); }
.empty p { margin: 0 0 16px; }

/* 상세 */
.player-wrap { background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; }
.player-wrap video { width: 100%; height: 100%; display: block; background: #000; }
.watch-title { font-size: 20px; margin: 16px 0 6px; }
.info-row { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 14px; }
.streamer { color: var(--text); font-weight: 700; }
.desc {
  margin-top: 16px; padding: 14px 16px; background: var(--surface); border-radius: var(--radius);
  white-space: pre-wrap; word-break: break-word; font-size: 14px;
}
.desc:empty { display: none; }

/* 등록 폼 */
.form { max-width: 640px; display: grid; gap: 18px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 14px; }
.field .hint { color: var(--muted); font-size: 12px; }
input[type=text], input[type=url], textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 100px; resize: vertical; }
.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; }
.tabs button[aria-selected=true] { border-color: var(--accent); color: var(--accent); }
.drop {
  display: grid; place-items: center; gap: 6px; padding: 28px 16px; text-align: center;
  border: 1.5px dashed var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--muted); cursor: pointer;
}
.drop.over { border-color: var(--accent); }
.drop strong { color: var(--text); }
.drop input { display: none; }
.preview { width: 100%; border-radius: var(--radius); background: #000; max-height: 320px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.error { color: var(--danger); font-size: 14px; min-height: 1.5em; }
[hidden] { display: none !important; }

@media (max-width: 600px) {
  .topbar { padding: 10px 16px; }
  main { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
}

/* ---- 2단계: 방송 ---- */
.nav { display: flex; gap: 8px; }
.btn-live { background: #ff3b5c; border-color: #ff3b5c; color: #fff; }
.btn-live:hover { filter: brightness(1.08); border-color: #ff3b5c; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 14px; }
.section-head h2 { font-size: 19px; margin: 0; }
.section-head .meta { margin: 0; }
section + section { margin-top: 36px; }
.empty-inline { color: var(--muted); padding: 24px 0; }

.live-thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  display: grid; place-items: center; text-align: center; padding: 12px;
  background: radial-gradient(circle at 30% 20%, #3a1d27, #17191e 70%);
  color: var(--text); font-weight: 700;
}
.live-thumb .who { font-size: 22px; }
.card.ended .live-thumb { background: var(--surface-2); color: var(--muted); }
.card.ended .card-title { color: var(--muted); }
.badge.live { top: 8px; left: 8px; background: #ff3b5c; color: #fff; }
.badge.ended { top: 8px; left: 8px; background: var(--surface); color: var(--muted); }
.badge.count { right: 8px; bottom: 8px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 4px; vertical-align: 1px; }
.badge.live .dot { animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.stage { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 9; }
.stage video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.stage video.mirror { transform: scaleX(-1); }
.stage .overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px;
  background: rgba(0, 0, 0, .55); color: var(--text); font-weight: 600;
}
.stage .hud { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.stage .hud .badge { position: static; }
.stage .unmute { position: absolute; right: 12px; bottom: 12px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.notice {
  padding: 12px 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); font-size: 14px; color: var(--muted);
}
.notice.warn { border-color: #6b4b16; color: #f1c27d; }
.summary { display: grid; gap: 4px; margin-top: 12px; font-size: 14px; color: var(--muted); }
.summary b { color: var(--text); font-weight: 600; }

/* 휴대폰 송출 화면: 세로 화면이면 영상 영역을 세로 비율로 */
@media (max-width: 600px) and (orientation: portrait) {
  .stage.portrait { aspect-ratio: 3 / 4; }
  .nav .btn { padding: 8px 10px; font-size: 14px; }
}

/* ---- 3단계: 로그인·소유자 제어·댓글 ---- */
.nav { align-items: center; }
#auth-slot { display: inline-flex; align-items: center; gap: 8px; }
#auth-slot .me { color: var(--muted); font-size: 14px; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auth-box { max-width: 420px; margin: 24px auto; display: grid; gap: 18px; }
input[type=password] {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
.owner-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px;
  padding: 10px 12px; border: 1px dashed var(--border); border-radius: var(--radius);
}
.owner-bar .meta { margin-right: auto; }
.edit-form { display: grid; gap: 10px; margin-top: 12px; }
.comments-wrap { margin-top: 28px; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea { min-height: 44px; }
.comments { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 4px; }
.comment { padding: 10px 12px; border-radius: 8px; background: var(--surface); }
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 14px; }
.comment-actions { margin-left: auto; display: inline-flex; gap: 8px; }
.comment-body { margin-top: 4px; white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.tag { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); }
button.link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
button.link:hover { color: var(--text); text-decoration: underline; }
.login-needed { text-align: center; padding: 40px 16px; }
/* 송출 화면: 방송 중 댓글을 영상 아래에 */
.live-comments .comments { max-height: 40vh; overflow-y: auto; }

/* ---- 4단계: 도네이션 ---- */
.btn-donate { margin-left: auto; background: #ffb020; border-color: #ffb020; color: #2a1a00; }
.btn-donate:hover { filter: brightness(1.06); border-color: #ffb020; }
.won { color: #ffc24a; }
.donations-wrap { margin-top: 28px; }
.donations-wrap .section-head { flex-wrap: wrap; }
.donations { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; max-height: 320px; overflow-y: auto; }
.donation { padding: 10px 12px; border-radius: 8px; background: var(--surface); border-left: 3px solid #ffb020; }
.donation-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 14px; }
.donation-head .meta { margin-left: auto; }
.donation-msg { margin-top: 2px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.donation-msg:empty { display: none; }
.donation-toast {
  position: fixed; left: 50%; top: 76px; transform: translateX(-50%); z-index: 50;
  max-width: min(92vw, 420px); padding: 14px 18px; border-radius: 12px; text-align: center;
  background: #2a2112; border: 1px solid #ffb020; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  transition: opacity .6s, transform .6s;
}
.donation-toast.out { opacity: 0; transform: translate(-50%, -10px); }

.donate-box { max-width: 560px; margin: 8px auto; display: grid; gap: 18px; }
.donate-box h1 { margin: 0; }
select {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
input[type=number] {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
.amounts { display: flex; flex-wrap: wrap; gap: 6px; }
.amounts .btn[aria-pressed=true] { border-color: #ffb020; color: #ffc24a; }
.btn-pay { justify-content: center; padding: 12px 16px; font-size: 16px; }

.result { text-align: center; padding: 24px 16px; border-radius: var(--radius); background: var(--surface); }
.result h1 { font-size: 20px; margin: 8px 0 6px; }
.result-icon {
  display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  font-size: 28px; font-weight: 800; background: var(--surface-2); color: var(--muted);
}
.result[data-state=ok] .result-icon { background: var(--accent); color: var(--accent-ink); }
.result[data-state=bad] .result-icon { background: #3a1d22; color: var(--danger); }
.result-table { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; text-align: left; margin: 18px auto 0; max-width: 420px; font-size: 14px; }
.result-table dt { color: var(--muted); }
.result-table dd { margin: 0; word-break: break-all; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

.fake-pg { background: #eef1f5; color: #1b1e24; }
.fake-pg .meta { color: #5d6470; }
.pg-card { margin-top: 40px; padding: 24px; border-radius: 14px; background: #fff; box-shadow: 0 8px 30px rgba(0, 0, 0, .12); display: grid; gap: 10px; }
.pg-head { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pg-amount { font-size: 30px; font-weight: 800; margin: 0; }
.pg-buttons { display: grid; gap: 8px; margin-top: 8px; }
.pg-buttons .btn { justify-content: center; background: #f2f4f7; color: #1b1e24; border-color: #d7dbe2; }
.pg-buttons .btn-primary { background: #3182f6; border-color: #3182f6; color: #fff; }

/* ---- 6단계: 데스크톱 앱 다운로드 ---- */
.dl-box { max-width: 880px; margin: 0 auto; display: grid; gap: 14px; }
.dl-box h1 { margin: 0; }
.dl-box h2 { font-size: 18px; margin: 18px 0 0; }
.dl-box h3 { margin: 0 0 6px; font-size: 16px; }
.dl-hero { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 18px; border-radius: var(--radius); background: var(--surface); }
.dl-main { font-size: 16px; padding: 12px 20px; }
.dl-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dl-table th, .dl-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.dl-table th { color: var(--muted); font-weight: 600; }
.dl-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.dl-steps section { padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); font-size: 14px; }
.dl-steps section.mine { border-color: var(--accent); }
.dl-steps ol, .dl-steps ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.dl-box code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
@media (max-width: 600px) { .dl-table { font-size: 13px; } .dl-table th:nth-child(4), .dl-table td:nth-child(4) { display: none; } }
