/* Quiet UI, light by default; the gear menu flips data-theme="dark" on <html>
   (persisted in localStorage by app.js). Issuer colors appear only on answers
   and row dots — the app chrome stays neutral. Keyed off data-issuer because
   the CSP forbids inline styles; an issuer with no rule falls back to --brand-x. */
:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #e9e9ee;
  --border: #d9d9df;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --focus: #2f5fd0;
  --ring: rgb(0 0 0 / 0.15);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d0d0d;
  --surface: #17181a;
  --surface-2: #1f2023;
  --border: #2a2b2f;
  --text: #f2f2f3;
  --muted: #9a9aa0;
  --focus: #7aa2ff;
  --ring: rgb(255 255 255 / 0.18);
  color-scheme: dark;
}

[data-issuer] { --brand: #3a3a3c; }
[data-issuer="chase"] { --brand: #117aca; }
[data-issuer="american-express"] { --brand: #006fcf; }
[data-issuer="capital-one"] { --brand: #b22222; }
[data-issuer="citi"] { --brand: #003b70; }
[data-issuer="discover"] { --brand: #d35400; }
[data-issuer="bank-of-america"] { --brand: #c41230; }
[data-issuer="wells-fargo"] { --brand: #b31b1b; }
[data-issuer="u-s-bank"] { --brand: #0c2074; }
[data-issuer="barclays"] { --brand: #00395d; }
[data-issuer="bilt"] { --brand: #111111; }
[data-issuer="fidelity"] { --brand: #39823e; }
[data-issuer="navy-federal"] { --brand: #0b2e5c; }
[data-issuer="robinhood"] { --brand: #1d7a1d; }
[data-issuer="td-bank"] { --brand: #cc0000; }

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding:
    calc(env(safe-area-inset-top) + 20px)
    calc(env(safe-area-inset-right) + 16px)
    calc(env(safe-area-inset-bottom) + 28px)
    calc(env(safe-area-inset-left) + 16px);
  max-width: 560px;
  margin-inline: auto;
}

h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── settings gear + menu ───────────────────────────────────────── */
header { position: relative; }

.head-row { display: flex; align-items: center; justify-content: space-between; }

.gear {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  appearance: none;
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  padding: 8px;
  margin: -8px;
  border-radius: 10px;
  cursor: pointer;
}

.gear:active { background: var(--surface-2); }

.gear:focus-visible { outline: 2px solid var(--focus); }

/* display:flex below beats the UA's [hidden]{display:none} — restate it,
   or the menu can never close. */
.menu[hidden] { display: none; }

.menu {
  position: absolute;
  top: 42px;
  right: 0;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}

.menu-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 10px 2px;
}

.menu button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  appearance: none;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 15px;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.menu button:active { background: var(--surface-2); }

.menu button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* the active choice wears a checkmark */
.menu button[aria-pressed="true"]::after { content: " ✓"; font-weight: 700; }

.sub {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.list { list-style: none; margin: 0; padding: 0; }

.item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  margin-bottom: 10px;
  overflow: hidden;
}

/* ── the tappable row ───────────────────────────────────────────── */
.row {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  appearance: none;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 12px 14px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease;
}

.row:active,
.item.open > .row { background: var(--surface-2); }

.row:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.ico { font-size: 22px; line-height: 1; width: 26px; text-align: center; flex: none; }

.label { flex: 1; font-weight: 500; }

.hint {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  /* No data-issuer on the hint (no card fits) → no --brand → white dot. */
  background: var(--brand, #fff);
  box-shadow: 0 0 0 1px var(--ring);
}

.hint .rate {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-right: 2px;
}

/* ── setup ──────────────────────────────────────────────────── */
h2 { font-size: 20px; margin: 18px 0 4px; letter-spacing: -0.01em; }

.field {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.field:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.pick-list { list-style: none; margin: 12px 0 90px; padding: 0; }
.pick { border-bottom: 1px solid var(--border); }
.pick > label { display: flex; align-items: center; gap: 12px; padding: 12px 4px; cursor: pointer; }
.pick input { width: 20px; height: 20px; flex: none; accent-color: var(--focus); }
.pick-name { flex: 1; font-weight: 500; }
.pick-issuer { color: var(--muted); font-size: 14px; }
.choice { border: 0; margin: 0 0 10px 36px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; }
.choice legend { color: var(--muted); font-size: 13px; padding: 0; margin-bottom: 4px; }

.setup-foot {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, calc((100vw - 528px) / 2)) calc(env(safe-area-inset-bottom) + 12px);
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.setup-foot .sub { margin: 0; }

.primary {
  font: inherit; font-weight: 600;
  padding: 12px 18px; border: 0; border-radius: 12px;
  background: var(--text); color: var(--bg); cursor: pointer;
}
.primary:disabled { opacity: 0.4; cursor: default; }
.primary:focus-visible, .mic:focus-visible, .link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ── ask ────────────────────────────────────────────────────── */
.ask { display: flex; gap: 8px; margin-top: 14px; }
.ask .field { flex: 1; min-width: 0; }
.mic {
  font-size: 20px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); padding: 0 12px; cursor: pointer;
}
.mic.live { background: #ff453a; border-color: #ff453a; }

#result:empty { display: none; }
#result { margin: 16px 0 6px; }
#result p { margin: 0; }
.asked { color: var(--muted); font-size: 14px; margin-bottom: 8px !important; }
.miss { color: var(--muted); }

.answer { background: var(--brand); color: #fff; border-radius: 14px; padding: 14px 16px; }
.answer-label { font-size: 12px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; opacity: 0.82; }
.answer-card { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; margin-top: 2px; }
.answer-rate { font-size: 18px; font-weight: 600; opacity: 0.92; margin-top: 2px; }
.answer-value { font-size: 14px; opacity: 0.8; margin-top: 2px; }
.why { margin-top: 12px !important; font-size: 15px; }
.note { margin-top: 6px !important; font-size: 13px; color: var(--muted); }
.runners-title { margin-top: 14px !important; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.runners { list-style: none; padding: 0; margin: 6px 0 0; font-size: 15px; }
.runners li { padding: 4px 0 4px 12px; border-left: 3px solid var(--brand); margin-bottom: 4px; }

.list-title { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 22px 0 8px; }
.hint .abbr { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: 0; }

/* Reserved for a future ad unit; hidden until one exists. */
.ad-slot { min-height: 100px; margin: 16px 0; }

/* ── install prompt ─────────────────────────────────────────── */
.install {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); font-size: 14px;
}
.install[hidden] { display: none; }
.install p { margin: 0; flex: 1 1 100%; }
.install .primary { padding: 8px 14px; }
.link { font: inherit; background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; }

footer { margin-top: 28px; font-size: 12px; color: var(--muted); }
#setup:not([hidden]) ~ footer { margin-bottom: 70px; }
