:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-soft: rgba(255, 255, 255, 0.06);
  --card: rgba(7, 17, 31, 0.72);
  --card-border: rgba(255, 255, 255, 0.1);
  --text: #e8eefc;
  --muted: #9caaca;
  --primary: #ff4d5a;
  --primary-2: #7c5cff;
  --success: #18c37e;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(124, 92, 255, 0.28), transparent 32%),
    radial-gradient(circle at top right, rgba(255, 77, 90, 0.2), transparent 25%),
    linear-gradient(180deg, #091321 0%, #050b14 100%);
  color: var(--text);
}

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

button,
input {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 36px;
  border: 1px solid var(--card-border);
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.16), rgba(255, 77, 90, 0.08)), var(--bg-soft);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero__badge {
  display: inline-flex;
  padding: 8px 14px;
  border-radius: 999px;
  margin-bottom: 18px;
  background: rgba(255, 255, 255, 0.08);
  color: #dfe7ff;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.05;
}

.hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.hero__install {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 24px;
}

.install-button {
  flex: 0 0 auto;
  min-width: 220px;
}

.install-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.install-hint--success {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(24, 195, 126, 0.35);
  background: rgba(24, 195, 126, 0.12);
  color: #d8ffe9;
  font-weight: 600;
}

.hero__controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 18px;
  margin-top: 28px;
}

.search-box,
.stats-card {
  border: 1px solid var(--card-border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
}

.search-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
}

.search-box span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 1rem;
}

.search-box input::placeholder {
  color: #7c8ba9;
}

.stats-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 18px;
}

.stats-card strong {
  font-size: 2rem;
  font-weight: 800;
}

.stats-card span {
  color: var(--muted);
}

.list-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 28px 0 18px;
}

.list-header h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
}

.list-header p {
  margin: 0;
  color: var(--muted);
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.video-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
  backdrop-filter: blur(20px);
}

.video-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.42);
}

.video-card__thumb-link {
  display: block;
  aspect-ratio: 16 / 9;
  background: linear-gradient(120deg, rgba(124, 92, 255, 0.28), rgba(255, 77, 90, 0.2));
}

.video-card__thumb {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.video-card__content {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 18px;
}

.video-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.83rem;
}

.video-card__index {
  font-weight: 700;
  color: #cad7f6;
}

.video-card__id {
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-card__title {
  margin: 0 0 18px;
  font-size: 1.05rem;
  line-height: 1.45;
  min-height: 3em;
}

.video-card__notes {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.video-card__notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.video-card__notes-header strong {
  font-size: 0.95rem;
}

.video-card__notes-count {
  color: var(--muted);
  font-size: 0.83rem;
}

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

.note-item {
  padding: 12px;
  border-radius: 16px;
  background: rgba(7, 17, 31, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.note-item__range {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.18);
  color: #d8d2ff;
  font-size: 0.78rem;
  font-weight: 700;
}

.note-item__title {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1.5;
}

.note-item__actions {
  display: flex;
  gap: 10px;
}

.button--small {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 0.9rem;
}

.button--secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.1);
}

.video-card__actions {
  display: flex;
  gap: 12px;
  margin-top: auto;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease, background 180ms ease, border-color 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button--primary {
  flex: 1;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  font-weight: 700;
}

.button--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--card-border);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 40px 24px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(24, 195, 126, 0.96);
  color: white;
  font-weight: 700;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 7, 14, 0.78);
  backdrop-filter: blur(10px);
}

.modal__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1240px, calc(100% - 24px));
  height: min(92vh, 920px);
  margin: 4vh auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(8, 18, 31, 0.98), rgba(7, 17, 31, 0.96));
  box-shadow: 0 32px 120px rgba(0, 0, 0, 0.5);
}

.modal__dialog.modal__dialog--expanded {
  width: 100%;
  height: 100vh;
  margin: 0;
  border-radius: 0;
  padding: 12px;
}

.modal__header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.modal__eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.modal__header h3 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.4;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 1.6rem;
  cursor: pointer;
}

.modal__actions {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.modal__viewer {
  position: relative;
  overflow: hidden;
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
}

.modal__loading {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(180deg, rgba(8, 18, 31, 0.96), rgba(7, 17, 31, 0.9));
  color: var(--text);
  text-align: center;
  padding: 20px;
}

.modal__loading[hidden] {
  display: none;
}

.modal__loading p {
  margin: 0;
  color: var(--muted);
  max-width: 320px;
  line-height: 1.6;
}

.modal__spinner {
  width: 52px;
  height: 52px;
  border: 4px solid rgba(255, 255, 255, 0.12);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.modal__viewer iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .video-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .hero {
    padding: 22px;
    border-radius: 24px;
  }

  .hero__controls {
    grid-template-columns: 1fr;
  }

  .hero__install {
    flex-direction: column;
    align-items: stretch;
  }

  .install-button {
    width: 100%;
    min-width: 0;
  }

  .video-grid {
    grid-template-columns: 1fr;
  }

  .video-card__actions {
    flex-direction: column;
  }

  .note-item__actions,
  .modal__actions {
    flex-direction: column;
  }

  .modal__dialog {
    width: min(100% - 12px, 1240px);
    height: min(96vh, 920px);
    margin: 2vh auto;
    padding: 14px;
    border-radius: 20px;
  }

  .modal__dialog.modal__dialog--expanded {
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 10px;
    border-radius: 0;
  }

  .modal__viewer {
    border-radius: 16px;
  }
}
