:root {
  color-scheme: dark;
  --bg: #08090b;
  --panel: #111317;
  --line: rgba(255,255,255,.11);
  --text: #f4f4f2;
  --muted: #8b9099;
  --accent: #ff496d;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  background:
    radial-gradient(circle at 50% -20%, rgba(255,73,109,.16), transparent 38%),
    var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(20px, 4vw, 30px); letter-spacing: -.035em; }
.lock {
  min-height: 100vh; display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}
.lock-card {
  width: min(100%, 360px); padding: 34px 30px 30px; text-align: center;
  border: 1px solid var(--line); border-radius: 28px;
  background: rgba(17,19,23,.88); backdrop-filter: blur(22px);
  box-shadow: 0 30px 90px rgba(0,0,0,.48);
}
.mark {
  display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 22px;
  border-radius: 18px; background: var(--accent); color: white;
  font: 800 25px/1 Georgia, serif; box-shadow: 0 12px 36px rgba(255,73,109,.3);
}
.hint { margin: 10px 0 25px; color: var(--muted); }
.dots { height: 18px; display: flex; justify-content: center; gap: 13px; margin-bottom: 25px; }
.dots i {
  width: 10px; height: 10px; border-radius: 50%; border: 1px solid #61656d;
  transition: .16s ease;
}
.dots i.filled { border-color: var(--accent); background: var(--accent); transform: scale(1.12); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.key, .control, .ghost {
  border: 1px solid var(--line); background: rgba(255,255,255,.045); cursor: pointer;
}
.key {
  height: 58px; border-radius: 18px; font-size: 20px; font-weight: 650;
}
.key:active, .control:active { transform: scale(.94); background: rgba(255,73,109,.18); }
.error { min-height: 22px; margin: 15px 0 -8px; color: #ff7892; font-size: 13px; }
.shake { animation: shake .4s ease; }
@keyframes shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }

main { width: min(100%, 1240px); margin: 0 auto; padding: 18px 18px 110px; }
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(4px, env(safe-area-inset-top)) 2px 16px;
}
.ghost {
  display: flex; align-items: center; gap: 7px;
  border-radius: 12px; padding: 9px 13px; color: #b7bbc2;
}
.ghost svg {
  width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.stage {
  position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 22px;
  background: #000; box-shadow: 0 24px 70px rgba(0,0,0,.42); touch-action: none;
}
.video-frame { position: relative; width: 100%; aspect-ratio: 16/9; }
.video-frame video-stream { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage:fullscreen {
  display: grid; place-items: center; width: 100%; height: 100%;
  border: 0; border-radius: 0; background: #000;
}
.stage:fullscreen::backdrop { background: #101216; }
.stage:fullscreen .video-frame { width: 100%; aspect-ratio: 16/9; }
.connecting { position: absolute; inset: 0; display: grid; place-items: center; color: #777c84; }
.live-pill {
  position: absolute; top: 14px; left: 14px; display: flex; align-items: center; gap: 7px;
  padding: 7px 10px; border-radius: 999px; background: rgba(5,6,8,.68);
  backdrop-filter: blur(10px); font-size: 11px; font-weight: 800; letter-spacing: .08em;
}
.live-pill i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  animation: liveBlink 1.35s ease-in-out infinite;
}
.media-controls {
  position: absolute; right: 14px; bottom: 14px; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  width: auto; padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.18); border-radius: 14px;
  background: rgba(5,6,8,.78); backdrop-filter: blur(12px);
  touch-action: auto;
}
.media-controls[hidden] { display: none; }
.media-controls button {
  flex: 0 0 42px; width: 42px; height: 38px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.08);
  color: #fff; font-size: 22px; line-height: 1; cursor: pointer;
}
@keyframes liveBlink { 50% { opacity: .22; transform: scale(.72); } }
.controls {
  display: grid; justify-items: center; gap: 18px; margin-top: 25px; padding: 22px;
  border: 1px solid var(--line); border-radius: 22px; background: var(--panel);
}
.control {
  width: 58px; height: 58px; border-radius: 18px; font-size: 23px;
  transition: transform .1s, background .1s;
}
.control:disabled {
  opacity: .38; cursor: wait; transform: none; background: rgba(255,255,255,.025);
}
.control.protected {
  opacity: .32; cursor: not-allowed; color: #8b9099;
  background: rgba(255,255,255,.02);
}
.control.protected:active { transform: none; background: rgba(255,255,255,.04); }
.dpad { display: grid; grid-template: repeat(3, 58px) / repeat(3, 58px); gap: 7px; }
.up { grid-area: 1 / 2; } .left { grid-area: 2 / 1; } .center { grid-area: 2 / 2; }
.right { grid-area: 2 / 3; } .down { grid-area: 3 / 2; }
.center { margin: 14px; border: 1px solid var(--line); border-radius: 50%; background: var(--accent); opacity: .75; }
#ptzStatus { margin: -3px 0 0; color: var(--muted); font-size: 12px; }
.record-button {
  position: fixed; z-index: 80; left: 50%; bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  min-width: 150px; justify-content: center; padding: 14px 22px;
  border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
  color: #fff; background: #e5385d; font-weight: 750; cursor: pointer;
  box-shadow: 0 14px 40px rgba(229,56,93,.32);
}
.record-button i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.record-label { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.08; }
.record-label strong { font-size: 14px; font-weight: 800; }
.record-label small { margin-top: 4px; font-size: 10px; font-weight: 650; opacity: .78; }
.record-button:disabled { cursor: wait; opacity: .82; }
.record-button.recording { background: #7c4dff; }
.record-button.recording i { animation: recordPulse 1s ease-in-out infinite; }
@keyframes recordPulse { 50% { opacity: .28; transform: scale(.75); } }
.gallery { grid-column: 1 / -1; min-height: 55vh; }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.gallery-card {
  overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--panel);
}
.gallery-card video { display: block; width: 100%; aspect-ratio: 16/9; background: #000; }
.gallery-info { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; }
.gallery-info strong { font-size: 13px; font-weight: 650; }
.gallery-info span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.gallery-actions { display: flex; align-items: center; gap: 10px; }
.delete-clip {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 1px solid rgba(255,73,109,.3); border-radius: 9px;
  color: #ff7892; background: rgba(255,73,109,.08); cursor: pointer;
}
.delete-clip:disabled { opacity: .45; cursor: wait; }
.delete-clip svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.gallery-empty { padding: 18vh 20px; color: var(--muted); text-align: center; }
.moving-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-content: center; justify-items: center; gap: 16px;
  background: rgba(8,9,11,.8); color: #fff;
  font-size: 13px; font-weight: 700; letter-spacing: .06em;
  cursor: wait;
}
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.18);
  border-top-color: var(--accent);
  box-shadow: 0 0 28px rgba(255,73,109,.2);
  animation: spin .72s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 600px) {
  main { padding: 12px 10px 100px; }
  .stage, .controls { border-radius: 17px; }
  .controls { margin-top: 12px; padding: 16px; }
}
@media (min-width: 900px) {
  main {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    grid-template-rows: auto auto;
    align-content: center;
    gap: 18px;
    padding: 24px;
  }
  header { grid-column: 1 / -1; padding: 0 2px 2px; }
  .stage { grid-column: 1; align-self: start; }
  .controls {
    grid-column: 2; align-self: stretch;
    align-content: center; margin-top: 0; padding: 28px 20px;
  }
  .dpad { grid-template: repeat(3, 64px) / repeat(3, 64px); gap: 9px; }
  .control { width: 64px; height: 64px; border-radius: 20px; }
}
