:root {
  /* Open Props --violet-5 / --violet-3 - a calibrated token, not a guessed hex */
  --accent: #845ef7;
  --accent-text: #b197fc;
  --accent-soft: rgba(132, 94, 247, 0.14);
  --accent-border: rgba(132, 94, 247, 0.22);
  --accent-gradient: linear-gradient(180deg, var(--accent-text), var(--accent));

  /* A thin top-edge highlight, the way light catches the top of a glossy
     surface - layered onto box-shadow alongside a real shadow/glow, never
     used alone. */
  --gloss-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --gloss-glow: 0 4px 18px rgba(132, 94, 247, 0.25);
  --gloss-glow-strong: 0 6px 22px rgba(132, 94, 247, 0.4);

  --font-ui: "Roboto", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, "SFMono-Regular", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

#app {
  position: relative;
  display: flex;
  height: 100vh;
  background: #0f0f0f;
  font-family: var(--font-ui);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  animation: spin 1.1s linear infinite;
  filter: drop-shadow(0 2px 10px rgba(132, 94, 247, 0.5));
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#start-feed {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--size-4);
  padding: var(--size-6);
  text-align: center;
}

#start-feed-button {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-2);
  background: var(--accent-gradient);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--gloss-highlight), var(--gloss-glow);
  transition: box-shadow 0.15s var(--ease-2), transform 0.15s var(--ease-2), filter 0.15s var(--ease-2);
}

#start-feed-button:hover {
  filter: brightness(1.08);
  box-shadow: var(--gloss-highlight), var(--gloss-glow-strong);
  transform: translateY(-1px);
}

#start-feed-button:active {
  transform: translateY(0);
  filter: brightness(0.96);
}

#start-feed-hint {
  max-width: 220px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #9a9a9a;
  line-height: 1.4;
}

#main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 360px;
}

#divider {
  flex: 0 0 6px;
  position: relative;
  cursor: col-resize;
}

#divider::after {
  content: "";
  position: absolute;
  inset: 0 2px;
  background: #303030;
  transition: background 0.15s ease;
}

#divider:hover::after,
#divider.dragging::after {
  background: var(--accent);
}

#video-header {
  display: flex;
  align-items: center;
  gap: var(--size-3);
  padding: var(--size-3) var(--size-4);
  border-bottom: 1px solid #272727;
}

/* Shared by the watch page's back-to-homepage arrow and the homepage
   picker's own back arrow (in its video-start popup), so both read as the
   same control. */
.icon-back-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-2);
  background: linear-gradient(180deg, var(--accent-border), var(--accent-soft));
  border: 1px solid var(--accent-border);
  color: var(--accent-text);
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
  box-shadow: var(--gloss-highlight);
  backdrop-filter: blur(6px);
  transition: box-shadow 0.15s var(--ease-2), background 0.15s var(--ease-2);
  cursor: pointer;
}

.icon-back-button:hover {
  background: linear-gradient(180deg, var(--accent-border), var(--accent-border));
  box-shadow: var(--gloss-highlight), var(--gloss-glow);
}

#video-meta {
  flex: 1;
  min-width: 0;
}

#video-title {
  font-size: 15px;
  font-weight: 500;
  color: #f1f1f1;
  line-height: 1.35;
}

#video-channel {
  margin-top: var(--size-1);
  font-family: var(--font-mono);
  font-size: 12px;
  color: #aaa;
}

#player {
  flex: 1;
  min-height: 0;
}

#chat-column {
  position: relative;
  flex: 0 0 auto;
  width: 380px;
  min-width: 280px;
  display: flex;
  flex-direction: column;
}

.panel-label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--size-2);
  padding: var(--size-3) var(--size-4);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-text);
  border-bottom: 1px solid #272727;
}

/* Sits inline with "Streamed Chat", on the right - not its own row. */
.fact-timeline-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-round);
  border: none;
  background: none;
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s var(--ease-2);
}

.fact-timeline-toggle:hover,
.fact-timeline-toggle.active {
  background: var(--accent-soft);
}

.fact-timeline-count {
  padding: 1px 6px;
  border-radius: var(--radius-round);
  background: var(--accent-border);
  font-size: 10px;
}

.fact-timeline-toggle svg {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  transition: transform 0.15s var(--ease-2);
}

.fact-timeline-toggle.active svg {
  transform: rotate(180deg);
}

/* A floating overlay anchored to .panel-label, not a row in normal flow -
   opening it drops down over the comment feed below instead of pushing it
   down, and closing it is instant with no layout to collapse. */
.fact-timeline-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 320px;
  overflow-y: auto;
  background: linear-gradient(180deg, #1c1c1c, #161616);
  border-bottom: 1px solid #272727;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.15s var(--ease-2), transform 0.15s var(--ease-2);
}

.fact-timeline-list.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.fact-timeline-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--size-2);
  padding: var(--size-2) var(--size-4);
  border: none;
  border-top: 1px solid #1e1e1e;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s var(--ease-2);
}

.fact-timeline-item:hover {
  background: var(--accent-soft);
}

.fact-timeline-item-icon {
  flex: 0 0 auto;
  display: flex;
  color: var(--accent-text);
}

.fact-timeline-item-icon svg {
  width: 14px;
  height: 14px;
}

.fact-timeline-item-headline {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: #e1e1e1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fact-timeline-item-time {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-text);
}

.fact-timeline-divider {
  padding: var(--size-2) var(--size-4) 4px;
  border-top: 1px solid #1e1e1e;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b6b6b;
}

#panel {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.comment-list {
  display: flex;
  flex-direction: column;
}

.loading {
  padding: var(--size-4);
  font-family: var(--font-mono);
  font-size: 12px;
  color: #aaa;
}

.summary-card {
  padding: var(--size-4);
  border-bottom: 1px solid #272727;
  background: linear-gradient(180deg, #1c1c1c, #161616);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.summary-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8a8a8a;
  margin-bottom: var(--size-2);
}

.summary-text {
  font-size: 13px;
  color: #e1e1e1;
  line-height: 1.5;
}

.comment-feed {
  display: flex;
  flex-direction: column;
}

.comment {
  display: flex;
  gap: var(--size-3);
  padding: var(--size-2) var(--size-4);
  border-bottom: 1px solid #1e1e1e;
}

/* Applied only to comments inserted live via poll (see insertComment in
   panel.js), not the initial frontloaded batch - those reveal via the scroll
   glide already, so animating all of them in too would be redundant motion.
   Curve generated by Motion's CSS spring generator (spring, duration 0.35s,
   bounce 0.18) - a gentle settle rather than a hard cut-in for "new message
   just arrived". */
.comment-enter {
  animation: comment-enter-in 650ms linear(0, 0.0831, 0.2573, 0.4484, 0.6193, 0.7554, 0.8552, 0.9233, 0.9665, 0.9916, 1.0046, 1.01, 1.0111, 1.0099, 1.0079, 1.0058, 1.004, 1.0025, 1.0015, 1.0008, 1.0003, 1);
}

@keyframes comment-enter-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-round);
  object-fit: cover;
  background: #272727;
}

.comment-body {
  flex: 1;
  min-width: 0;
}

.comment-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--size-2);
  margin-bottom: 2px;
}

.author {
  font-weight: 500;
  font-size: 13px;
  color: #f1f1f1;
}

.posted-at {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #8a8a8a;
}

.comment-text {
  font-size: 13px;
  color: #e1e1e1;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.likes {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--size-1);
  font-family: var(--font-mono);
  font-size: 11px;
  color: #8a8a8a;
}

.likes svg {
  width: 13px;
  height: 13px;
}

.insight-card {
  padding: var(--size-2) var(--size-4);
  border-bottom: 1px solid #1e1e1e;
  background: linear-gradient(180deg, var(--accent-soft), rgba(132, 94, 247, 0.06));
  border-left: 3px solid var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.insight-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-text);
  background: var(--accent-border);
  padding: 2px var(--size-2);
  border-radius: var(--radius-round);
  margin-bottom: var(--size-1);
}

.insight-label svg {
  width: 11px;
  height: 11px;
}

.insight-headline {
  font-size: 14px;
  font-weight: 700;
  color: #f1f1f1;
  line-height: 1.3;
  margin-bottom: 4px;
}

.insight-video-reference {
  font-size: 11px;
  font-style: italic;
  color: #8a8a8a;
  line-height: 1.4;
  margin-bottom: var(--size-2);
  padding-left: 6px;
  border-left: 2px solid var(--accent-border);
}

.insight-text {
  font-size: 13px;
  color: #ede9fe;
  line-height: 1.4;
}

.insight-source {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--size-2);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-text);
  text-decoration: none;
}

.insight-source svg {
  width: 12px;
  height: 12px;
}

.insight-source:hover {
  text-decoration: underline;
}

.jump-to-current {
  position: absolute;
  bottom: var(--size-4);
  left: 50%;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-round);
  background: linear-gradient(180deg, var(--accent-border), var(--accent-soft));
  backdrop-filter: blur(6px);
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--gloss-highlight), 0 4px 14px rgba(0, 0, 0, 0.35), var(--gloss-glow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s var(--ease-2), transform 0.2s var(--ease-2);
}

.jump-to-current.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.jump-to-current svg {
  width: 14px;
  height: 14px;
}
