* { -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0e0e10;
  --card: #18181b;
  --card-2: #26262c;
  --border: #2f2f35;
  --text: #efeff1;
  --muted: #adadb8;
  --on-accent: #000;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 24px);
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h2 { font-size: 20px; }

/* Primary buttons: filled with the accent color. */
.search button,
.join button,
.chat-input button,
.login-button {
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--fg);
  color: var(--on-accent);
  font-weight: 600;
}

header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; font-size: 17px; }
.pill { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--card-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: color-mix(in srgb, var(--fg) 18%, transparent); color: var(--fg); }
.pill.bad { background: rgba(255, 77, 77, 0.15); color: #ff7a7a; }

main, .join { padding: 0 16px; }

/* --- Join / waiting --- */
.join { padding-top: 10vh; text-align: center; }
.join strong { color: var(--text); }
.join form { display: flex; gap: 8px; justify-content: center; margin-top: 24px; }
.join input {
  width: 9ch;
  text-align: center;
  text-transform: uppercase;
  font-size: 26px;
  letter-spacing: 0.15em;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}
.error { color: #ff7a7a; min-height: 1.4em; }
#unlock-password { width: 14ch; text-transform: none; letter-spacing: normal; font-size: 18px; }

/* --- Now playing --- */
.now {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--card);
}
.now-text { flex: 1; min-width: 0; }
.now-name { font-weight: 700; font-size: 17px; }
.now-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Show problems in full so they can be read out. */
.now.problem .now-sub { white-space: normal; overflow-wrap: anywhere; color: #ff9a9a; }
.now.live .now-name::before {
  content: "LIVE";
  margin-right: 8px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #eb0400;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 2px;
}
.now-actions { display: flex; gap: 8px; }
.icon {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 10px;
  background: var(--card-2);
  font-size: 17px;
}

/* --- Tabs --- */
.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--card);
  margin-bottom: 14px;
}
.tabs button {
  padding: 9px 4px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-weight: 600;
}
.tabs button.active { background: var(--card-2); color: var(--text); }

h3 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 22px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* --- Channel lists --- */
.search { display: flex; gap: 8px; }
.search input, .chat-input input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-size: 16px; /* stops iOS zooming in on focus */
}
.search input:focus, .chat-input input:focus, .join input:focus { outline: none; border-color: var(--fg); }
::placeholder { color: #6e6e78; }

.list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.empty { color: var(--muted); font-size: 13px; margin: 6px 0; }
.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--card);
}
.item .play {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  padding: 0;
  background: none;
  text-align: left;
}
.item img { width: 64px; height: 36px; object-fit: cover; border-radius: 6px; background: #000; flex: none; }
.item img.avatar { width: 36px; border-radius: 50%; }
.item .text { min-width: 0; }
.item .name { font-weight: 600; }
.platform {
  display: inline-block;
  margin-right: 6px;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  vertical-align: 2px;
  color: #000;
}
.platform-kick { background: #53fc18; }
.platform-twitch { background: #a970ff; }
.item .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item.live .sub { color: #ff7a7a; }
.item .star { border: 0; background: none; font-size: 20px; color: #6e6e78; padding: 4px 6px; }
.item .star.on { color: #ffd23f; }
.item.playing { box-shadow: inset 0 0 0 2px var(--fg); }

.link { border: 0; background: none; color: var(--fg); font-size: 13px; font-weight: 600; padding: 4px; }
.link.danger { color: #ff7a7a; margin-top: 24px; }

/* --- Layout --- */
.hint { color: var(--muted); font-size: 12px; }
.preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  background: var(--card);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.preview-chat {
  position: absolute;
  border-radius: 6px;
  background: color-mix(in srgb, var(--fg) 25%, transparent);
  box-shadow: inset 0 0 0 2px var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.preview-chat.off { opacity: 0.35; }
.resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px 0 6px 0;
  background: var(--fg);
}

.presets, .accents { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.presets button, .accents button {
  padding: 7px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--card-2);
  font-size: 13px;
}
.accents button[aria-checked="true"] { box-shadow: inset 0 0 0 2px var(--text); }
.accents button[data-accent-choice="green"] { --swatch: #39ff6a; }
.accents button[data-accent-choice="amber"] { --swatch: #ffb000; }
.accents button[data-accent-choice="cyan"] { --swatch: #00e5ff; }
.accents button[data-accent-choice="white"] { --swatch: #e8e8e8; }
.accents button::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--swatch);
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.row output { color: var(--muted); font-variant-numeric: tabular-nums; }
.row select { padding: 6px 10px; border-radius: 8px; background: var(--card-2); border: 0; }

/* Sliders */
.row input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  height: 22px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: none;
}
.row input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--card-2); }
.row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--fg);
}
.row input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--card-2); }
.row input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--fg); }

/* On/off switches */
.toggle input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 44px;
  height: 26px;
  margin: 0;
  border-radius: 13px;
  background: var(--card-2);
  cursor: pointer;
  transition: background 0.15s;
}
.toggle input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.toggle input:checked { background: var(--fg); }
.toggle input:checked::before { transform: translateX(18px); }

.toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 60px);
  transform: translateX(-50%);
  z-index: 10;
  max-width: 90vw;
  padding: 9px 16px;
  border-radius: 10px;
  background: #fff;
  color: #000;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

/* --- Phone chat --- */
.account {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
}
.account img { width: 24px; height: 24px; border-radius: 50%; }
.account strong { color: var(--text); }
.account .spacer { flex: 1; }
.login-button { display: block; width: 100%; text-align: center; text-decoration: none; }

.chat-panel { position: relative; }
.phone-chat {
  height: calc(100dvh - 320px);
  min-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--card);
  font-size: 14px;
}
.phone-chat .msg { font-weight: 500; line-height: 1.45; padding: 3px 0; overflow-wrap: anywhere; }
.phone-chat .msg.selected { background: var(--card-2); border-radius: 6px; }
.phone-chat .emote { height: 26px; vertical-align: middle; margin: -4px 1px; }
.phone-chat .emote.zero-width { margin-left: -28px; }

.jump {
  position: absolute;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  padding: 6px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--fg);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 12px;
}

.chat-form { margin-top: 8px; }
.chat-input { display: flex; gap: 8px; }
.chat-input :disabled { opacity: 0.45; }
.reply-to {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: var(--card);
  font-size: 12px;
  color: var(--muted);
}
.reply-to button { border: 0; background: none; color: var(--muted); font-size: 16px; }
