:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-subtle: #f1f3f7;
  --text: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #dc2626;
  --accent-hover: #b91c1c;
  --accent-soft: rgba(220, 38, 38, 0.08);
  --primary: #111827;
  --primary-text: #ffffff;
  --highlight-bg: #fef08a;
  --highlight-text: #111827;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-md: 0 8px 24px rgba(17, 24, 39, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: "Inter", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0b0e14;
  --surface: #131722;
  --surface-subtle: #1b2130;
  --text: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border: #232a3b;
  --border-strong: #323c52;
  --accent: #ef4444;
  --accent-hover: #f87171;
  --accent-soft: rgba(239, 68, 68, 0.14);
  --primary: #f3f4f6;
  --primary-text: #0b0e14;
  --highlight-bg: #854d0e;
  --highlight-text: #fef9c3;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.nav-links a:hover {
  color: var(--text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.85rem;
}

.btn-xs {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: 6px;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-subtle);
  color: var(--text);
}

.btn-icon, .btn-icon-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}

.btn-icon:hover, .btn-icon-text:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* Hero */
.hero {
  padding: 56px 0 36px;
  text-align: center;
}

.hero-inner {
  max-width: 820px;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.hero-title {
  margin: 0 0 16px;
  font-size: clamp(1.9rem, 3.8vw, 2.85rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.hero-subtitle {
  margin: 0 auto 28px;
  max-width: 680px;
  font-size: 1.05rem;
  color: var(--text-secondary);
}

.hero-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* Workspace Section */
.workspace-section {
  padding: 16px 0 72px;
}

.control-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.control-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.section-heading {
  margin: 0 0 4px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-desc {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.demo-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chips-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.input-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
  margin-bottom: 14px;
}

.input-group label,
.textarea-toolbar label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.track-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.track-selector label {
  margin-bottom: 0;
  font-size: 0.78rem;
  white-space: nowrap;
}

.select-sm {
  padding: 5px 10px !important;
  font-size: 0.82rem !important;
}

.fetch-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-secondary);
}

.banner-action {
  margin-left: auto;
  border: 1px solid currentColor;
  color: inherit;
}

.fetch-banner.loading {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
  color: #2563eb;
}

[data-theme="dark"] .fetch-banner.loading {
  color: #60a5fa;
}

.fetch-banner.success {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
  color: #059669;
}

[data-theme="dark"] .fetch-banner.success {
  color: #34d399;
}

.fetch-banner.warn {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
}

[data-theme="dark"] .fetch-banner.warn {
  color: #fbbf24;
}

.fetch-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.fetch-banner.loading .fetch-dot {
  animation: pulseFade 1s infinite ease-in-out;
}

@keyframes pulseFade {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Colab Helper Panel */
.colab-panel {
  margin-bottom: 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface-subtle);
}

.colab-panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.colab-panel-title {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
}

.colab-panel-desc {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  max-width: 660px;
}

.colab-panel-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.colab-panel-actions .select-input {
  width: auto;
}

.colab-code-box {
  margin: 0;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
  overflow-x: auto;
  max-height: 280px;
  color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="search"],
.select-input,
textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
.select-input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.engine-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.transcript-input-area {
  margin-bottom: 16px;
}

.textarea-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.textarea-toolbar label {
  margin-bottom: 0;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

textarea {
  resize: vertical;
  min-height: 110px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.55;
}

textarea.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.control-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.stats-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stat-item strong {
  color: var(--text);
  font-family: var(--font-mono);
}

.stat-divider {
  color: var(--border-strong);
}

/* Studio Grid */
.studio-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 24px;
  align-items: start;
}

.studio-left {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mono-badge {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.status-tag {
  display: inline-block;
  margin-top: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #059669;
}

[data-theme="dark"] .status-tag {
  color: #34d399;
}

/* Video Frame */
.video-frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface-subtle);
}

.video-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  gap: 10px;
}

.video-placeholder p {
  margin: 0;
  font-size: 0.88rem;
  max-width: 340px;
}

/* Summary Body */
.summary-body {
  padding: 20px;
}

.summary-block {
  margin-bottom: 22px;
}

.summary-block:last-child {
  margin-bottom: 0;
}

.summary-block-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
  margin: 0 0 10px;
}

.tldr-box {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border-left: 3px solid var(--accent);
  font-size: 0.95rem;
  line-height: 1.65;
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.keyword-tag {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.bullet-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.93rem;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chapter-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}

.chapter-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.ts-pill {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  cursor: pointer;
}

.ts-pill:hover {
  background: var(--accent);
  color: #fff;
}

.chapter-title {
  font-weight: 600;
  font-size: 0.92rem;
}

.chapter-summary {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

/* Transcript Panel */
.transcript-panel {
  display: flex;
  flex-direction: column;
  max-height: 920px;
}

.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.search-bar svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar input {
  border: none;
  background: transparent;
  padding: 4px 0;
  box-shadow: none !important;
}

.search-count {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.transcript-list {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.transcript-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background-color 0.12s ease;
}

.transcript-row:hover {
  background: var(--surface-subtle);
}

.transcript-row.active-row {
  background: var(--accent-soft);
}

.transcript-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
}

.transcript-text mark {
  background: var(--highlight-bg);
  color: var(--highlight-text);
  padding: 0 3px;
  border-radius: 3px;
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Dropdown */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 170px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.dropdown-menu button {
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.84rem;
  color: var(--text);
  cursor: pointer;
}

.dropdown-menu button:hover {
  background: var(--surface-subtle);
}

/* Features & Workflow */
.features-section,
.workflow-section {
  padding: 64px 0;
  border-top: 1px solid var(--border);
}

.section-center-head {
  text-align: center;
  max-width: 600px;
  margin: 0 auto 40px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.feature-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.feature-card h3 {
  margin: 0 0 8px;
  font-size: 1.02rem;
  font-weight: 700;
}

.feature-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 26px;
}

.step-num {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
}

.step-card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.step-card p {
  margin: 0;
  font-size: 0.89rem;
  color: var(--text-secondary);
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  background: var(--surface);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--primary);
  color: var(--primary-text);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive */
@media (max-width: 1024px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
  .transcript-panel {
    max-height: 620px;
  }
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
  }
  .input-grid {
    grid-template-columns: 1fr;
  }
  .input-with-btn {
    flex-wrap: wrap;
  }
  .features-grid,
  .steps-grid {
    grid-template-columns: 1fr;
  }
  .hero {
    padding: 36px 0 24px;
  }
  .control-card {
    padding: 18px;
  }
}
