:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #5b9fd4;
  --accent-hover: #7ab5e3;
  --danger: #e85d5d;
  --folder: #e8b84a;
  --folder-dim: rgba(232, 184, 74, 0.15);
  --audio: #6bc9a8;
  --audio-dim: rgba(107, 201, 168, 0.12);
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(ellipse at top, #1a2a3d 0%, var(--bg) 60%);
}

.login-card {
  background: var(--surface);
  padding: 2rem;
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
}

.login-card p {
  color: var(--muted);
  margin: 0 0 1.5rem;
}

.login-card input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--surface2);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0.75rem;
}

.login-card button {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.login-card button:hover {
  background: var(--accent-hover);
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 11rem;
}

@media (min-width: 700px) {
  .app {
    padding-bottom: 9.5rem;
  }
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--surface2);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  font-size: 1.75rem;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border-radius: 10px;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.mode-toggle {
  display: flex;
  gap: 0.25rem;
  background: var(--bg);
  padding: 0.25rem;
  border-radius: 10px;
}

.mode-toggle button {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}

.mode-toggle button.active {
  background: var(--accent);
  color: #fff;
}

.main {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr) minmax(240px, 300px);
  flex: 1;
  min-height: 0;
}

@media (max-width: 1100px) {
  .main {
    grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  }
  .playlist-panel {
    grid-column: 1 / -1;
    max-height: 36vh;
    border-top: 1px solid var(--surface2);
    border-left: none;
  }
}

@media (max-width: 700px) {
  .main {
    grid-template-columns: 1fr;
  }
  .sidebar {
    max-height: 35vh;
    overflow: auto;
  }
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--surface2);
  overflow: hidden;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar .panel:first-child {
  flex-shrink: 0;
  max-height: 28%;
  overflow: auto;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--surface2);
}

.sidebar .library-panel {
  flex: 1;
  min-height: 0;
}

.playlist-panel {
  background: var(--surface);
  border-left: 1px solid var(--surface2);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.playlist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--surface2);
  flex-shrink: 0;
}

.playlist-header h2 {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.playlist-count {
  color: var(--accent);
  font-weight: 700;
}

.playlist-actions {
  display: flex;
  gap: 0.35rem;
}

.playlist-action {
  border: 1px solid var(--surface2);
  background: var(--bg);
  color: var(--text);
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
}

.playlist-action.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  min-width: 2.25rem;
}

.playlist-action:hover {
  filter: brightness(1.1);
}

.playlist-hint {
  margin: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  flex-shrink: 0;
}

.playlist-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  overflow: auto;
  flex: 1;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
  border-radius: 8px;
  background: var(--bg);
}

.playlist-item.active {
  outline: 2px solid var(--accent);
}

.playlist-item-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 0.55rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
}

.playlist-item-main:hover {
  background: var(--surface2);
  border-radius: 8px;
}

.playlist-item-icon {
  flex-shrink: 0;
  opacity: 0.75;
}

.playlist-item-text {
  min-width: 0;
}

.playlist-item-text strong {
  display: block;
  font-size: 0.88rem;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.playlist-item-text small {
  color: var(--muted);
  font-size: 0.72rem;
}

.playlist-item-remove {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.playlist-item-remove:hover {
  color: var(--danger);
  background: var(--surface2);
}

.icon-btn,
.list-row-add {
  flex: 0 0 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
  min-width: 1.75rem;
  max-width: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn-svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.icon-btn:hover,
.list-row-add:hover {
  background: var(--accent);
  color: #fff;
}

.track-list .list-row {
  flex: 1;
  min-width: 0;
}

.track-list .list-row-main {
  flex: 1 1 0;
  min-width: 0;
}

.panel h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.5rem 0;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li button {
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.list li button:hover {
  background: var(--surface2);
}

.list li button.active {
  background: var(--accent);
  color: #fff;
}

.list .icon {
  opacity: 0.7;
  width: 1.25rem;
  text-align: center;
}

.list-row {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  width: 100%;
}

.list-row-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.list-row-main:hover {
  background: var(--surface2);
}

.list-row-play {
  flex-shrink: 0;
  width: 2.5rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}

.list-row-play:hover {
  background: var(--accent-hover);
}

/* —— Knihovna: kompaktní seznam —— */
.library-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.library-toolbar {
  margin-bottom: 0.5rem;
}

.library-toolbar h2 {
  margin-bottom: 0.5rem;
}

.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--muted);
  pointer-events: none;
}

.browse-filter {
  width: 100%;
  padding: 0.55rem 0.65rem 0.55rem 2.15rem;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  box-shadow: inset 0 0 0 1px var(--surface2);
}

.browse-filter:focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 2px rgba(91, 159, 212, 0.2);
}

.breadcrumb-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem 0.25rem;
  margin-bottom: 0.45rem;
}

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  border: none;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
  text-align: left;
}

.crumb:hover {
  color: var(--text);
  background: var(--surface2);
}

.crumb--current {
  color: var(--text);
  background: var(--surface2);
  font-weight: 600;
}

.crumb--root .crumb-icon {
  width: 0.85rem;
  height: 0.85rem;
}

.crumb-sep {
  flex-shrink: 0;
  color: var(--muted);
  opacity: 0.35;
  font-size: 0.7rem;
}

.browse-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.stat-chip {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--muted);
}

.stat-chip--folder {
  background: var(--folder-dim);
  color: var(--folder);
}

.stat-chip--audio {
  background: var(--audio-dim);
  color: var(--audio);
}

.favorites-browser,
.lib-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow: auto;
  min-height: 0;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--surface2);
}

.lib-list--loading {
  opacity: 0.55;
  pointer-events: none;
}

.lib-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.lib-loading-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  animation: lib-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes lib-pulse {
  from { opacity: 0.35; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.browse-empty,
.lib-empty-hint {
  text-align: center;
  padding: 1.25rem 0.75rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.lib-section {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.45rem 0.75rem 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  list-style: none;
}

.lib-row {
  display: flex;
  align-items: stretch;
  min-height: 3rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.12s;
}

.lib-row:last-child {
  border-bottom: none;
}

.lib-row:hover,
.lib-row:focus-within {
  background: rgba(255, 255, 255, 0.04);
}

.lib-row--parent {
  background: rgba(91, 159, 212, 0.06);
  border-bottom: 1px solid rgba(91, 159, 212, 0.15);
}

.lib-row--parent:hover {
  background: rgba(91, 159, 212, 0.1);
}

.lib-row--file {
  opacity: 0.45;
}

.lib-row-hit {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.6rem 0.35rem 0.6rem 0.65rem;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.lib-row-hit:disabled {
  cursor: default;
}

.lib-thumb {
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}

.lib-thumb-inner {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lib-thumb-inner svg {
  width: 1.15rem;
  height: 1.15rem;
}

.lib-thumb-inner--folder {
  background: linear-gradient(145deg, #3d4f6a 0%, #2a3548 100%);
  color: #f0d78c;
  border-radius: 10px;
}

.lib-thumb-inner--audio {
  background: linear-gradient(145deg, #2d5a4a 0%, #1e3d32 100%);
  color: #8ee4c0;
  border-radius: 50%;
}

.lib-thumb-inner--parent {
  background: var(--surface2);
  color: var(--accent);
  border-radius: 50%;
}

.lib-thumb-inner--file {
  background: var(--surface2);
  color: var(--muted);
}

.lib-text {
  flex: 1;
  min-width: 0;
}

.lib-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.lib-meta {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.lib-tag {
  flex-shrink: 0;
  align-self: center;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.15rem;
}

.lib-tag--folder {
  background: var(--folder-dim);
  color: var(--folder);
}

.lib-tag--audio {
  background: var(--audio-dim);
  color: var(--audio);
}

.lib-tag--muted {
  background: var(--surface2);
  color: var(--muted);
}

.lib-chevron {
  flex-shrink: 0;
  align-self: center;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--muted);
  opacity: 0.5;
  margin-right: 0.25rem;
}

.lib-chevron svg {
  width: 100%;
  height: 100%;
  display: block;
}

.lib-row:hover .lib-chevron {
  opacity: 1;
  color: var(--accent);
}

.lib-row-menu {
  display: flex;
  align-items: center;
  align-self: center;
  gap: 0.2rem;
  padding-right: 0.5rem;
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(4px);
  transition: opacity 0.15s, transform 0.15s;
}

.lib-row:hover .lib-row-menu,
.lib-row:focus-within .lib-row-menu {
  opacity: 1;
  transform: translateX(0);
}

.lib-act {
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.lib-act--play {
  background: var(--accent);
  color: #fff;
}

.lib-act--play:hover {
  background: var(--accent-hover);
}

.lib-act--icon {
  flex: 0 0 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
  min-width: 1.75rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.lib-act--icon .icon-btn-svg {
  width: 1rem;
  height: 1rem;
}

.lib-act--add {
  background: var(--surface2);
  color: var(--accent);
}

.lib-act--add:hover {
  background: var(--accent);
  color: #fff;
}

@media (max-width: 700px) {
  .lib-row-menu {
    opacity: 1;
    transform: none;
  }
}

.player-area {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  min-height: 0;
  overflow: auto;
}

.now-playing {
  margin-bottom: 1rem;
}

.now-playing h2 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.now-playing .meta {
  color: var(--muted);
}

.placeholder {
  color: var(--muted);
}

.track-list {
  flex: 1;
  overflow: auto;
  margin-bottom: 1rem;
}

.track-list ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.track-list li button,
.track-list li .list-row {
  width: 100%;
}

.track-list li button {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border: none;
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  margin-bottom: 0.35rem;
  cursor: pointer;
  text-align: left;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.track-list li button:hover {
  background: var(--surface2);
}

.track-list li button.playing {
  outline: 2px solid var(--accent);
}

.track-list .resume {
  font-size: 0.8rem;
  color: var(--accent);
}

.play-folder-btn {
  margin-top: 0.75rem;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.play-folder-btn:hover {
  background: var(--accent-hover);
}

.now-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.track-list .queue-section {
  list-style: none;
  margin: 0.5rem 0 0.25rem;
}

.queue-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  padding: 0 0.5rem;
}

.track-list [data-track-index].playing {
  outline: 2px solid var(--accent);
  border-radius: 8px;
}

.player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border-top: 1px solid var(--surface2);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
}

.player-bar-inner {
  max-width: 960px;
  margin: 0 auto;
}

.player-bar-track {
  margin-bottom: 0.5rem;
  min-width: 0;
}

.player-bar-track strong {
  display: block;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.progress-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ctrl-btn {
  border: none;
  background: var(--surface2);
  color: var(--text);
  min-width: 3rem;
  padding: 0.45rem 0.5rem;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.ctrl-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ctrl-btn.primary {
  min-width: 3.75rem;
  padding: 0.55rem 0.65rem;
  background: var(--accent);
  color: #fff;
}

.ctrl-btn:not(:disabled):hover {
  filter: brightness(1.12);
}

.ctrl-icon {
  font-size: 1.1rem;
  line-height: 1;
  font-weight: 700;
}

.ctrl-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ctrl-btn.primary .ctrl-label {
  color: rgba(255, 255, 255, 0.85);
}

@media (max-width: 520px) {
  .ctrl-label {
    display: none;
  }
  .ctrl-btn {
    min-width: 2.6rem;
    padding: 0.55rem;
    border-radius: 50%;
  }
  .ctrl-btn.primary {
    min-width: 3.2rem;
  }
}

.extra {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.extra label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.extra select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--surface2);
  border-radius: 6px;
  padding: 0.25rem;
}

.ghost {
  border: 1px solid var(--surface2);
  background: transparent;
  color: var(--accent);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
}

.ghost:hover {
  background: var(--surface2);
}
