* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root,
:root[data-ui-mode="0"] {
  --bg-app: #f4f6f8;
  --bg-main: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-elevated: #ffffff;
  --bg-input: #f8f9fb;
  --bg-pill: #f1f3f5;
  --bg-pill-active: #e7f0ff;
  --text-on-active: #1d4ed8;
  --border-subtle: #e3e6ea;
  --border-strong: #d0d5dc;
  --text-primary: #0f1419;
  --text-secondary: #5c6670;
  --text-muted: #8b949e;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-soft: #dbeafe;
  --status-teal: #0d9488;
  --status-teal-bg: #ccfbf1;
  --sort-active-bg: #dbeafe;
  --sort-active-text: #1d4ed8;
  --suggestion-text: #5c6670;
  --suggestion-border: #e3e6ea;
  --send-gradient-start: #6366f1;
  --send-gradient-end: #3b82f6;
  --hero-glow: radial-gradient(
    ellipse 70% 50% at 50% 38%,
    rgba(99, 140, 220, 0.12) 0%,
    rgba(99, 140, 220, 0.04) 42%,
    transparent 70%
  );
  --shadow-soft: 0 8px 32px rgba(15, 20, 25, 0.06);
  --shadow-card: 0 2px 8px rgba(15, 20, 25, 0.05);
  --thumb-placeholder: repeating-linear-gradient(
    -45deg,
    #eceff3,
    #eceff3 8px,
    #e2e6eb 8px,
    #e2e6eb 16px
  );
  --badge-summary-bg: #ecfdf5;
  --badge-summary-text: #0f766e;
  --badge-nosummary-bg: #f3f4f6;
  --badge-nosummary-text: #6b7280;
  --chat-user-bg: #e7f0ff;
  --chat-assistant-bg: #f3f4f6;
  --chat-system-bg: #eef2f7;
  --error: #dc2626;
}

:root[data-ui-mode="1"] {
  --bg-app: #06090f;
  --bg-main: #06090f;
  --bg-sidebar: #0b1018;
  --bg-elevated: #121821;
  --bg-input: #0e141d;
  --bg-pill: #141b26;
  --border-subtle: #1c2430;
  --border-strong: #2a3544;
  --text-primary: #ffffff;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --accent: #63e6ff;
  --accent-strong: #63e6ff;
  --accent-soft: rgba(99, 230, 255, 0.14);
  --status-teal: #63e6ff;
  --status-teal-bg: transparent;
  --sort-active-bg: #63e6ff;
  --sort-active-text: #0b0d17;
  --bg-pill-active: linear-gradient(90deg, #63e6ff 0%, #c4b5fd 100%);
  --text-on-active: #0b0d17;
  --suggestion-text: #f8fafc;
  --suggestion-border: rgba(255, 255, 255, 0.2);
  --send-gradient-start: #93c5fd;
  --send-gradient-end: #818cf8;
  --hero-glow: radial-gradient(
    ellipse 72% 58% at 50% 40%,
    rgba(70, 130, 190, 0.34) 0%,
    rgba(50, 90, 150, 0.16) 36%,
    rgba(20, 35, 60, 0.06) 58%,
    transparent 72%
  );
  --shadow-soft: 0 12px 40px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.25);
  --thumb-placeholder: repeating-linear-gradient(
    -45deg,
    #151b24,
    #151b24 8px,
    #1a2230 8px,
    #1a2230 16px
  );
  --badge-summary-bg: rgba(45, 212, 191, 0.16);
  --badge-summary-text: #5eead4;
  --badge-nosummary-bg: rgba(107, 114, 128, 0.22);
  --badge-nosummary-text: #9ca3af;
  --chat-user-bg: #1a2740;
  --chat-assistant-bg: #111722;
  --chat-system-bg: #151b24;
  --error: #f87171;
}

@media (prefers-color-scheme: dark) {
  :root[data-ui-mode="2"] {
    --bg-app: #06090f;
    --bg-main: #06090f;
    --bg-sidebar: #0b1018;
    --bg-elevated: #121821;
    --bg-input: #0e141d;
    --bg-pill: #141b26;
    --border-subtle: #1c2430;
    --border-strong: #2a3544;
    --text-primary: #ffffff;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --accent: #63e6ff;
    --accent-strong: #63e6ff;
    --accent-soft: rgba(99, 230, 255, 0.14);
    --status-teal: #63e6ff;
    --status-teal-bg: transparent;
    --sort-active-bg: #63e6ff;
    --sort-active-text: #0b0d17;
    --bg-pill-active: linear-gradient(90deg, #63e6ff 0%, #c4b5fd 100%);
    --text-on-active: #0b0d17;
    --suggestion-text: #f8fafc;
    --suggestion-border: rgba(255, 255, 255, 0.2);
    --send-gradient-start: #93c5fd;
    --send-gradient-end: #818cf8;
    --hero-glow: radial-gradient(
      ellipse 72% 58% at 50% 40%,
      rgba(70, 130, 190, 0.34) 0%,
      rgba(50, 90, 150, 0.16) 36%,
      rgba(20, 35, 60, 0.06) 58%,
      transparent 72%
    );
    --shadow-soft: 0 12px 40px rgba(0, 0, 0, 0.35);
    --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.25);
    --thumb-placeholder: repeating-linear-gradient(
      -45deg,
      #151b24,
      #151b24 8px,
      #1a2230 8px,
      #1a2230 16px
    );
    --badge-summary-bg: rgba(45, 212, 191, 0.16);
    --badge-summary-text: #5eead4;
    --badge-nosummary-bg: rgba(107, 114, 128, 0.22);
    --badge-nosummary-text: #9ca3af;
    --chat-user-bg: #1a2740;
    --chat-assistant-bg: #111722;
    --chat-system-bg: #151b24;
    --error: #f87171;
  }
}

@media (prefers-color-scheme: light) {
  :root[data-ui-mode="2"] {
    --bg-app: #f4f6f8;
    --bg-main: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-elevated: #ffffff;
    --bg-input: #f8f9fb;
    --bg-pill: #f1f3f5;
    --bg-pill-active: #e7f0ff;
    --text-on-active: #1d4ed8;
    --border-subtle: #e3e6ea;
    --border-strong: #d0d5dc;
    --text-primary: #0f1419;
    --text-secondary: #5c6670;
    --text-muted: #8b949e;
    --accent: #3b82f6;
    --accent-strong: #2563eb;
    --accent-soft: #dbeafe;
    --status-teal: #0d9488;
    --status-teal-bg: #ccfbf1;
    --sort-active-bg: #dbeafe;
    --sort-active-text: #1d4ed8;
    --suggestion-text: #5c6670;
    --suggestion-border: #e3e6ea;
    --send-gradient-start: #6366f1;
    --send-gradient-end: #3b82f6;
    --hero-glow: radial-gradient(
      ellipse 70% 50% at 50% 38%,
      rgba(99, 140, 220, 0.12) 0%,
      rgba(99, 140, 220, 0.04) 42%,
      transparent 70%
    );
    --shadow-soft: 0 8px 32px rgba(15, 20, 25, 0.06);
    --shadow-card: 0 2px 8px rgba(15, 20, 25, 0.05);
    --thumb-placeholder: repeating-linear-gradient(
      -45deg,
      #eceff3,
      #eceff3 8px,
      #e2e6eb 8px,
      #e2e6eb 16px
    );
    --badge-summary-bg: #ecfdf5;
    --badge-summary-text: #0f766e;
    --badge-nosummary-bg: #f3f4f6;
    --badge-nosummary-text: #6b7280;
    --chat-user-bg: #e7f0ff;
    --chat-assistant-bg: #f3f4f6;
    --chat-system-bg: #eef2f7;
    --error: #dc2626;
  }
}

body {
  height: 100vh;
  overflow: hidden;
  font-family: "Segoe UI", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* —— Main stage (left) —— */
.main-stage {
  position: relative;
  flex: 1 1 62%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  border-right: 1px solid var(--border-subtle);
  min-height: 0;
  overflow: hidden;
}

.main-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--hero-glow);
  z-index: 0;
}

.main-stage > * {
  position: relative;
  z-index: 1;
}

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 32px 8px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}

.brand-banner-logo {
  display: block;
  height: 38px;
  width: auto;
  max-width: min(280px, 42vw);
  object-fit: contain;
  object-position: left center;
}

.brand-banner-logo-dark {
  display: none;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 38px;
}

.brand-banner-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.brand-banner-text {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #ffffff;
  line-height: 1;
  white-space: nowrap;
}

:root[data-ui-mode="1"] .brand-banner-logo-light {
  display: none;
}

:root[data-ui-mode="1"] .brand-banner-logo-dark {
  display: inline-flex;
}

@media (prefers-color-scheme: dark) {
  :root[data-ui-mode="2"] .brand-banner-logo-light {
    display: none;
  }

  :root[data-ui-mode="2"] .brand-banner-logo-dark {
    display: inline-flex;
  }
}

.session-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.session-history-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.session-history-select {
  min-width: 0;
  max-width: 200px;
  padding: 6px 28px 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.session-reset-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.main-stage-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 24px;
  width: 100%;
}

.main-stage-body::before {
  content: '';
  flex: 1 1 auto;
  min-height: clamp(80px, 20vh, 220px);
}

.main-stage--conversation .main-stage-body {
  padding-top: 8px;
}

.main-stage--conversation .main-stage-body::before {
  display: none;
}

.hero-block {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  gap: 20px;
  width: 100%;
  max-width: min(960px, 100%);
  margin: 0 auto;
  padding-top: 0;
  padding-bottom: clamp(12px, 3vh, 32px);
}

.main-stage-composer {
  flex: 0 0 auto;
  width: 100%;
  padding: 12px 24px 20px;
  border-top: 1px solid var(--border-subtle);
  background: transparent;
}

.composer-card {
  width: 100%;
  max-width: min(960px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.main-stage-composer .composer-card {
  max-width: none;
  margin: 0;
}

.main-stage--conversation .hero-block {
  display: none;
}

.main-stage--conversation .chat-messages {
  display: flex !important;
  flex: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0 12px;
}

.status-pill {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--status-teal);
  background: var(--status-teal-bg);
  padding: 0;
  border-radius: 0;
}

.hero-title {
  font-size: clamp(1.85rem, 3.8vw, 2.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: var(--text-primary);
  max-width: 22ch;
}

.composer-input {
  width: 100%;
  min-height: 110px;
  padding: 18px 20px 8px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.5;
  font-family: inherit;
  resize: none;
  outline: none;
}

.composer-input::placeholder {
  color: var(--text-muted);
}

.composer-input--busy,
.composer-input:disabled {
  opacity: 0.7;
  cursor: wait;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 10px 14px 14px;
}

.app-shell.video-selection-mode .catalog-filter-bar {
  display: none !important;
}

.composer-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: transparent;
  background-image: url('res/images/submit-button-default.svg');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  color: transparent;
  font-size: 0;
  cursor: pointer;
  box-shadow: none;
  transition: transform 0.08s ease;
}

.composer-send:hover:not(:disabled) {
  background-image: url('res/images/submit-button-hover.svg');
  filter: none;
}

.composer-send:active:not(:disabled),
.composer-send.is-pressed:not(:disabled) {
  background-image: url('res/images/submit-button-pressed.svg');
  transform: translateY(1px);
}

.composer-send:disabled {
  opacity: 0.45;
  cursor: default;
  background-image: url('res/images/submit-button-default.svg');
}

.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: min(960px, 100%);
}

.suggestion-chip {
  border: 1px solid var(--suggestion-border);
  border-radius: 999px;
  background: var(--bg-pill);
  color: var(--suggestion-text);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 16px;
  cursor: pointer;
  font-family: inherit;
}

.suggestion-chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.suggestion-chip--loading {
  cursor: default;
  min-width: 56px;
  pointer-events: none;
  opacity: 0.9;
}

.suggestion-chip--loading:hover {
  border-color: var(--suggestion-border);
  color: var(--suggestion-text);
}

.suggestion-loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 1em;
}

.suggestion-loading-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
  animation: suggestion-loading-bounce 1.2s ease-in-out infinite;
}

.suggestion-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.suggestion-loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes suggestion-loading-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40% { transform: translateY(-3px); opacity: 1; }
}

.main-stage--conversation .suggestion-row {
  display: none;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0 16px;
  width: 100%;
}

.chat-message {
  max-width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message-user {
  align-self: flex-end;
  max-width: min(720px, 88%);
  background: var(--chat-user-bg);
  color: var(--text-primary);
}

.chat-message-system {
  align-self: flex-start;
  max-width: min(720px, 88%);
  background: var(--chat-system-bg);
  color: var(--text-secondary);
}

.chat-message-assistant {
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  background: var(--chat-assistant-bg);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message-waiting {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  align-self: flex-start;
  width: auto;
  max-width: min(720px, 88%);
  color: var(--text-secondary);
}

.chat-waiting-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-waiting-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: chat-waiting-bounce 1.2s ease-in-out infinite;
}

.chat-waiting-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-waiting-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-waiting-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.chat-answer-text,
.chat-answer-heading,
.chat-bullet-item {
  font-size: 14px;
  line-height: 1.55;
}

.chat-answer-heading,
.chat-bullet-bold {
  font-weight: 600;
}

.chat-bullet-list {
  list-style: disc;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bullet-ref {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent-strong);
  font: inherit;
  cursor: pointer;
}

.chat-bullet-ref:hover {
  text-decoration: underline;
}

.chat-ref-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chat-ref-card {
  flex: 0 0 180px;
  width: 180px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-elevated);
  padding: 8px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-ref-thumb-wrap,
.ref-panel-thumb-wrap,
.thumb-wrap {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: var(--thumb-placeholder);
  position: relative;
}

.chat-ref-thumb-wrap img,
.ref-panel-thumb-wrap img,
.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* —— Favorites sidebar (right) —— */
.sidebar-resize-handle {
  flex: 0 0 6px;
  width: 6px;
  cursor: col-resize;
  position: relative;
  z-index: 5;
  background: transparent;
  touch-action: none;
}

.sidebar-resize-handle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 2px;
  background: var(--border-subtle);
  transition: background 0.15s ease, width 0.15s ease, left 0.15s ease;
}

.sidebar-resize-handle:hover::before,
.sidebar-resize-handle--active::before {
  left: 1px;
  width: 4px;
  background: var(--accent, #63e6ff);
}

.sidebar-resize-handle--hidden {
  display: none;
}

body.is-resizing-sidebar {
  cursor: col-resize;
  user-select: none;
}

body.is-resizing-sidebar iframe {
  pointer-events: none;
}

.favorites-sidebar {
  flex: 0 0 38%;
  max-width: none;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  min-height: 0;
}

.favorites-sidebar--collapsed {
  display: none;
}

.sidebar-header {
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.sidebar-header-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
}

.sidebar-header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-end;
}

.sidebar-search-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-pill);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.sidebar-search-btn svg {
  width: 14px;
  height: 14px;
}

.sidebar-search-btn:hover,
.sidebar-search-btn[aria-expanded="true"] {
  color: var(--text-primary);
  border-color: var(--accent);
}

.sidebar-search-field {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 220px;
}

.sidebar-search-field[hidden] {
  display: none !important;
}

.sidebar-search-input {
  width: 100%;
  box-sizing: border-box;
  height: 30px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 0 12px;
  font: inherit;
  font-size: 12px;
}

.sidebar-search-input::placeholder {
  color: var(--text-muted);
}

.sidebar-search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
  margin-left: 0;
}

.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.sidebar-count {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.sort-segment {
  display: inline-flex;
  gap: 0;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
}

.sort-segment-btn {
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 0 1 auto;
}

.sort-segment-btn[data-sort="channel"] {
  flex: 1 1 3.2em;
  max-width: 6.4em;
}

.sort-segment-btn--active {
  background: var(--sort-active-bg);
  color: var(--sort-active-text);
  box-shadow: none;
}

:root[data-ui-mode="0"] .sort-segment {
  border-color: var(--border-strong);
  background: var(--bg-pill);
}

:root[data-ui-mode="0"] .sort-segment-btn {
  color: var(--text-secondary);
}

@media (prefers-color-scheme: light) {
  :root[data-ui-mode="2"] .sort-segment {
    border-color: var(--border-strong);
    background: var(--bg-pill);
  }

  :root[data-ui-mode="2"] .sort-segment-btn {
    color: var(--text-secondary);
  }
}

.sidebar-open-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.feed-back-btn {
  margin: 10px 18px 0;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--accent-strong);
  font-size: 13px;
  cursor: pointer;
  width: fit-content;
}

.catalog-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  padding: 10px 18px 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.catalog-filter-bar[hidden] {
  display: none !important;
}

.catalog-filter-label {
  display: none;
}

.catalog-filter-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.catalog-filter-chip {
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-pill);
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.catalog-filter-chip--active {
  background: var(--bg-pill-active);
  border-color: transparent;
  color: var(--text-on-active);
}

.catalog-filter-more {
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--accent-strong);
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.catalog-filter-more:hover {
  text-decoration: underline;
}

.sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px 24px;
}

.state-message {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.state-message[hidden],
.feed-sections[hidden],
#loadingState[hidden],
#errorState[hidden],
#emptyState[hidden] {
  display: none !important;
}

.state-error {
  color: var(--error);
}

.feed-sections {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.video-grid {
  --video-card-base: 200px;
  --video-card-min: calc(var(--video-card-base) * 0.8);
  display: grid;
  /* Grow to fill leftover space; add a column once another min-width card fits. */
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(100%, var(--video-card-min)), 1fr)
  );
  gap: 14px 12px;
}

.video-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.summary-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 14px;
  height: 14px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.95);
  background: transparent;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  padding: 0;
  font-size: 0;
  color: transparent;
  cursor: pointer;
  appearance: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

/* Transcript / summary ready: solid dot inside the hollow circle */
.summary-badge::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.summary-badge:hover {
  transform: scale(1.12);
  border-color: var(--accent);
}

.summary-badge:hover::after {
  background: var(--accent);
}

.summary-badge--selected {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 230, 255, 0.22), 0 1px 3px rgba(0, 0, 0, 0.35);
}

.summary-badge--selected::after {
  background: #fff;
}

.favorite-context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 190px;
  padding: 5px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-soft);
}

.favorite-context-menu-item {
  width: 100%;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-primary);
  padding: 9px 11px;
  text-align: left;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.favorite-context-menu-item:hover,
.favorite-context-menu-item:focus-visible {
  outline: none;
  background: var(--bg-pill-active);
  color: var(--accent-strong);
}

.thumb-processing-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.video-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-title a {
  color: inherit;
  text-decoration: none;
}

.video-title a:hover {
  color: var(--accent-strong);
}

.video-meta {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.channel-link {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.channel-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.video-date {
  color: var(--text-muted);
}

.catalog-filter-empty,
.results-heading,
.date-heading {
  color: var(--text-secondary);
  font-size: 14px;
}

.results-heading,
.date-heading {
  font-weight: 600;
  margin-bottom: 8px;
}

.ref-panel-grid {
  --video-card-base: 200px;
  --video-card-min: calc(var(--video-card-base) * 0.8);
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(100%, var(--video-card-min)), 1fr)
  );
  gap: 14px 12px;
}

.ref-panel-card {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-elevated);
  padding: 10px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ref-panel-card-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.ref-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.ref-panel-time {
  font-size: 12px;
  color: var(--accent-strong);
  font-weight: 600;
}

.ref-panel-snippet {
  font-size: 12px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-playback-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.feed-player-wrap,
.video-player-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  position: relative;
}

.feed-player-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.yt-player-mount,
.yt-player-mount iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.feed-player-title,
.single-video-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.feed-player-summary,
.single-video-summary,
.video-summary {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.favorites-sidebar-single .sidebar-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.favorites-sidebar-single .feed-sections {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.favorites-sidebar-single .feed-playback-layout {
  height: 100%;
  min-height: 0;
}

.segment-list,
.live-transcript-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-pill);
}

.segment-row {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.segment-row:last-child {
  border-bottom: none;
}

.segment-row-active {
  background: var(--bg-pill-active);
  border-left: 3px solid var(--accent);
}

@media (max-width: 960px) {
  .app-shell {
    flex-direction: column;
  }

  .main-stage {
    flex: 1 1 58%;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
  }

  .favorites-sidebar {
    flex: 1 1 42%;
    max-width: none;
    min-width: 0;
    width: auto !important;
  }

  .sidebar-resize-handle {
    display: none;
  }

  .brand-bar,
  .main-stage-body {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 640px) {
  .video-grid,
  .ref-panel-grid {
    --video-card-base: 160px;
  }

  .hero-title {
    max-width: none;
  }

  .suggestion-row {
    justify-content: flex-start;
  }
}
