/* SpoilerFeed — matches the feed-prototype design language */
:root {
  --bg: #0f0f0f;
  --surface: #1c1c1c;
  --surface-2: #242424;
  --border: #383838;
  --text: #f1f1f1;
  --text-2: #b9b9b9;
  --text-3: #8a8a8a;
  --accent: #ff4e45;
  --accent-soft: rgba(255, 78, 69, 0.12);
  --amber: #f5b544;
  --pill-bg: rgba(20, 8, 32, 0.92);
  --pill-border: #6d28d9;
  --pill-fg: #e9d5ff;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Roboto", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
}
a { color: inherit; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(15, 15, 15, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner, #topbar {
  /* keep #topbar as the bar; inner layout via flex */
}
#topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 10px 20px;
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.brand span { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.status { font-size: 12px; color: var(--text-3); }
.ghost-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: 20px; padding: 7px 14px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
.ghost-btn:hover { background: var(--surface-2); }

/* ---------- tabs (Feed / Watch Later) ---------- */
.tabs {
  display: flex; gap: 8px; padding: 10px 20px 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.tab {
  background: transparent; border: none; color: var(--text-2);
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 4px; margin-right: 14px; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- centered views (login / setup) ---------- */
.center-view {
  max-width: 560px; margin: 0 auto; padding: 72px 24px; text-align: center;
}
.center-view h1 { font-size: 36px; letter-spacing: -0.01em; margin: 0 0 12px; }
.lede { color: var(--text-2); font-size: 16px; line-height: 1.5; }
.fineprint { color: var(--text-3); font-size: 12px; margin-top: 18px; }
.primary-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 24px;
  padding: 13px 30px; font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 10px;
  font-family: inherit;
}
.primary-btn:hover { filter: brightness(1.1); }
.spinner {
  width: 40px; height: 40px; margin: 0 auto 16px;
  border: 4px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.google-btn {
  display: inline-flex; align-items: center; gap: 12px;
  background: #fff; color: #1f1f1f; border: 1px solid #dadce0;
  border-radius: 24px; padding: 12px 28px;
  font-size: 16px; font-weight: 600; cursor: pointer; margin-top: 14px;
  font-family: inherit;
}
.google-btn:hover { background: #f6fafe; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.auth-error { color: #ff7b72; font-size: 14px; margin-top: 16px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2);
  border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px 4px 4px;
}
.user-chip img { width: 26px; height: 26px; border-radius: 50%; }

/* ---------- setup card ---------- */
.setup-card {
  max-width: 560px; margin: 24px auto 0; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.setup-card label { display: block; margin: 18px 0 6px; font-weight: 700; font-size: 14px; }
.setup-card label:first-child { margin-top: 0; }
.setup-card input {
  width: 100%; padding: 11px 12px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 14px; font-family: inherit;
}
.setup-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.setup-card .hint { font-size: 13px; color: var(--text-2); margin: 8px 0 0; line-height: 1.5; }
.setup-card .hint code {
  background: var(--surface-2); padding: 2px 6px; border-radius: 4px;
  font-size: 12px; color: var(--text); word-break: break-all;
}
.setup-card .google-btn { margin-top: 22px; width: 100%; justify-content: center; }

/* ---------- feed grid: borderless YouTube-style cards ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px 16px;
  padding: 24px 20px;
  max-width: 1440px;
  margin: 0 auto;
}
.card { min-width: 0; cursor: pointer; animation: rise 0.4s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.thumb-wrap {
  position: relative; aspect-ratio: 16 / 9;
  border-radius: var(--radius); overflow: hidden;
  background: var(--surface);
  transition: transform 0.28s ease, box-shadow 0.28s ease;
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .card:hover .thumb-wrap { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55); }
}
.thumb-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s ease; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .card:hover .thumb-wrap img { transform: scale(1.03); }
}
.thumb-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--surface-2), #141414);
  color: var(--text-3); font-size: 13px; text-align: center; padding: 12px;
}
.secrets-pill {
  position: absolute; left: 10px; bottom: 10px;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  color: var(--pill-fg); font-size: 12px; font-weight: 700;
  padding: 6px 12px; border-radius: 20px;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.dur-badge {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(0, 0, 0, 0.82); color: #fff;
  font-size: 11px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
  pointer-events: none; letter-spacing: 0.02em;
}
.more-btn {
  display: block; margin: 14px auto 4px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 20px; padding: 9px 22px;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.more-btn:hover:not(:disabled) { border-color: var(--text-3); background: var(--surface); }
.more-btn:disabled { opacity: 0.7; cursor: default; }
.more-note { text-align: center; color: var(--text-3); font-size: 13px; margin: 14px 0 4px; }
.card-meta { padding: 10px 2px 0; }
.card-title {
  margin: 0 0 5px; font-size: 15px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card:hover .card-title { color: var(--accent); }
.card-sub { font-size: 13px; color: var(--text-2); }
.card-sub .dot { margin: 0 6px; color: var(--text-3); }

/* ---------- floating 60% summary box ---------- */
#scrim {
  position: fixed; inset: 0; z-index: 90;
  background: transparent; /* click-away layer, no dimming */
}
#preview-box {
  position: fixed; z-index: 100;
  width: min(60vw, 760px);
  max-height: 86vh;
  display: flex; flex-direction: column;
  background: rgba(18, 18, 18, 0.96);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  animation: pop 0.18s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(6px); } to { opacity: 1; transform: none; } }
.close-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; border: 1px solid #444;
  font-size: 14px; cursor: pointer; font-family: inherit;
}
.close-btn:hover { background: #333; }
#preview-body { overflow-y: auto; padding: 0 0 8px; }
.preview-head { display: flex; gap: 12px; align-items: center; padding: 16px 48px 0 18px; }
.preview-thumb-wrap { width: 112px; flex: none; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; }
.preview-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
.preview-thumb-wrap .thumb-fallback { font-size: 11px; }
.preview-head-text { min-width: 0; }
.preview-head-text h2 { margin: 0 0 4px; font-size: 16px; line-height: 1.3; letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.preview-head .preview-channel { color: var(--text-2); font-size: 12px; }
.preview-content { padding: 14px 22px 6px; }
.takeaways { list-style: none; margin: 0 0 14px; padding: 0; counter-reset: tk; }
.takeaways li {
  counter-increment: tk;
  position: relative;
  padding: 10px 12px 10px 44px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px; line-height: 1.5;
}
.takeaways li::before {
  content: counter(tk);
  position: absolute; left: 12px; top: 10px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.verdict {
  margin: 4px 0 10px; padding: 10px 14px;
  font-size: 14px; line-height: 1.5; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  border-left: 3px solid var(--amber);
}
.verdict strong {
  display: block; font-size: 12px; text-transform: uppercase;
  letter-spacing: 1px; color: var(--amber); margin-bottom: 4px;
}
.preview-loading, .preview-error { padding: 40px 24px; text-align: center; color: var(--text-2); }
.retry-btn {
  margin-top: 12px; background: var(--accent); color: #fff; border: none;
  border-radius: 20px; padding: 9px 22px; font-size: 14px; font-weight: 700; cursor: pointer;
  font-family: inherit;
}
.preview-footer {
  border-top: 1px solid var(--border);
  padding: 0;
  display: flex; justify-content: stretch;
}
.yt-badge {
  flex: 1; display: block; text-align: center; text-decoration: none;
  font-size: 13px; font-weight: 600; color: var(--accent);
  padding: 12px; background: rgba(255, 78, 69, 0.06);
}
.yt-badge:hover { background: rgba(255, 78, 69, 0.14); }

.empty-state { text-align: center; padding: 80px 24px; color: var(--text-2); }
.empty-state h2 { color: var(--text); }

/* ---------- bottom loading indicator (progressive feed) ---------- */
.bottom-loader {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 10px;
  background: rgba(28, 28, 28, 0.95); border: 1px solid var(--border);
  color: var(--text-2); font-size: 13px; font-weight: 600;
  padding: 10px 18px; border-radius: 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}
.spinner-small { width: 18px; height: 18px; border-width: 3px; margin: 0; flex: none; }

@media (max-width: 700px) {
  #preview-box { width: calc(100vw - 24px); }
  .grid { grid-template-columns: 1fr; padding: 16px; }
  .center-view h1 { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, #preview-box { animation: none; }
  .card:hover .thumb-wrap { transform: none; box-shadow: none; }
}
