:root {
  --bg: #0b0c0f;
  --bg-elev: #141620;
  --bg-elev-2: #1b1e2b;
  --line: #262a3a;
  --line-soft: #1d2030;
  --text: #e8eaf2;
  --text-dim: #9aa0b4;
  --text-faint: #6b7187;
  --accent: #5ad6a0;
  --accent-dim: #2a8f68;

  /* per-button hues for fast scanning */
  --b-shift: #56b6ff;
  --b-option: #ffb454;
  --b-edit: #5ad6a0;
  --b-play: #ff6ec7;
  --b-dir: #aab0c6;

  --radius: 12px;
  --radius-sm: 8px;
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 12, 15, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px 8px;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 980px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.brand-mark {
  font-weight: 700;
  letter-spacing: 0.5px;
  background: var(--accent);
  color: #04150e;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 15px;
}

.brand-text {
  font-weight: 600;
  color: var(--text-dim);
  font-size: 14px;
  white-space: nowrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

#search {
  width: 100%;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 32px 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search::placeholder { color: var(--text-faint); }

#search:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(90, 214, 160, 0.12);
}

.clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- Filters ---------- */
.filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 18px 0 2px;
  max-width: 980px;
  margin: 0 auto;
  -webkit-overflow-scrolling: touch;
}
.filters::-webkit-scrollbar { display: none; }

.filter-chip {
  flex: none;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}

.filter-chip:hover { color: var(--text); border-color: #36405c; }

.filter-chip.active {
  color: #04150e;
  background: var(--accent);
  border-color: var(--accent);
}

.filter-chip .count {
  opacity: 0.6;
  font-weight: 500;
  margin-left: 4px;
}

/* ---------- Results ---------- */
.results {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 14px 0;
}

.cat-group { margin-bottom: 22px; }

.cat-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 4px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}

.cat-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent);
}

.cat-head .blurb {
  font-size: 12px;
  color: var(--text-faint);
}

.cat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.entry {
  display: grid;
  grid-template-columns: minmax(120px, 168px) 1fr;
  gap: 10px;
  align-items: start;
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

.entry-combo {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.entry-text { min-width: 0; }

.entry-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.entry-desc {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 1px;
}

/* ---------- Button chips ---------- */
.key {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--b-dir);
  white-space: nowrap;
}

.key.k-shift  { color: var(--b-shift);  border-color: rgba(86,182,255,0.4); }
.key.k-option { color: var(--b-option); border-color: rgba(255,180,84,0.4); }
.key.k-edit   { color: var(--b-edit);   border-color: rgba(90,214,160,0.4); }
.key.k-play   { color: var(--b-play);   border-color: rgba(255,110,199,0.4); }

.joiner {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 600;
  padding: 0 1px;
}

.cmd {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(90,214,160,0.08);
  border: 1px solid rgba(90,214,160,0.25);
  border-radius: 6px;
  padding: 3px 8px;
}

mark {
  background: rgba(255,180,84,0.28);
  color: #ffd9a0;
  border-radius: 3px;
  padding: 0 1px;
}

/* ---------- Misc ---------- */
.empty {
  max-width: 980px;
  margin: 30px auto;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
  padding: 0 14px;
}

.footer {
  max-width: 980px;
  margin: 20px auto;
  padding: 16px 14px 30px;
  border-top: 1px solid var(--line-soft);
  color: var(--text-faint);
  font-size: 11.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.footer .sep { opacity: 0.5; }

/* ---------- M8 panel legend ---------- */
.panel-legend {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 14px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.panel-svg {
  width: 100%;
  max-width: 150px;
  height: auto;
}

.panel-body {
  fill: var(--bg-elev);
  stroke: #353a4e;
  stroke-width: 1.5;
}

.panel-screen {
  fill: #05060a;
  stroke: var(--line);
  stroke-width: 1.5;
}
.screen-col { stroke: rgba(90,214,160,0.10); stroke-width: 1; }
.screen-art .art-edit   { fill: rgba(90,214,160,0.75); }
.screen-art .art-play   { fill: rgba(255,110,199,0.7); }
.screen-art .art-option { fill: rgba(255,180,84,0.7); }
.screen-art .art-shift  { fill: rgba(86,182,255,0.7); }

.panel-mic { fill: #4a5168; }
.panel-speaker circle { fill: #3a4060; }

.panel-logo {
  fill: var(--text-faint);
  font-family: var(--font);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-anchor: middle;
}

.pk rect {
  fill: var(--bg-elev-2);
  stroke: var(--line);
  stroke-width: 1.5;
}
.pk text {
  font-family: var(--mono);
  font-size: 7.5px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
}
.pk-dir rect   { stroke: rgba(170,176,198,0.5); }
.pk-dir text   { fill: var(--b-dir); font-size: 14px; }
.pk-shift rect { stroke: rgba(86,182,255,0.55); }
.pk-shift text { fill: var(--b-shift); }
.pk-option rect{ stroke: rgba(255,180,84,0.55); }
.pk-option text{ fill: var(--b-option); }
.pk-edit rect  { stroke: rgba(90,214,160,0.55); }
.pk-edit text  { fill: var(--b-edit); }
.pk-play rect  { stroke: rgba(255,110,199,0.55); }
.pk-play text  { fill: var(--b-play); }

.panel-caption {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-faint);
}

/* ---------- Tile favorite action ---------- */
.entry { position: relative; padding-right: 38px; }

.tile-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 2px;
}

.act {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-faint);
  padding: 0;
  transition: color 0.12s, background 0.12s;
}
.act:hover { background: var(--bg-elev-2); color: var(--text-dim); }
.act svg { width: 15px; height: 15px; display: block; }

.act-fav.on { color: var(--b-option); }
.act-fav.on svg { fill: currentColor; }

/* Favorites group accent */
.cat-group.fav .cat-head h2 { color: var(--b-option); }

/* ---------- Wider screens: two columns of entries ---------- */
@media (min-width: 720px) {
  .cat-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Narrow phones: stack combo above text ---------- */
@media (max-width: 460px) {
  body { font-size: 14px; }
  .entry {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .brand-text { display: none; }
}
