/* Aidot Casting — 모바일 퍼스트, Twitch/YouTube Live 톤의 다크 UI */
:root {
  --bg: #0b0f17; --panel: #121826; --elev: #1a2230;
  --border: #232d3f; --text: #e7edf6; --dim: #8fa0b8;
  --accent: #17a3c4; --live: #f8285a; --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text);
  font-family: -apple-system, 'Pretendard', 'Noto Sans KR', sans-serif; }
.view { min-height: 100dvh; display: flex; flex-direction: column; }
.inp { background: var(--elev); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 16px; /* iOS 줌 방지 */ width: 100%; }
.btn-primary { background: var(--accent); color: #04222b; border: 0; border-radius: 10px;
  padding: 12px 18px; font-weight: 800; font-size: 15px; cursor: pointer; text-decoration: none;
  display: inline-block; text-align: center; }
.btn-primary.big { width: 100%; padding: 15px; font-size: 16px; }
.btn-danger { background: var(--live); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 16px; font-weight: 800; cursor: pointer; }
.dim { color: var(--dim); font-size: 13px; }

/* ===== 공통 헤더 ===== */
.cast-top { display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: rgba(11,15,23,.92); backdrop-filter: blur(8px); z-index: 10; }
.cast-top h1 { font-size: 17px; margin: 0; flex: 1; }
.brand { color: var(--dim); text-decoration: none; font-size: 14px; font-weight: 700; }
.live-pill { background: rgba(248,40,90,.15); color: #ff8aa8; border: 1px solid rgba(248,40,90,.4);
  border-radius: 999px; padding: 4px 12px; font-size: 12.5px; font-weight: 800; }
.live-pill.on { background: var(--live); color: #fff; border: 0; }

/* ===== 디스커버리 ===== */
.home-main { flex: 1; padding: 16px; max-width: 1100px; width: 100%; margin: 0 auto; }
.live-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px)  { .live-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .live-grid { grid-template-columns: repeat(3, 1fr); } }
.live-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: transform .12s, border-color .12s; }
.live-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.live-thumb { aspect-ratio: 16/9; background:
  radial-gradient(circle at 30% 30%, #15314a, #0d1522); display: flex;
  align-items: center; justify-content: center; font-size: 42px; position: relative; }
.live-thumb .live-pill { position: absolute; top: 10px; left: 10px; }
.live-body { padding: 12px 14px; }
.live-body strong { display: block; font-size: 15px; margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; padding: 70px 20px; color: var(--dim); }
.empty-ic { font-size: 56px; margin-bottom: 12px; }

/* ===== 스튜디오 ===== */
.studio-main { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 14px;
  max-width: 1200px; width: 100%; margin: 0 auto; }
.stage { position: relative; background: #000; border-radius: var(--radius);
  overflow: hidden; aspect-ratio: 16/9; border: 1px solid var(--border); }
#studio-preview { width: 100%; height: 100%; object-fit: contain; }
.stage-overlay { position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; color: var(--dim); background: rgba(0,0,0,.4); }
.studio-panel { display: flex; flex-direction: column; gap: 14px; }
.setup { display: flex; flex-direction: column; gap: 10px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.src-row { display: flex; gap: 8px; }
.src-btn { flex: 1; background: var(--elev); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 12px; font-size: 14px; cursor: pointer; }
.src-btn.active { border-color: var(--accent); color: var(--accent); font-weight: 800; }
.src-btn.flip { flex: 0 0 auto; }
.onair { display: flex; align-items: center; gap: 12px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  flex-wrap: wrap; }
.onair-meta { flex: 1; min-width: 0; }
.onair-meta strong { display: block; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.onair-ctl { display: flex; gap: 8px; align-items: center; }
.ctl { width: 44px; height: 42px; border: 1px solid var(--border); background: var(--elev);
  color: var(--text); border-radius: 10px; cursor: pointer; font-size: 17px; }
.ctl.off { background: rgba(248,40,90,.15); border-color: rgba(248,40,90,.4); }

/* ===== 채팅 (공용) ===== */
.chat { display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  min-height: 200px; max-height: 320px; }
.chat-list { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex;
  flex-direction: column; gap: 7px; }
.chat-msg { font-size: 13.5px; line-height: 1.45; word-break: break-word; }
.chat-msg b { color: var(--accent); margin-right: 6px; font-size: 12.5px; }
.chat-msg.sys { color: var(--dim); font-size: 12px; }
.chat-form { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--border); }
.chat-form .send { width: 46px; border: 0; border-radius: 9px; background: var(--accent);
  color: #04222b; font-size: 17px; cursor: pointer; }

/* ===== 시청 ===== */
#view-watch { flex-direction: row; height: 100dvh; }
.watch-stage { position: relative; flex: 1; background: #000; min-width: 0; }
#watch-video { width: 100%; height: 100%; object-fit: contain; }
.watch-top { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 10px;
  align-items: center; padding: 12px 14px;
  background: linear-gradient(rgba(0,0,0,.65), transparent); }
.watch-title { flex: 1; font-weight: 800; font-size: 14.5px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.viewers { font-size: 12.5px; background: rgba(0,0,0,.45); border-radius: 999px;
  padding: 4px 10px; }
.watch-ended { position: absolute; inset: 0; background: rgba(5,8,13,.92); display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.unmute-cta { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  background: rgba(0,0,0,.75); color: #fff; border: 1px solid rgba(255,255,255,.4);
  border-radius: 999px; padding: 13px 22px; font-size: 15px; font-weight: 800; cursor: pointer; }
.react-bar { position: absolute; bottom: calc(14px + var(--safe-b)); left: 50%;
  transform: translateX(-50%); display: flex; gap: 8px;
  background: rgba(10,14,22,.78); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 10px; backdrop-filter: blur(8px); }
.react-bar button { background: none; border: 0; font-size: 22px; cursor: pointer;
  padding: 4px 6px; transition: transform .1s; }
.react-bar button:active { transform: scale(1.35); }
.chat-toggle { font-size: 19px !important; }

/* 플로팅 리액션 */
.reactions { position: absolute; right: 18px; bottom: 70px; width: 60px; height: 55%;
  pointer-events: none; overflow: hidden; }
.float-emo { position: absolute; bottom: -36px; left: 50%; font-size: 28px;
  animation: floatUp 2.6s ease-out forwards; }
@keyframes floatUp {
  0%   { transform: translate(-50%, 0) scale(.7); opacity: 0; }
  12%  { opacity: 1; transform: translate(-50%, -8%) scale(1.1); }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), -480px) scale(1); opacity: 0; }
}

/* 시청 채팅: 데스크톱 사이드 / 모바일 오버레이 시트 */
.watch-chat { width: 340px; background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; }
.chat-head { display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 800;
  font-size: 14px; }
.chat-head button { background: none; border: 0; color: var(--dim); font-size: 15px;
  cursor: pointer; display: none; }
.watch-chat .chat-form { padding-bottom: calc(8px + var(--safe-b)); }

@media (max-width: 820px) {
  #view-watch { flex-direction: column; }
  .watch-chat { position: fixed; inset: auto 0 0 0; height: 55dvh; width: auto;
    border-left: 0; border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0; transform: translateY(105%);
    transition: transform .22s ease; z-index: 30;
    box-shadow: 0 -12px 36px rgba(0,0,0,.5); }
  .watch-chat.open { transform: translateY(0); }
  .chat-head button { display: block; }
  .studio-main { padding: 10px; }
}
@media (min-width: 821px) {
  .chat-toggle { display: none; }
  .studio-main { display: grid; grid-template-columns: 1fr 360px; align-items: start; }
  .stage { grid-row: span 2; }
}
