:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.hidden { display: none !important; }

.yt-tool-container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 28px 18px 64px;
}

.yt-hero {
  text-align: center;
  margin-bottom: 24px;
}

.yt-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}

.yt-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
}

.yt-hero p {
  margin: 0 auto;
  max-width: 700px;
  color: var(--muted);
}

/* Input Card */
.yt-input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.yt-form {
  display: flex;
  gap: 10px;
}

.yt-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 4px 8px;
  background: #fff;
  transition: border-color 0.2s;
}

.yt-input-wrap:focus-within { border-color: var(--primary); }

.yt-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  padding: 10px 8px;
  min-width: 0;
}

.btn-icon {
  background: #f1f5f9;
  border: none;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
}
.btn-icon:hover { background: #e2e8f0; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  transition: background 0.2s;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.7; cursor: wait; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.yt-quick-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
}
.btn-link:hover { text-decoration: underline; }

.yt-alert {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  font-size: 14px;
}

/* History */
.yt-history {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.yt-history-head {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.yt-history-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.history-chip {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  cursor: pointer;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-chip:hover { background: var(--accent-soft); border-color: var(--primary); }

/* Workspace Layout */
.yt-workspace {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 20px;
  margin-top: 22px;
  align-items: start;
}

.yt-sidebar > div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.yt-player-box {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}
.yt-player-box img { width: 100%; height: 100%; object-fit: cover; display: block; }

.yt-play-overlay {
  position: absolute;
  inset: auto 10px 10px 10px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.yt-play-overlay:hover { background: var(--primary); }

#ytIframeMount iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.yt-video-meta { padding: 14px; }
.yt-video-meta h2 { margin: 0 0 4px; font-size: 15px; line-height: 1.35; }
.yt-channel { margin: 0 0 10px; font-size: 13px; color: var(--muted); }

.yt-meta-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.meta-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  color: #334155;
}

.yt-stats-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  text-align: center;
  padding: 12px 8px;
}
.yt-stats-card strong { display: block; font-size: 16px; }
.yt-stats-card span { font-size: 11.5px; color: var(--muted); }

/* Right Content Area */
.yt-content-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Language & Translator Bar Above Transcript */
.yt-translator-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.translator-row {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 12px;
  margin-bottom: 12px;
}

.translator-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}

.translator-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.translator-field select {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  background: #fff;
  cursor: pointer;
}
.translator-field select:focus { outline: none; border-color: var(--primary); }

.translating-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--accent-soft);
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.quick-lang-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.quick-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-right: 4px;
}

.lang-pill {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.lang-pill:hover { border-color: var(--primary); color: var(--primary); }
.lang-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Split Row: Transcript + Main Points */
.yt-split-panels {
  display: grid;
  grid-template-columns: 1.25fr 0.9fr;
  gap: 16px;
  align-items: stretch;
}

.yt-main-panel,
.yt-bullets-panel,
.yt-summary-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.yt-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fcfcfd;
}

.yt-panel-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.yt-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.segmented {
  display: inline-flex;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 8px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  color: #475569;
}
.seg-btn.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.yt-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
}

.yt-search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.yt-search-box input {
  padding: 6px 64px 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  width: 200px;
}
.search-count {
  position: absolute;
  right: 8px;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}

.yt-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.action-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.btn-action {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn-action.small { padding: 5px 10px; font-size: 12px; }
.btn-action.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-action.primary:hover { background: var(--primary-hover); }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 225px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  padding: 6px;
}
.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  cursor: pointer;
}
.dropdown-menu button:hover { background: var(--accent-soft); color: var(--primary); }

.export-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.btn-export {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.btn-export:hover { border-color: var(--primary); color: var(--primary); }

/* Transcript Box */
.yt-transcript-box {
  padding: 16px 18px;
  height: 480px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.75;
}

.yt-paragraph { margin: 0 0 14px; }
.yt-paragraph:last-child { margin-bottom: 0; }

.yt-seg-row {
  display: flex;
  gap: 10px;
  padding: 5px 6px;
  border-radius: 6px;
}
.yt-seg-row:hover { background: #f8fafc; }

.yt-ts-btn {
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--primary);
  border: none;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
  height: fit-content;
  margin-top: 3px;
}
.yt-ts-btn:hover { background: var(--primary); color: #fff; }

mark {
  background: #fef08a;
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

/* Main Points (Bullets) Panel */
.panel-subnote {
  margin: 0;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.yt-bullets-list {
  margin: 0;
  padding: 14px 16px;
  list-style: none;
  height: 525px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.yt-bullet-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.55;
}

/* Summary Panel Below */
.summary-title-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.yt-topic-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 18px 0;
}

.topic-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.topic-tag {
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--primary);
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
}

.yt-summary-box {
  padding: 14px 18px 18px;
  font-size: 15px;
  line-height: 1.75;
}
.yt-summary-box p { margin: 0 0 12px; }
.yt-summary-box p:last-child { margin-bottom: 0; }

/* RTL Support for Urdu, Arabic, Persian, Hebrew */
.is-rtl {
  direction: rtl;
  text-align: right;
  font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Segoe UI", Tahoma, Arial, sans-serif;
}
.is-rtl .yt-seg-row,
.is-rtl .yt-bullet-item {
  flex-direction: row;
}

/* SEO & FAQ */
.yt-seo-section { margin-top: 48px; }
.yt-seo-section h2 { font-size: 1.35rem; margin: 28px 0 14px; }

.yt-steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.step-card span {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 13px;
}
.step-card h3 { margin: 10px 0 6px; font-size: 16px; }
.step-card p { margin: 0; font-size: 14px; color: var(--muted); }

.yt-faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.yt-faq summary { font-weight: 600; cursor: pointer; }
.yt-faq details p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

/* Toast */
.yt-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

@media (max-width: 1080px) {
  .yt-workspace { grid-template-columns: 1fr; }
  .yt-split-panels { grid-template-columns: 1fr; }
  .yt-transcript-box,
  .yt-bullets-list { height: auto; max-height: 440px; }
}

@media (max-width: 720px) {
  .translator-row { grid-template-columns: 1fr; }
  .yt-steps-grid { grid-template-columns: 1fr; }
  .yt-form { flex-direction: column; }
  .btn-primary { width: 100%; justify-content: center; }
  .yt-search-box input { width: 160px; }
}

.yt-replace-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.yt-replace-bar input {
  flex: 1;
  min-width: 140px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
}

.btn-action.speaking {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.yt-main-panel,
.yt-bullets-panel,
.yt-summary-panel {
  min-width: 0;
}

.yt-bullet-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}