:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --panel-2: #21252e;
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --accent: #ff4d4d;
  --border: #2c313c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

.muted { color: var(--muted); font-weight: 400; }

/* Top bar with sticky search */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand {
  margin: 0;
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--accent);
}

.search {
  flex: 1;
  max-width: 560px;
  padding: 10px 14px;
  font-size: 15px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
.search:focus { border-color: var(--accent); }

.adminlink { margin-left: auto; color: var(--muted); text-decoration: none; }

.shuffle {
  padding: 10px 18px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.shuffle:hover { border-color: var(--accent); color: var(--accent); }
.shuffle:active { transform: translateY(1px); }

/* Video grid — capped width and centered so it doesn't span very wide desktops */
main {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: block;
}

.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }

.card .title {
  font-size: 14px;
  line-height: 1.35;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .links { display: flex; gap: 14px; font-size: 13px; }
.card .links a { color: var(--muted); text-decoration: none; }
.card .links a:hover { color: var(--text); }
.card .links a.yt:hover { color: var(--accent); }

.card .links .info-btn {
  margin-left: auto;
  background: none;
  border: none;
  padding: 0;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.card .links .info-btn:hover { color: var(--text); }

#desc-dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 28px 22px;
  max-width: 540px;
  width: calc(100% - 40px);
  font-family: inherit;
}
#desc-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}
#desc-title {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}
#desc-body {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
  white-space: pre-wrap;
}
#desc-close {
  display: block;
  margin-left: auto;
  padding: 8px 20px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
#desc-close:hover { border-color: var(--accent); color: var(--accent); }

.status { text-align: center; color: var(--muted); padding: 24px; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 48px; font-size: 16px; }
#sentinel { height: 1px; }

/* Admin */
.adminmain { max-width: 900px; margin: 0 auto; }

.adminrow {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.adminthumb img { width: 160px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: #000; }
.adminthumb .noimg {
  width: 160px; aspect-ratio: 16/9; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--muted); font-size: 12px;
}

.adminform { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field .lbl { font-size: 12px; color: var(--muted); }
.adminform input,
.adminform textarea {
  width: 100%;
  padding: 8px 10px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  resize: vertical;
}
.adminform .meta { display: flex; gap: 14px; align-items: center; font-size: 12px; }
.adminform button {
  align-self: flex-start;
  padding: 8px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
.adminform button:hover { filter: brightness(1.08); }

.editthumb {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.editthumb:hover { color: var(--accent); }

/* Per-video review page */
.topbar-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 14px;
}

.review-main { max-width: 1100px; margin: 0 auto; padding: 20px; }

.review-saved {
  background: rgba(50, 200, 100, 0.1);
  border: 1px solid #32c864;
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  margin-bottom: 18px;
}

.review-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}

.review-player video {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 10px;
  display: block;
}

.review-meta {
  margin-top: 10px;
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
}

.yt-btn {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.yt-btn:hover { text-decoration: underline; }

.review-path { font-size: 12px; margin: 6px 0 0; }

.review-form { display: flex; flex-direction: column; gap: 10px; }

.field-hint { font-size: 11px; color: var(--muted); font-weight: 400; }

.review-form textarea {
  width: 100%;
  padding: 10px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}
.review-form textarea:focus { outline: none; border-color: var(--accent); }

.save-btn {
  align-self: flex-start;
  padding: 10px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  margin-top: 4px;
}
.save-btn:hover { filter: brightness(1.08); }

/* Admin list — reviewed badge + review link */
.reviewed-badge {
  color: #32c864;
  font-size: 13px;
  font-weight: 600;
}

.review-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  margin-left: 8px;
}
.review-link:hover { color: var(--text); }

/* Add-video panel */
.add-video {
  padding: 18px 0 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.add-title {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.add-forms {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
}
.add-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.add-form .field { flex: 1; min-width: 200px; }
.add-url-input {
  width: 340px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
.add-url-input:focus { outline: none; border-color: var(--accent); }
.add-form input[type="file"] {
  padding: 6px 10px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.add-form button {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}
.add-form button:hover { filter: brightness(1.08); }
.add-form button:disabled { opacity: 0.55; cursor: default; }
.add-sep {
  color: var(--muted);
  font-size: 13px;
  padding-bottom: 10px;
}

/* Thumbnail picker page */
.thumbtitle { margin: 8px 0 4px; }

.notice {
  background: rgba(255, 77, 77, 0.12);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
}

.currentthumb {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 0 20px;
}
.currentthumb img,
.currentthumb .noimg {
  width: 240px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
}
.currentthumb .noimg {
  display: flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--muted); font-size: 13px;
}
.currentthumb .lbl { font-size: 13px; margin-bottom: 2px; }

.frames {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.frame { margin: 0; }
.framebtn {
  width: 100%;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
  overflow: hidden;
  display: block;
  position: relative;
}
.framebtn:hover { border-color: var(--accent); }
.framebtn img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: #000;
}
.framebtn .tlabel {
  position: absolute;
  bottom: 4px;
  right: 4px;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  padding: 1px 5px;
  border-radius: 4px;
}
