/* Hum Finder — dark theme echoing the displayer's look (spec §10).
   Mobile-first single column, max-width ~720 px centered on desktop. */

@font-face {
  font-family: "Saira Extra Condensed";
  font-style: normal;
  font-weight: 400;
  src: url("fonts/saira-extra-condensed-400.woff2") format("woff2");
}

@font-face {
  font-family: "Saira Extra Condensed";
  font-style: normal;
  font-weight: 500;
  src: url("fonts/saira-extra-condensed-500.woff2") format("woff2");
}

@font-face {
  font-family: "Saira Extra Condensed";
  font-style: normal;
  font-weight: 700;
  src: url("fonts/saira-extra-condensed-700.woff2") format("woff2");
}

:root {
  --bg: #14161a;
  --panel: #1d2026;
  --panel-2: #23262d;
  --line: #33373f;
  --fg: #e8e8ea;
  --muted: #9aa0aa;
  --accent: #63b3e4;
  --accent-ink: #8fd0f5;
  --hit: #ffd479;
  --weak: #6b7078;
  --heading: "Saira Extra Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}

main, .app-head, .app-foot {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 0.9rem;
}

h1, h2, h3 {
  font-family: var(--heading);
  letter-spacing: 0.02em;
  margin: 0.4rem 0;
}

.app-head { padding-top: 1rem; }
.app-head h1 { font-size: 2.2rem; font-weight: 700; }
.tagline { color: var(--muted); margin: 0 0 0.8rem; }

/* --------------------------------------------------- mode switcher */

.mode-switch {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  overflow: hidden;
  margin-bottom: 0.9rem;
}

.mode-tab {
  flex: 1;
  padding: 0.7rem 0;
  min-height: 44px;
  background: var(--panel);
  color: var(--muted);
  border: none;
  font-family: var(--heading);
  font-size: 1.15rem;
  font-weight: 500;
  cursor: pointer;
}

.mode-tab + .mode-tab { border-left: 1px solid var(--line); }
.mode-tab.on { background: var(--panel-2); color: var(--accent-ink); }

/* --------------------------------------------------- shared panel bits */

.input-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.panel-hint { color: var(--muted); font-size: 0.9rem; margin: 0.6rem 0 0; }

.btn {
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.55rem 1rem;
  min-height: 44px;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn:hover { border-color: var(--muted); }
.btn-primary { border-color: var(--accent); color: var(--accent-ink); }

.entry-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
  margin-right: auto;
  min-height: 44px;
}

.entry-strip {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  flex-wrap: wrap;
  min-height: 3rem;
  margin-top: 0.7rem;
  padding: 0.4rem;
  background: var(--bg);
  border-radius: 0.5rem;
}

.strip-empty { color: var(--weak); font-size: 0.85rem; padding: 0.5rem; }

.roll-chip {
  --roll-y: 0.5;
  font-size: 0.75rem;
  padding: 0.1rem 0.3rem;
  border-radius: 0.3rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  margin-bottom: calc((1 - var(--roll-y)) * 1.4rem);
}

.sym {
  font-weight: 700;
  width: 1.6rem;
  text-align: center;
  padding: 0.25rem 0;
  border-radius: 0.3rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.sym-u { color: #8fd88f; }
.sym-d { color: #e49090; }
.sym-r { color: var(--muted); }

/* --------------------------------------------------- hum panel */

.mic-btn {
  position: relative;
  display: block;
  margin: 0.4rem auto 0.8rem;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--panel-2);
  font-size: 2rem;
  cursor: pointer;
  color: var(--fg);
}

.mic-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.mic-ring {
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
}

.mic-btn.recording { border-color: #e46363; }
.mic-btn.recording .mic-ring {
  border-color: #e46363;
  animation: pulse 1.1s ease-out infinite;
}

.mic-btn.analyzing { border-color: var(--muted); }

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}

.trace {
  display: block;
  width: 100%;
  height: 120px;
  background: var(--bg);
  border-radius: 0.5rem;
}

.hum-after { margin-top: 0.7rem; }

.chip {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.25rem 0.8rem;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.query-roll {
  display: block;
  width: 100%;
  height: 70px;
  background: var(--bg);
  border-radius: 0.5rem;
}

/* --------------------------------------------------- keyboard */

.kb-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.3rem;
}

.kb {
  display: flex;
  height: 150px;
  width: max-content;
  user-select: none;
  touch-action: pan-x;
}

.kb-white {
  position: relative;
  width: 46px;
  flex: none;
  background: #e9e7e0;
  border: 1px solid #444;
  border-radius: 0 0 4px 4px;
  cursor: pointer;
}

.kb-name {
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.7rem;
  color: #333;
  pointer-events: none;
}

.kb-black {
  position: absolute;
  top: 0;
  right: -14px;
  width: 28px;
  height: 92px;
  background: #24262a;
  border: 1px solid #000;
  border-radius: 0 0 3px 3px;
  z-index: 2;
  cursor: pointer;
}

.kb-hit { filter: brightness(1.35); }

/* --------------------------------------------------- udr */

.udr-pads { display: flex; gap: 0.5rem; }

.udr-pad {
  flex: 1;
  min-height: 60px;
  font-size: 1.1rem;
  font-weight: 700;
}

.udr-field {
  width: 100%;
  margin-top: 0.7rem;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font-size: 1rem;
  letter-spacing: 0.15em;
}

/* --------------------------------------------------- results */

.results-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.results-head h2 { font-size: 1.5rem; }
.results-sub { color: var(--muted); font-size: 0.85rem; }
.results-note { color: var(--muted); font-size: 0.9rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 0.8rem 1rem;
  margin-bottom: 0.8rem;
}

.card.weak { opacity: 0.65; }

.card-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.rank {
  flex: none;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.pct {
  flex: none;
  font-family: var(--heading);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--accent-ink);
  min-width: 3rem;
}

.card.weak .pct { color: var(--weak); }

.card-title { min-width: 0; }
.card-title h3 { font-size: 1.25rem; margin: 0; }
.card-meta { color: var(--muted); font-size: 0.85rem; }

.preview-details summary {
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  margin-top: 0.4rem;
}

/* Height-capped, auto-scrolled to the first highlighted bar (§10.7). */
.preview {
  max-height: 340px;
  overflow-y: auto;
  margin-top: 0.5rem;
  background: #f4f2ec;
  border-radius: 0.4rem;
  padding: 0.5rem;
  color: #1a1a1a; /* abcjs draws with currentColor */
}

.preview svg { max-width: 100%; height: auto; }

.hf-hit { fill: #b0680a; color: #b0680a; }

.hf-hl-rect {
  fill: var(--hit);
  opacity: 0.28;
}

.abc-error { color: #c96e6e; font-size: 0.85rem; }

/* --------------------------------------------------- debug */

.debug {
  border: 1px dashed var(--line);
  border-radius: 0.8rem;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  font-size: 0.85rem;
}

.debug-controls { display: flex; flex-direction: column; gap: 0.4rem; }
.debug-slider { display: flex; align-items: center; gap: 0.6rem; }
.debug-slider span { min-width: 7rem; color: var(--muted); }
.debug-slider input { flex: 1; }

.debug-table { border-collapse: collapse; }
.debug-table th, .debug-table td {
  border: 1px solid var(--line);
  padding: 0.15rem 0.5rem;
  text-align: right;
}

.debug-abc { background: #f4f2ec; color: #1a1a1a; border-radius: 0.4rem; margin-top: 0.5rem; }

/* --------------------------------------------------- footer */

.app-foot {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
  padding-top: 1rem;
  padding-bottom: 2rem;
}
