:root {
  --bg: #101012;
  --panel: #16161a;
  --surface: #1e1e23;
  --surface-2: #2a2a30;
  --line: #2c2c33;
  --text: #f2f0eb;
  --muted: #9b9891;
  --dim: #6c6a65;
  --accent: #e8a33d;
  --accent-ink: #1b1305;
  --danger: #f07b6b;
  --radius: 10px;
  --bar-h: 64px;
  --tab-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
a { color: var(--accent); }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 5px; word-break: break-all; }

.ic { width: 22px; height: 22px; flex: none; display: block; }
.dim { color: var(--dim); }
.muted { color: var(--muted); }
.err { color: var(--danger); }
.accent { color: var(--accent) !important; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 14px;
  transition: background .15s, transform .1s;
}
.btn:hover { background: #34343b; }
.btn:active { transform: scale(.97); }
.btn .ic { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #f0b152; }
.btn.small { height: 32px; padding: 0 14px; font-size: 13px; }
.btn.wide { width: 100%; height: 46px; font-size: 15px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); flex: none; transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }
.icon-btn.play { background: var(--text); color: var(--bg); }
.icon-btn.play:hover { background: #fff; color: var(--bg); transform: scale(1.04); }

/* ---------- Configuração inicial ---------- */
.setup { min-height: 100%; overflow: auto; height: 100%; padding: calc(24px + var(--safe-t)) 16px 40px; display: flex; justify-content: center; align-items: flex-start; }
.setup-card { width: 100%; max-width: 560px; margin-top: 4vh; }
.setup-card h1 { font-size: 26px; line-height: 1.2; margin: 18px 0 10px; letter-spacing: -.01em; }
.setup-card p { color: var(--muted); margin: 8px 0; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: .01em; }
.brand-ic { color: var(--accent); width: 26px; height: 26px; }
.steps { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0; }
.steps summary { cursor: pointer; font-weight: 600; }
.steps ol { margin: 12px 0 0; padding-left: 20px; color: var(--muted); }
.steps li { margin: 10px 0; }
.steps b { color: var(--text); }
.copy { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.field { display: block; margin: 16px 0 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; height: 46px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); outline: none; }
.field input:focus { border-color: var(--accent); }
.fine { font-size: 13px; color: var(--dim) !important; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 16px 0 8px; color: var(--dim); }
.crumbs button { color: var(--accent); padding: 2px 4px; border-radius: 4px; }
.crumbs button:last-child { color: var(--text); font-weight: 600; }
.folders { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); max-height: 46vh; overflow: auto; }
.folders p { padding: 14px 16px; margin: 0; }
.folder-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); }
.folder-btn:last-child { border-bottom: 0; }
.folder-btn:hover { background: var(--surface); }
.folder-btn span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-btn .ic:first-child { color: var(--accent); }
.row-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.row-btns.left { justify-content: flex-start; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--surface-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 28px 0 12px; }
.scan { font-variant-numeric: tabular-nums; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Estrutura ---------- */
.shell { height: 100%; display: grid; grid-template-columns: 232px 1fr; grid-template-rows: 1fr auto; }
.nav { grid-row: 1; grid-column: 1; background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.nav .brand { padding: 4px 10px 18px; }
.nav-btn { display: flex; align-items: center; gap: 14px; height: 42px; padding: 0 12px; border-radius: 8px; color: var(--muted); font-weight: 600; text-align: left; }
.nav-btn:hover { color: var(--text); background: var(--surface); }
.nav-btn.on { color: var(--text); background: var(--surface-2); }
.nav-btn.on .ic { color: var(--accent); }
.status { margin-top: auto; padding: 12px; font-size: 12px; color: var(--dim); }
.main { grid-row: 1; grid-column: 2; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.head { display: flex; align-items: center; gap: 8px; padding: calc(20px + var(--safe-t)) 24px 6px; }
.head-text { flex: 1; min-width: 0; }
.head h1 { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head #back { margin-left: -10px; }
.mobile-only { display: none; }
.search { position: relative; margin: 10px 24px 4px; max-width: 520px; }
.search .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--dim); pointer-events: none; }
.search input { width: 100%; height: 40px; border-radius: 999px; border: 1px solid transparent; background: var(--surface); padding: 0 16px 0 40px; outline: none; }
.search input:focus { border-color: var(--line); background: var(--surface-2); }
.search input::-webkit-search-cancel-button { filter: invert(.6); }
.toolbar { display: flex; gap: 10px; padding: 10px 24px 8px; min-height: 8px; }
.toolbar:empty { padding: 4px 24px; }
.list { flex: 1; min-height: 0; overflow-y: auto; position: relative; padding: 0 12px; overscroll-behavior: contain; }
.vl-inner { position: relative; }
.vl-row { position: absolute; left: 0; right: 0; height: 60px; }
.empty { color: var(--muted); padding: 24px; margin: 0; }
.settings { flex: 1; overflow: auto; padding: 8px 24px 32px; max-width: 720px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 12px 0; }
.card h2 { font-size: 16px; margin: 0 0 8px; }
.card p { margin: 6px 0; }

/* ---------- Linhas ---------- */
.row { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 8px 0 12px; border-radius: 8px; cursor: pointer; user-select: none; }
.row:hover { background: var(--surface); }
.row:active { background: var(--surface-2); }
.meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.meta .t, .meta .s { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta .t { font-weight: 550; }
.meta .s { font-size: 13px; color: var(--muted); }
.row.on .t { color: var(--accent); }
.row.past { opacity: .5; }
.row .fav { width: 16px; height: 16px; color: var(--accent); }
.row .icon-btn { width: 36px; height: 36px; }
.num { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.row.on .num { color: var(--accent); }

.tile {
  width: 44px; height: 44px; border-radius: 6px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, hsl(var(--h) 32% 34%), hsl(calc(var(--h) + 40) 30% 20%));
  color: hsl(var(--h) 40% 85%); font-weight: 700; font-size: 15px; letter-spacing: .02em;
}
.tile.round { border-radius: 50%; }
.tile.folder { background: var(--surface-2); color: var(--accent); }
.tile.playing { background: var(--surface-2); }
.tile.huge { width: 100%; height: 100%; border-radius: 12px; font-size: 64px; }

.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eq i { width: 3px; height: 4px; background: var(--accent); border-radius: 1px; }
.eq.run i { animation: eq .9s ease-in-out infinite; }
.eq.run i:nth-child(2) { animation-delay: -.3s; }
.eq.run i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 4px; } 50% { height: 14px; } }

/* ---------- Barra do player ---------- */
.bar {
  grid-row: 2; grid-column: 1 / -1; position: relative;
  height: 84px; background: var(--panel); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: minmax(180px, 1fr) minmax(320px, 2fr) minmax(180px, 1fr); align-items: center; gap: 16px; padding: 0 16px;
}
.bar.empty { display: none; }
.bar-progress { display: none; }
.bar-info { display: flex; align-items: center; gap: 12px; min-width: 0; text-align: left; }
.bar-art { width: 52px; height: 52px; flex: none; border-radius: 6px; overflow: hidden; }
.bar-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bar-art .tile { width: 100%; height: 100%; }
.bar-center { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.controls { display: flex; align-items: center; gap: 10px; }
.bar .icon-btn.play { width: 38px; height: 38px; }
.bar-right { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.seek { display: flex; align-items: center; gap: 10px; width: 100%; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.seek > span { width: 42px; text-align: center; }

input[type=range] {
  -webkit-appearance: none; appearance: none; flex: 1; height: 16px; background: transparent; margin: 0; cursor: pointer;
  --p: 0%;
}
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--text) var(--p), var(--surface-2) var(--p)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--surface-2); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--text); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--text); margin-top: -4px; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--text); }
#vol { flex: none; width: 100px; --p: 100%; }

.mini-spin { width: 18px; height: 18px; border: 2px solid rgba(0,0,0,.2); border-top-color: currentColor; border-radius: 50%; animation: spin .8s linear infinite; }

/* ---------- Tocando agora ---------- */
.now {
  position: fixed; inset: 0; z-index: 20; background: linear-gradient(180deg, #24211c 0%, var(--bg) 70%);
  transform: translateY(100%); transition: transform .25s ease; overflow: auto;
}
.now.show { transform: none; }
.now-inner { max-width: 460px; margin: 0 auto; min-height: 100%; padding: calc(10px + var(--safe-t)) 24px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 18px; }
.now-head { display: flex; align-items: center; justify-content: space-between; }
.now-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.now-art { width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface); box-shadow: 0 20px 50px rgba(0,0,0,.45); margin-top: 8px; }
.now-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.now-meta { display: flex; align-items: center; gap: 12px; }
.now-meta .t { font-size: 22px; font-weight: 700; }
.now-meta .s { font-size: 15px; }
.now .seek { flex-direction: column; align-items: stretch; gap: 4px; }
.now .times { display: flex; justify-content: space-between; }
.controls.big { justify-content: space-between; }
.controls.big .icon-btn { width: 48px; height: 48px; }
.controls.big .icon-btn .ic { width: 28px; height: 28px; }
.controls.big .icon-btn.play { width: 68px; height: 68px; }
.controls.big .icon-btn.play .ic { width: 32px; height: 32px; }
.now-foot { display: flex; justify-content: center; margin-top: auto; }

/* ---------- Menu de ações ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,0); transition: background .18s; display: flex; align-items: flex-end; justify-content: center; }
.sheet.show { background: rgba(0,0,0,.55); }
.sheet-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: 16px 16px 0 0; padding: 14px 8px calc(14px + var(--safe-b)); transform: translateY(100%); transition: transform .18s ease; }
.sheet.show .sheet-card { transform: none; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 4px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.sheet-btn { display: flex; align-items: center; gap: 16px; width: 100%; height: 50px; padding: 0 16px; border-radius: 8px; text-align: left; }
.sheet-btn:hover { background: var(--surface-2); }
.sheet-btn .ic { color: var(--muted); }
.sheet-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-path { font-size: 12px; color: var(--dim); padding: 8px 16px 0; margin: 0; word-break: break-all; }
@media (min-width: 768px) {
  .sheet { align-items: center; }
  .sheet-card { border-radius: 16px; padding-bottom: 14px; }
}

.toast {
  position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); z-index: 40; transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Celular ---------- */
@media (max-width: 767px) {
  .shell { display: flex; flex-direction: column; }
  .main { flex: 1; padding-bottom: calc(var(--tab-h) + var(--safe-b)); }
  body.has-bar .main { padding-bottom: calc(var(--tab-h) + var(--bar-h) + 8px + var(--safe-b)); }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    height: calc(var(--tab-h) + var(--safe-b)); padding: 0 0 var(--safe-b);
    flex-direction: row; gap: 0; border-right: 0; border-top: 1px solid var(--line);
    background: rgba(22,22,26,.96); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); overflow: visible;
  }
  .nav .brand, .nav .status, .nav-btn.extra { display: none; }
  .nav-btn { flex: 1; flex-direction: column; justify-content: center; gap: 3px; height: 100%; padding: 0; font-size: 10.5px; font-weight: 600; border-radius: 0; }
  .nav-btn:hover, .nav-btn.on { background: none; }
  .nav-btn.on { color: var(--text); }
  .mobile-only { display: inline-flex; }
  .head { padding: calc(14px + var(--safe-t)) 16px 4px; }
  .head h1 { font-size: 24px; }
  .search { margin: 8px 16px 2px; max-width: none; }
  .toolbar { padding: 10px 16px 6px; }
  .toolbar:empty { padding: 4px 16px; }
  .list { padding: 0 4px; }
  .settings { padding: 4px 16px 24px; }
  .bar {
    position: fixed; left: 8px; right: 8px; bottom: calc(var(--tab-h) + var(--safe-b) + 6px); z-index: 11;
    height: var(--bar-h); border: 0; border-radius: 10px; background: #2b2823;
    grid-template-columns: 1fr auto; gap: 4px; padding: 0 6px 0 8px; overflow: hidden;
  }
  .bar-progress { display: block; position: absolute; left: 10px; right: 10px; bottom: 2px; height: 2px; background: rgba(255,255,255,.12); border-radius: 2px; overflow: hidden; }
  .bar-progress i { display: block; height: 100%; width: 0; background: var(--text); }
  .bar-art { width: 46px; height: 46px; }
  .bar .desk { display: none; }
  .bar .icon-btn.play { background: none; color: var(--text); width: 44px; height: 44px; }
  .bar .icon-btn.play .ic { width: 28px; height: 28px; }
  .bar .controls { gap: 0; }
  .bar .controls .icon-btn { color: var(--text); }
  .bar .mini-spin { border-color: rgba(255,255,255,.2); border-top-color: var(--text); }
  .toast { bottom: calc(var(--tab-h) + var(--bar-h) + 24px + var(--safe-b)); }
}
@media (max-width: 767px) and (max-height: 700px) {
  .now-inner { gap: 12px; }
  .now-art { width: 78%; align-self: center; }
}
