:root {
  --bg: #0d0d10;
  --surface: #17171c;
  --text: #ececf0;
  --muted: #9a9aa6;
  --accent: #e50914;
  --line: #2a2a32;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; }
a { color: inherit; text-decoration: none; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 10; }
.brand { font-weight: 800; font-size: 20px; color: var(--accent); }
.nav { display: flex; gap: 18px; margin-left: auto; }
.nav a { color: var(--muted); }
.nav a:hover { color: var(--text); }

.app { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; color: inherit; }
.card .poster { aspect-ratio: 2/3; background: #222; display: block; width: 100%; object-fit: cover; }
.card .meta { padding: 10px 12px; }
.card .title { font-weight: 600; font-size: 14px; margin: 0 0 6px; }
.card .sub { color: var(--muted); font-size: 12px; }

.badge { display: inline-block; font-size: 11px; padding: 2px 6px; border-radius: 6px; background: #2b2b33; color: #cfcfe0; }
.badge.ai { background: #1d3b5a; color: #9cd0ff; }
.badge.deepfake { background: #5a1d1d; color: #ff9c9c; }

.btn { display: inline-block; padding: 10px 16px; border-radius: 10px; background: var(--accent); color: #fff; border: none; font-weight: 600; cursor: pointer; }
.btn.secondary { background: #2a2a32; }

.player-wrap { max-width: 900px; margin: 0 auto; }
video { width: 100%; border-radius: var(--radius); background: #000; }
.label-overlay { position: absolute; top: 10px; left: 10px; pointer-events: none; }

/* Shorts vertical feed */
.shorts { max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.short { position: relative; aspect-ratio: 9/16; background: var(--surface); border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.short .thumb { width: 100%; height: 100%; object-fit: cover; }
.short.spoiler .thumb { filter: blur(22px); transform: scale(1.1); }
.short .overlay-text { position: absolute; bottom: 16px; left: 16px; right: 16px; font-weight: 700; text-shadow: 0 1px 4px #000; }

.dialog-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; }
.dialog { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; max-width: 360px; text-align: center; }
.dialog p { color: var(--text); }
.dialog .row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

.muted { color: var(--muted); }
.center { text-align: center; padding: 40px 0; }
.error { color: #ff9c9c; }
.field { display: block; width: 100%; padding: 10px; margin: 6px 0 14px; border-radius: 8px; border: 1px solid var(--line); background: #101015; color: var(--text); }

/* Language toggle */
.lang-toggle { background: #2a2a32; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.lang-toggle:hover { background: #34343e; }

/* Editor — region picker visual bar */
.range-bar { position: relative; height: 10px; border-radius: 6px; background: #101015; border: 1px solid var(--line); margin: 6px 0; overflow: hidden; }
.range-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--accent); border-radius: 6px; }

/* Editor — fork→publish→process stepper */
.stepper { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.step-chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #1d1d24; color: var(--muted); border: 1px solid var(--line); }
.step-chip.active { background: #1d3b5a; color: #9cd0ff; border-color: #2a5680; }
.step-chip.done { background: #1d3a25; color: #9cffb0; border-color: #2a6840; }

/* Shared progress bar (editor jobs, upload bytes) */
.progress-bar { height: 8px; border-radius: 6px; background: #101015; border: 1px solid var(--line); margin: 10px 0; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }

/* Production-method ("제작 방식") panel */
.production-panel .badges { min-height: 22px; }

/* Highlight the deepfake attestation when it becomes required */
.labeled.required .field { border-color: var(--accent); }

/* ── Accessibility: skip link + focus states ───────────────────────────── */
.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 8px;
  transition: top .15s ease;
}
.skip-link:focus { top: 8px; }

:focus-visible { outline: 2px solid #9cd0ff; outline-offset: 2px; border-radius: 6px; }
.card:focus-visible { outline-offset: -2px; }
#app:focus { outline: none; }
.nav a:focus-visible, .btn:focus-visible, .lang-toggle:focus-visible { outline-offset: 3px; }

/* ── Shared loading / empty / error states ─────────────────────────────── */
.state { padding: 40px 0; }
.state-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { position: relative; background: #1d1d24; overflow: hidden; border-radius: 6px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
  transform: translateX(-100%); animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skeleton-card { cursor: default; }
.skeleton-line { height: 12px; margin: 0 0 8px; }
.skeleton-line.short { width: 55%; }

/* ── Dialog title (accessible modal) ───────────────────────────────────── */
.dialog-title { margin: 0 0 8px; font-size: 16px; }

/* ── Responsive nav (CSS-only collapse) ────────────────────────────────── */
.hamburger { display: none; }
.hamburger span, .hamburger span::before, .hamburger span::after {
  display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; position: relative;
}
.hamburger span::before, .hamburger span::after { content: ""; position: absolute; left: 0; }
.hamburger span::before { top: -7px; }
.hamburger span::after { top: 7px; }

/* ── Mobile-first breakpoints ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
  .nav { margin-left: 0; }
  .hamburger {
    display: flex; align-items: center; justify-content: center;
    margin-left: auto; width: 40px; height: 40px; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--line);
  }
  /* Collapsed by default; the hidden checkbox toggles it open. */
  .nav {
    flex-basis: 100%; flex-direction: column; gap: 4px;
    max-height: 0; overflow: hidden; transition: max-height .2s ease;
  }
  .nav-toggle:checked ~ .nav { max-height: 320px; }
  .nav a, .nav .lang-toggle { padding: 10px 4px; width: 100%; }

  .app { padding: 16px 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .shorts { max-width: 100%; }
  .short { aspect-ratio: 9/16; max-height: 88vh; }
  .dialog { max-width: 92vw; }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .player-wrap { max-width: 760px; }
}

/* ── Respect reduced-motion preferences ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
