:root {
  --ink: #0c1a14;
  --green: #064e3b;
  --green-2: #0a5f49;
  --green-3: #14916c;
  --clay: #a83f30;
  --bg: #edf1eb;
  --card: #fff;
  --line: #e6ece6;
  --line-2: #eef2ee;
  --muted: #5a6b61;
  --muted-2: #7a877f;
  --muted-3: #9aa69d;
  --mint: #e7f0ea;
  --mint-border: #d4e6dc;
  --mint-bright: #9be3c0;
  --amber: #9a6b1a;
  --amber-bg: #f3ead6;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--ink);
  background:
    radial-gradient(1100px 560px at 50% -12%, #e7f0ea 0%, rgba(231, 240, 234, 0) 62%),
    radial-gradient(860px 500px at 82% 114%, #e9f1eb 0%, rgba(233, 241, 235, 0) 56%),
    var(--bg);
  min-height: 100vh;
}

.app {
  max-width: 430px;
  margin: 0 auto;
  padding: 30px 16px calc(30px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Header */
.hdr { padding: 2px; }
.hdr-brand { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hdr-name { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; color: var(--green); }
.hdr-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--green-2);
  background: var(--mint);
  border: 1px solid var(--mint-border);
  padding: 3px 8px;
  border-radius: 6px;
}
.hdr-tagline { margin: 11px 0 0; font-size: 14.5px; line-height: 1.45; color: #3c4a43; max-width: 320px; }
.hdr-tagline b { color: var(--green-2); font-weight: 600; }
.hdr-sub { margin: 6px 0 0; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; color: var(--muted-2); }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(8, 40, 28, 0.04), 0 10px 26px rgba(8, 40, 28, 0.05);
}

/* Recorder */
.recorder { padding: 20px 18px 22px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.spectro-box {
  width: 100%;
  height: 56px;
  background: #f4f7f4;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 9px 12px;
  display: flex;
  align-items: flex-end;
}
.spectro { display: flex; align-items: flex-end; gap: 2px; height: 100%; width: 100%; }
.spectro .bar {
  flex: 1 1 0;
  min-width: 0;
  background: #bcccc2;
  border-radius: 2px;
  transform-origin: bottom;
  height: 12%;
  transition: height 0.08s linear;
}

.rec-wrap { height: 84px; display: flex; align-items: center; justify-content: center; }
.rec {
  width: 84px; height: 84px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s ease;
}
.rec:active { transform: scale(0.95); }
.rec-ready { background: var(--green); box-shadow: 0 6px 18px rgba(6, 78, 59, 0.34); }
.rec-ready .rec-dot { width: 27px; height: 27px; border-radius: 50%; background: #fff; }
.rec-recording { background: var(--clay); animation: bs-pulse 1.4s infinite; }
.rec-recording .rec-dot { width: 24px; height: 24px; border-radius: 6px; background: #fff; }
.rec-analyzing { background: var(--green-2); box-shadow: 0 6px 18px rgba(10, 95, 73, 0.32); cursor: default; gap: 6px; }
.rec-analyzing .rec-dot { display: none; }
.rec-analyzing .blink { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: bs-blink 1s infinite; }
.rec-analyzing .blink:nth-child(2) { animation-delay: 0.18s; }
.rec-analyzing .blink:nth-child(3) { animation-delay: 0.36s; }

@keyframes bs-pulse {
  0%, 100% { box-shadow: 0 6px 18px rgba(168, 63, 48, 0.35), 0 0 0 0 rgba(168, 63, 48, 0.45); }
  50% { box-shadow: 0 6px 18px rgba(168, 63, 48, 0.35), 0 0 0 14px rgba(168, 63, 48, 0); }
}
@keyframes bs-blink { 0%, 100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

.status { text-align: center; display: flex; flex-direction: column; gap: 5px; align-items: center; }
.status-line { display: flex; align-items: center; gap: 9px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-3); }
.status-label { font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: 0.14em; color: var(--ink); }
.elapsed { font-family: var(--mono); font-size: 12px; color: var(--clay); font-weight: 600; }
.status-sub { font-size: 12.5px; color: var(--muted); max-width: 260px; line-height: 1.4; }

/* Location */
.loc { padding: 14px 16px; border-radius: 18px; }
.loc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.loc-label { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: #1c2a23; font-weight: 500; }
.switch { width: 44px; height: 26px; border-radius: 99px; background: #cfd8d2; position: relative; flex: 0 0 auto; transition: background 0.2s; }
.switch.on { background: var(--green-3); }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: left 0.2s; }
.switch.on .knob { left: 21px; }
.loc-readout { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-2); font-family: var(--mono); font-size: 11px; letter-spacing: 0.03em; color: var(--muted-3); }
.loc-readout.on { color: var(--green-2); }

/* Results */
.results { display: flex; flex-direction: column; gap: 12px; }
.providers { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  color: var(--green-2); background: var(--mint); border: 1px solid var(--mint-border);
  padding: 4px 9px; border-radius: 99px;
}
.pill .led { width: 5px; height: 5px; border-radius: 50%; background: var(--green-3); }
.pill.solid { color: #fff; background: var(--green-2); border-color: var(--green-2); }

/* Hero */
.hero { background: var(--card); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; box-shadow: 0 1px 2px rgba(8, 40, 28, 0.04), 0 12px 30px rgba(8, 40, 28, 0.07); }
.hero-photo { position: relative; height: 184px; background: linear-gradient(158deg, #075240, #04281d); background-size: cover; background-position: center; overflow: hidden; }
.hero-scan { position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.045) 0, rgba(255, 255, 255, 0.045) 1px, transparent 1px, transparent 8px); }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(4, 33, 24, 0.15) 0%, rgba(4, 33, 24, 0.05) 40%, rgba(4, 33, 24, 0.72) 100%); }
.hero-spectro { position: absolute; left: 16px; right: 16px; top: 54px; bottom: 60px; opacity: 0.9; }
.hero-spectro .bar { background: #5fd6a8; }
.hero-badges { position: absolute; top: 14px; left: 16px; display: flex; gap: 6px; align-items: center; }
.hb { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; padding: 4px 8px; border-radius: 99px; }
.hb.ghost { color: #cdebdb; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.18); }
.hb.in { color: #0c1a14; background: var(--mint-bright); font-weight: 600; letter-spacing: 0.1em; }
.hb.out { color: #4a360e; background: #e7c98a; font-weight: 600; letter-spacing: 0.1em; }
.hero-conf { position: absolute; top: 12px; right: 16px; text-align: right; }
.hero-conf .pct { font-family: var(--mono); font-size: 30px; font-weight: 600; color: #fff; line-height: 1; }
.hero-conf .pct small { font-size: 15px; }
.hero-conf .lbl { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.18em; color: #86c2a7; margin-top: 4px; }
.hero-name { position: absolute; left: 16px; bottom: 14px; right: 16px; }
.hero-name .common { font-size: 23px; font-weight: 700; color: #fff; letter-spacing: -0.01em; }
.hero-name .sci { font-size: 13px; font-style: italic; color: #cdebdb; }
.hero-credit { position: absolute; right: 12px; bottom: 9px; font-family: var(--mono); font-size: 8px; letter-spacing: 0.1em; color: rgba(255, 255, 255, 0.32); }

.hero-ref { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line-2); }
.play-btn { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 50%; border: none; cursor: pointer; background: var(--mint); display: flex; align-items: center; justify-content: center; }
.play-btn .pause { display: none; gap: 3px; }
.play-btn .pause span { width: 3.5px; height: 13px; background: var(--green-2); border-radius: 1px; }
.play-btn.playing .pause { display: flex; }
.play-btn.playing .play { display: none; }
.ref-wave { flex: 1 1 auto; height: 24px; }
.ref-wave .bar { background: #9fc4b3; }
.ref-credit { font-family: var(--mono); font-size: 9.5px; line-height: 1.5; color: var(--muted-2); text-align: right; flex: 0 0 auto; }

/* Ranked list */
.ranked { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 1px 2px rgba(8, 40, 28, 0.04), 0 8px 22px rgba(8, 40, 28, 0.04); padding: 6px 16px 12px; }
.ranked-title { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 12px 0 2px; }
.cand { display: flex; gap: 12px; align-items: flex-start; padding: 13px 0; border-top: 1px solid var(--line-2); }
.cand-rank { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto; background: var(--line-2); color: var(--green-2); font-family: var(--mono); font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center; margin-top: 2px; }
.cand-spark { width: 42px; flex: 0 0 auto; height: 24px; margin-top: 1px; }
.cand-body { flex: 1 1 auto; min-width: 0; }
.cand-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cand-common { font-weight: 600; font-size: 15px; color: var(--ink); }
.cand-pct { font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--green); }
.cand-pct.out { color: var(--amber); }
.cand-sci { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 1px; }
.cand-bar { height: 6px; background: var(--line-2); border-radius: 99px; margin: 9px 0 8px; overflow: hidden; }
.cand-bar i { display: block; height: 100%; border-radius: 99px; background: var(--green-2); }
.cand-bar i.out { background: var(--amber); }
.cand-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-family: var(--mono); font-size: 10px; letter-spacing: 0.03em; color: var(--muted-2); }
.cand-meta .sep { opacity: 0.4; }
.tag { padding: 2px 7px; border-radius: 99px; font-weight: 600; letter-spacing: 0.06em; }
.tag.in { color: var(--green-2); background: var(--mint); }
.tag.out { color: var(--amber); background: var(--amber-bg); }

/* Acoustic signature */
.sig { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 1px 2px rgba(8, 40, 28, 0.04); overflow: hidden; }
.sig-toggle { width: 100%; background: none; border: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--green-2); font-weight: 600; }
.sig-toggle .chevron { color: var(--muted); }
.sig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-2); border-radius: 10px; margin: 0 16px 16px; overflow: hidden; border: 1px solid var(--line-2); }
.sig-cell { background: #fff; padding: 11px 12px; }
.sig-cell .k { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; color: var(--muted-2); }
.sig-cell .v { font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--ink); margin-top: 3px; }

/* Save */
.save-btn { width: 100%; padding: 14px; border-radius: 14px; border: 1px solid #cfe1d6; background: #fff; color: var(--green); font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; }
.save-done { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 14px; border-radius: 14px; background: var(--green); color: #fff; font-size: 14px; font-weight: 600; }

/* Life list */
.lifelist-btn { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-family: inherit; box-shadow: 0 1px 2px rgba(8, 40, 28, 0.04); }
.ll-label { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: #1c2a23; }
.ll-count { font-family: var(--mono); font-size: 11px; color: #fff; background: var(--green-2); padding: 2px 8px; border-radius: 99px; }
.chevron { color: var(--muted-2); }
.lifelist { padding: 8px 16px 14px; border-radius: 18px; }
.ll-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-2); }
.ll-item:first-child { border-top: none; }
.ll-item .body { flex: 1 1 auto; min-width: 0; }
.ll-item .common { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.ll-item .meta { font-family: var(--mono); font-size: 10.5px; color: var(--muted-2); margin-top: 2px; }
.ll-del { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px; border: none; background: var(--bg); color: var(--clay); cursor: pointer; font-size: 15px; }
.ll-empty { padding: 18px 4px; margin: 0; font-size: 13px; color: var(--muted); text-align: center; line-height: 1.5; }
.ll-empty b { color: var(--green-2); }

/* Footer */
.ftr { margin-top: 6px; padding: 8px 4px 0; text-align: center; }
.ftr p { margin: 0; font-size: 11px; line-height: 1.5; color: #8a958c; }
.ftr-mono { margin-top: 8px; font-family: var(--mono); font-size: 9px; letter-spacing: 0.08em; color: #9aa69d; }

.is-error .status-label { color: var(--clay); }

/* Keyboard focus visibility */
.rec:focus-visible,
.loc-row:focus-visible,
.lifelist-btn:focus-visible,
.save-btn:focus-visible,
.sig-toggle:focus-visible,
.play-btn:focus-visible,
.ll-del:focus-visible {
  outline: 3px solid var(--green-3);
  outline-offset: 2px;
}

/* Respect reduced-motion preference: drop the pulsing/blinking animations */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .rec-recording { box-shadow: 0 6px 18px rgba(168, 63, 48, 0.4); }
}
