:root {
  --bg:        #1c1a17;
  --surface:   #26221d;
  --surface-2: #2f2a23;
  --line:      #3a352c;
  --text:      #ece6da;
  --text-dim:  #a89e8d;
  --text-mute: #6b6357;
  --accent:    #e8a33d;
  --accent-dim: #8a6529;
  --good:      #7fa876;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

.hidden { display: none !important; }

/* ---------------------------------------------------- user picker */

.user-picker {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.user-picker__card {
  width: min(90vw, 380px);
  padding: 40px 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.user-picker__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  margin: 0 0 24px;
  color: var(--text);
}

.user-picker__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.user-picker__list button {
  text-align: left;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  cursor: pointer;
  font-size: 15px;
}

.user-picker__list button:hover {
  border-color: var(--accent-dim);
}

.user-picker__new {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.user-picker__new input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
}

.user-picker__new button {
  padding: 10px 16px;
  background: var(--accent);
  color: #1c1a17;
  border: none;
  border-radius: 3px;
  font-weight: 600;
  cursor: pointer;
}

/* ---------------------------------------------------- layout / topbar */

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 120px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
}

.topbar__reel { color: var(--accent); }

.topbar__nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-btn {
  padding: 8px 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 3px;
}

.nav-btn:hover { color: var(--text); }

.nav-btn--active {
  color: var(--accent);
  background: var(--surface);
}

.topbar__user {
  font-size: 13px;
  color: var(--text-mute);
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------------------------------------------------- controls */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 28px;
}

.controls__search {
  flex: 1 1 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 14px;
}

.controls__select {
  flex: 0 1 auto;
  max-width: 150px;
  padding: 10px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle-btn {
  flex: 0 1 auto;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  font-size: 14px;
}

.toggle-btn[data-active="true"] {
  color: var(--accent);
  border-color: var(--accent-dim);
  background: var(--surface-2);
}

/* ---------------------------------------------------- section labels */

.section-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 0 0 12px;
}

.empty-state {
  color: var(--text-mute);
  font-size: 14px;
  padding: 40px 0;
  text-align: center;
}

/* ---------------------------------------------------- episode rows */

.row-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-list--continue {
  margin-bottom: 32px;
}

.episode-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
}

.episode-row:hover {
  border-color: var(--line);
  background: var(--surface-2);
}

.episode-row__image {
  width: 56px;
  height: 56px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
}

.episode-row__body {
  flex: 1;
  min-width: 0;
}

.episode-row__top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}

.episode-row__title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.episode-row__meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-mute);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}

.episode-row__desc {
  font-size: 13px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.episode-row__status {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--text-mute);
  cursor: pointer;
}

.episode-row__status[data-status="listened"] {
  background: var(--accent);
  border-color: var(--accent);
}

.episode-row__status[data-status="in_progress"] {
  border-color: var(--accent);
  background: conic-gradient(var(--accent) var(--pct, 40%), transparent 0);
}

.episode-row__play {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
}

.episode-row__fav {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-mute);
}

.episode-row__fav[data-active="true"] { color: var(--accent); }

/* ---------------------------------------------------- series grid */

.series-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.series-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
}

.series-card:hover { border-color: var(--accent-dim); }

.series-card__image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.series-card__body { padding: 12px; }

.series-card__name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.series-card__count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-mute);
}

/* ---------------------------------------------------- detail view */

.detail__back {
  margin-bottom: 20px;
  display: inline-block;
}

.detail__header {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.detail__image {
  width: 160px;
  height: 160px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
}

.detail__fav-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s;
}

.detail__fav-btn:hover {
  color: var(--text);
}

.detail__fav-btn[data-active="true"] {
  color: var(--accent);
}

.detail__meta { flex: 1; min-width: 0; }

.detail__series {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.detail__title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 10px;
  line-height: 1.2;
}

.detail__stats {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.detail__stats .dot { color: var(--text-mute); }

.detail__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.play-btn {
  padding: 10px 18px;
  background: var(--accent);
  color: #1c1a17;
  border: none;
  border-radius: 3px;
  font-weight: 600;
  cursor: pointer;
}

.listened-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}

.listened-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  margin: 0;
  border: 1.5px solid var(--text-dim);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.listened-check input[type="checkbox"]:hover {
  border-color: var(--text);
}

.listened-check input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.listened-check input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 9px;
  border: solid #1c1a17;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.detail__description {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-dim);
  max-width: 68ch;
  margin-bottom: 36px;
  white-space: pre-wrap;
}

/* ---------------------------------------------------- mini player */

.mini-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 50;
}

.mini-player__image {
  width: 40px;
  height: 40px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
}

.mini-player__info { flex: 1; min-width: 0; }

.mini-player__title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.mini-player__seekrow {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-player__time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mute);
  width: 42px;
  flex-shrink: 0;
}

.mini-player__time:last-child { text-align: right; }

.mini-player__seek {
  flex: 1;
  accent-color: var(--accent);
}

.mini-player__playpause {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--accent-dim);
  background: var(--bg);
  color: var(--accent);
  font-size: 14px;
  cursor: pointer;
}

@media (max-width: 600px) {
  .detail__header { flex-direction: column; }
  .detail__image { width: 100%; height: auto; aspect-ratio: 1; }
  .mini-player__image { display: none; }
  .controls__select { max-width: 46%; flex: 1 1 46%; }
  .toggle-btn { flex: 1 1 46%; text-align: center; }
}
