:root {
  --color-primary: #ffd60a; /* main yellow */
  --color-primary-strong: #e6b800; /* hover/active */
  --color-on-primary: #1a1a1a; /* dark text on yellow */
  --bg: #fafafa;
  --surface: #fff;
  --border: #e6e6e6;
  --text: #1a1a1a;
  --muted: #777;
  --danger: #c0362c;
  --player-h: 84px;
  --sidebar-w: 232px;
  --mobile-bar-h: 56px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
}

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

h1,
h2,
h3 {
  margin: 0.2em 0 0.6em;
}

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

.error {
  color: var(--danger);
  font-size: 0.9rem;
}

.success {
  color: #2e7d32;
  font-size: 0.9rem;
}

/* ---- sidebar ---------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  bottom: var(--player-h);
  left: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 0.75rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 30;
}

.sidebar__brand {
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.5rem 0.75rem 1rem;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar__footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.sidebar__user {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0 0.75rem;
}

.navlink {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-weight: 500;
}

.navlink:hover {
  background: rgb(0 0 0 / 5%);
}

.navlink.active {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.subnav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

/* ---- mobile bar & backdrop (hidden on desktop) ------------------------ */
.mobile-bar {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

/* ---- layout ----------------------------------------------------------- */
.content {
  margin-left: var(--sidebar-w);
  min-height: calc(100vh - var(--player-h));
  padding-bottom: var(--player-h);
}

.content--bare {
  margin-left: 0;
}

/* ---- responsive: drawer sidebar on small screens --------------------- */
@media (width <= 860px) {
  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 25;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: var(--mobile-bar-h);
    padding: 0 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .mobile-bar__brand {
    font-weight: 700;
  }

  .sidebar {
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 2px 0 16px rgb(0 0 0 / 15%);
  }

  .layout--drawer-open .sidebar {
    transform: translateX(0);
  }

  .layout--drawer-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 29;
    border: 0;
    padding: 0;
    cursor: pointer;
    background: rgb(0 0 0 / 45%);
  }

  .content {
    margin-left: 0;
  }
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

section {
  margin-bottom: 2rem;
}

.backlink {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--muted);
}

/* ---- buttons ---------------------------------------------------------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn:hover {
  border-color: var(--color-primary-strong);
}

.btn--primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: 600;
}

.btn--primary:hover {
  background: var(--color-primary-strong);
  border-color: var(--color-primary-strong);
}

.btn--ghost {
  background: transparent;
}

.btn--sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.btn--danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---- grids & cards ---------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem;
  text-align: left;
  cursor: pointer;
}

.card:hover {
  border-color: var(--color-primary-strong);
}

.card.is-current {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
}

.card__art {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #eee;
}

.card__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card__art--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 2rem;
  color: var(--muted);
}

.card__title {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__sub {
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---- list rows -------------------------------------------------------- */
.list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.podcast-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.podcast-row:hover {
  border-color: var(--color-primary-strong);
}

.podcast-row.is-current {
  border-color: var(--color-primary);
}

.podcast-row__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.podcast-row__name {
  font-weight: 600;
}

.podcast-row__sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex: none;
  background: #eee;
}

.thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

/* ---- progress line (YouTube style) ----------------------------------- */
.progress-track {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: rgb(0 0 0 / 8%);
}

.progress-line {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}

/* ---- search ----------------------------------------------------------- */
.search-box {
  width: 100%;
  max-width: 420px;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}

.search-box:focus {
  outline: 2px solid var(--color-primary);
  border-color: var(--color-primary);
}

/* ---- login ------------------------------------------------------------ */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login__card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.login__title {
  text-align: center;
  margin: 0;
}

.login__hint {
  text-align: center;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.login__submit {
  margin-top: 0.5rem;
}

.login__links {
  text-align: center;
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
}

/* ---- modal ------------------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}

.modal__backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: rgb(0 0 0 / 45%);
}

.modal__dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  margin: auto;
}

/* ---- forms ------------------------------------------------------------ */
.form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 520px;
}

.modal__dialog .form {
  margin-bottom: 0;
  max-width: none;
  box-shadow: 0 12px 40px rgb(0 0 0 / 25%);
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input,
select {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
}

input:focus,
select:focus {
  outline: 2px solid var(--color-primary);
  border-color: var(--color-primary);
}

.form__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* ---- admin tables ----------------------------------------------------- */
.admin-section__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.admin-table th {
  background: #f5f5f5;
  color: var(--muted);
  font-weight: 600;
}

.admin-table__actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
}

/* ---- playlist detail -------------------------------------------------- */
.playlist-head {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.playlist-head__art {
  width: 160px;
  height: 160px;
  border-radius: 12px;
  object-fit: cover;
  background: #eee;
}

.playlist-head__art--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--muted);
}

.playlist-head__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ---- playlist podcast manager ------------------------------------------- */
.podcast-manager__add {
  margin-bottom: 1.25rem;
  max-width: 420px;
}

.podcast-manager__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.podcast-manager__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.podcast-manager__name {
  font-weight: 600;
}

.podcast-manager__sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.podcast-manager__buttons {
  margin-left: auto;
  display: flex;
  gap: 0.3rem;
}

/* ---- player fullscreen ------------------------------------------------ */
.player-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
}

.player-fullscreen__close {
  position: absolute;
  top: 1rem;
  left: 1rem;
  font-size: 1.4rem;
  width: 44px;
  height: 44px;
}

.player-fullscreen__art {
  width: min(280px, 60vw);
  height: min(280px, 60vw);
  border-radius: 12px;
  overflow: hidden;
  background: var(--border);
  flex-shrink: 0;
}

.player-fullscreen__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-fullscreen__art-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  color: var(--muted);
}

.player-fullscreen__meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  text-align: center;
}

.player-fullscreen__name {
  font-size: 1.3rem;
  font-weight: 700;
}

.player-fullscreen__sub {
  font-size: 1rem;
  color: var(--muted);
}

.player-fullscreen__seek {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: min(480px, 90vw);
}

.player-fullscreen__controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.icon-btn--lg {
  font-size: 1.6rem;
  width: 52px;
  height: 52px;
}

.icon-btn--xl {
  font-size: 1.8rem;
  width: 64px;
  height: 64px;
}

/* ---- player bar ------------------------------------------------------- */
.player-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--player-h);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 20;
}

.player-bar__track {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 240px;
  min-width: 0;
}

.player-bar__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.player-bar__name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-bar__sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.player-bar__center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  max-width: 640px;
  margin: 0 auto;
}

.player-bar__controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.player-bar__seek {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
}

.player-bar__status {
  width: 160px;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.player-bar__expand {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.seek {
  flex: 1;
  accent-color: var(--color-primary);
  padding: 0;
}

.time {
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--muted);
  width: 38px;
  text-align: center;
}

.icon-btn {
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--text);
}

.icon-btn:hover {
  background: rgb(0 0 0 / 6%);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-btn--primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: 1.2rem;
}

.icon-btn--primary:hover {
  background: var(--color-primary-strong);
}

.repeat-btn--off {
  color: var(--muted);
}

.repeat-btn--all,
.repeat-btn--one {
  color: var(--color-primary-strong);
  font-weight: 700;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 24px 0 8px;
}

.pager__info {
  color: var(--muted);
  font-size: 14px;
}

@media (width <= 720px) {
  .player-bar {
    gap: 0.75rem;
    padding: 0 1rem;
  }

  .player-bar__track {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  /* Shrink center to just the play/pause button on mobile */
  .player-bar__center {
    flex: 0;
    flex-shrink: 0;
  }

  .player-bar__seek {
    display: none;
  }

  /* Hide prev, next, repeat — keep only the primary play/pause button */
  .player-bar__controls .icon-btn:not(.icon-btn--primary) {
    display: none;
  }

  .player-bar__status {
    width: auto;
    flex-shrink: 0;
  }

  /* Hide error text on mobile, keep expand button */
  .player-bar__status .error {
    display: none;
  }

  .player-bar__expand {
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
  }

  .playlist-head {
    flex-direction: column;
  }
}
