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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #0f0f11;
  color: #e0e0e0;
  min-height: 100vh;
}

/* ---- Header ---- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid #222;
  position: sticky;
  top: 0;
  background: #0f0f11;
  z-index: 10;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

#addBtn {
  background: #6c63ff;
  color: #fff;
  border: none;
  padding: 0.55rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.2s;
}

#addBtn:hover {
  background: #574fd6;
}

/* ---- Grid ---- */
main {
  padding: 2rem;
}

.video-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1100px) {
  .video-grid { grid-template-columns: repeat(3, 1fr); }
}

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

@media (max-width: 480px) {
  main { padding: 1rem; }
  .video-grid { grid-template-columns: 1fr; }
}

/* ---- Card ---- */
.card {
  background: #1a1a1f;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 1px solid #2a2a30;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #2a2a30;
  display: block;
}

.card-thumb-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #2a2a30;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: #555;
  user-select: none;
}

.card-info {
  padding: 0.75rem 1rem;
}

.card-title {
  font-size: 0.875rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #c8c8d0;
  word-break: break-word;
}

.card-delete {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 28px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  backdrop-filter: blur(4px);
}

.card:hover .card-delete {
  opacity: 1;
}

.card-delete:hover {
  background: #e53935;
}

/* ---- Overlay & Modal ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 101;
  width: min(480px, 94vw);
}

.modal-box {
  background: #1a1a1f;
  border: 1px solid #333;
  border-radius: 16px;
  padding: 2rem;
  position: relative;
}

.modal h2 {
  margin-bottom: 1.25rem;
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #888;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color 0.15s;
}

.modal-close:hover {
  color: #e0e0e0;
}

#urlInput {
  width: 100%;
  background: #0f0f11;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: #e0e0e0;
  font-size: 1rem;
  margin-bottom: 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}

#urlInput:focus {
  border-color: #6c63ff;
}

#urlInput::placeholder {
  color: #555;
}

#submitUrl {
  width: 100%;
  padding: 0.75rem;
  background: #6c63ff;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

#submitUrl:hover:not(:disabled) {
  background: #574fd6;
}

#submitUrl:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Spinner ---- */
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #333;
  border-top-color: #6c63ff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 1rem auto 0;
}

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

/* ---- Utilities ---- */
.hidden {
  display: none !important;
}

.error {
  color: #ef5350;
  font-size: 0.875rem;
  margin-top: 0.6rem;
}

.empty-state {
  text-align: center;
  color: #555;
  margin-top: 5rem;
  font-size: 1rem;
  line-height: 1.6;
}
