:root {
  --bg: #0e1116;
  --bg-soft: #161b22;
  --bg-card: #1c232d;
  --border: #2a3441;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #6ee7b7;
  --accent-dim: #2f6f5a;
  --good: #6ee7b7;
  --ok: #facc15;
  --bad: #f87171;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-size: 18px; font-weight: 700; color: var(--text); letter-spacing: 0.3px; }
.tagline { color: var(--muted); font-size: 13px; flex: 1; }

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
.ghost:hover { border-color: var(--accent-dim); }

/* ------------------------------------------------------------------ layout */

main { max-width: 780px; margin: 0 auto; padding: 26px 20px 60px; }

/* ------------------------------------------------------------------ search */

.searchbox form { display: flex; gap: 10px; }
.searchbox input {
  flex: 1;
  padding: 13px 16px;
  font-size: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
}
.searchbox input:focus { border-color: var(--accent-dim); }

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.btn.primary { background: var(--accent-dim); border-color: var(--accent-dim); color: #052e22; }
.btn.primary:hover { background: var(--accent); }
.btn:hover { border-color: var(--muted); }
.btn.fb { padding: 8px 12px; font-size: 14px; }
.btn.fb.on { background: var(--accent-dim); border-color: var(--accent); }
.btn.mini { padding: 2px 8px; font-size: 11px; border-radius: 6px; margin-left: auto; flex-shrink: 0; }

.muted { color: var(--muted); }

/* ------------------------------------------------------------------ status */

.status, .error {
  margin-top: 26px;
  padding: 22px;
  border-radius: var(--radius);
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
}
.error { color: var(--bad); border-color: var(--bad); border-style: solid; }

.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ results */

.results-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 30px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.card {
  display: flex;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.thumb {
  width: 160px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--bg-soft);
}

.meta { flex: 1; min-width: 0; }

.row1 { display: flex; align-items: flex-start; gap: 10px; }
.score {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 13px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 2px;
}
.score.good { background: rgba(110, 231, 183, 0.15); color: var(--good); }
.score.ok { background: rgba(250, 204, 21, 0.15); color: var(--ok); }
.score.meh { background: rgba(248, 113, 113, 0.15); color: var(--bad); }

h3 { margin: 0; font-size: 16px; line-height: 1.35; }
.sub { color: var(--muted); font-size: 13px; margin: 4px 0 6px; }
.reason { color: #b7c3cd; font-size: 14px; margin: 0 0 10px; }

.actions { display: flex; gap: 8px; align-items: center; }
.watched-badge {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
}

/* ------------------------------------------------------------------ player */

.player-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.gate-note { color: var(--muted); font-size: 13px; margin-left: auto; }

.player h1 { font-size: 22px; margin: 0 0 4px; line-height: 1.3; }

video {
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: var(--radius);
  margin: 16px 0;
}

.player .reason {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-dim);
  padding: 12px 14px;
  border-radius: 8px;
  margin: 0 0 16px;
}

/* ------------------------------------------------------------------ panel */

.panel {
  position: fixed;
  top: 64px;
  right: 18px;
  width: min(420px, 92vw);
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  z-index: 20;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.panel.hidden { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel h2 { margin: 0; font-size: 17px; }
.panel h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.panel textarea {
  width: 100%;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  resize: vertical;
  margin: 10px 0;
}
.panel hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.fb-list { list-style: none; margin: 0; padding: 0; }
.fb-list li {
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.fb-list .tag { font-weight: 700; }
.tag.liked { color: var(--good); }
.tag.disliked { color: var(--bad); }
.fb-list .t { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------------ misc */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--accent-dim);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 30;
}
.toast.hidden { display: none; }

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 18px;
  border-top: 1px solid var(--border);
}

@media (max-width: 560px) {
  .thumb { width: 120px; height: 68px; }
  .card { flex-direction: column; }
  .thumb { width: 100%; height: auto; aspect-ratio: 16/9; }
}

/* ------------------------------------------------------------------ auth */

[hidden] { display: none !important; }

.user-badge {
  color: var(--muted);
  font-size: 13px;
  margin-left: auto;
  white-space: nowrap;
}

.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, #141b24 0%, var(--bg) 65%);
  z-index: 40;
}

.login-card {
  width: min(360px, 90vw);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 20px; text-align: center; }
.login-card input {
  padding: 11px 14px;
  font-size: 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
}
.login-card input:focus { border-color: var(--accent-dim); }

.add-user {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.add-user input {
  padding: 9px 12px;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
}
