:root {
  --fundo: #0f0f0f;
  --superficie: #1f1f1f;
  --texto: #f1f1f1;
  --texto-2: #aaa;
  --destaque: #ff0033;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.topo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-size: 14px;
}
.marca { font-weight: 700; }
.conexao { color: var(--texto-2); }

main[hidden] { display: none !important; }

/* ---------- sem sala ---------- */
.aviso {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px;
}
.aviso-icone { font-size: 56px; }
.aviso h1 { font-size: 22px; margin: 12px 0 8px; }
.aviso p { color: var(--texto-2); max-width: 320px; margin: 0; }

/* ---------- controle ---------- */
.controle {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 8px 24px 32px;
}
.app.desligado .botoes,
.app.desligado .progresso,
.app.desligado .volume,
.app.desligado .busca,
.app.desligado .lista,
.app.desligado .botao-texto { opacity: 0.4; pointer-events: none; }

.capa-moldura {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: var(--superficie);
}
.capa { width: 100%; height: 100%; object-fit: cover; display: block; }
.capa-vazia {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 48px;
  color: #555;
}
.capa[hidden], .capa-vazia[hidden] { display: none; }

.info { min-width: 0; }
.titulo {
  font-size: 20px;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.canal { margin: 0; color: var(--texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- sliders ---------- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  margin: 0;
  --p: 0%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--destaque) var(--p), #3a3a3a var(--p));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: #3a3a3a; }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--destaque); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: #fff;
}
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #fff; }

.tempos {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--texto-2);
  font-variant-numeric: tabular-nums;
}

/* ---------- botões ---------- */
.botoes {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 28px;
}
.botao {
  width: 64px;
  height: 64px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--texto);
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}
.botao:active { background: var(--superficie); }
.botao svg { width: 36px; height: 36px; fill: currentColor; }
.botao svg[hidden] { display: none; }
.botao-principal { width: 84px; height: 84px; background: var(--texto); color: var(--fundo); }
.botao-principal:active { background: #ccc; }
.botao-principal svg { width: 44px; height: 44px; }

.volume { display: flex; align-items: center; gap: 10px; }
.volume svg { width: 22px; height: 22px; fill: var(--texto-2); flex: none; }

/* ---------- abas (Tocando / Buscar / Fila) ---------- */
html, body { height: 100dvh; }
body { overflow: hidden; }

.app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.app[hidden] { display: none; }

.painel { flex: 1; min-height: 0; overflow-y: auto; }

.abas {
  display: flex;
  border-top: 1px solid #272727;
  background: var(--fundo);
}
.aba {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 10px;
  border: 0;
  background: none;
  color: var(--texto-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
}
.aba svg { width: 24px; height: 24px; fill: currentColor; }
.aba.ativa { color: var(--texto); }
.selo {
  position: absolute;
  top: 4px;
  left: calc(50% + 8px);
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--destaque);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  font-weight: 700;
}
.selo[hidden] { display: none; }

/* ---------- listas (busca e fila) ---------- */
.lista-painel {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px 16px;
}

.busca {
  display: flex;
  gap: 8px;
  position: sticky;
  top: 0;
  padding: 4px 0 12px;
  background: var(--fundo);
  z-index: 1;
}
.busca input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 16px;
  border: 1px solid #333;
  border-radius: 22px;
  background: var(--superficie);
  color: var(--texto);
  font: inherit;
}
.busca input:focus { outline: 2px solid #3ea6ff; outline-offset: -1px; }
.busca button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--superficie);
  color: var(--texto);
  display: grid;
  place-items: center;
}
.busca button svg { width: 22px; height: 22px; fill: currentColor; }

.lista-status { color: var(--texto-2); font-size: 14px; text-align: center; margin: 24px 8px; }
.lista-status[hidden] { display: none; }

.lista { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.item-tocar {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.item-capa {
  position: relative;
  flex: none;
  width: 96px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  background: var(--superficie);
}
.item-capa img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-duracao {
  position: absolute;
  right: 4px;
  bottom: 4px;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.8);
  font-size: 11px;
  line-height: 16px;
}
.item-texto { min-width: 0; }
.item-titulo {
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-canal { font-size: 12px; color: var(--texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.item-acao {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--texto-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}
.item-acao:active { background: var(--superficie); }
.item-acao svg { width: 24px; height: 24px; fill: currentColor; }
.item-acao.feito { color: #2ba640; }

.fila-topo { display: flex; justify-content: space-between; align-items: center; }
.fila-topo h2 { font-size: 18px; margin: 4px 0 8px; }
.contagem { color: var(--texto-2); font-weight: 400; font-size: 14px; }
.botao-texto {
  border: 0;
  background: none;
  color: #3ea6ff;
  font: inherit;
  font-size: 14px;
  padding: 8px;
  cursor: pointer;
}
.botao-texto[hidden] { display: none; }

.aviso-toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 8px;
  background: #f1f1f1;
  color: #0f0f0f;
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.2s;
}
.aviso-toast[hidden] { display: block; opacity: 0; }
