:root {
  --bg: #121212;
  --panel: #181818;
  --panel-soft: #222;
  --text: #ffffff;
  --muted: #b3b3b3;
  --accent: #1db954;
  --error: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1f1f1f 0%, #121212 55%);
  color: var(--text);
}

a {
  color: var(--accent);
}

code {
  background: #000;
  padding: 2px 6px;
  border-radius: 6px;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid #2c2c2c;
  position: sticky;
  top: 0;
  backdrop-filter: blur(6px);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chip {
  border: 1px solid #333;
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--muted);
}

.page {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px 24px;
  display: grid;
  gap: 16px;
}

.panel {
  background: linear-gradient(145deg, var(--panel) 0%, var(--panel-soft) 100%);
  border-radius: 14px;
  padding: 20px;
  border: 1px solid #2f2f2f;
}

.panel h2 {
  margin-top: 0;
}

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

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

input {
  background: #0d0d0d;
  border: 1px solid #3a3a3a;
  color: white;
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
}

.flatpickr-input[readonly] {
  cursor: pointer;
}

.flatpickr-calendar {
  background: #161616;
  border: 1px solid #2f2f2f;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year,
.flatpickr-weekday,
.flatpickr-day {
  color: #fff;
}

.flatpickr-day:hover,
.flatpickr-day:focus,
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: var(--accent);
  border-color: var(--accent);
  color: #101010;
}

.flatpickr-day.today {
  border-color: #6f6f6f;
}

.btn {
  background: var(--accent);
  border: none;
  color: #101010;
  font-weight: 700;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-secondary {
  background: #2f2f2f;
  color: white;
}

.btn-danger {
  background: #7f1d1d;
  color: #fff;
}

.series-form,
.upload-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  align-items: start;
}

.field {
  min-width: 0;
}

.field span {
  display: block;
  margin-bottom: 6px;
}

.field-file,
.form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-start;
}

.field input[type="file"] {
  padding: 10px;
  overflow: hidden;
}

.series-list {
  display: grid;
  gap: 12px;
}

.list-toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.toolbar-search {
  flex: 1;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.series-row {
  background: #111;
  border-radius: 12px;
  border: 1px solid #2f2f2f;
  overflow: hidden;
}

.series-main {
  display: grid;
  grid-template-columns: 88px minmax(0, 2fr) minmax(140px, auto) minmax(120px, auto);
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
}

.series-thumb {
  width: 88px;
  height: 88px;
  border-radius: 14px;
  overflow: hidden;
  background: #1d1d1d;
  border: 1px solid #2f2f2f;
}

.series-thumb img,
.media-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.series-thumb-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 8px;
}

.series-title h3 {
  margin: 0 0 4px;
}

.series-title .meta {
  margin: 0;
}

.series-body {
  border-top: 1px solid #2f2f2f;
  padding: 16px 18px;
}

.series-body-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.series-body-head h4 {
  margin: 0;
}

.meta {
  color: var(--muted);
  margin: 4px 0;
}

.links {
  display: flex;
  gap: 10px;
  margin: 12px 0;
}

.podcast-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.podcast-list:empty {
  display: none;
}

.podcast-table-head,
.podcast-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) minmax(320px, 420px) 96px;
  gap: 12px;
  align-items: center;
}

.podcast-table-head {
  padding: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid #2f2f2f;
}

.podcast-row {
  padding: 10px 0;
  border-bottom: 1px solid #1f1f1f;
}

.podcast-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.podcast-actions form {
  margin: 0;
}

.podcast-actions audio {
  width: min(320px, 100%);
}

.upload-box {
  margin-top: 0;
}

.upload-box summary {
  list-style: none;
  width: fit-content;
}

.upload-box summary::-webkit-details-marker {
  display: none;
}

.upload-form {
  margin-top: 14px;
}

.podcast-summary {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #2f2f2f;
}

.pagination-links {
  display: flex;
  gap: 10px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.auth-card {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid #333;
  border-radius: 16px;
  padding: 28px;
}

.muted {
  color: var(--muted);
}

.alert {
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.toast-stack {
  position: fixed;
  inset: 96px 0 auto;
  display: grid;
  justify-items: center;
  gap: 10px;
  z-index: 1000;
  pointer-events: none;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 7, 7, 0.68);
  display: grid;
  place-items: center;
  z-index: 1100;
}

.loading-overlay[hidden] {
  display: none !important;
}

.loading-card {
  width: min(320px, calc(100vw - 32px));
  padding: 22px 24px;
  border-radius: 18px;
  background: rgba(22, 22, 22, 0.96);
  border: 1px solid #2f2f2f;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.loading-text {
  margin: 12px 0 0;
  color: #fff;
  font-weight: 600;
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto;
  border-radius: 999px;
  border: 4px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  animation: spin 0.85s linear infinite;
}

.toast {
  width: min(420px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  animation: toast-fade 3.8s ease forwards;
}

.alert-error {
  background: rgba(255, 107, 107, 0.12);
  color: #ffb2b2;
  border: 1px solid rgba(255, 107, 107, 0.35);
}

.alert-success {
  background: rgba(29, 185, 84, 0.12);
  color: #9ef0ba;
  border: 1px solid rgba(29, 185, 84, 0.35);
}

@keyframes toast-fade {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }

  10%,
  80% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

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

@media (max-width: 900px) {
  .series-main {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .podcast-summary {
    justify-content: flex-start;
  }

  .podcast-table-head,
  .podcast-row {
    grid-template-columns: 1fr;
  }

  .podcast-table-head {
    display: none;
  }

  .podcast-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .panel-head,
  .top-nav,
  .series-form,
  .upload-form {
    grid-template-columns: 1fr;
  }

  .panel-head {
    display: grid;
  }

  .top-nav {
    gap: 12px;
    align-items: flex-start;
  }

  .nav-right {
    width: 100%;
    justify-content: space-between;
  }

  .list-toolbar,
  .toolbar-actions,
  .pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination-links {
    justify-content: space-between;
  }
}
