:root {
  --bg: #0f0f13;
  --bg2: #18181f;
  --bg3: #22222c;
  --border: #2e2e3a;
  --text: #e8e8f0;
  --text2: #9090a8;
  --accent: #7c6af7;
  --accent-hover: #9080ff;
  --green: #4caf7d;
  --red: #e05c5c;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

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

/* Navbar */
.navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}
.nav-actions { display: flex; gap: 8px; align-items: center; }

/* Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg3); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { color: var(--text); background: var(--bg3); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

/* Flash */
.flash {
  background: var(--bg3);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 20px;
  font-size: 14px;
}
.flash.error { border-color: var(--red); }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.page-header h1 { font-size: 26px; font-weight: 700; }

/* Feed Grid */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.feed-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s;
  display: block;
}
.feed-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.feed-art { aspect-ratio: 1; overflow: hidden; background: var(--bg3); }
.feed-art img { width: 100%; height: 100%; object-fit: cover; }
.feed-art-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px;
  min-height: 120px;
}
.feed-art-placeholder.large { min-height: 160px; font-size: 64px; }
.feed-info { padding: 12px; }
.feed-title { font-weight: 600; font-size: 14px; line-height: 1.3; margin-bottom: 4px; }
.feed-meta { font-size: 12px; color: var(--text2); }

/* Feed Header (detail page) */
.feed-header {
  display: flex;
  gap: 24px;
  margin-bottom: 32px;
  align-items: flex-start;
}
.feed-header-art {
  width: 140px;
  min-width: 140px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg3);
}
.feed-header-art img { width: 100%; display: block; }
.feed-header-info { flex: 1; }
.feed-header-info h1 { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.feed-description { color: var(--text2); font-size: 14px; margin-bottom: 16px; }
.feed-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.feed-sync-time { font-size: 12px; color: var(--text2); }

/* Season */
.season-section { margin-bottom: 8px; }
.season-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  transition: background 0.15s;
}
.season-header:hover { background: var(--bg3); }
.season-meta { color: var(--text2); font-size: 13px; font-weight: 400; margin-left: auto; }
.season-toggle { font-size: 12px; color: var(--text2); transition: transform 0.2s; }
.season-section.collapsed .season-toggle { transform: rotate(-90deg); }
.season-episodes { margin-top: 2px; }
.season-section.collapsed .season-episodes { display: none; }

.season-section:not(.collapsed) .season-header {
  border-radius: var(--radius) var(--radius) 0 0;
}

/* Episode Row */
.episode-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-top: none;
  background: var(--bg2);
  transition: background 0.1s;
}
.season-episodes .episode-row:first-child { border-top: 1px solid var(--border); margin-top: 2px; }
.episode-list .episode-row { border-radius: 0; }
.episode-list .episode-row:first-child { border-radius: var(--radius) var(--radius) 0 0; border-top: 1px solid var(--border); }
.episode-list .episode-row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.episode-row:hover { background: var(--bg3); }
.episode-row.listened { opacity: 0.45; }

.episode-info { flex: 1; min-width: 0; }
.episode-title { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.4; }
.episode-meta { font-size: 12px; color: var(--text2); margin-top: 3px; }

.episode-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Play button */
.btn-play {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding-left: 3px; /* optical center the triangle */
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
  padding-bottom: 3px;
}
.btn-play:hover { background: var(--accent-hover); transform: scale(1.07); }
.btn-play:active { transform: scale(0.95); }

/* Listened indicator — pill/dot, no text */
.listened-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  position: relative;
}
.listened-btn::after {
  content: '';
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.15s;
}
.listened-btn.is-listened {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 15%, transparent);
}
.listened-btn.is-listened::after { background: var(--green); }
.listened-btn:hover { border-color: var(--green); }
.listened-btn:hover::after { background: var(--green); }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.filter-btn {
  padding: 8px 20px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { background: var(--bg3); color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Hidden by filter */
.episode-row.filter-hidden { display: none; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state h2 { font-size: 22px; color: var(--text); margin-bottom: 8px; }
.empty-state p { margin-bottom: 24px; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h2 { font-size: 20px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text2); font-size: 18px; cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="password"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  transition: border-color 0.15s;
}
.form-group input:focus { outline: none; border-color: var(--accent); }
.form-group small { font-size: 12px; color: var(--text2); margin-top: 4px; display: block; }
.optional { font-weight: 400; color: var(--text2); text-transform: none; }
.form-actions { margin-top: 24px; }

/* Settings */
.settings-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  max-width: 600px;
}
.settings-preview {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.settings-preview-img { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; }
.settings-preview-title { font-size: 18px; font-weight: 700; }
.divider { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.danger-zone h3 { color: var(--red); font-size: 16px; margin-bottom: 8px; }
.danger-zone p { font-size: 14px; color: var(--text2); margin-bottom: 16px; }

/* Login */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
}
.login-logo { font-size: 48px; text-align: center; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 24px; font-weight: 700; margin-bottom: 28px; }

/* Player bar */
.player-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 150;
}
.player-bar.hidden { display: none; }

.player-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding-left: 3px;
  padding-bottom: 3px;
  flex-shrink: 0;
  transition: background 0.15s;
}
.player-btn:hover { background: var(--accent-hover); }

.player-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.player-title {
  font-size: 14px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-progress-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-time {
  font-size: 11px;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.player-scrubber {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 99px;
  cursor: pointer;
  position: relative;
  /* larger touch target without affecting visual height */
  padding: 8px 0;
  margin: -8px 0;
  box-sizing: content-box;
}
.player-scrubber-fill {
  height: 4px;
  background: var(--accent);
  border-radius: 99px;
  width: 0%;
  transition: width 0.5s linear;
  pointer-events: none;
  padding: 8px;
  margin-top: -6px;
  margin-left: 2px;
  margin-right: 2px;
}

body:has(.player-bar:not(.hidden)) .container { padding-bottom: 90px; }

/* Skip buttons */
.player-btn-skip {
  background: var(--bg3);
  color: var(--text2);
  font-size: 20px;
  width: 36px; height: 36px;
}
.player-btn-skip:hover { background: var(--border); color: var(--text); }

/* Episode description */
.episode-desc {
  display: none;
  font-size: 13px;
  color: var(--text2);
  margin-top: 8px;
  line-height: 1.5;
}
.episode-desc.open { display: block; }
.desc-hint { opacity: 0.5; }

/* Continue listening */
.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text2);
  margin-bottom: 10px;
  padding: 0 16px;
}
.continue-section { margin-bottom: 24px; }
.continue-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 0 16px;
}
.continue-art {
  width: 52px; height: 52px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg3);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.continue-art img { width: 100%; height: 100%; object-fit: cover; }
.continue-info { flex: 1; min-width: 0; }
.continue-label { font-size: 11px; color: var(--text2); margin-bottom: 2px; }
.continue-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 6px; }
.continue-progress-wrap { height: 3px; background: var(--border); border-radius: 99px; margin-bottom: 4px; }
.continue-progress-bar { height: 100%; background: var(--accent); border-radius: 99px; width: 0%; }
.continue-time { font-size: 11px; color: var(--text2); }

/* Responsive */
@media (max-width: 600px) {
  .navbar { padding: 0 16px; height: 52px; }
  .container { padding: 16px 0; } /* full width on mobile */
  .feed-header { flex-direction: column; padding: 0 16px; }
  .feed-header-art { width: 100%; max-width: 140px; }
  .feed-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; padding: 0 16px; }
  .filter-bar { padding: 0 16px; }
  .season-header { border-radius: 0 !important; border-left: none; border-right: none; }
  .season-section:first-child .season-header { border-top: 1px solid var(--border); }
  .episode-row { padding: 14px 16px; border-left: none; border-right: none; }
  .episode-list .episode-row:first-child { border-radius: 0; }
  .episode-list .episode-row:last-child { border-radius: 0; }
  .episode-title { font-size: 15px; }
  .page-header { padding: 0 16px; }
  .flash { margin: 0 16px 16px; }
  .settings-card { border-radius: 0; border-left: none; border-right: none; }
}
