:root {
  --bg: #1b1333;
  --bg-light: #2a1f4d;
  --accent: #ff9f5b;
  --accent-2: #7c5cff;
  --text: #f4f1ff;
  --text-dim: #b9b0e0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: linear-gradient(180deg, var(--bg) 0%, #120b26 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* PWA/standalone módban (iOS "black-translucent" státuszbár) a tartalom a
     kijelző tetejéig ér — ez nélkül a gombok a notch/óra/akku-ikonok alá
     csúsznának. A safe-area-inset-top adja a biztonságos távolságot. */
  padding: calc(1.2rem + env(safe-area-inset-top, 0px)) 1.2rem 0.6rem;
}

.app-header h1 {
  font-size: 1.3rem;
  margin: 0;
}

.icon-btn {
  background: var(--bg-light);
  color: var(--text);
  border: none;
  border-radius: 12px;
  width: 48px;
  height: 48px;
  font-size: 1.3rem;
  cursor: pointer;
}

.player {
  max-width: 480px;
  margin: 1rem auto;
  padding: 1.5rem 1.2rem 2rem;
  background: var(--bg-light);
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

.current-title {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 600;
  min-height: 3rem;
  margin: 0 0 1.2rem;
  line-height: 1.4;
}

.seek-row { margin-bottom: 1.4rem; }

#seek-bar {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: #3a2d66;
  border-radius: 4px;
  outline: none;
}

#seek-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  margin-top: -7px;
}

#seek-bar::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  margin-bottom: 1.4rem;
}

.ctrl-btn {
  background: var(--bg);
  color: var(--text);
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 1.4rem;
  cursor: pointer;
}

.ctrl-btn.small {
  width: 56px;
  height: 56px;
  font-size: 0.95rem;
  border-radius: 16px;
}

.play-btn {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #1b1333;
  border: none;
  border-radius: 50%;
  width: 84px;
  height: 84px;
  font-size: 2.1rem;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.5);
}

.ctrl-btn:active, .play-btn:active { transform: scale(0.94); }

.bookmark-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}

.bookmark-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid #3a2d66;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.bookmark-btn:active { transform: scale(0.96); }

.bookmark-btn.saved,
.bookmark-btn.downloaded {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #1b1333;
  border-color: transparent;
}

.bookmark-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.speed-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  color: var(--text-dim);
}

#speed-select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid #3a2d66;
  border-radius: 10px;
  padding: 0.4rem 0.6rem;
  font-size: 0.95rem;
}

.chapter-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 85vw);
  background: var(--bg-light);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 20;
  padding: 1rem;
  overflow-y: auto;
}

body.list-open .chapter-panel { transform: translateX(0); }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 10;
}

body.list-open .backdrop {
  opacity: 1;
  pointer-events: auto;
}

.chapter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  /* ugyanaz a notch/státuszbár-védelem, mint az app-header-nél */
  padding-top: env(safe-area-inset-top, 0px);
}

.chapter-panel-header h2 {
  font-size: 1.1rem;
  margin: 0;
}

#chapter-list,
#bookmark-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

#chapter-list li {
  padding: 0.9rem 0.8rem;
  border-radius: 12px;
  margin-bottom: 0.4rem;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#chapter-list li:active { background: var(--bg); }

#chapter-list li.active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #1b1333;
  font-weight: 600;
}

#chapter-list li.completed::before {
  content: "✓ ";
  opacity: 0.7;
}

.bookmarks-section {
  margin-bottom: 1.2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #3a2d66;
}

.bookmarks-section.hidden { display: none; }

.bookmarks-section h3 {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0 0 0.5rem;
  font-weight: 600;
}

#bookmark-list li {
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  margin-bottom: 0.4rem;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg);
}

#bookmark-list li:active { opacity: 0.85; }

.bookmark-remove {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
  flex-shrink: 0;
}

@media (min-width: 600px) {
  .player { margin-top: 2.5rem; }
}
