:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --card: #ffffff;
  --ink: #191d24;
  --muted: #5d6571;
  --line: #d8e0ea;
  --teal: #0b6a60;
  --teal-soft: #d9f0ed;
  --gap: 16px;
  --min-card: 180px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.35;
}

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

img {
  display: block;
  max-width: 100%;
}

.page-shell {
  width: min(calc(100% - 48px), 1750px);
  margin: 0 auto;
  padding: 64px 0;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0;
  margin-bottom: 4px;
  font-family: "Fredoka", "Inter", sans-serif;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  font-weight: 600;
}

.brand img {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin-right: -3px;
}

h1 {
  margin: 0;
  font-size: clamp(2.65rem, 5.2vw, 5.25rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.page-header h1,
.show-profile h1 {
  font-size: clamp(2.65rem, 5.2vw, 4rem);
  font-weight: 900;
}

.dek {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.4vw, 1.15rem);
  font-weight: 850;
  text-align: right;
}

.leaderboard {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(
    auto-fit,
    minmax(
      min(
        100%,
        max(
          var(--min-card),
          calc((100% - 4 * var(--gap)) / 5)
        )
      ),
      1fr
    )
  );
}

.podcast-card {
  overflow: hidden;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.podcast-card:hover {
  border-color: var(--teal);
  box-shadow: 0 10px 30px rgba(27, 31, 35, 0.08);
  transform: translateY(-2px);
}

.podcast-card:focus-visible {
  outline: 3px solid var(--teal-soft);
  outline-offset: 3px;
}

.artwork-wrap {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #e7edf5;
}

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

.podcast-card-body {
  min-height: 82px;
  padding: 14px;
  box-shadow: inset 0px 10px 10px rgba(0, 0, 0, 0.03);
}

.podcast-card h2 {
  margin: 0 0 10px;
  font-size: clamp(0.96rem, 1.08vw, 1.15rem);
  line-height: 1.18;
  letter-spacing: 0;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 0.8rem;
  font-weight: 900;
}

.ranking-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.podcast-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.movement {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.movement-up {
  color: #18703a;
}

.movement-down {
  color: #b42318;
}

.score {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.page-footer {
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: right;
}

.page-footer p {
  margin: 0;
}

.history-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.history-form select,
.history-form button {
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}

.history-form button {
  cursor: pointer;
}

.history-date-controls {
  display: inline-flex;
  gap: 8px;
}

.history-notice {
  color: var(--muted);
  font-size: 0.9rem;
}

.history-notice a {
  color: var(--teal);
  text-decoration: underline;
}

.show-profile-page {
  max-width: 1000px;
}

.show-profile-page .page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.profile-back,
.profile-feed a {
  color: var(--teal);
  text-decoration: underline;
}

.profile-feed {
  margin: 24px 0 0;
}

.show-profile {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  align-items: start;
  gap: 40px;
}

.show-profile-artwork {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.episode-page .show-profile h1 {
  overflow-wrap: anywhere;
}

.show-abstract {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 1.125rem;
  line-height: 1.6;
}

.latest-episodes {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.latest-episodes h2 {
  margin: 0;
  font-size: 1.5rem;
}

.episodes-status,
.episode-unavailable,
.audio-player-error {
  color: var(--muted);
  font-size: 0.9rem;
}

.episode-list {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.episode-row {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.episode-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.episode-row h3 {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.episode-date {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.latest-episodes a {
  color: var(--teal);
  text-decoration: underline;
}

.episodes-retry {
  border: 1px solid var(--teal);
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--card);
  color: var(--teal);
  font: inherit;
  cursor: pointer;
}

/* RSSDB player layout, scoped to this site's episode section. */
.latest-episodes .audio-player {
  display: grid;
  width: max-content;
  max-width: 100%;
  gap: 6px;
  margin-top: 14px;
}

.latest-episodes .episode-audio {
  width: min(320px, 100%);
  max-width: 100%;
}

.latest-episodes .audio-player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.latest-episodes [hidden] {
  display: none;
}

.latest-episodes .audio-player-button {
  position: relative;
  display: inline-grid;
  width: 48px;
  height: 48px;
  min-height: 48px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  padding: 0;
  background: var(--card);
  color: var(--teal);
  cursor: pointer;
}

.latest-episodes .audio-player-button:hover,
.episodes-retry:hover {
  background: var(--teal-soft);
}

.latest-episodes button:focus-visible,
.latest-episodes a:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

.latest-episodes .audio-player-toggle {
  width: 56px;
  height: 56px;
  min-height: 56px;
}

.latest-episodes .audio-player-icon {
  display: block;
  width: 27px;
  height: 27px;
}

.latest-episodes .audio-player-toggle .audio-player-icon {
  width: 25px;
  height: 25px;
}

.latest-episodes .audio-player-skip-amount {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-top: 2px;
  font-size: 9px;
  line-height: 1;
}

.latest-episodes .audio-player-time {
  justify-self: center;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.audio-player-error {
  max-width: 32em;
  margin: 4px 0 0;
}

.rank-history {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.rank-history h2 {
  margin: 0;
  font-size: 1.5rem;
}

.rank-history-note {
  margin: 8px 0 20px;
  color: var(--muted);
}

.rank-history-chart {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  margin-right: 4px;
}

.rank-history-axis {
  position: relative;
  color: var(--muted);
  font-size: 0.85rem;
}

.rank-history-axis span {
  position: absolute;
  right: 12px;
  transform: translateY(-50%);
}

.rank-history-plot {
  display: block;
  overflow: visible;
}

.rank-history-grid {
  stroke: var(--line);
}

.rank-history-line {
  stroke: var(--teal);
  stroke-width: 2;
  stroke-linecap: round;
}

.rank-history-point {
  fill: var(--teal);
}

.rank-history-dates {
  grid-column: 2;
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.rank-history-single-date {
  justify-content: center;
}

.rank-history-data {
  margin-top: 24px;
}

.rank-history-data summary {
  width: fit-content;
  color: var(--teal);
  cursor: pointer;
}

.rank-history-table-wrap {
  max-height: 300px;
  overflow: auto;
  margin-top: 12px;
}

.rank-history-data table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.rank-history-data caption {
  text-align: left;
  padding-bottom: 8px;
  color: var(--muted);
}

.rank-history-data th,
.rank-history-data td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.rank-history-data th[scope="row"] {
  font-weight: 400;
}

@media (max-width: 700px) {
  .page-shell {
    width: min(calc(100% - 28px), 1750px);
    padding: 32px 0;
  }

  .page-header {
    display: block;
  }

  .dek {
    text-align: left;
  }

  .show-profile {
    grid-template-columns: 1fr;
    gap: 24px;
  }

}
