:root {
  --bg: #0f0f0f;
  --panel: #181818;
  --panel-2: #222;
  --text: #f5f5f5;
  --muted: #aaa;
  --line: #303030;
  --primary: #ff0033;
  --primary-dark: #cc0029;
  --input: #121212;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

a { color: inherit; text-decoration: none; }
button { border: 0; cursor: pointer; font-family: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 64px;
  padding: 0 24px;
  background: rgba(15, 15, 15, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand, .auth-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 900;
}

.search-box {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 120px;
}

.search-box input {
  width: min(560px, 100%);
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 999px 0 0 999px;
  background: var(--input);
  color: var(--text);
  outline: none;
}

.search-box button {
  padding: 0 18px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 999px 999px 0;
  background: var(--panel-2);
  color: var(--text);
}

.top-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }

.ghost-btn, .primary-btn, .logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 700;
}

.ghost-btn { border: 1px solid var(--line); background: transparent; color: var(--text); }
.primary-btn { background: var(--primary); color: white; }
.primary-btn:hover { background: var(--primary-dark); }
.logout-btn { background: var(--panel-2); color: var(--text); }

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  padding: 24px;
}

.sidebar {
  position: sticky;
  top: 88px;
  height: calc(100vh - 100px);
  padding: 10px;
  border-right: 1px solid var(--line);
}

.side-item {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 4px;
}

.side-item:hover, .side-item.active { background: var(--panel-2); }

.section-head { margin-bottom: 22px; }
.section-head h1 { margin: 0 0 6px; font-size: 28px; }
.section-head p { margin: 0; color: var(--muted); }

.video-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 26px 18px;
}

.video-card { min-width: 0; transition: transform 0.15s ease; }
.video-card:hover { transform: translateY(-3px); }

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 14px;
  background: linear-gradient(135deg, #2b2b2b, #111);
  border: 1px solid var(--line);
}

.thumb img { width: 100%; height: 100%; object-fit: cover; }

.duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.8);
  font-size: 12px;
}

.video-card h2 { margin: 10px 0 6px; font-size: 16px; line-height: 1.35; }
.video-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.video-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.video-tag {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #272727;
  color: #cfcfcf;
  font-size: 12px;
}

.no-result {
  grid-column: 1 / -1;
  padding: 50px 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
}

.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 24px;
  padding: 24px;
}

.player-box { width: 100%; background: black; border-radius: 14px; overflow: hidden; }
video { display: block; width: 100%; aspect-ratio: 16 / 9; background: black; }

.video-info { padding: 18px 2px; border-bottom: 1px solid var(--line); }
.video-info h1 { margin: 0 0 8px; font-size: 24px; }
.video-info p { margin: 6px 0; color: var(--muted); }

.comments { padding-top: 18px; }
.comments-head { display: flex; align-items: center; gap: 10px; }
.comments h2, .recommend h2 { margin: 0 0 14px; font-size: 20px; }
.comments-head span { color: var(--muted); }

.comment-form { display: flex; gap: 10px; margin: 14px 0 22px; }

.comment-form input {
  flex: 1;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--input);
  color: var(--text);
  outline: none;
}

.comment-form button {
  padding: 0 18px;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-weight: 800;
}

.comment { padding: 14px 0; border-bottom: 1px solid var(--line); }
.comment strong { display: block; margin-bottom: 6px; }
.comment p { margin: 0; line-height: 1.55; }

.timestamp { color: #3ea6ff; font-weight: 800; cursor: pointer; }

.recommend-card {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.recommend-card .thumb { border-radius: 10px; }
.recommend-card h3 { margin: 0 0 6px; font-size: 14px; line-height: 1.35; }
.recommend-card p { margin: 0; color: var(--muted); font-size: 12px; }

.auth-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.auth-card.wide { width: min(560px, 100%); }
.auth-logo { margin-bottom: 26px; }
.auth-card h1 { margin: 0 0 8px; font-size: 28px; }
.auth-desc { margin: 0 0 24px; color: var(--muted); line-height: 1.5; }

.form { display: grid; gap: 16px; }
.form label { display: grid; gap: 8px; font-weight: 700; }

.form input, .admin-form textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--input);
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.admin-form textarea { min-height: 140px; resize: vertical; }

.full { width: 100%; margin-top: 4px; }

.auth-bottom { margin: 22px 0 0; color: var(--muted); text-align: center; }
.auth-bottom a { color: #3ea6ff; font-weight: 800; }

.policy-box {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #111;
}

.policy-box h2 { margin: 0 0 8px; font-size: 16px; }
.policy-box p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 14px; }

.checkbox-row { display: flex !important; align-items: center; gap: 10px !important; }
.checkbox-row input { width: 18px; height: 18px; }

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  padding: 24px;
}

.admin-panel, .admin-help {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  padding: 24px;
}

.admin-help h2 { margin: 0 0 14px; font-size: 20px; }
.admin-help ol { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.9; }

.user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1180px) {
  .video-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .watch-layout { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .admin-layout { grid-template-columns: 1fr; padding: 14px; }
}

@media (max-width: 820px) {
  .topbar { height: auto; padding: 14px; flex-wrap: wrap; }
  .brand { width: 100%; }
  .search-box { order: 3; width: 100%; }
  .top-actions { margin-left: auto; }
  .layout { grid-template-columns: 1fr; padding: 14px; }
  .sidebar {
    position: static;
    height: auto;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0 0 12px;
  }
  .side-item { white-space: nowrap; }
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
  .watch-layout { padding: 14px; }
  .recommend-card { grid-template-columns: 140px 1fr; }
}

@media (max-width: 520px) {
  .video-grid { grid-template-columns: 1fr; }
  .recommend-card { grid-template-columns: 120px 1fr; }
  .auth-card { padding: 24px; }
}


/* Modal login */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(10px);
}

.login-modal {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(24, 24, 24, 0.96);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
}

.login-modal h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.modal-logo {
  margin-bottom: 24px;
}

.modal-close {
  position: absolute;
  right: 16px;
  top: 14px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

body.modal-open {
  overflow: hidden;
}

.locked-player {
  position: relative;
}

.locked-player video {
  filter: blur(8px) brightness(0.42);
  pointer-events: none;
}

.player-lock {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.18);
}

.locked-player .player-lock {
  display: flex;
}

.lock-card {
  width: min(360px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(24, 24, 24, 0.9);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.lock-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 20px;
}

.lock-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}


/* Admin video management */
.wide-admin {
  grid-template-columns: minmax(320px, 460px) minmax(0, 1fr);
}

.admin-list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.admin-video-list {
  display: grid;
  gap: 12px;
}

.admin-video-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #131313;
}

.admin-video-row .thumb {
  border-radius: 10px;
}

.admin-video-info h3 {
  margin: 0 0 6px;
  font-size: 16px;
  line-height: 1.35;
}

.admin-video-info p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.admin-video-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 700;
  background: #8b1e2d;
  color: white;
}

.danger-btn:hover {
  background: #a62638;
}

.edit-modal {
  width: min(620px, 100%);
  max-height: 90vh;
  overflow: auto;
}

@media (max-width: 1080px) {
  .wide-admin {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .admin-video-row {
    grid-template-columns: 1fr;
  }

  .admin-video-actions {
    justify-content: flex-start;
  }
}
