:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1f2630;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --gold: #f59e0b;
  --green: #22c55e;
  --orange: #f97316;
  --purple: #a855f7;
  --radius: 12px;
}

* {
  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.45;
}

/* Header */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

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

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.script-toggle {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.toggle-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}

.toggle-btn.active {
  background: var(--accent);
  color: #fff;
}

.progress-pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
  font-size: 0.8rem;
  color: var(--muted);
}

.progress-bar-track {
  height: 6px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--accent));
  transition: width 0.25s ease;
}

/* Filters */
.filters-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: #10151c;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

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

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip-gold.active {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--gold);
  color: #fcd34d;
}

.select-input,
.search-input {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.84rem;
}

.search-input {
  min-width: 210px;
}

/* Workspace Layout */
.workspace {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  padding: 20px 24px;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

/* Feed Panel */
.feed-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 160px);
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 600;
}

.phrase-feed {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feed-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.feed-item:hover {
  background: var(--surface-2);
}

.feed-item.active {
  background: rgba(59, 130, 246, 0.14);
  border-color: var(--accent);
}

.feed-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.feed-phrase {
  font-weight: 700;
  font-size: 0.96rem;
}

.feed-translation {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

.feed-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.74rem;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-base {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
}

.badge-slang {
  background: rgba(168, 85, 247, 0.2);
  color: #d8b4fe;
}

.badge-dialogue {
  background: rgba(34, 197, 94, 0.18);
  color: #86efac;
}

.badge-gold {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-status-known {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.badge-status-learning {
  background: rgba(249, 115, 22, 0.15);
  color: #fdba74;
}

/* Active Card */
.phrase-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.badges-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radar-score {
  font-size: 0.84rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 8px;
}

.phrase-title {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.phrase-translation {
  margin: 4px 0 12px;
  font-size: 1.15rem;
  color: #93c5fd;
  font-weight: 500;
}

.usage-box {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
}

.usage-label {
  color: var(--muted);
  font-weight: 600;
  margin-right: 6px;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 10px;
}

@media (max-width: 640px) {
  .metrics-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}

.metric-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}

.metric-val {
  font-size: 1.05rem;
  font-weight: 700;
}

.metric-lbl {
  font-size: 0.74rem;
  color: var(--muted);
}

/* Player Section */
.player-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.player-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.source-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
}

.example-title {
  font-size: 0.88rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 420px;
}

.player-actions {
  display: flex;
  gap: 8px;
}

.player-frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 360px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
}

.player-frame-wrap iframe,
#ytPlayerMount {
  width: 100%;
  height: 100%;
}

.clip-time-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  background: rgba(13, 17, 23, 0.85);
  color: #e6edf3;
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  pointer-events: none;
}

.clip-progress-track {
  height: 5px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.clip-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.12s linear;
}

.subtitle-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.subtitle-box.cue-active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.subtitle-label {
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.subtitle-line {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.5;
}

.highlight-phrase {
  background: rgba(245, 158, 11, 0.25);
  color: #fde68a;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
}

.examples-switcher {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.example-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ex-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.ex-btn.active {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.18);
}

/* Buttons & Footer */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

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

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

.btn-ghost:hover {
  border-color: var(--accent);
}

.btn-success {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.45);
  color: #4ade80;
}

.btn-success:hover {
  background: rgba(34, 197, 94, 0.3);
}

.btn-warn {
  background: rgba(249, 115, 22, 0.18);
  border-color: rgba(249, 115, 22, 0.45);
  color: #fdba74;
}

.btn-warn:hover {
  background: rgba(249, 115, 22, 0.3);
}

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

.srs-buttons {
  display: flex;
  gap: 10px;
}

.muted {
  color: var(--muted);
}

/* CLS-safe Monetization Ad Slot */
.ad-slot {
  margin-top: 14px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.ad-slot-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.ad-slot-body {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.84rem;
  color: var(--muted);
  text-align: center;
}

/* SEO Footer */
.seo-footer {
  max-width: 1400px;
  margin: 12px auto 32px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.88rem;
}

.seo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 24px;
}

@media (max-width: 768px) {
  .seo-grid {
    grid-template-columns: 1fr;
  }
}

.seo-footer h2,
.seo-footer h3 {
  color: var(--text);
  margin: 0 0 8px;
  font-size: 1rem;
}

.seo-footer ul {
  margin: 0;
  padding-left: 18px;
}

.seo-legal {
  margin-top: 16px;
  font-size: 0.78rem;
}

.seo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.seo-links a {
  color: #93c5fd;
  text-decoration: none;
  font-size: 0.84rem;
}

.seo-links a:hover {
  text-decoration: underline;
}
