:root {
  --bg: #fffafd;
  --bg-2: #fff0f8;
  --panel: #ffffff;
  --panel-strong: #fff5fa;
  --line: rgba(255, 107, 157, 0.18);
  --text: #4a3347;
  --muted: #8b7089;
  --soft: #c084fc;
  --pink: #ff6b9d;
  --pink-2: #ff9ec5;
  --violet: #c084fc;
  --blue: #c084fc;
  --green: #16a34a;
  --red: #dc2626;
  --grey: #b89db7;
  --shadow: 0 4px 20px rgba(255, 107, 157, 0.14);
  font-family: 'Quicksand', 'PingFang SC', 'Microsoft YaHei', ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 100px;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  min-width: 320px;
}

body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 107, 157, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(192, 132, 252, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(255, 158, 197, 0.04) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.noscript {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--text);
  background: var(--bg);
}

.app-shell {
  min-height: 100vh;
}

.auth-gate {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg);
}

.auth-logo-img {
  width: clamp(260px, 55vw, 500px);
  height: auto;
  display: block;
}

.login-link {
  position: fixed;
  top: 22px;
  right: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 20px;
  border: 2px solid var(--pink-2);
  border-radius: 999px;
  color: var(--pink);
  text-decoration: none;
  background: white;
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: all 0.3s;
}

.login-link:hover {
  background: var(--pink);
  color: white;
}

.topbar {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  height: 68px;
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
  background: rgba(255, 250, 253, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  box-shadow: 0 2px 12px rgba(255, 107, 157, 0.08);
}

.topbar-status {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 600;
}

.topbar-date {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.topbar-remaining {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.topbar-remaining strong {
  color: var(--pink);
  font-size: 15px;
}

.topbar-done {
  color: var(--green);
  font-weight: 700;
  font-size: 13px;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
}
.brand-logo {
  height: 44px;
  width: auto;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 13px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--text);
  background: rgba(255, 107, 157, 0.1);
}

.nav-links a.nav-active {
  color: white;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  font-weight: 700;
}

.user-area {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.topbar-metrics {
  display: flex;
  gap: 14px;
  align-items: center;
}

.topbar-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.topbar-metric-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .02em;
}

.topbar-metric-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--pink);
  font-variant-numeric: tabular-nums;
}

.topbar-metric-sep {
  width: 1px;
  height: 24px;
  background: var(--line);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--pink-2);
  object-fit: cover;
  background: linear-gradient(135deg, var(--pink), var(--violet));
}

.user-name {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-weight: 600;
}

.logout-form {
  margin: 0;
}

.ghost-button,
.primary-button,
.round-button {
  border: 0;
  cursor: pointer;
  color: var(--text);
}

.btn-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 6px;
}

.ghost-button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: white;
  border: 1.5px solid var(--line) !important;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s;
}

.ghost-button:hover {
  border-color: var(--pink-2) !important;
  color: var(--pink);
}

.dashboard {
  min-height: 100vh;
  padding: 96px 28px 112px;
  background: var(--bg);
}

.grid-layout {
  display: grid;
  grid-template-columns: minmax(220px, 25%) minmax(320px, 1fr) minmax(220px, 25%);
  gap: 18px;
  max-width: 1480px;
  margin: 0 auto;
}

.panel {
  border: 1.5px solid var(--line);
  border-radius: 1.2rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.rank-panel,
.player-panel,
.calendar-panel {
  padding: 18px;
}

.panel-title {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.subsection-title {
  margin: 22px 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.rank-list {
  display: grid;
  gap: 10px;
}

.rank-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px;
  border-radius: 0.8rem;
  background: #fff5fa;
  border: 1px solid var(--line);
}

.rank-index {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-weight: 700;
  background: linear-gradient(135deg, var(--pink), var(--violet));
}

.rank-main {
  min-width: 0;
}

.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  color: var(--text);
}

.rank-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.player-panel {
  min-height: 440px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.content-kicker {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.content-title {
  margin: 6px 0 0;
  font-size: clamp(22px, 3vw, 36px);
  line-height: 1.15;
  font-weight: 700;
  color: var(--text);
}

.content-source {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.player-controls {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 22px;
}

.audio-player {
  width: 100%;
  min-height: 44px;
  accent-color: var(--pink);
}

.round-button {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 34px;
  line-height: 1;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  box-shadow: 0 8px 24px rgba(255, 107, 157, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}

.round-button:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 12px 32px rgba(255, 107, 157, 0.45);
}

.round-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.metrics {
  display: grid;
  gap: 10px;
}

.metric {
  padding: 14px;
  border: 1.5px solid var(--line);
  border-radius: 0.8rem;
  background: #fff5fa;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.metric-value {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.primary-button {
  width: fit-content;
  min-height: 42px;
  padding: 0 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  color: white !important;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(255, 107, 157, 0.35);
  transition: all 0.3s;
}

.primary-button:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(255, 107, 157, 0.45);
}

.player-tabs-bar {
  display: flex;
  gap: 6px;
  padding: 10px 0 4px;
}

.player-tab {
  border: 0;
  cursor: pointer;
  padding: 6px 18px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  transition: all 0.2s;
}

.player-tab:hover {
  color: var(--pink);
  background: var(--bg-2);
}

.player-tab.active {
  color: white;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  box-shadow: 0 3px 12px rgba(255, 107, 157, 0.3);
}

.recommendations {
  display: grid;
  gap: 9px;
}

.playlist-item-row {
  display: flex;
  flex-direction: column;
  border: 1.5px solid var(--line);
  border-radius: 0.8rem;
  background: white;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(255, 107, 157, 0.06);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.playlist-item-row.selected {
  border-color: var(--pink);
  box-shadow: 0 4px 16px rgba(255, 107, 157, 0.2);
}

.playlist-item-row .recommendation-item {
  border: none;
  border-radius: 0;
  background: transparent;
}

.playlist-item-row .recommendation-item:hover {
  background: #fff5fa;
}

.playlist-label-btns {
  display: flex;
  gap: 6px;
  padding: 0 10px 8px;
}

.label-btn {
  padding: 3px 10px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.label-btn:hover {
  border-color: var(--pink-2);
  color: var(--pink);
}

.label-btn.label-never-active {
  border-color: rgba(220, 38, 38, 0.5);
  color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
}

.label-btn.label-repeat-active {
  border-color: rgba(22, 163, 74, 0.5);
  color: #16a34a;
  background: rgba(22, 163, 74, 0.08);
}

.recommendation-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1.5px solid var(--line);
  border-radius: 0.8rem;
  color: var(--text);
  text-align: left;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
}

.recommendation-item:hover,
.recommendation-item.selected {
  border-color: var(--pink);
  background: #fff5fa;
}

.recommendation-title {
  font-weight: 700;
  color: var(--text);
}

.recommendation-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--violet);
  background: rgba(192, 132, 252, 0.12);
  border: 1px solid rgba(192, 132, 252, 0.25);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.calendar-panel {
  max-width: 1480px;
  margin: 18px auto 0;
}

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

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.calendar-nav {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.cal-nav-btn {
  background: white;
  border: 1.5px solid var(--line);
  color: var(--muted);
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s;
}

.cal-nav-btn:hover {
  border-color: var(--pink-2);
  color: var(--pink);
}

.calendar-months {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.month-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.weekday,
.day-cell {
  aspect-ratio: 1;
  min-width: 0;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.weekday {
  aspect-ratio: auto;
  height: 22px;
  color: var(--muted);
}

.day-cell {
  position: relative;
  border: 1px solid var(--line);
  color: var(--muted);
  background: white;
}

.day-cell.completed {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.3);
  color: #16a34a;
  font-weight: 700;
}

.day-cell.incomplete {
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(220, 38, 38, 0.25);
  color: #dc2626;
  font-weight: 700;
}

.day-cell.empty {
  opacity: 0;
  pointer-events: none;
}

.day-cell:hover::after,
.day-cell:focus-visible::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 8;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 210px;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 0.8rem;
  color: var(--text);
  background: white;
  box-shadow: var(--shadow);
  white-space: pre-line;
  font-size: 12px;
  font-weight: 600;
}

.bottom-bar {
  position: fixed;
  z-index: 25;
  left: 18px;
  right: 18px;
  bottom: 16px;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
  border: 1.5px solid var(--line);
  border-radius: 1.2rem;
  background: rgba(255, 250, 253, 0.96);
  box-shadow: 0 8px 30px rgba(255, 107, 157, 0.15);
  backdrop-filter: blur(16px);
}

.today-date {
  color: var(--muted);
  font-weight: 600;
}

.remaining {
  font-size: clamp(22px, 3vw, 36px);
  font-weight: 700;
  color: var(--text);
}

.completed-badge {
  color: var(--green);
  font-weight: 700;
}

.state-message {
  padding: 14px;
  border: 1.5px dashed var(--line);
  border-radius: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

@media (max-width: 980px) {
  .topbar {
    height: auto;
    min-height: 68px;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "brand status user"
      "nav nav nav"
      "tbm tbm tbm";
    padding: 10px 14px 0;
  }

  .brand {
    grid-area: brand;
    margin-left: 12px;
  }

  .topbar-status {
    grid-area: status;
    text-align: center;
    padding: 0 8px;
    font-size: 12px;
  }

  .nav-links {
    grid-area: nav;
    justify-content: flex-start;
    overflow-x: auto;
    padding-top: 4px;
    padding-left: 20px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links a {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .user-area {
    grid-area: user;
  }

  .topbar-metrics {
    grid-area: tbm;
    justify-content: center;
    gap: 20px;
    padding: 6px 0 8px;
    border-top: 1px solid var(--line);
    margin-top: 4px;
  }

  .topbar-metric {
    flex-direction: row;
    gap: 6px;
    align-items: baseline;
  }

  .topbar-metric-label {
    font-size: 12px;
  }

  .topbar-metric-value {
    font-size: 16px;
  }

  .topbar-metric-sep {
    display: none;
  }

  .dashboard {
    padding: 185px 14px 90px;
  }

  .grid-layout,
  .calendar-months {
    grid-template-columns: 1fr;
  }

  .player-controls {
    grid-template-columns: 1fr;
  }

  .round-button {
    margin: 0 auto;
  }

  .bottom-bar {
    left: 10px;
    right: 10px;
    bottom: 10px;
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .nav-links a {
    padding: 6px 10px;
    font-size: 13px;
  }

  .user-name {
    display: none;
  }

  .calendar-head {
    display: grid;
  }

  .rank-panel,
  .player-panel,
  .calendar-panel {
    padding: 14px;
  }

  .player-panel {
    min-height: 0;
    gap: 12px;
  }

  .player-tabs-bar {
    background: var(--panel);
    padding: 6px 0;
    margin: 0 -14px;
    padding-left: 14px;
    padding-right: 14px;
    border-bottom: 1px solid var(--line);
  }

  #yt-player iframe {
    width: 100%;
    height: 100%;
    display: block;
  }
}
