:root {
  --bg: #050508;
  --bg-elevated: #0d0d12;
  --bg-card: #101019;
  --border: #1c1c26;
  --border-strong: #2a2a38;
  --text: #f0f0f5;
  --text-dim: #8a8a99;
  --text-faint: #5a5a68;
  --accent: #DC2626;
  --accent-hover: #ef4444;
  --accent-dim: #991B1B;
  --accent-glow: rgba(220, 38, 38, 0.25);
  --radius-card: 16px;
  --radius-btn: 10px;
  --radius-pill: 999px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.site-header {
  position: sticky;
  top: 0;
  background: rgba(5, 5, 8, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 36px;
  max-width: 1600px;
  margin: 0 auto;
}

.site-title {
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}

#search {
  width: 100%;
  padding: 11px 16px;
  padding-right: 60px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#search::placeholder { color: var(--text-faint); }

#search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-count {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-faint);
  pointer-events: none;
}

.categories {
  display: flex;
  gap: 8px;
  padding: 0 36px 16px;
  max-width: 1600px;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}
.categories::-webkit-scrollbar { display: none; }

.cat-pill {
  flex-shrink: 0;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-transform: capitalize;
}

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

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

main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 32px 36px 80px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-5px);
  border-color: var(--accent);
  box-shadow: 0 12px 32px -8px var(--accent-glow), inset 0 0 0 1px var(--accent-dim);
}

.thumb {
  position: relative;
  width: 100%;
  background: #000;
  overflow: hidden;
}

.thumb.vertical { aspect-ratio: 9 / 16; }
.thumb.horizontal { aspect-ratio: 16 / 9; }

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
}

.card:hover .thumb img { transform: scale(1.04); }

.duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 3px 7px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  letter-spacing: 0.02em;
}

.card-body {
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.tag {
  display: inline-block;
  padding: 3px 9px;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  text-transform: capitalize;
  align-self: flex-start;
  letter-spacing: 0.02em;
}

.empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-faint);
  font-size: 15px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade-in 0.2s ease-out;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.modal-panel {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  width: 100%;
  max-width: 1100px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background var(--transition);
}

.modal-close:hover { background: var(--accent); }

.modal-body {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 0;
  flex: 1;
  min-height: 0;
}

.player-wrap {
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

#player {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 48px);
  object-fit: contain;
  background: #000;
}

.modal-side {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  border-left: 1px solid var(--border);
}

.modal-side h2 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
}

.modal-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.modal-meta .dot { color: var(--text-faint); }
#modal-duration { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.btn {
  flex: 1;
  padding: 11px 16px;
  border-radius: var(--radius-btn);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #fff;
  box-shadow: 0 4px 12px -2px var(--accent-glow);
}

.btn-primary:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 18px -2px var(--accent-glow);
}

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

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

.transcript-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex: 1;
  min-height: 0;
}

.transcript-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.btn-mini {
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-mini:hover { color: var(--accent); border-color: var(--accent); }
.btn-mini.copied { color: #4ade80; border-color: #4ade80; }

#transcript-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

@media (max-width: 900px) {
  .header-inner { padding: 16px 20px; flex-wrap: wrap; }
  .categories { padding: 0 20px 14px; }
  main { padding: 24px 20px 60px; }
  .modal-body { grid-template-columns: 1fr; grid-template-rows: auto auto; }
  .modal-side { border-left: none; border-top: 1px solid var(--border); padding: 20px; }
  .player-wrap { max-height: 50vh; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .modal { padding: 0; }
  .modal-panel { max-width: 100%; max-height: 100vh; border-radius: 0; }
}
