:root {
  --bg: #f4f6f8;
  --bg-elev: #ffffff;
  --ink: #14202b;
  --muted: #5b6b7c;
  --line: #e4e9ef;
  --accent: #0d8a7f;
  --accent-soft: #e6f5f3;
  --accent-ink: #065f58;
  --danger: #c23b3b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 32, 43, 0.04), 0 8px 24px rgba(20, 32, 43, 0.06);
  --font: "Figtree", "Segoe UI", sans-serif;
  --font-display: "Sora", "Figtree", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% 0%, #dff3f0 0%, transparent 55%),
    radial-gradient(700px 360px at 100% 0%, #e8eef5 0%, transparent 50%),
    var(--bg);
  line-height: 1.5;
}

a {
  color: var(--accent-ink);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

.wrap {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 246, 248, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.site-header .inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand span {
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-links a:hover,
.nav-links a.is-active {
  color: var(--ink);
  background: var(--bg-elev);
  box-shadow: inset 0 0 0 1px var(--line);
  text-decoration: none;
}

.hero {
  padding: 2.25rem 0 1rem;
}

.hero h1 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3.5vw, 2.35rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 36rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 1.25rem 0 1.35rem;
}

.search {
  flex: 1 1 240px;
}

.search input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.8rem 1.1rem;
  font: inherit;
  outline: none;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search input:focus {
  border-color: #9ad5cf;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.meta-pill {
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  padding-bottom: 2.5rem;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  content-visibility: auto;
  contain-intrinsic-size: 320px;
}

.card:hover {
  transform: translateY(-3px);
  border-color: #c9dde0;
  box-shadow: 0 10px 28px rgba(20, 32, 43, 0.1);
  text-decoration: none;
}

.card .poster {
  aspect-ratio: 2 / 3;
  background: #e9eef3;
  overflow: hidden;
}

.card .poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card .body {
  padding: 0.85rem 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.card .duration {
  color: var(--muted);
  font-size: 0.8rem;
}

.card .cta {
  margin-top: auto;
  padding-top: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

.empty,
.error-box {
  grid-column: 1 / -1;
  padding: 2rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: var(--bg-elev);
}

/* Detalle: solo URL, sin reproductor */
.detail-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  padding: 1.5rem 0 3rem;
  align-items: start;
}

.detail-poster {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
  background: #e9eef3;
}

.detail-poster img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.detail-panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  box-shadow: var(--shadow);
}

.detail-panel h1 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.8vw, 1.9rem);
  letter-spacing: -0.02em;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.85rem 0 1rem;
}

.chip {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid #c6e8e3;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
}

.detail-panel > p {
  margin: 0 0 1.2rem;
  color: var(--muted);
}

.url-block {
  margin-top: 0.25rem;
}

.url-block label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.url-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.url-row code {
  flex: 1;
  word-break: break-all;
  font-size: 0.86rem;
  background: #f0f4f7;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem 0.9rem;
  color: var(--ink);
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.25rem 0 2rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer .inner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
}

.pager {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
  padding-bottom: 2rem;
  color: var(--muted);
}

.pager a {
  font-weight: 600;
  text-decoration: none;
}

/* Buttons */
.btn-primary,
.btn-ghost,
.btn-danger,
.btn-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary,
.btn-copy {
  background: var(--accent);
  color: #fff;
  border: none;
}

.btn-copy:hover,
.btn-primary:hover {
  filter: brightness(0.96);
  text-decoration: none;
}

.btn-copy.is-done {
  background: #1f7a45;
}

.btn-ghost {
  background: var(--bg-elev);
  border-color: var(--line);
  color: var(--ink);
}

.btn-danger {
  background: #fff5f5;
  border-color: #f0c4c4;
  color: var(--danger);
  padding: 0.45rem 0.8rem;
  font-size: 0.8rem;
}

/* Admin */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem;
}

.admin-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  box-shadow: var(--shadow);
}

.admin-card h2 {
  margin: 0 0 0.3rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.admin-card .muted,
.muted {
  color: var(--muted);
}

.admin-form {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.9rem;
}

.admin-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.admin-form label.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
}

.admin-form input,
.admin-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fafbfc;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font: inherit;
}

.admin-form input:focus,
.admin-form textarea:focus {
  outline: none;
  border-color: #9ad5cf;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.flash-ok {
  padding: 0.95rem 1.05rem;
  border-radius: var(--radius);
  background: #eaf8ef;
  border: 1px solid #c6e8d1;
  color: #1f6b3a;
}

.table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.7rem 0.45rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table .thumb {
  width: 40px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.admin-table .actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: flex-end;
}

.admin-table .actions form {
  margin: 0;
}

.api-box {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.api-box label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.api-box code,
.token-box {
  display: block;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.8rem;
  background: #f0f4f7;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  color: var(--ink);
}

@media (max-width: 720px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-poster {
    max-width: 180px;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .url-row {
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }
}
