:root {
  --bg: #0b0b12;
  --surface: #17172a;
  --surface-2: #22223c;
  --text: #f4f4fb;
  --muted: #a3a3c2;
  --accent: #ff2e88;
  --accent-2: #6c5ce7;
  --ok: #29d398;
  --tap: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 18px;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { font-weight: 700; font-size: 20px; flex: 1; }
.name-chip {
  background: var(--surface-2);
  color: var(--text);
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 15px;
  max-width: 45vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conn { font-size: 14px; }
.conn--up { color: var(--ok); }
.conn--down { color: #ff5c5c; }

/* Views */
main { flex: 1; overflow-y: auto; padding: 12px 16px 96px; -webkit-overflow-scrolling: touch; }
.view { display: none; }
.view--active { display: block; }

.section-label { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 4px 8px; }
.hint { color: var(--muted); text-align: center; margin: 24px 8px; font-size: 15px; }

/* Search */
.search-input {
  width: 100%;
  min-height: var(--tap);
  background: var(--surface-2);
  border: 2px solid transparent;
  border-radius: 14px;
  color: var(--text);
  font-size: 18px;
  padding: 0 16px;
  outline: none;
}
.search-input:focus { border-color: var(--accent-2); }

/* Clear (✕) button inside the search field */
.search-wrap { position: relative; }
.search-wrap .search-input { padding-right: 48px; }
/* Hide the browser's native search clear so there aren't two crosses */
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.search-clear:hover, .search-clear:active { color: var(--text); }
.search-clear[hidden] { display: none; }

/* Lists */
.list { list-style: none; margin: 12px 0 0; padding: 0; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  background: var(--surface);
  border: none;
  border-radius: 14px;
  color: var(--text);
  text-align: left;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.row:active { background: var(--surface-2); }
.row-src {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-add { color: var(--accent); font-size: 30px; font-weight: 700; padding: 0 6px; }
.row-singer {
  background: var(--accent-2);
  color: #fff;
  font-size: 12px;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.row-remove {
  background: transparent;
  border: none;
  color: #ff5c5c;
  font-size: 24px;
  padding: 4px 8px;
}
.flash { animation: flash .6s ease; }
@keyframes flash { from { background: var(--ok); } to { background: var(--surface); } }

/* Now playing */
.now { background: linear-gradient(135deg, var(--accent-2), var(--accent)); border-radius: 18px; padding: 18px; }
.now--compact { padding: 14px; margin-bottom: 16px; }
.now-empty { background: var(--surface); color: var(--muted); text-align: center; }
.now-status { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.now-title { font-size: 22px; font-weight: 700; margin: 4px 0; }
.now-artist { opacity: .9; }
.progress { height: 8px; background: rgba(255,255,255,.25); border-radius: 999px; margin-top: 14px; overflow: hidden; }
.progress-fill { height: 100%; background: #fff; width: 0; transition: width .4s linear; }
.progress-time { display: flex; justify-content: space-between; font-size: 12px; margin-top: 6px; opacity: .85; }

/* Controls */
.controls-grid { display: grid; gap: 12px; margin-top: 16px; }
.ctl {
  min-height: var(--tap);
  background: var(--surface-2);
  color: var(--text);
  border: none;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 600;
}
.ctl:active { filter: brightness(1.25); }
.ctl--primary { background: var(--accent); }
.ctl--round { width: 60px; height: 60px; border-radius: 50%; font-size: 30px; }
.pitch { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 28px; }
.pitch-label { color: var(--muted); margin-right: 4px; }
.pitch-value { font-size: 28px; font-weight: 700; min-width: 42px; text-align: center; }

/* Tabs */
.tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}
.tab {
  flex: 1;
  min-height: 60px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}
.tab--active { color: var(--text); box-shadow: inset 0 3px 0 var(--accent); }
.badge {
  display: inline-block;
  min-width: 20px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 12px;
  padding: 1px 6px;
}
.badge:empty { display: none; }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 20;
}
.modal[hidden] { display: none; }
.modal-card { background: var(--surface); border-radius: 18px; padding: 24px; width: 100%; max-width: 360px; }
.modal-card h2 { margin: 0 0 4px; }
.modal-card .ctl { width: 100%; margin-top: 16px; }
.modal-card .search-input { margin-top: 12px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 84px; left: 50%;
  transform: translateX(-50%);
  background: var(--ok);
  color: #04231a;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: 999px;
  z-index: 30;
}
.toast[hidden] { display: none; }
