/* Tapwhich. Tokens follow the Agent Tools design standard (DESIGN.md); the display face is the system serif. */
:root {
  --fg: #1D1D1B;
  --muted: #5C5C57;
  --accent: #0B5CAD;
  --on-accent: #FFFFFF;
  --bg: #FBFBF9;
  --card-bg: #FFFFFF;
  --rail-bg: #F5F5F0;
  --line: #DCDCD4;
  --serif: ui-serif, "New York", "Iowan Old Style", "Charter", "Source Serif Pro", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #ECECE6;
    --muted: #A3A39B;
    --accent: #6DB3F2;
    --on-accent: #151514;
    --bg: #151514;
    --card-bg: #222220;
    --rail-bg: #1C1C1A;
    --line: #44443F;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 1rem/1.65 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.label {
  margin: 0;
  font: 500 0.75rem/1.3 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.meta { margin: 0; font-size: 0.875rem; line-height: 1.5; color: var(--muted); }
.display {
  margin: 0;
  font: 400 clamp(2.25rem, 9vw, 3.5rem)/1.04 var(--serif);
  letter-spacing: -0.025em;
  text-wrap: balance;
}

/* Top bar: the wordmark and the language switch, one line at any width. */
.top { border-bottom: 1px solid var(--line); padding: 16px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left)); }
.top-in { max-width: 72rem; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.mark {
  font: 500 0.875rem/1 var(--mono);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--fg);
  text-decoration: none;
}
.lang {
  background: none;
  border: 0;
  padding: 8px 0;
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
}
.lang:hover { color: var(--fg); text-decoration-color: currentColor; }

.wrap {
  width: 100%;
  max-width: 74rem;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: grid;
  gap: 40px;
  flex: 1;
}

.ask { display: grid; gap: 16px; align-content: start; min-width: 0; }
.ask .display { margin-bottom: 8px; }

.field {
  width: 100%;
  min-height: 48px;
  padding: 8px 16px;
  font: inherit;
  font-size: 1.0625rem;
  color: var(--fg);
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.field::placeholder { color: var(--muted); opacity: 1; }
.field:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 1px var(--accent); }
.field.small { min-height: 40px; font-size: 1rem; }

.search { position: relative; }
.suggest {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.suggest:empty { display: none; }
.suggest li { padding: 8px 16px; cursor: pointer; display: flex; justify-content: space-between; gap: 16px; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--rail-bg); }
.suggest .hint { font: 0.75rem/1.9 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 16px;
  font-size: 0.875rem;
  line-height: 1.6;
  cursor: pointer;
}
@media (hover: hover) { .chip:hover { border-color: var(--fg); } }
.chip[aria-pressed="true"] { border-color: var(--fg); font-weight: 600; }

.link {
  justify-self: start;
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
#geo-note:empty { display: none; }
.amount { display: grid; gap: 8px; min-width: 0; }

/* The answer: a label line, the card in large serif, then ruled blocks. */
.answer { min-width: 0; border-top: 1px solid var(--line); padding-top: 24px; display: grid; gap: 16px; align-content: start; }
.answer .display { font-size: clamp(2.5rem, 11vw, 4rem); }
.answer .head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.answer .change { display: none; font-size: 0.875rem; }
.answer .lede { margin: 0; font-size: 1.375rem; line-height: 1.35; font-weight: 500; letter-spacing: -0.01em; }
.answer .rate { margin: -8px 0 0; color: var(--muted); }
.answer .empty { margin: 0; color: var(--muted); font: 400 1.25rem/1.45 var(--serif); }
.conditions { margin: 0; padding: 0 0 0 16px; color: var(--fg); }
.conditions li { margin: 4px 0; }
.block { border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 8px; }
.block p { margin: 0; }
.terms { font-weight: 500; text-underline-offset: 3px; }
.block.all { padding-top: 8px; }
.all summary { padding: 8px 0; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 0.875rem; }
.all summary::-webkit-details-marker { display: none; }
.all summary::after, .add summary::after, .extras summary::after { content: "+"; font: 400 1.25rem/1 var(--mono); color: var(--muted); }
.all[open] summary::after, .add[open] summary::after, .extras[open] summary::after { content: "−"; }
.all ol { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; counter-reset: rank; }
.all li { display: flex; justify-content: space-between; gap: 16px; font-size: 0.9375rem; }
.all li .num { font-family: var(--mono); font-size: 0.875rem; white-space: nowrap; }
.answer .foot { margin: 0; font-size: 0.875rem; color: var(--muted); }

/* Cards: the chosen ones first, then the rest of the pack behind a search box. */
.cards { min-width: 0; border-top: 1px solid var(--line); padding-top: 24px; }
.add { border-bottom: 1px solid var(--line); }
.add summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 48px; color: var(--accent); }
.add summary::-webkit-details-marker { display: none; }
.add summary::after { color: var(--accent); }
.add[open] summary { margin-bottom: 8px; }
.add .list > li:last-child { border-bottom: 0; }
.list { margin: 8px 0 0; padding: 0; list-style: none; }
.list:empty { display: none; }
.list > li { border-bottom: 1px solid var(--line); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; min-height: 48px; cursor: pointer; }
.row .name { min-width: 0; }
.extras { margin: -8px 0 0; padding-left: 16px; }
.extras summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 44px; font-size: 0.875rem; color: var(--accent); }
.extras summary::-webkit-details-marker { display: none; }
.extras summary::after { color: var(--accent); }
.extras[open] { display: grid; gap: 8px; padding-bottom: 16px; }
.extras summary span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.extras .label { margin-top: 8px; }
.picks { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.picks .label { flex-basis: 100%; }

.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 44px;
  height: 26px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--line);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--muted);
  box-sizing: border-box;
  transition: transform 0.15s;
}
.switch:checked { background: var(--fg); border-color: var(--fg); }
.switch:checked::after { background: var(--bg); border-color: var(--bg); transform: translateX(18px); }

.bottom {
  border-top: 1px solid var(--line);
  padding: 24px 0 max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  max-width: 72rem;
  width: calc(100% - 32px);
  margin: 0 auto;
}
.bottom p { margin: 0; }

/* On a phone a chosen place swaps the question for the answer; "Change" brings the question back. */
@media (max-width: 959.98px) {
  .answered .ask, .answered .amount { display: none; }
  .answered .answer { border-top: 0; padding-top: 0; }
  /* The padding gives "Change" a 44 px target; the matching negative margin keeps it on the label's baseline. */
  .answered .answer .change { display: inline; padding: 12px 0 12px 16px; margin: -12px 0; }
  .answer:has(> .empty) { border-top: 0; padding-top: 0; }
  .answer:has(> .quiet) { display: none; }
  .wrap { gap: 24px; }
}

/* Touch screens get 44 px targets; the drawn chip stays the same size inside. */
@media (pointer: coarse) {
  .chip, .lang { min-height: 44px; }
  .link:not(.change) { min-height: 44px; display: inline-flex; align-items: center; }
}

@media (min-width: 960px) {
  .wrap {
    grid-template-columns: minmax(0, 26rem) minmax(0, 1fr);
    grid-template-areas: "ask answer" "amount answer" "cards answer";
    grid-template-rows: auto auto 1fr;
    column-gap: 64px;
    row-gap: 40px;
    align-items: start;
    padding-top: 64px;
  }
  .ask { grid-area: ask; }
  .amount { grid-area: amount; }
  .cards { grid-area: cards; }
  .answer {
    grid-area: answer;
    position: sticky;
    top: 40px;
    border-top: 0;
    padding: 0;
    max-width: 44rem;
  }
  .answer .display { font-size: 4rem; }
  /* Once there is an answer, the question steps down so one headline leads. */
  .answered .ask .display { font: 620 1.375rem/1.3 var(--sans); letter-spacing: 0; margin-bottom: 0; }
  .answer .empty { font-size: 1.75rem; max-width: 24ch; padding-top: 12px; }
}

/* The method page: one reading column. */
.prose { width: 100%; max-width: 44rem; margin: 0 auto; padding: 40px 16px 64px; flex: 1; }
.prose .display { margin-bottom: 24px; }
.prose .lede { margin: 0 0 24px; font-size: 1.25rem; line-height: 1.45; color: var(--muted); }
.prose h2 { margin: 40px 0 16px; font-size: 1.375rem; font-weight: 620; line-height: 1.3; letter-spacing: -0.01em; }
.prose p, .prose li { margin: 0 0 16px; }
.prose ol { margin: 0 0 16px; padding-left: 24px; }
.prose code { font: 0.875em var(--mono); background: var(--rail-bg); border-radius: 4px; padding: 0 4px; }
.prose pre { margin: 0 0 16px; padding: 16px; overflow-x: auto; background: var(--rail-bg); border: 1px solid var(--line); border-radius: 8px; }
.prose pre code { background: none; padding: 0; font-size: 0.8125rem; line-height: 1.6; }
a.lang { text-decoration: underline; text-decoration-color: var(--line); }

@media (prefers-reduced-motion: reduce) {
  .switch, .switch::after { transition: none; }
}
