/* ══════════════════════════════════════════════════════════
   Watch Cam · Twitch-style Design System
   Neutral dark surfaces, purple accent for interactions.
   Red reserved for LIVE / recording / error states.
   No webfonts (LAN-safe).
   ══════════════════════════════════════════════════════════ */

:root {
  /* surfaces */
  --bg: #0e0e10;
  --bg-deep: #0a0a0b;
  --panel: #18181b;
  --card: #1f1f23;
  --card-hover: #2a2a2e;

  /* lines */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* text */
  --fg: #efeff1;
  --muted: #adadb8;
  --faint: #77777f;

  /* accent: purple (interactive). red = LIVE / recording / error only */
  --accent: #9147ff;
  --accent-hover: #772ce8;
  --accent-soft: rgba(145, 71, 255, 0.16);
  --accent-glow: rgba(145, 71, 255, 0.4);
  --live: #f43f5e;
  --live-soft: rgba(244, 63, 94, 0.14);
  --live-glow: rgba(244, 63, 94, 0.35);

  /* shape + depth */
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 24px -8px rgba(0, 0, 0, 0.55),
               0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 48px -16px rgba(0, 0, 0, 0.7);
  --inset-line: inset 0 1px 0 rgba(255, 255, 255, 0.05);

  /* motion */
  --ease: cubic-bezier(0.2, 0, 0.2, 1);

  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", "JetBrains Mono", monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--bg-deep);
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}

/* ── header ─────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 22px;
  background: rgba(18, 18, 20, 0.8);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--fg);
  text-decoration: none;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 10px var(--live-glow), 0 0 20px rgba(244, 63, 94, 0.18);
  flex: none;
  animation: pulse 2.4s var(--ease) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.82); }
}

.site-nav {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: color 0.15s var(--ease), background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.site-nav a:hover {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
}

body.page-live .site-nav a[data-page="live"],
body.page-recents .site-nav a[data-page="recents"],
body.page-archive .site-nav a[data-page="archive"] {
  color: var(--fg);
  background: var(--card);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.nav-icon {
  width: 15px;
  height: 15px;
  flex: none;
  opacity: 0.85;
}

.logout-link {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: var(--muted);
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.logout-link:hover { color: var(--fg); background: rgba(255, 255, 255, 0.05); }
.logout-link .nav-icon { width: 17px; height: 17px; }

/* ── layout ─────────────────────────────────────────── */
main {
  padding: 22px;
  max-width: 1280px;
  margin: 0 auto;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.section-hint {
  font-size: 12px;
  color: var(--faint);
  margin: 0;
}

/* ── live player ────────────────────────────────────── */
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.4),
              0 0 48px -20px var(--accent-glow);
}

.video-wrap .video-js {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  font-size: 14px;
}

.video-wrap .vjs-tech { object-fit: contain; }

/* video.js skin */
.video-js .vjs-control-bar {
  background: linear-gradient(to top, rgba(7, 10, 15, 0.85), rgba(7, 10, 15, 0.45));
  backdrop-filter: blur(6px);
  font-size: 13px;
}
.video-js .vjs-play-progress,
.video-js .vjs-volume-level { background-color: var(--accent); }
.video-js .vjs-play-progress::before { color: var(--accent); text-shadow: 0 0 6px var(--accent-glow); }
.video-js .vjs-progress-holder { height: 4px; }
.video-js .vjs-progress-control:hover .vjs-progress-holder { font-size: 1.6em; }
.video-js .vjs-load-progress div { background: rgba(255, 255, 255, 0.12); }
.video-js .vjs-live-control,
.video-js .vjs-live-display { color: var(--live); font-weight: 700; letter-spacing: 0.5px; }
.video-js .vjs-seek-to-live-control { display: none; }
.video-js .vjs-big-play-button {
  background: rgba(18, 18, 20, 0.72) !important;
  border-color: var(--accent) !important;
  border-radius: 50% !important;
  width: 64px !important;
  height: 64px !important;
  line-height: 64px !important;
  backdrop-filter: blur(8px);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.video-js:hover .vjs-big-play-button {
  background: rgba(145, 71, 255, 0.55) !important;
  box-shadow: 0 0 32px var(--accent-glow);
  transform: scale(1.06);
}

/* LIVE badge */
.live-status {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.92), rgba(214, 45, 79, 0.92));
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  font: 700 11px/1 var(--sans);
  letter-spacing: 1.2px;
  cursor: pointer;
  z-index: 2;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(244, 63, 94, 0.45);
}
.live-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.6s var(--ease) infinite;
}
.live-status.behind {
  background: rgba(14, 14, 16, 0.8);
  color: var(--fg);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.live-status.behind::before { background: var(--muted); animation: none; }
.live-status.connecting {
  background: rgba(14, 14, 16, 0.8);
  color: var(--muted);
  border-color: var(--border);
  cursor: default;
  box-shadow: none;
}
.live-status.connecting::before { background: var(--faint); }
.live-status .label { font-variant-numeric: tabular-nums; }

/* error overlay */
.video-error {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(7, 10, 15, 0.86);
  backdrop-filter: blur(6px);
  text-align: center;
  padding: 24px;
  font-size: 14px;
}
.video-error[hidden] { display: none; }
.video-error p { margin: 0; color: var(--fg); }
.video-error button {
  background: var(--accent);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 9px 22px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(244, 63, 94, 0.4);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.video-error button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(244, 63, 94, 0.55);
}

/* ── hour bundles ───────────────────────────────────── */
.hours {
  padding: 26px 0 40px;
}

.hour-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 14px;
}

.hour-card {
  background: linear-gradient(180deg, var(--card-hover), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm), var(--inset-line);
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease),
              box-shadow 0.18s var(--ease);
}
.hour-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md), var(--inset-line);
}

.hour-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
}

.hour-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg);
  font-family: var(--mono);
  letter-spacing: 0.3px;
}

.hour-count {
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
  font-family: var(--mono);
}

.hour-bundle {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #000;
  display: block;
  border-top: 1px solid var(--border);
}

/* ── archive ────────────────────────────────────────── */
.archive-grid {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.archive-card {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.archive-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm), var(--inset-line);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.15s var(--ease);
}
.archive-card:hover .archive-thumb {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.archive-card:hover .archive-thumb img { transform: scale(1.05); }
.archive-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s var(--ease);
}
.archive-thumb .badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 7px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 5px;
  color: var(--fg);
  font: 600 11px/1.4 var(--mono);
  letter-spacing: 0.3px;
}

.archive-name {
  display: block;
  margin-top: 8px;
  font: 600 12.5px/1.4 var(--mono);
  letter-spacing: 0.3px;
  color: var(--muted);
}
.archive-card:hover .archive-name { color: var(--fg); }

#archive-player {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 10px;
  width: min(960px, 94vw);
  box-shadow: var(--shadow-lg);
}
#archive-player::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}
#archive-player video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-sm);
}
#archive-player .dialog-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--fg);
  font-size: 14px;
  cursor: pointer;
}
#archive-player .dialog-close:hover { background: var(--card-hover); }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 20px;
  background: var(--panel);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  line-height: 1.7;
}

/* ── login ──────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
  background:
    radial-gradient(700px 420px at 50% 18%, rgba(145, 71, 255, 0.08), transparent 70%),
    var(--bg);
}

.login-form {
  background: linear-gradient(180deg, var(--card-hover), var(--panel));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 352px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-lg), var(--inset-line);
}

.login-form h1 {
  margin: 0 0 2px 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.login-form .sub {
  margin: 0 0 6px 0;
  text-align: center;
  font-size: 12px;
  color: var(--faint);
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.login-form input {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  min-height: 44px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.login-form input::placeholder { color: var(--faint); }
.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-form button {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 4px;
  box-shadow: 0 4px 18px rgba(145, 71, 255, 0.35);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.login-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(145, 71, 255, 0.5);
}

.error {
  background: var(--live-soft);
  border: 1px solid rgba(244, 63, 94, 0.4);
  color: #fda4af;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin: 0;
  font-size: 12px;
  text-align: center;
}
.tab-bar {
  left: 0;
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: none;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  background: rgba(10, 10, 11, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}

.tab-bar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 48px;
  border-radius: 12px;
  color: var(--faint);
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.tab-bar a:hover { color: var(--muted); }
.tab-bar .tab-icon { width: 20px; height: 20px; }

body.page-live .tab-bar a[data-page="live"],
body.page-recents .tab-bar a[data-page="recents"],
body.page-archive .tab-bar a[data-page="archive"] {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ── responsive ─────────────────────────────────────── */
@media (max-width: 1024px) {
  main { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 768px) {
  .site-header { padding: 10px 16px; }
  .site-nav { display: none; }          /* replaced by tab bar */
  .tab-bar { display: flex; }
  body { padding-bottom: 64px; }

  main { padding: 14px; }
  .hours { padding: 10px 0 18px; }

  .video-wrap { border-radius: var(--radius-sm); }
  .section-hint { display: none; }
  .hour-grid { gap: 10px; }
  .archive-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .login-form { padding: 28px 22px; }
}

@media (max-width: 480px) {
  .hour-grid { grid-template-columns: 1fr; }
  .live-status { top: 8px; right: 8px; padding: 5px 10px; }
}
