:root {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-alt: #161b22;
  --bg-card: #1f242c;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #2f81f7;
  --accent-hover: #1f6feb;
  --danger: #f85149;
  --success: #3fb950;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* display: flex 등이 걸린 오버레이/모달이라도 hidden 속성을 항상 우선시킨다. */
[hidden] { display: none !important; }

body.siteBody {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
body.siteBody.centerLayout { display: flex; align-items: center; justify-content: center; }

.pageWrap { max-width: 1200px; margin: 0 auto; padding: 32px 24px 80px; }

/* nav */
.topNav, .publicNav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.navBrand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit; font-weight: 600;
}
.navLogo { font-size: 22px; }
.navTitle { font-size: 16px; }
.navUser { position: relative; }
.navUserButton {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.navUserButton:hover { background: var(--bg-card); }
.navUserMenu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px; min-width: 160px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.4); z-index: 50;
}
.navUserMenu form { margin: 0; }
.dangerLink {
  background: transparent; border: none; color: var(--danger); cursor: pointer;
  padding: 6px 8px; font-size: 14px; width: 100%; text-align: left;
}
.dangerLink:hover { background: rgba(248,81,73,0.1); border-radius: 6px; }

/* generic */
.hero h1 { margin: 8px 0 8px; font-size: 30px; }
.hero p { color: var(--text-muted); margin: 0 0 24px; }
.muted { color: var(--text-muted); font-size: 13px; text-decoration: none; }

.primaryButton, .secondaryButton, .dangerButton {
  border-radius: 8px; padding: 9px 16px; font-size: 14px; cursor: pointer;
  border: 1px solid transparent; text-decoration: none; display: inline-block;
}
.primaryButton { background: var(--accent); color: white; }
.primaryButton:hover { background: var(--accent-hover); }
.secondaryButton { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.secondaryButton:hover { background: var(--bg-alt); }
.dangerButton { background: var(--danger); color: white; }

.dashboardHeader {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.dashboardActions { display: flex; gap: 8px; flex-wrap: wrap; }

/* folder grid */
.folderGrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.folderCard {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: transform .08s ease;
}
.folderCard:hover { transform: translateY(-2px); border-color: var(--accent); }
.folderCardLink {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-decoration: none; color: inherit;
}
.folderIcon { font-size: 40px; }
.folderName { font-size: 15px; word-break: break-all; text-align: center; }

/* video grid */
.videoGrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.videoCard {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; padding: 0; text-align: left;
  font: inherit;
}
.videoCard:hover { border-color: var(--accent); }
.videoThumb {
  aspect-ratio: 16/9; background: linear-gradient(135deg, #1f242c, #0d1117);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; color: var(--accent);
}
.videoTitle { padding: 10px 12px; font-size: 14px; }

/* login */
.loginCard {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px; min-width: 320px;
}
.loginForm { display: flex; flex-direction: column; gap: 14px; }
.loginForm label { display: flex; flex-direction: column; gap: 6px; }
.loginForm input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 10px 12px; font-size: 14px;
}
.errorBanner {
  background: rgba(248,81,73,0.15); border: 1px solid var(--danger);
  color: #ffb1ab; padding: 10px 12px; border-radius: 8px; font-size: 13px;
}

/* context menu */
.ctxMenu {
  position: fixed; z-index: 100; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.4); min-width: 160px;
}
.ctxMenu button {
  display: block; width: 100%; text-align: left; background: transparent;
  border: none; color: var(--text); padding: 8px 10px; font-size: 13px;
  border-radius: 6px; cursor: pointer;
}
.ctxMenu button:hover { background: var(--bg-alt); }

.flashToast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 12px);
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 18px; font-size: 14px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  opacity: 0; transition: opacity 180ms ease, transform 180ms ease;
  z-index: 300; pointer-events: none;
}
.flashToast.show { opacity: 1; transform: translate(-50%, 0); }

/* modal */
.modalOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modalCard {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px; min-width: 320px;
}
.modalCard h2 { margin: 0 0 16px; font-size: 18px; }
.modalCard label { display: flex; flex-direction: column; gap: 6px; }
.modalCard input[type="text"] {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 10px 12px; font-size: 14px;
}
.modalActions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* player modal */
.playerOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center; z-index: 300;
}
.playerModal {
  position: relative; background: #000; border-radius: 12px;
  width: min(960px, 92vw); max-height: 92vh; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.playerClose {
  position: absolute; top: 8px; right: 12px; background: transparent;
  border: none; color: white; font-size: 22px; cursor: pointer; z-index: 1;
}
.playerTitle { color: white; font-size: 16px; margin-right: 36px; }
.playerModal video { width: 100%; max-height: 80vh; background: #000; }

.standalonePlayer { background: #000; border-radius: 10px; padding: 12px; }
.standalonePlayer video { width: 100%; max-height: 80vh; }

/* editor */
.editorNav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; background: var(--bg-alt);
  border-bottom: 1px solid var(--border); gap: 12px;
}
.editorNavLeft { display: flex; align-items: center; gap: 16px; flex: 1; }
.editorNavRight { display: flex; gap: 8px; }
.titleInput {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 8px 12px; font-size: 15px; min-width: 280px;
  flex: 1; max-width: 480px;
}
.editorMain { padding: 24px; }
.editorStage { max-width: 1200px; margin: 0 auto; }
.dropZone {
  background: var(--bg-card); border: 2px dashed var(--border);
  border-radius: 12px; padding: 40px; text-align: center;
  display: flex; flex-direction: column; gap: 14px; align-items: center;
}
.dropZone.dragOver { border-color: var(--accent); background: rgba(47,129,247,0.08); }
.dropTitle { font-size: 18px; margin: 0; }
.ytRow {
  display: flex; gap: 8px; width: 100%; max-width: 640px; flex-wrap: wrap;
}
.ytRow input {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 10px 12px; font-size: 14px;
  min-width: 240px;
}
#downloadProgress { width: 100%; max-width: 640px; height: 8px; }

.videoPanel { display: flex; flex-direction: column; gap: 16px; }
.videoPanel video {
  width: 100%; max-height: 60vh; background: #000; border-radius: 10px;
}
.trimTimeline {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.trimTimelineHeader {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.timeReadout {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px; color: var(--text);
}
.trimTimelineActions { display: flex; gap: 6px; flex-wrap: wrap; }
.trimTimelineActions button {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.trimTimelineActions button:hover { background: var(--bg-alt); border-color: var(--accent); }
.trimBar {
  position: relative; height: 44px; margin: 8px 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  user-select: none; touch-action: none; cursor: pointer;
}
.trimRangeFill {
  position: absolute; top: 0; bottom: 0;
  background: rgba(47, 129, 247, 0.22);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  pointer-events: none;
}
.trimHandle {
  position: absolute; top: -6px; bottom: -6px;
  width: 14px; margin-left: -7px;
  background: var(--accent); border-radius: 4px;
  cursor: ew-resize;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  z-index: 2;
}
.trimHandle:hover, .trimHandle.dragging { background: var(--accent-hover); }
.trimHandle::before {
  content: ''; width: 2px; height: 60%; background: rgba(255,255,255,0.85);
  border-radius: 1px;
}
.trimPlayhead {
  position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px;
  background: #ffffff; pointer-events: none;
  box-shadow: 0 0 4px rgba(255,255,255,0.45);
  z-index: 1;
}
.trimNumericRow {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.trimNumericRow label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted);
}
.trimNumericRow input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 6px 10px; font-size: 14px; width: 110px;
}
.trimDuration {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; color: var(--text-muted);
}
.adminFolder { position: relative; }
.adminVideo { position: relative; }
