:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --surface-2: #243041;
  --border: #2e3d4f;
  --text: #e8eef4;
  --muted: #8b9cb0;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --radius: 12px;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden { display: none !important; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 20, 25, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

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

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

.header-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-wrap input {
  width: min(260px, 70vw);
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.count {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Main grid */
.main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
  padding: 0;
  color: inherit;
  font: inherit;
  width: 100%;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  outline: none;
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.85;
}

.thumb-fallback {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem;
  text-align: center;
}

.play-badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(to top, rgba(0,0,0,0.45), transparent 55%);
  pointer-events: none;
}

.play-badge svg {
  width: 48px;
  height: 48px;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
  opacity: 0.95;
}

.card-body {
  padding: 0.85rem 1rem 1rem;
}

.card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
}

.card-meta {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.site-footer code {
  background: var(--surface);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.78rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.modal-panel {
  position: relative;
  width: min(960px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem 1.15rem 1.15rem;
}

.modal-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 650;
}

.icon-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}

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

.player-wrap {
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

.player-wrap video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.modal-desc {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

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

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

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

body.modal-open { overflow: hidden; }

@media (max-width: 560px) {
  .brand h1 { font-size: 1rem; }
  .modal-panel { padding: 0.85rem; }
}
