:root {
  --bg: #15171c;
  --panel: #1c1f27;
  --panel-2: #242833;
  --line: #2e3340;
  --text: #e8eaf0;
  --muted: #949bad;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.16);
  --sidebar-w: 340px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#sidebar header {
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
}

#sidebar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

#count {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

#list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}

.item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 2px;
  cursor: pointer;
  font: inherit;
}

.item:hover { background: var(--panel-2); }

.item.active { background: var(--accent-soft); }

.item .title {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.item.active .meta { color: var(--text); }

.badge {
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--panel-2);
  color: var(--muted);
}

.badge.resume { background: var(--accent-soft); color: var(--accent); }

.badge.done { background: rgba(80, 200, 120, 0.16); color: #58c87a; }

.bar {
  position: relative;
  height: 3px;
  margin-top: 8px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
}

#empty {
  padding: 24px 20px;
  color: var(--muted);
}

#empty code {
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 6px;
}

main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 22px;
  gap: 14px;
}

#now {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  min-height: 20px;
}

#player { width: 100%; }

.plyr {
  flex: 1;
  min-height: 0;
  border-radius: 12px;
  overflow: hidden;
}

:root {
  --plyr-color-main: var(--accent);
}

@media (max-width: 720px) {
  body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
  main {
    order: 1;
    flex: none;
    padding: 10px 10px 8px;
    gap: 8px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  #now { font-size: 14px; }
  .plyr {
    flex: none;
    aspect-ratio: 16 / 9;
    max-height: 55vh;
    border-radius: 10px;
  }
  #sidebar {
    order: 2;
    flex: 1;
    min-height: 0;
    border-right: 0;
  }
  #sidebar header { padding: 13px 15px 9px; }
  #list {
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .item { padding: 13px 12px; }
  .item .title { white-space: normal; }
}
