:root {
  --bg: #121212;
  --surface: #232323;
  --surface-hover: #2f2f2f;
  --text: #f4f4f4;
  --muted: #9a9a9a;
  --accent: #7c5cff;
  --ok: #6fe38a;
}

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

[hidden] {
  display: none !important;
}

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

main {
  min-height: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#remote,
#pair {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pair-title {
  margin: 0 0 10px;
  font-size: 24px;
}

.pair-help {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

#pairForm {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

#code {
  width: 100%;
  padding: 16px 12px;
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 22px;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

#code:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.primary {
  padding: 16px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

.primary:active {
  transform: scale(0.98);
}

.pair-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: #ff8a8a;
  font-size: 14px;
}

.status {
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 28px;
}

.status[data-kind="ok"] {
  color: var(--ok);
}

.art {
  width: min(70vw, 280px);
  aspect-ratio: 1;
  border-radius: 16px;
  background-color: var(--surface);
  background-size: cover;
  background-position: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  margin-bottom: 28px;
}

h1 {
  width: 100%;
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#artist {
  width: 100%;
  min-height: 1.2em;
  margin: 6px 0 28px;
  font-size: 16px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-bottom: 28px;
}

.volume {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 36px;
}

#vol {
  min-width: 56px;
  font-size: 15px;
  color: var(--muted);
}

.controls,
.volume {
  transition: opacity 0.2s ease;
}

body[data-live="false"] .controls,
body[data-live="false"] .volume {
  opacity: 0.35;
  pointer-events: none;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.btn svg {
  width: 30px;
  height: 30px;
  fill: currentColor;
}

.btn:hover {
  background: var(--surface-hover);
}

.btn:active {
  transform: scale(0.92);
}

.btn.big {
  width: 84px;
  height: 84px;
  background: var(--accent);
}

.btn.big:hover {
  background: #8d71ff;
}

.btn.big svg {
  width: 38px;
  height: 38px;
}

.btn.small {
  width: 52px;
  height: 52px;
}

.toggle .i-pause {
  display: none;
}

.toggle[data-playing="true"] .i-play {
  display: none;
}

.toggle[data-playing="true"] .i-pause {
  display: block;
}

.note {
  margin: 0 0 8px;
  font-size: 11px;
  color: #666;
}

.linkbtn {
  border: none;
  background: none;
  color: #777;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.queue-btn {
  margin: -12px 0 24px;
  padding: 10px 22px;
  border: none;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.queue-btn:active {
  background: var(--surface-hover);
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: calc(12px + env(safe-area-inset-top)) 0 env(safe-area-inset-bottom);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 12px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 20px;
}

.sheet-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.queue-list {
  flex: 1;
  margin: 0;
  padding: 0 12px 16px;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 8px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.queue-item:active {
  background: var(--surface);
}

.queue-item.past {
  opacity: 0.45;
}

.queue-item.current {
  background: var(--surface);
}

.queue-item.current .queue-title {
  color: var(--accent);
  font-weight: 600;
}

.queue-num {
  flex: none;
  width: 26px;
  text-align: right;
  font-size: 13px;
  color: var(--muted);
}

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

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

.queue-title {
  font-size: 15px;
}

.queue-artist {
  font-size: 13px;
  color: var(--muted);
}

.queue-dur {
  flex: none;
  font-size: 12px;
  color: var(--muted);
}

.queue-empty {
  margin: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

.volume {
  width: 100%;
  gap: 12px;
  padding: 0 4px;
}

#vol {
  min-width: 44px;
  text-align: right;
}

.vol-icon {
  flex: none;
  width: 22px;
  height: 22px;
  fill: var(--muted);
}

.vol-slider {
  flex: 1;
  min-width: 0;
  height: 36px;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
  cursor: pointer;
}

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: -8px 0 22px;
  padding: 0 4px;
  transition: opacity 0.2s ease;
}

body[data-live="false"] .progress {
  opacity: 0.35;
  pointer-events: none;
}

.time {
  flex: none;
  min-width: 38px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.time-now {
  text-align: right;
}

.prog-slider {
  flex: 1;
  min-width: 0;
  height: 28px;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
  cursor: pointer;
}

.pills {
  display: flex;
  gap: 10px;
  margin: -12px 0 24px;
}

.pills .queue-btn {
  margin: 0;
}

body[data-live="false"] .pills {
  opacity: 0.35;
  pointer-events: none;
}

.search-form {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px; 
}

.search-input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.search-go {
  padding: 0 16px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
