:root {
  --bg: #0d0f12;
  --panel: #171a1f;
  --panel-2: #1f242b;
  --line: #2b313a;
  --fg: #e8ecf1;
  --muted: #929cab;
  --accent: #4c9aff;
  --live: #35d07f;
  --warn: #ffb020;
  --bad: #ff5c5c;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-text-size-adjust: 100%;
}

button, input { font: inherit; }

/* ── 로그인 ───────────────────────────────────────────── */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.login-card p.sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.85rem;
}

.field { position: relative; display: block; margin-bottom: 12px; }

.field input {
  width: 100%;
  padding: 12px 44px 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--fg);
  outline: none;
}

.field input:focus { border-color: var(--accent); }

/* 비밀번호 표시 토글 — 제출 버튼과 헷갈리지 않게 아이콘만 둔다 */
.reveal {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.reveal:hover { color: var(--fg); background: rgba(255, 255, 255, 0.06); }
.reveal:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #06121f;
  border: 0;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.btn:disabled { opacity: 0.55; cursor: progress; }

.msg { margin: 12px 0 0; font-size: 0.85rem; min-height: 1.2em; color: var(--bad); }

/* ── 뷰어 ─────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.topbar h1 { margin: 0; font-size: 0.95rem; font-weight: 600; }

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

/* 맥박(심장박동) 애니메이션은 산만해서 뺐다 — 색만으로 충분히 구분된다. */
.dot.live { background: var(--live); }
.dot.error { background: var(--bad); }

.spacer { flex: 1 1 auto; }

.pill {
  font-size: 0.75rem;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* 버튼 숨김 모드 — 영상만 남는다. 화면을 누르면 되돌아온다. */
.app.chrome-hidden .topbar,
.app.chrome-hidden .toolbar { display: none; }

.hint {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 2;
  margin: 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(8, 10, 13, 0.85);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 0.8rem;
  pointer-events: none;
  white-space: nowrap;
}

.hint[hidden] { display: none; }

.stage {
  flex: 1 1 auto;
  position: relative;
  background: #000;
  min-height: 0;
  overflow: hidden;
}

/* grid + place-items 로 가운데 정렬하면 <video> 가 자기 비율대로 커져서
   영역을 넘치고 아래 툴바를 덮는다. absolute 로 영역에 딱 맞춘 뒤
   object-fit 으로 비율을 지키는 편이 확실하다. */
video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

/* 원본 크기 모드 — 640x480 을 억지로 늘리지 않아 훨씬 또렷하다.
   화면보다 크면 줄어들기만 한다(max-*). */
.stage.native video {
  inset: auto;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  background: rgba(8, 10, 13, 0.82);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.overlay[hidden] { display: none; }
.overlay { cursor: pointer; }
.overlay:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }

.overlay strong { display: block; color: var(--fg); margin-bottom: 6px; font-size: 1rem; }

.spinner {
  width: 26px; height: 26px;
  margin: 0 auto 12px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
  overflow-x: auto;
}

.tool {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 9px;
  padding: 9px 13px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.tool:hover { border-color: var(--accent); }
.tool.ghost { color: var(--muted); }
.tool:disabled { cursor: default; opacity: 0.7; }
.tool:disabled:hover { border-color: var(--line); }

