:root {
  --bg: #14101f;
  --surface: #1f1a30;
  --surface-now: #3a1f4d;
  --text: #f3effa;
  --muted: #a79fbd;
  --accent: #ff4fa3;
  --accent-text: #ffffff;
  --border: #2f2846;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

h1 {
  margin: 0;
  font-size: 1.4rem;
}

.status {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 16px;
  background: #5a3a00;
  color: #ffd98a;
  font-size: 0.9rem;
  text-align: center;
}

.count {
  color: var(--muted);
  font-size: 0.9rem;
}

main {
  flex: 1;
  padding: 12px 16px;
  /* leave room for the fixed form */
  padding-bottom: 200px;
}

.queue {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.item.now {
  background: var(--surface-now);
  border-color: var(--accent);
}

.pos {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--border);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.item.now .pos {
  background: var(--accent);
  color: var(--accent-text);
}

.cover {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--border);
}

.cover.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 1.4rem;
}

.item.now .cover {
  width: 72px;
  height: 72px;
  box-shadow: 0 0 0 2px var(--accent);
}

.info {
  flex: 1;
  min-width: 0;
}

.label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 2px;
}

.singer {
  font-weight: 700;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.song {
  color: var(--muted);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.actions {
  flex: none;
  display: flex;
  gap: 4px;
}

.actions button {
  min-width: 44px;
  height: 44px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.actions button:active { background: var(--border); }

.actions .done {
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0 14px;
}

.empty {
  color: var(--muted);
  text-align: center;
  margin-top: 40px;
}

.add-form {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.add-form input,
.add-form button {
  width: 100%;
  height: 48px;
  border-radius: 10px;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
}

.add-form input {
  padding: 0 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.add-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.song-field {
  position: relative;
}

/* Opens upward, since the form sits at the bottom of the screen. */
.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 50dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

.suggestions li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.suggestions li.active,
.suggestions li:active {
  background: var(--border);
}

.suggestions img {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 4px;
  object-fit: cover;
}

.suggestions .s-text {
  min-width: 0;
}

.suggestions .s-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestions .s-sub {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-form button {
  border: none;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  cursor: pointer;
}

.add-form button:disabled {
  opacity: 0.6;
}

@media (min-width: 640px) {
  main, .add-form {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
  }
  .add-form {
    grid-template-columns: 1fr 1fr auto;
    border-radius: 12px 12px 0 0;
    border: 1px solid var(--border);
  }
  .add-form button { width: auto; padding: 0 24px; }
  main { padding-bottom: 100px; }
}
