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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a2e;
  --surface2: #16213e;
  --accent: #e94560;
  --accent2: #0f3460;
  --text: #e0e0e0;
  --text-muted: #888;
  --border: #2a2a4a;
  --nav-h: 52px;
  --np-h: 64px;
  --radius: 8px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  overscroll-behavior: none;
}

/* ── Nav ── */
#nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  transition: color 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.nav-btn.active { color: var(--accent); }
.nav-btn:hover { color: var(--text); }
.nav-icon { font-size: 18px; line-height: 1; }

/* ── Main content area ── */
#main {
  position: fixed;
  top: 0;
  left: 0; right: 0;
  bottom: calc(var(--nav-h) + var(--np-h));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#main.no-player { bottom: var(--nav-h); }

/* ── Now Playing bar ── */
#now-playing {
  position: fixed;
  left: 0; right: 0;
  bottom: var(--nav-h);
  height: var(--np-h);
  background: var(--surface2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  z-index: 90;
  cursor: pointer;
}
#now-playing.hidden { display: none; }

#np-artwork {
  width: 42px; height: 42px;
  border-radius: 6px;
  background: var(--surface);
  flex-shrink: 0;
  overflow: hidden;
}
#np-artwork img { width: 100%; height: 100%; object-fit: cover; }

#np-info { flex: 1; min-width: 0; }
#np-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#np-feed  { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#np-controls { display: flex; align-items: center; gap: 6px; }
#np-controls button {
  background: none; border: none; color: var(--text); font-size: 13px;
  cursor: pointer; padding: 6px; border-radius: 4px;
}
#np-controls button:hover { background: var(--border); }

/* ── Views ── */
.view { padding: 0 0 8px; }

header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px 10px;
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
header h1 { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; }

/* ── Lists ── */
.list { list-style: none; }

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
  overflow: hidden;
}
.item-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  pointer-events: none;
}
.list-item:hover { background: var(--surface); }
.list-item:active { background: var(--surface2); }

.item-artwork {
  width: 48px; height: 48px;
  border-radius: 6px;
  background: var(--surface);
  flex-shrink: 0;
  overflow: hidden;
}
.item-artwork img { width: 100%; height: 100%; object-fit: cover; }

.item-body { flex: 1; min-width: 0; }
.item-title { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
#feed-list .item-title { white-space: normal; }
.item-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-badge { font-size: 11px; background: var(--accent2); color: var(--text); border-radius: 10px; padding: 2px 7px; flex-shrink: 0; }

/* ── Player ── */
#view-player { padding: 0; }

#player-artwork {
  width: 100%;
  aspect-ratio: 1;
  max-height: 260px;
  background: var(--surface);
  overflow: hidden;
}
#player-artwork img { width: 100%; height: 100%; object-fit: cover; }

#player-video-wrap, #player-youtube-wrap { width: 100%; background: #000; }
#player-video { width: 100%; max-height: 50vh; display: block; }
#player-youtube { width: 100%; aspect-ratio: 16/9; display: block; border: none; }

#player-meta { padding: 16px 16px 8px; }
#player-title { font-size: 15px; font-weight: 600; line-height: 1.4; }
#player-feed  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

#player-audio-wrap { padding: 12px 16px 20px; }

#scrub {
  width: 100%;
  accent-color: var(--accent);
  margin-bottom: 4px;
}

#time-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-bottom: 16px; }

#controls-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 14px; }
#controls-row button {
  background: none; border: none; color: var(--text);
  font-size: 15px; cursor: pointer; padding: 8px; border-radius: 6px;
}
#controls-row button:hover { background: var(--surface); }
#btn-play-pause { font-size: 24px !important; padding: 10px !important; }

#btn-fullscreen { font-size: 18px !important; padding: 6px 8px !important; }

#speed-select {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px; padding: 4px 8px;
  font-size: 13px; cursor: pointer;
}

#format-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.fmt-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 6px; padding: 4px 12px;
  cursor: pointer; font-size: 13px; transition: all 0.15s;
}
.fmt-btn.active { background: var(--accent2); color: var(--text); border-color: var(--accent2); }

/* ── Settings ── */
.settings-section { padding: 16px; border-bottom: 1px solid var(--border); }
.settings-section h2 { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }

.file-label {
  display: block;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  text-align: center;
}
.file-label input { display: none; }
.file-label:hover { border-color: var(--accent); }

.input-row { display: flex; gap: 8px; }
.input-row input {
  flex: 1;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius);
  padding: 8px 12px; font-size: 14px;
}
.input-row input:focus { outline: none; border-color: var(--accent); }

.status-msg { font-size: 13px; color: var(--text-muted); margin-top: 8px; }
.status-msg.error { color: var(--accent); }
.status-msg.success { color: #4caf50; }

/* ── Buttons ── */
button:not([class]) {
  background: var(--accent2); border: none; color: var(--text);
  border-radius: var(--radius); padding: 7px 14px; font-size: 13px; cursor: pointer;
  transition: opacity 0.15s;
}
button:not([class]):hover { opacity: 0.85; }

#btn-back, #btn-back-ep {
  background: none; border: none; color: var(--accent);
  font-size: 14px; cursor: pointer; padding: 4px 0; white-space: nowrap;
}

#btn-star {
  background: none; border: none; color: var(--text-muted);
  font-size: 18px; cursor: pointer; margin-left: auto;
}
#btn-star.starred { color: #ffd700; }

.toggle { font-size: 12px; display: flex; align-items: center; gap: 4px; color: var(--text-muted); white-space: nowrap; }
.toggle input { accent-color: var(--accent); }

.twit-item { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; }
.twit-item input[type="url"] {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius);
  padding: 7px 10px; font-size: 13px; width: 100%;
}
.twit-item input:focus { outline: none; border-color: var(--accent); }

/* ── Settings feed list ── */
.settings-feed-item { border-bottom: 1px solid var(--border); }

.settings-feed-main {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
}
.settings-feed-main .item-body { flex: 1; min-width: 0; }

.settings-feed-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.feed-action-btns { display: flex; gap: 6px; }
.feed-auto-dl-row { justify-content: flex-end; }
.feed-edit-btn, .feed-delete-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 6px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
  transition: all 0.15s;
}
.feed-edit-btn:hover  { color: var(--text); border-color: var(--accent2); }
.feed-delete-btn:hover { color: var(--accent); border-color: var(--accent); }

.feed-edit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 16px 12px;
}
.feed-edit-input {
  flex: 1;
  min-width: 0;
  background: var(--surface); border: 1px solid var(--accent);
  color: var(--text); border-radius: var(--radius);
  padding: 7px 10px; font-size: 13px;
}
.feed-edit-input:focus { outline: none; }
.feed-save-btn, .feed-cancel-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 6px;
  padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.feed-save-btn:hover   { background: var(--accent2); border-color: var(--accent2); }
.feed-cancel-btn:hover { color: var(--text-muted); }
.feed-edit-status { width: 100%; font-size: 12px; }

/* ── Info Tabs (Chapters / Show Notes / Bookmarks) ── */
#info-tabs {
  margin-top: 16px;
  border-top: 1px solid var(--border);
}
#info-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}
.info-tab {
  flex: 1;
  padding: 9px 4px;
  font-size: 13px;
  font-weight: 500;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.info-tab:hover { color: var(--text); }
.info-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.info-panel {
  padding: 12px 16px 0;
}
.info-empty {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px 0;
}
#shownotes-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  padding-bottom: 16px;
}
#shownotes-content a { color: var(--accent); }
#shownotes-content p { margin: 0 0 8px; }
#shownotes-content ul, #shownotes-content ol { padding-left: 20px; margin: 0 0 8px; }
#chapters-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chapter-item {
  display: flex;
  align-items: baseline;
  gap: 0;
  padding: 7px 4px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s;
}
.chapter-item:hover { background: var(--surface2); }
.chapter-active { background: var(--surface2); }
.chapter-active .chapter-title { color: var(--accent); }
.chapter-num {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  flex-shrink: 0;
}
.chapter-title {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  padding-left: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chapter-dur {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 72px;
  text-align: right;
  margin-left: 8px;
}
.chapter-ts {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 44px;
  text-align: right;
  white-space: nowrap;
  border-left: 1px solid var(--border);
  margin-left: 10px;
  padding-left: 10px;
}

/* ── Collapsible ── */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.collapsible-header h2 { margin: 0; }
.collapsible-arrow { color: var(--text-muted); font-size: 14px; transition: transform 0.15s; }
.collapsible-body { margin-top: 12px; }

/* ── Downloads ── */
.dl-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.dl-btn:hover  { color: var(--text); border-color: var(--accent2); }
.dl-btn:disabled { opacity: 0.5; cursor: default; }

.dl-group { margin-bottom: 16px; }
.dl-group-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  padding: 4px 0 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.dl-file {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 13px;
  color: var(--text-muted);
}
.dl-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 12px; }
.dl-file-size { flex-shrink: 0; }

.hidden { display: none !important; }

/* ── Utility ── */
.list-empty {
  padding: 24px 16px;
  color: var(--text-muted);
}

.star-icon {
  color: #ffd700;
  font-size: 16px;
  flex-shrink: 0;
}

/* ── Starred notes ── */
.starred-item { border-bottom: 1px solid var(--border); }
.starred-item-main { border-bottom: none; }
.starred-note-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.starred-note-btn {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
.starred-note-btn:hover { color: var(--text); }
.starred-note-editor {
  padding: 8px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.starred-note-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 8px;
  resize: vertical;
  box-sizing: border-box;
}
.starred-note-actions {
  display: flex;
  gap: 8px;
}
.starred-note-actions button {
  padding: 6px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}
.starred-note-save {
  background: var(--accent);
  color: #fff;
  border: none;
}
.starred-note-cancel {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.settings-hint {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 12px;
}

.section-status {
  font-size: 14px;
  margin-bottom: 12px;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.input-mono { font-family: monospace; font-size: 13px; }

.picker-msg {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}
.picker-msg.error { color: var(--accent); }

/* ── Episodes header ── */
.episodes-header {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.episodes-header-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.episodes-header-top h1 {
  flex: 1;
  white-space: normal;
  line-height: 1.3;
}

.ep-header-artwork {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  background: var(--surface);
  flex-shrink: 0;
  overflow: hidden;
}
.ep-header-artwork img { width: 100%; height: 100%; object-fit: cover; }

.episodes-header-bottom {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.episodes-select-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 0 2px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}
.episodes-select-bar-actions {
  display: flex;
  gap: 6px;
}
#btn-mark-read, #btn-mark-unread {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: var(--radius);
  cursor: pointer;
}
#btn-mark-read {
  border: none;
  background: var(--accent);
  color: #fff;
}
#btn-mark-unread {
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
}
#btn-mark-read:disabled, #btn-mark-unread:disabled { opacity: 0.4; cursor: default; }
.ep-select {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}
.ep-played .item-title { color: var(--text-muted); }

/* ── Settings section helpers ── */
#dl-folder-status {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 12px;
}

#drive-status {
  font-size: 14px;
  margin-bottom: 12px;
}

#drive-folder-name {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

.twit-item small { color: var(--text-muted); }

/* ── Drive folder picker modal ── */
.drive-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.drive-picker {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}
.drive-picker-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drive-picker-path {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drive-picker-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer; padding: 4px; flex-shrink: 0;
}
.drive-picker-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.drive-picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.1s;
}
.drive-picker-item:hover { background: var(--surface2); }
.drive-picker-item-icon { font-size: 18px; flex-shrink: 0; }
.drive-picker-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-picker-item-arrow { color: var(--text-muted); flex-shrink: 0; }
.drive-picker-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.drive-picker-footer button { flex: 1; }
