/* Align the submit, clear, and theme toggle buttons in a row */
.button-row {
  display: flex;
  align-items: center;
  gap: calc(16px * var(--ui-scale));
  flex-wrap: wrap;
}
/* Footer: full width, single line, left-aligned for app page */
.footer {
  width: 100%;
  background: var(--dark);
  color: var(--gray-light);
  padding: 16px 20px;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 100;
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.1);
  display: block;
  visibility: visible;
  opacity: 1;
}

@media (max-width: 600px) {
  .footer {
    padding: 14px 12px;
    font-size: 14px;
  }
}
.footer .container {
  max-width: 100vw;
  width: 100%;
  padding: 0 32px;
}
.footer-content {
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: flex-start;
  margin-bottom: 0;
}
.footer-brand {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  display: flex;
}
.footer-logo {
  width: 28px !important;
  height: 28px !important;
}
.footer-brand p,
.footer-bottom p {
  margin: 0;
  white-space: nowrap;
  color: var(--gray-light);
  font-size: 0.95rem;
}
.footer-bottom {
  border-top: none;
  padding-top: 0;
}

@media (max-width: 768px) {
  .footer {
    padding: 16px 12px;
  }
  .footer .container {
    padding: 0 16px;
  }
  .footer-content {
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
  }
  .footer-brand p {
    font-size: 0.9rem;
  }
  .footer-logo {
    width: 24px !important;
    height: 24px !important;
  }
}

@media (max-width: 480px) {
  .footer {
    padding: 14px 8px;
  }
  .footer .container {
    padding: 0 12px;
  }
  .footer-brand p {
    font-size: 0.8rem;
    white-space: normal;
    text-align: center;
    line-height: 1.4;
  }
  .footer-content {
    gap: 8px;
    flex-direction: column;
  }
}
/* Theme variables */
:root {
  --ui-scale: 0.9;
  --color-bg: #181818;
  --color-surface: #212121;
  --color-surface-alt: #282828;
  --color-text: #ffffff;
  --color-text-soft: #ddd;
  --color-text-muted: #888;
  --color-border: #444;
  --color-border-soft: #333;
  --color-accent: #ff0000;
  --color-accent-hover: #cc0000;
  --color-accent-fade: rgba(255, 0, 0, 0.12);
  --focus-outline: #ff0000;
  --gradient-skeleton: linear-gradient(90deg, #333 25%, #3d3d3d 37%, #333 63%);
  --radius-sm: calc(6px * var(--ui-scale));
  --radius-md: calc(12px * var(--ui-scale));
  --radius-lg: calc(16px * var(--ui-scale));
  --transition-fast: 0.18s ease;
}
[data-theme="light"] {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-alt: #f8fafc;
  --color-text: #000000;
  --color-text-soft: #1a1a1a;
  --color-text-muted: #4a4a4a;
  --color-border: #cbd5e1;
  --color-border-soft: #e2e8f0;
  --color-accent: #6366f1;
  --color-accent-hover: #4f46e5;
  --color-accent-fade: rgba(99, 102, 241, 0.14);
  --focus-outline: #6366f1;
  --gradient-skeleton: linear-gradient(
    90deg,
    #f1f5f9 25%,
    #e2e8f0 37%,
    #f1f5f9 63%
  );
}

html {
  font-size: calc(100% * var(--ui-scale));
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
    "Ubuntu", "Cantarell", sans-serif;
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 80px;
}

@media (max-width: 768px) {
  body {
    padding-bottom: 90px;
  }
}

@media (max-width: 480px) {
  body {
    padding-bottom: 100px;
  }
}

/* Accessibility utility: hide element visually but keep for screen readers */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

/* Accessibility focus styles */
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 2px;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px * var(--ui-scale)) calc(28px * var(--ui-scale))
    calc(12px * var(--ui-scale));
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  gap: calc(32px * var(--ui-scale));
  flex-wrap: wrap;
  box-sizing: border-box;
  overflow-x: hidden;
  max-width: 100vw;
}
.header-top-row {
  display: contents;
}
.header-search-row {
  display: contents;
}
.header-utils {
  display: none;
  align-items: center;
  gap: calc(10px * var(--ui-scale));
}
.header-theme-toggle {
  display: none;
}
.brand-group {
  display: flex;
  align-items: center;
  gap: calc(14px * var(--ui-scale));
  flex-shrink: 1;
  min-width: 0;
}
.app-header a {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 700;
}
.app-header a:hover {
  color: var(--color-accent);
  text-decoration: underline;
}
.logo {
  height: calc(46px * var(--ui-scale));
  width: calc(46px * var(--ui-scale));
  border-radius: calc(8px * var(--ui-scale));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  background: #ffffff; /* always white for clarity */
  border: 1px solid #555; /* dark theme outline by default */
  flex-shrink: 0;
}
.app-title {
  font-size: 1.55em;
  margin: 0;
  letter-spacing: 0.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.header-search {
  flex: 1;
  min-width: calc(280px * var(--ui-scale));
}
.header-input-group {
  margin: 0;
}
/* (legacy left/right radius rules removed: using pill input + circular icon button) */
.app-header .error-message {
  margin: 4px 0 0 4px;
  font-size: 0.8em;
  font-weight: 500;
}



@media (max-width: 1000px) {
  .app-header {
    gap: calc(16px * var(--ui-scale));
  }
  .header-search {
    min-width: 100%;
    order: 3;
  }
  .brand-group {
    flex: 1;
  }
}

/* Show utilities row on medium screens */
@media (max-width: 1000px) {
  .header-utils {
    order: 2;
    display: flex;
  }
}
}

@media (max-width: 880px) {
  .app-header {\n    padding: calc(12px * var(--ui-scale)) calc(20px * var(--ui-scale));\n  }\n  .header-input-group {\n    gap: calc(10px * var(--ui-scale));\n  }\n  #video-url {\n    font-size: 0.92rem;\n  }\n}\n\n@media (max-width: 760px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: calc(14px * var(--ui-scale));
    padding: calc(12px * var(--ui-scale)) calc(16px * var(--ui-scale));
  }
  .brand-group {
    justify-content: center;
  }
  .header-search {
    width: 100%;
    min-width: 100%;
  }
  .logo {
    height: calc(38px * var(--ui-scale));
    width: calc(38px * var(--ui-scale));
  }
  .app-title {
    font-size: 1.3em;
  }
}

/* Mobile: show theme toggle next to lock, hide desktop toggle */
@media (max-width: 760px) {
  .app-header {
    position: relative;
    flex-direction: column;
    padding: 0;
    gap: 0;
  }
  /* Top row: brand + utilities - stays fixed */
  .header-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 100vw;
    padding: calc(8px * var(--ui-scale)) calc(6px * var(--ui-scale));
    background: var(--color-surface);
    position: sticky;
    top: 0;
    z-index: 51;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    box-sizing: border-box;
    overflow: hidden;
    gap: calc(4px * var(--ui-scale));
    flex-wrap: nowrap;
  }
  /* Search row: scrolls with page */
  .header-search-row {
    display: block;
    width: 100%;
    padding: calc(10px * var(--ui-scale)) calc(8px * var(--ui-scale));
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border-soft);
  }
  .brand-group {
    justify-content: flex-start;
    flex-shrink: 1;
    min-width: 0;
    gap: calc(6px * var(--ui-scale));
    overflow: hidden;
    flex: 1;
  }
  .header-utils {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: calc(4px * var(--ui-scale));
    flex-shrink: 0;
  }
  .header-search {
    width: 100%;
    min-width: 100%;
  }
  .logo {
    height: calc(32px * var(--ui-scale));
    width: calc(32px * var(--ui-scale));
    flex-shrink: 0;
    min-width: calc(32px * var(--ui-scale));
  }
  .app-title {
    font-size: 1.1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }
  #theme-toggle {
    display: none;
  }
  .header-theme-toggle {
    display: inline-flex;
  }
}

/* Extra small screens: further reduce header elements */
@media (max-width: 400px) {
  .header-top-row {
    padding: calc(6px * var(--ui-scale)) calc(4px * var(--ui-scale));
    gap: calc(2px * var(--ui-scale));
  }
  .brand-group {
    gap: calc(4px * var(--ui-scale));
  }
  .logo {
    height: calc(28px * var(--ui-scale));
    width: calc(28px * var(--ui-scale));
    min-width: calc(28px * var(--ui-scale));
  }
  .app-title {
    font-size: 1em;
  }
  .header-theme-toggle {
    padding: calc(4px * var(--ui-scale)) calc(8px * var(--ui-scale));
    font-size: 0.9rem;
  }
}\n\n.container {
  max-width: calc(520px * var(--ui-scale));
  margin: calc(32px * var(--ui-scale)) auto calc(48px * var(--ui-scale));
  background: var(--color-surface);
  border-radius: calc(16px * var(--ui-scale));
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  padding: calc(40px * var(--ui-scale)) calc(32px * var(--ui-scale))
    calc(48px * var(--ui-scale));
  text-align: center;
  position: relative;
  overflow: hidden;
}

@media (max-width: 600px) {
  .container {
    margin: calc(20px * var(--ui-scale)) calc(12px * var(--ui-scale)) calc(32px * var(--ui-scale));
    padding: calc(24px * var(--ui-scale)) calc(20px * var(--ui-scale)) calc(32px * var(--ui-scale));
  }
}

.initial-screen.fade-out {
  animation: fadeOut 0.45s forwards ease;
}
@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
  }
}

.yt-title {
  color: #ffffff;
  font-size: 2.3em;
  margin: 0 0 28px;
  letter-spacing: 1px;
  font-weight: 700;
}

.input-group {
  display: flex;
  justify-content: center;
  margin-bottom: calc(16px * var(--ui-scale));
}

/* Unified pill input style (URL + chat input) */
#video-url,
#chat-input,
.chat-form textarea {
  flex: 1;
  padding: calc(14px * var(--ui-scale)) calc(18px * var(--ui-scale));
  border: 1px solid var(--color-border);
  background: #303030;
  color: #fff;
  border-radius: 999px; /* pill */
  font-size: 0.95rem;
  outline: none;
  transition: border-color var(--transition-fast),
    background var(--transition-fast), opacity var(--transition-fast);
  max-width: calc(100% - 64px); /* Ensure space for send button */
}
#video-url:focus,
#chat-input:focus,
.chat-form textarea:focus {
  border-color: var(--color-accent);
  background: #2a2a2a;
}

#chat-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Submit button disabled state in chat */
.chat-form button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Light theme overrides */
[data-theme="light"] #video-url,
[data-theme="light"] #chat-input,
[data-theme="light"] .chat-form textarea {
  background: #ececec;
  color: #1b1b1b;
  border-color: var(--color-border);
}
[data-theme="light"] #video-url:focus,
[data-theme="light"] #chat-input:focus,
[data-theme="light"] .chat-form textarea:focus {
  background: #e2e2e2;
}
[data-theme="light"] #chat-input:disabled {
  opacity: 0.5;
}

/* Adjust chat form layout now that textarea is pill shaped */
.chat-form {
  align-items: flex-start;
  box-sizing: border-box;
  width: 100%;
}
.chat-form button {
  height: calc(48px * var(--ui-scale));
  min-height: calc(48px * var(--ui-scale));
}
.chat-form button.cancel-active {
  background: #5a5a5a;
  color: #fff;
}
.chat-form button.cancel-active:hover {
  background: #666;
}
.chat-form button.cancel-active:active {
  transform: translateY(1px);
}

/* Submit & Clear buttons (accent) */
#submit-btn,
#confirm-btn,
#clear-all-btn {
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: calc(12px * var(--ui-scale)) calc(20px * var(--ui-scale));
  font-size: calc(1em * var(--ui-scale));
  cursor: pointer;
  transition: background var(--transition-fast),
    box-shadow var(--transition-fast);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#submit-btn:hover,
#confirm-btn:hover,
#clear-all-btn:hover {
  background: var(--color-accent-hover);
}

/* Layout: gap between input and action buttons */
.header-input-group {
  display: flex;
  align-items: center;
  gap: calc(12px * var(--ui-scale));
  flex-wrap: wrap;
}
#clear-all-btn {
  border-radius: 999px;
  padding: calc(12px * var(--ui-scale)) calc(20px * var(--ui-scale));
  white-space: nowrap;
}

/* Icon submit button (circular) */
#submit-btn {
  width: calc(48px * var(--ui-scale));
  min-width: calc(48px * var(--ui-scale));
  height: calc(48px * var(--ui-scale));
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  line-height: 0;
}
#submit-btn svg {
  width: calc(22px * var(--ui-scale));
  height: calc(22px * var(--ui-scale));
  display: block;
  pointer-events: none;
}
#submit-btn:active {
  transform: translateY(1px);
}

/* Fallback if Clear not present */
.header-input-group:not(:has(#clear-all-btn)) #submit-btn {
  margin-right: 0;
}

/* Light theme override remains same color logic */
[data-theme="light"] #submit-btn,
[data-theme="light"] #confirm-btn,
[data-theme="light"] #clear-all-btn {
  color: #fff;
}
/* Light theme link appearance */
[data-theme="light"] .app-header a {
  color: #0f172a;
  text-decoration: none;
}
[data-theme="light"] .app-header a:hover {
  color: var(--color-accent);
}
/* Light theme: soften icon outline while keeping white background */
[data-theme="light"] .logo {
  background: #ffffff;
  border: 1px solid #e2e2e2;
}

.error-message {
  color: #ff5252;
  margin-bottom: calc(12px * var(--ui-scale));
  min-height: calc(20px * var(--ui-scale));
  font-weight: 600;
}
.helper-text {
  color: #aaa;
  font-size: 0.9em;
  margin-top: 60px;
  text-align: center;
}

.video-preview {
  margin: calc(24px * var(--ui-scale)) 0 calc(12px * var(--ui-scale)) 0;
  min-height: 0;
  transition: min-height 0.3s;
}

.video-preview iframe {
  border-radius: calc(8px * var(--ui-scale));
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  width: 100%;
  height: calc(270px * var(--ui-scale));
  border: none;
}

#confirm-btn {
  margin-top: calc(12px * var(--ui-scale));
  background: var(--color-accent);
  border-radius: calc(4px * var(--ui-scale));
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: calc(24px * var(--ui-scale)) 0;
}

.spinner {
  border: calc(6px * var(--ui-scale)) solid #303030;
  border-top: calc(6px * var(--ui-scale)) solid var(--color-accent);
  border-radius: 50%;
  width: calc(48px * var(--ui-scale));
  height: calc(48px * var(--ui-scale));
  animation: spin 1s linear infinite;
  margin-bottom: calc(12px * var(--ui-scale));
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* --- New 3-column layout and summary panel --- */
.three-col-layout {
  display: flex;
  gap: calc(18px * var(--ui-scale));
  padding: calc(28px * var(--ui-scale)) calc(28px * var(--ui-scale))
    calc(56px * var(--ui-scale));
  animation: fadeIn 0.5s ease;
  min-height: calc(100vh - 120px);
  align-items: flex-start;
}
.area {
  background: var(--color-surface);
  border-radius: calc(16px * var(--ui-scale));
  padding: calc(20px * var(--ui-scale)) calc(20px * var(--ui-scale))
    calc(28px * var(--ui-scale));
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
}
.area1 {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  gap: calc(20px * var(--ui-scale));
  position: sticky;
  top: calc(100px * var(--ui-scale));
  align-self: flex-start;
}
.area2 {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.area3 {
  flex: 0.7;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.video-container iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  border-radius: calc(12px * var(--ui-scale));
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}
.summary-panel {
  background: var(--color-surface-alt);
  border-radius: calc(12px * var(--ui-scale));
  padding: calc(16px * var(--ui-scale)) calc(20px * var(--ui-scale))
    calc(22px * var(--ui-scale));
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.summary-panel h2 {
  margin: 0 0 calc(12px * var(--ui-scale));
  color: var(--color-accent);
  font-size: 1.15em;
  letter-spacing: 0.5px;
}
/* Summary progress animation */
.summary-progress {
  display: flex;
  align-items: center;
  gap: calc(10px * var(--ui-scale));
  margin: calc(6px * var(--ui-scale)) 0 calc(12px * var(--ui-scale));
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  font-weight: 600;
}
.summary-progress.fade-out-progress {
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

/* Inline chat loading (re-using pulse keyframes) */
.chat-msg.loading {
  background: #2a2a2a;
  color: var(--color-text-muted);
  font-style: italic;
}

/* Fix: Light theme override for chat loading ("Thinking") background */
/* Transparent background for chat loading in light theme */
[data-theme="light"] .chat-msg.loading {
  background: transparent;
  color: #4a4a4a;
}
.chat-msg.loading .inline-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
}
.chat-msg.loading .inline-dots span {
  width: 6px;
  height: 6px;
  background: var(--color-accent);
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1s infinite ease-in-out;
}
.chat-msg.loading .inline-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.chat-msg.loading .inline-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
.summary-dots {
  display: inline-flex;
  gap: 4px;
}
.summary-dots span {
  width: 7px;
  height: 7px;
  background: var(--color-accent);
  border-radius: 50%;
  opacity: 0.45;
  animation: pulse 1.2s ease-in-out infinite;
}
.summary-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.summary-dots span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(0.55);
    opacity: 0.35;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}
.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(12px * var(--ui-scale));
}
.mini-btn {
  background: #303030;
  color: #fff;
  border: 1px solid var(--color-border);
  padding: calc(6px * var(--ui-scale)) calc(12px * var(--ui-scale));
  font-size: 0.7rem;
  border-radius: calc(6px * var(--ui-scale));
  cursor: pointer;
  letter-spacing: 0.5px;
  font-weight: 600;
  text-transform: uppercase;
  transition: background 0.2s, border-color 0.2s,
    transform var(--transition-fast);
  white-space: nowrap;
}
.mini-btn:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
}
.mini-btn:active {
  transform: translateY(1px);
}
.mini-btn:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 2px;
}
.summary-content {
  font-size: 0.98em;
  line-height: 1.5;
  text-align: justify;
  white-space: normal;
}
.summary-content.placeholder {
  color: #888;
  font-style: italic;
}

/* Skeleton loader */
.skeleton {
  background: var(--gradient-skeleton);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}
.summary-skeleton-line {
  height: 12px;
  margin: 8px 0;
}
.summary-skeleton-line.wide {
  width: 92%;
}
.summary-skeleton-line.mid {
  width: 70%;
}
.summary-skeleton-line.short {
  width: 48%;
}

/* Inner tabs (Area 2) */
.inner-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.inner-tab-btn {
  flex: 1;
  background: #303030;
  color: #fff;
  border: 1px solid var(--color-border);
  padding: 10px 14px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: background 0.2s, border-color 0.2s;
}
.inner-tab-btn.active,
.inner-tab-btn:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
}
#inner-tab-panels {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.inner-tab-panel {
  display: none;
  animation: fadeIn 0.25s ease;
  line-height: 1.5;
  font-size: 0.95em;
  color: #ddd;
  flex: 1;
  min-height: 0;
}
.inner-tab-panel.active {
  display: flex;
  flex-direction: column;
}

.stripe-buy {
  display: flex;
  justify-content: center;
  margin: calc(12px * var(--ui-scale)) 0;
}
.stripe-buy stripe-buy-button {
  max-width: 320px;
}

/* Responsive */
@media (max-width: 1200px) {
  .area1 {
    flex: 1.1;
  }
  .area3 {
    flex: 0.6;
  }
}
@media (max-width: 1000px) {
  .three-col-layout {
    flex-wrap: wrap;
    align-items: stretch;
  }
  .area1 {
    flex: 1 1 100%;
    position: relative;
    top: auto;
    max-height: none;
    overflow-y: visible;
  }
  .area2 {
    flex: 1 1 55%;
  }
  .area3 {
    flex: 1 1 40%;
    min-height: calc(280px * var(--ui-scale));
  }
}
@media (max-width: 700px) {
  .three-col-layout {
    padding: calc(20px * var(--ui-scale)) calc(12px * var(--ui-scale))
      calc(64px * var(--ui-scale));
  }
  .area2,
  .area3 {
    flex: 1 1 100%;
  }
  .area {
    padding: calc(18px * var(--ui-scale)) calc(16px * var(--ui-scale))
      calc(24px * var(--ui-scale));
  }
}

@media (max-width: 600px) {
  #video-url {
    font-size: 0.9rem;
    padding: calc(12px * var(--ui-scale)) calc(16px * var(--ui-scale));
  }
  #submit-btn {
    width: calc(44px * var(--ui-scale));
    min-width: calc(44px * var(--ui-scale));
    height: calc(44px * var(--ui-scale));
  }
  #clear-all-btn,
  #theme-toggle {
    font-size: 0.85rem;
    padding: calc(10px * var(--ui-scale)) calc(14px * var(--ui-scale));
  }
  .button-row {
    gap: calc(8px * var(--ui-scale));
  }
  .chat-wrapper {
    gap: calc(10px * var(--ui-scale));
  }
  .chat-log {
    padding: calc(12px * var(--ui-scale));
    gap: calc(12px * var(--ui-scale));
  }
  .chat-msg.user,
  .chat-msg.ai {
    max-width: 92%;
    font-size: 0.88rem;
  }
}

.reveal {
  animation: fadeIn 0.55s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Generated by Copilot!!!! (extended) */
/* --- Added component & theming extensions --- */
.primary-btn {
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: calc(10px * var(--ui-scale)) calc(18px * var(--ui-scale));
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: calc(8px * var(--ui-scale));
  cursor: pointer;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(6px * var(--ui-scale));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: background var(--transition-fast),
    transform var(--transition-fast);
  white-space: nowrap;
}
.primary-btn:hover {
  background: var(--color-accent-hover);
}
.primary-btn:active {
  transform: translateY(1px);
}
.primary-btn.secondary {
  background: #303030;
  color: var(--color-text-soft);
  box-shadow: none;
}
.primary-btn.secondary:hover {
  background: #3a3a3a;
}

/* Restructure summary header: place heading above buttons */
.summary-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.summary-header h2 {
  margin: 0 0 calc(10px * var(--ui-scale));
  color: var(--color-accent);
}

/* Chat */
.chat-wrapper {
  display: flex;
  flex-direction: column;
  gap: calc(12px * var(--ui-scale));
  flex: 1;
  min-height: 0;
}
.chat-log {
  flex: 1;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-soft);
  padding: calc(14px * var(--ui-scale)) calc(16px * var(--ui-scale));
  border-radius: calc(14px * var(--ui-scale));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: calc(14px * var(--ui-scale));
  font-size: 0.9rem;
  min-height: 0;
}
.chat-msg {
  line-height: 1.45;
  animation: fadeIn 0.3s ease;
  position: relative;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--color-accent-fade);
  border: 1px solid var(--color-accent);
  color: var(--color-text);
  padding: calc(10px * var(--ui-scale)) calc(14px * var(--ui-scale));
  border-radius: calc(14px * var(--ui-scale)) calc(14px * var(--ui-scale))
    calc(4px * var(--ui-scale)) calc(14px * var(--ui-scale));
  max-width: 78%;
}
.chat-msg.ai {
  align-self: flex-start;
  background: #303030;
  border: 1px solid var(--color-border);
  padding: calc(10px * var(--ui-scale)) calc(32px * var(--ui-scale))
    calc(10px * var(--ui-scale)) calc(14px * var(--ui-scale));
  border-radius: calc(14px * var(--ui-scale)) calc(14px * var(--ui-scale))
    calc(14px * var(--ui-scale)) calc(4px * var(--ui-scale));
  max-width: 85%;
  color: var(--color-text-soft);
}
.chat-msg.error {
  background: #3a0000;
  border-color: #660000;
  color: #ff9d9d;
}
.chat-msg-copy {
  position: absolute;
  top: calc(8px * var(--ui-scale));
  right: calc(8px * var(--ui-scale));
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--color-border);
  color: var(--color-text-soft);
  padding: calc(4px * var(--ui-scale)) calc(8px * var(--ui-scale));
  border-radius: calc(6px * var(--ui-scale));
  cursor: pointer;
  font-size: 0.7rem;
  transition: background var(--transition-fast),
    transform var(--transition-fast);
  opacity: 0.7;
}
.chat-msg-copy:hover {
  background: rgba(0, 0, 0, 0.5);
  opacity: 1;
  transform: scale(1.05);
}
.chat-msg-copy:active {
  transform: scale(0.95);
}
.chat-msg-copy.copied {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
[data-theme="light"] .chat-msg-copy {
  background: rgba(255, 255, 255, 0.6);
  color: #2b2b2b;
}
[data-theme="light"] .chat-msg-copy:hover {
  background: rgba(255, 255, 255, 0.9);
}

.chat-msg-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.chat-msg-share {
  background: #2bb826;
  border: 1px solid #25a020;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  opacity: 0.9;
}
.chat-msg-share:hover {
  background: #25a020;
  opacity: 1;
  transform: scale(1.05);
}
.chat-msg-share:active {
  transform: scale(0.95);
}
[data-theme="light"] .chat-msg-share {
  background: #2bb826;
  border-color: #25a020;
  color: #fff;
}
[data-theme="light"] .chat-msg-share:hover {
  background: #25a020;
}

/* Share Modal */
.share-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s;
}
.share-modal-overlay.active {
  opacity: 1;
}

.share-modal {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 360px;
  width: 90%;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s;
}
.share-modal-overlay.active .share-modal {
  transform: scale(1);
}

.share-modal-header {
  padding: 16px;
  border-bottom: 1px solid #444;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.share-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}
.share-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: color 0.2s;
}
.share-modal-close:hover {
  color: var(--color-text);
}

.share-modal-options {
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.share-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
  color: var(--color-text);
}
.share-option:hover {
  background: var(--color-accent-fade);
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.share-icon {
  font-size: 1.5rem;
  font-weight: bold;
  display: inline-block;
  min-width: 24px;
  text-align: center;
}

.share-icon-svg {
  display: inline-block;
  min-width: 32px;
  height: 32px;
}

.share-facebook .share-icon-svg {
  color: #1877f2;
}

.share-copy .share-icon-svg {
  color: var(--color-text);
}
.share-label {
  font-weight: 500;
  font-size: 0.8rem;
}

.share-hint {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-top: 4px;
  line-height: 1.2;
}

[data-theme="light"] .share-modal {
  background: #f5f5f5;
  border-color: #ddd;
}
[data-theme="light"] .share-modal-header {
  border-bottom-color: #ddd;
}
[data-theme="light"] .share-modal-close {
  color: #666;
}
[data-theme="light"] .share-modal-close:hover {
  color: #000;
}
[data-theme="light"] .share-option {
  background: #fff;
  border-color: #ddd;
  color: #333;
}
[data-theme="light"] .share-option:hover {
  background: #f0f0f0;
  border-color: #999;
}

.chat-form {
  display: flex;
  gap: calc(10px * var(--ui-scale));
  margin-top: calc(10px * var(--ui-scale));
  flex-wrap: wrap;
  align-items: flex-start;
}
.chat-form textarea {
  flex: 1;
  resize: vertical;
  min-height: calc(46px * var(--ui-scale));
  max-height: calc(180px * var(--ui-scale));
  padding: calc(12px * var(--ui-scale)) calc(14px * var(--ui-scale));
  border: 1px solid var(--color-border);
  background: #303030;
  color: var(--color-text);
  border-radius: calc(10px * var(--ui-scale));
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.35;
}
.chat-form button {
  border-radius: calc(10px * var(--ui-scale));
  white-space: nowrap;
}

@media (max-width: 600px) {
  .chat-form {
    gap: calc(8px * var(--ui-scale));
    padding: 0;
    flex-wrap: nowrap;
    flex-direction: row;
  }
  .chat-form #chat-input {
    flex: 1 1 auto;
    min-width: 150px;
    width: auto;
    font-size: 0.88rem;
    padding: calc(10px * var(--ui-scale)) calc(14px * var(--ui-scale));
    min-height: calc(40px * var(--ui-scale));
    height: calc(40px * var(--ui-scale));
    box-sizing: border-box;
    border-radius: calc(20px * var(--ui-scale));
  }
  .chat-form button[type="submit"] {
    flex: 0 0 auto;
    min-width: calc(70px * var(--ui-scale));
    height: calc(40px * var(--ui-scale));
    min-height: calc(40px * var(--ui-scale));
    padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
    font-size: 0.85rem;
  }
  #clear-chat-btn {
    display: none;
  }
  .chat-form .mini-btn {
    padding: calc(8px * var(--ui-scale)) calc(10px * var(--ui-scale));
    font-size: 0.75rem;
    min-width: 0;
  }
  /* Ensure buttons stay in a single row with input on top */
  #chat-form {
    flex-direction: row;
  }
  #chat-form > button:not(#chat-input) {
    display: flex;
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .chat-form {
    gap: calc(6px * var(--ui-scale));
  }
  .chat-form #chat-input {
    font-size: 0.85rem;
    padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
    height: calc(38px * var(--ui-scale));
    min-height: calc(38px * var(--ui-scale));
    box-sizing: border-box;
  }
  .chat-form button[type="submit"] {
    min-width: calc(60px * var(--ui-scale));
    height: calc(38px * var(--ui-scale));
    min-height: calc(38px * var(--ui-scale));
    padding: calc(8px * var(--ui-scale)) calc(10px * var(--ui-scale));
    font-size: 0.8rem;
  }
  #clear-chat-btn {
    display: none;
  }
}

/* Plan */
.plan-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.plan-controls {
  display: flex;
  gap: calc(12px * var(--ui-scale));
  align-items: center;
  margin-bottom: calc(12px * var(--ui-scale));
  flex-wrap: wrap;
  flex-shrink: 0;
}
.plan-controls select {
  background: #303030;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: calc(10px * var(--ui-scale)) calc(14px * var(--ui-scale));
  border-radius: calc(10px * var(--ui-scale));
  font-size: 0.85rem;
}
/* Plan Output - Match summary-content for theme responsiveness */
.plan-output {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-soft);
  padding: calc(16px * var(--ui-scale)) calc(18px * var(--ui-scale))
    calc(22px * var(--ui-scale));
  border-radius: calc(14px * var(--ui-scale));
  font-size: 0.9rem;
  line-height: 1.5;
  overflow-y: auto;
  position: relative;
  flex: 1;
  min-height: 0;
  color: var(--color-text);
  background-clip: padding-box;
  transition: color 0.3s, background 0.3s;
}
.plan-output.placeholder {
  color: var(--color-text-muted);
  font-style: italic;
}
/* Light theme adjustment for plan-output */
[data-theme="light"] .plan-output {
  color: var(--color-text);
}
.plan-output pre,
.plan-output code {
  background: #303030;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
}

/* Toasts */
.toast-container {
  position: fixed;
  top: calc(14px * var(--ui-scale));
  right: calc(14px * var(--ui-scale));
  display: flex;
  flex-direction: column;
  gap: calc(10px * var(--ui-scale));
  z-index: 200;
  width: min(calc(340px * var(--ui-scale)), 90vw);
}
.toast {
  background: var(--color-surface-alt);
  color: var(--color-text-soft);
  border: 1px solid var(--color-border);
  padding: calc(12px * var(--ui-scale)) calc(16px * var(--ui-scale));
  border-radius: calc(12px * var(--ui-scale));
  font-size: 0.85rem;
  display: flex;
  gap: calc(12px * var(--ui-scale));
  align-items: flex-start;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  animation: slideIn 0.35s ease;
  position: relative;
}
.toast.success {
  border-color: #1b7f3b;
}
.toast.error {
  border-color: #b00020;
}
.toast .toast-close {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: calc(1rem * var(--ui-scale));
  line-height: 1;
  position: absolute;
  top: calc(6px * var(--ui-scale));
  right: calc(8px * var(--ui-scale));
}
@keyframes slideIn {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Theme Toggle */
.theme-toggle-btn {
  background: #303030;
  border: 1px solid var(--color-border);
  color: var(--color-text-soft);
  padding: calc(8px * var(--ui-scale)) calc(14px * var(--ui-scale));
  border-radius: calc(8px * var(--ui-scale));
  cursor: pointer;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: calc(6px * var(--ui-scale));
  letter-spacing: 0.5px;
  transition: background var(--transition-fast);
}
.theme-toggle-btn:hover {
  background: #3a3a3a;
}
[data-theme="light"] .theme-toggle-btn {
  background: #ececec;
  color: #222;
}
[data-theme="light"] .theme-toggle-btn:hover {
  background: #e2e2e2;
}

/* Scrollbars */
.chat-log::-webkit-scrollbar,
.plan-output::-webkit-scrollbar {
  width: calc(10px * var(--ui-scale));
}
.chat-log::-webkit-scrollbar-track,
.plan-output::-webkit-scrollbar-track {
  background: transparent;
}
.chat-log::-webkit-scrollbar-thumb,
.plan-output::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: 20px;
  border: 2px solid #272727;
}
[data-theme="light"] .chat-log::-webkit-scrollbar-thumb,
[data-theme="light"] .plan-output::-webkit-scrollbar-thumb {
  background: #c2c2c2;
  border: 2px solid #f2f2f2;
}

/* Light theme adjustments */
[data-theme="light"] .chat-msg.ai {
  background: #f1f5f9;
  border-color: var(--color-border);
  color: #1e293b;
}
[data-theme="light"] .chat-msg.user {
  background: var(--color-accent-fade);
  color: #0f172a;
}
[data-theme="light"] .plan-output pre,
[data-theme="light"] .plan-output code {
  background: #f1f1f1;
}
[data-theme="light"] .mini-btn {
  background: #ececec;
  color: #222;
}
[data-theme="light"] .mini-btn:hover {
  background: var(--color-accent);
  color: #fff;
}

.hidden {
  display: none !important;
}

/* === Chapters Tab Styles === */
/* Chapters Wrapper - Match summary-content for theme responsiveness */
.chapters-wrapper {
  display: flex;
  flex-direction: column;
  gap: calc(12px * var(--ui-scale));
  flex: 1;
  min-height: 0;
  color: var(--color-text);
  background-clip: padding-box;
  transition: color 0.3s, background 0.3s;
}
.chapters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chapters-header h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.5px;
  color: var(--color-text);
  transition: color 0.3s;
}
.chapters-actions {
  display: flex;
  gap: calc(10px * var(--ui-scale));
}
.chapters-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: calc(10px * var(--ui-scale));
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.chapters-empty {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  margin-top: calc(6px * var(--ui-scale));
}
/* Light theme adjustment for chapters-wrapper */
[data-theme="light"] .chapters-wrapper {
  color: var(--color-text);
}
.chapter-item {
  background: #303030;
  border: 1px solid var(--color-border);
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-radius: calc(10px * var(--ui-scale));
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: calc(4px * var(--ui-scale));
  transition: background 0.18s, border-color 0.18s;
}
.chapter-item:hover,
.chapter-item:focus {
  background: var(--color-accent-fade);
  border-color: var(--color-accent);
  outline: none;
}
.chapter-item[aria-current="true"] {
  background: var(--color-accent);
  border-color: var(--color-accent-hover);
  color: #fff;
}
/* Improve selected chapter readability on light theme */
[data-theme="light"] .chapter-item[aria-current="true"] {
  background: var(--color-accent-fade);
  border-color: var(--color-accent);
  color: var(--color-text);
}
[data-theme="light"] .chapter-item[aria-current="true"] .chapter-title,
[data-theme="light"] .chapter-item[aria-current="true"] .chapter-time,
[data-theme="light"] .chapter-item[aria-current="true"] .chapter-hook {
  color: var(--color-text);
}
.chapter-time {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  opacity: 0.75;
}
.chapter-title {
  font-size: 0.82rem;
  font-weight: 600;
}
.chapter-hook {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  line-height: 1.25;
}
.chapters-list::-webkit-scrollbar {
  width: calc(8px * var(--ui-scale));
}
.chapters-list::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: calc(20px * var(--ui-scale));
}
[data-theme="light"] .chapter-item {
  background: #f4f4f4;
}
[data-theme="light"] .chapter-item:hover {
  background: var(--color-accent-fade);
}
[data-theme="light"] .chapter-hook {
  color: #475569;
}

/* === Related Videos Panel === */
.related-wrapper {
  display: flex;
  flex-direction: column;
  gap: calc(12px * var(--ui-scale));
  flex: 1;
  min-height: 0;
}
.related-panel {
  background: transparent;
  border-radius: calc(12px * var(--ui-scale));
  padding: calc(14px * var(--ui-scale)) calc(18px * var(--ui-scale))
    calc(20px * var(--ui-scale));
  display: flex;
  flex-direction: column;
  gap: calc(14px * var(--ui-scale));
  height: 100%;
  width: 100%;
}
.related-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.related-header h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  color: var(--color-accent);
}
.related-header h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.5px;
}
.related-actions {
  display: flex;
  gap: calc(10px * var(--ui-scale));
}
.related-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: calc(12px * var(--ui-scale));
  overflow-y: auto;
}
.related-item {
  display: flex;
  gap: calc(12px * var(--ui-scale));
  background: #303030;
  border: 1px solid var(--color-border);
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-radius: calc(12px * var(--ui-scale));
  cursor: pointer;
  align-items: stretch;
  transition: background 0.18s, border-color 0.18s;
  pointer-events: auto;
  user-select: none;
}
.related-item:hover,
.related-item:focus {
  background: var(--color-accent-fade);
  border-color: var(--color-accent);
  outline: none;
}
.related-thumb {
  width: calc(120px * var(--ui-scale));
  aspect-ratio: 16/9;
  background: #222;
  border-radius: calc(8px * var(--ui-scale));
  object-fit: cover;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
  pointer-events: none;
}
.related-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  pointer-events: none;
}
.related-title {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
}
.related-reason {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  line-height: 1.3;
}
.related-channel {
  font-size: 0.6rem;
  opacity: 0.75;
}
.related-empty {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  margin-top: calc(4px * var(--ui-scale));
}
.related-error {
  font-size: 0.7rem;
  color: #ff9d9d;
  background: #3a0000;
  border: 1px solid #660000;
  padding: calc(8px * var(--ui-scale)) calc(10px * var(--ui-scale));
  border-radius: calc(8px * var(--ui-scale));
}
.related-skeleton {
  display: flex;
  gap: calc(12px * var(--ui-scale));
  background: #303030;
  border: 1px solid var(--color-border);
  padding: calc(10px * var(--ui-scale)) calc(12px * var(--ui-scale));
  border-radius: calc(12px * var(--ui-scale));
}
.related-skeleton .thumb-skel {
  width: calc(120px * var(--ui-scale));
  aspect-ratio: 16/9;
  border-radius: calc(8px * var(--ui-scale));
}
.related-skeleton .lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: calc(8px * var(--ui-scale));
}
.tag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: calc(6px * var(--ui-scale));
}
.tag-pill {
  background: #3a3a3a;
  color: #ccc;
  font-size: 0.55rem;
  padding: calc(3px * var(--ui-scale)) calc(6px * var(--ui-scale));
  border-radius: calc(20px * var(--ui-scale));
  letter-spacing: 0.5px;
}
[data-theme="light"] .related-item {
  background: #f4f4f4;
}
[data-theme="light"] .related-item:hover {
  background: var(--color-accent-fade);
}
[data-theme="light"] .related-title {
  color: #1f2937; /* slate-800 */
}
[data-theme="light"] .related-reason {
  color: #475569;
}
[data-theme="light"] .related-channel {
  color: #64748b; /* slate-500 */
  opacity: 1;
}
[data-theme="light"] .tag-pill {
  background: #e2e2e2;
  color: #333;
}

.video-error-state {
  background: linear-gradient(
    135deg,
    rgba(255, 0, 0, 0.12),
    rgba(255, 0, 0, 0.04)
  );
  border: 1px solid var(--color-border);
  border-radius: calc(12px * var(--ui-scale));
  padding: calc(24px * var(--ui-scale)) calc(20px * var(--ui-scale));
  text-align: center;
  color: var(--color-text-soft);
  min-height: calc(220px * var(--ui-scale));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(16px * var(--ui-scale));
}
.video-error-state p {
  margin: 0;
  max-width: calc(340px * var(--ui-scale));
  line-height: 1.45;
}
.video-error-detail {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.video-error-state .mini-btn {
  width: auto;
  min-width: calc(140px * var(--ui-scale));
}
.video-error-state .mini-btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* === Recent Videos Section === */
.recent-videos-section {
  display: none; /* Hidden by default, shown when videos exist */
  margin-bottom: calc(16px * var(--ui-scale));
  padding-bottom: calc(16px * var(--ui-scale));
  border-bottom: 1px solid var(--color-border-soft);
}

.recent-videos-title {
  margin: 0 0 calc(12px * var(--ui-scale));
  font-size: 0.9rem;
  color: var(--color-text-soft);
  letter-spacing: 0.5px;
  font-weight: 600;
}

.session-expiry-label {
  margin-left: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-soft);
  position: relative;
  display: inline-flex;
  align-items: center;
}

.expiry-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 69, 0, 0.18), rgba(255, 0, 0, 0.12));
  border: 1px solid rgba(255, 99, 71, 0.6);
  color: var(--color-text);
  box-shadow: 0 0 0 0 rgba(255, 99, 71, 0.4);
  animation: expiryPulse 1.6s ease-in-out infinite;
}

.warning-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 99, 71, 0.9);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  color: rgba(255, 99, 71, 0.95);
  background: rgba(0, 0, 0, 0.15);
}

.expiry-text {
  white-space: nowrap;
}

.session-expiry-label[data-tooltip]:hover::after,
.session-expiry-label[data-tooltip]:focus::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.35;
  max-width: 240px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 20;
  pointer-events: none;
}

.session-expiry-label[data-tooltip]:hover::before,
.session-expiry-label[data-tooltip]:focus::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 14px;
  border-width: 6px;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;
  z-index: 21;
  pointer-events: none;
}

@keyframes expiryPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 99, 71, 0.5);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(255, 99, 71, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 99, 71, 0);
  }
}

.recent-videos-list {
  display: flex;
  gap: calc(12px * var(--ui-scale));
  overflow-x: auto;
  padding-bottom: calc(8px * var(--ui-scale));
}

.recent-videos-list::-webkit-scrollbar {
  height: calc(6px * var(--ui-scale));
}

.recent-videos-list::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: calc(20px * var(--ui-scale));
}

.recent-video-item {
  position: relative;
  flex-shrink: 0;
  width: calc(120px * var(--ui-scale));
  cursor: pointer;
  border-radius: calc(8px * var(--ui-scale));
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.recent-video-item:hover,
.recent-video-item:focus {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 0, 0, 0.4);
  outline: none;
}

.recent-video-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}

.recent-video-badge {
  position: absolute;
  bottom: calc(4px * var(--ui-scale));
  right: calc(4px * var(--ui-scale));
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 0.55rem;
  padding: calc(2px * var(--ui-scale)) calc(4px * var(--ui-scale));
  border-radius: calc(3px * var(--ui-scale));
  font-weight: 700;
  letter-spacing: 0.5px;
}

.recent-video-remove {
  position: absolute;
  top: calc(4px * var(--ui-scale));
  right: calc(4px * var(--ui-scale));
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  border: none;
  width: calc(20px * var(--ui-scale));
  height: calc(20px * var(--ui-scale));
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  z-index: 10;
}

.recent-video-item:hover .recent-video-remove,
.recent-video-item:focus .recent-video-remove {
  opacity: 1;
}

.recent-video-remove:hover {
  background: var(--color-accent);
}

[data-theme="light"] .recent-videos-list::-webkit-scrollbar-thumb {
  background: #c2c2c2;
}

/* === Plan Fullscreen Modal === */
.plan-fullscreen-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(0, 0, 0, 0.3);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px * var(--ui-scale));
  opacity: 0;
  transition: opacity 0.3s ease, backdrop-filter 0.3s ease;
}

.plan-fullscreen-modal.hidden {
  display: none;
}

.plan-fullscreen-modal.active {
  opacity: 1;
}

.plan-fullscreen-content {
  background: var(--color-surface);
  border-radius: calc(16px * var(--ui-scale));
  width: 100%;
  max-width: calc(1400px * var(--ui-scale));
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.plan-fullscreen-modal.active .plan-fullscreen-content {
  transform: scale(1);
}

.plan-fullscreen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(20px * var(--ui-scale)) calc(28px * var(--ui-scale));
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.plan-fullscreen-header h2 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--color-accent);
  letter-spacing: 0.5px;
}

.plan-close-btn {
  background: transparent;
  border: none;
  color: var(--color-text-soft);
  cursor: pointer;
  padding: calc(8px * var(--ui-scale));
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: calc(8px * var(--ui-scale));
  transition: background 0.2s, color 0.2s;
}

.plan-close-btn:hover {
  background: var(--color-surface-alt);
  color: var(--color-accent);
}

.plan-close-btn svg {
  width: calc(24px * var(--ui-scale));
  height: calc(24px * var(--ui-scale));
}

.plan-fullscreen-body {
  flex: 1;
  overflow-y: auto;
  padding: calc(32px * var(--ui-scale)) calc(40px * var(--ui-scale));
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--color-text-soft);
}

.plan-fullscreen-body h1,
.plan-fullscreen-body h2,
.plan-fullscreen-body h3 {
  color: var(--color-text);
  margin-top: calc(24px * var(--ui-scale));
  margin-bottom: calc(12px * var(--ui-scale));
}

.plan-fullscreen-body p {
  margin-bottom: calc(16px * var(--ui-scale));
}

.plan-fullscreen-body ul,
.plan-fullscreen-body ol {
  margin-bottom: calc(16px * var(--ui-scale));
  padding-left: calc(28px * var(--ui-scale));
}

.plan-fullscreen-body li {
  margin-bottom: calc(8px * var(--ui-scale));
}

.plan-fullscreen-body::-webkit-scrollbar {
  width: calc(10px * var(--ui-scale));
}

.plan-fullscreen-body::-webkit-scrollbar-track {
  background: transparent;
}

.plan-fullscreen-body::-webkit-scrollbar-thumb {
  background: #3a3a3a;
  border-radius: calc(20px * var(--ui-scale));
  border: 2px solid var(--color-surface);
}

[data-theme="light"] .plan-fullscreen-body::-webkit-scrollbar-thumb {
  background: #c2c2c2;
}

.plan-content-wrapper {
  position: relative;
}

.maximize-plan-btn {
  position: absolute;
  top: calc(12px * var(--ui-scale));
  right: calc(12px * var(--ui-scale));
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  width: calc(36px * var(--ui-scale));
  height: calc(36px * var(--ui-scale));
  border-radius: calc(8px * var(--ui-scale));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.2s, background 0.2s;
  z-index: 10;
}

.plan-content-wrapper:hover .maximize-plan-btn {
  opacity: 1;
}

.maximize-plan-btn:hover {
  background: var(--color-accent);
}

.maximize-plan-btn svg {
  width: calc(20px * var(--ui-scale));
  height: calc(20px * var(--ui-scale));
  display: block;
}

[data-theme="light"] .maximize-plan-btn {
  background: rgba(255, 255, 255, 0.9);
  color: #222;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .maximize-plan-btn:hover {
  background: var(--color-accent);
  color: #fff;
}

#maximize-plan-btn svg {
  width: calc(16px * var(--ui-scale));
  height: calc(16px * var(--ui-scale));
  display: block;
}

@media (max-width: 768px) {
  .plan-fullscreen-content {
    max-width: 100%;
    max-height: 95vh;
    border-radius: calc(12px * var(--ui-scale));
  }

  .plan-fullscreen-body {
    padding: calc(20px * var(--ui-scale)) calc(24px * var(--ui-scale));
    font-size: 1rem;
  }
}

/* ================= Shepherd.js Tour Styling ================= */
.shepherd-element {
  border-radius: 16px !important;
  border: 2px solid var(--color-accent) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3) !important;
  max-width: 380px !important;
}

.shepherd-content {
  border-radius: 14px !important;
  background: var(--color-surface) !important;
  color: var(--color-text) !important;
  padding: 18px 20px !important;
}

.shepherd-text {
  color: var(--color-text) !important;
  font-size: 0.95rem !important;
  line-height: 1.5 !important;
}

.shepherd-header {
  padding-bottom: 8px !important;
}

.shepherd-footer {
  padding-top: 12px !important;
  display: flex !important;
  gap: 10px !important;
  justify-content: flex-end !important;
}

.shepherd-button {
  background: var(--color-accent) !important;
  color: white !important;
  border: none !important;
  border-radius: 8px !important;
  padding: 8px 18px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: background 0.2s !important;
  font-size: 0.9rem !important;
}

.shepherd-button:hover {
  background: var(--color-accent-hover) !important;
}

.shepherd-button-secondary {
  background: var(--color-surface-alt) !important;
  border: 1px solid var(--color-border) !important;
}

.shepherd-button-secondary:hover {
  background: var(--color-border) !important;
}

.shepherd-cancel-icon {
  color: var(--color-text) !important;
  opacity: 0.6 !important;
}

.shepherd-cancel-icon:hover {
  opacity: 1 !important;
}

.shepherd-modal-overlay-container {
  background: rgba(0, 0, 0, 0.6) !important;
}
