:root {
  color-scheme: light;
  --paper: #f4efe4;
  --card: #fffaf3;
  --ink: #231c14;
  --muted: #6d6256;
  --line: #e3d5c3;
  --accent: #9a3412;
  --good: #1d4d38;
  --bad: #9f1239;
  --shadow: 0 1px 0 rgba(80, 50, 20, 0.04);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 12rem),
    var(--paper);
  color: var(--ink);
}

header, main, footer {
  width: min(1080px, calc(100% - 2rem));
  margin-inline: auto;
}

header { padding: 2.2rem 0 0.4rem; }

.kicker {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent);
}

h1 {
  margin: 0.2rem 0;
  font-size: 2.4rem;
  font-weight: 640;
  letter-spacing: -0.03em;
}

.lede, .hint, footer, .detail, .note, .search-hint, .empty, .match-count {
  color: var(--muted);
  line-height: 1.45;
}

.lede strong { color: var(--ink); font-weight: 650; }

.steps {
  margin: 0.9rem 0 0;
  padding: 0.85rem 0.85rem 0.85rem 2rem;
  max-width: 48rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  line-height: 1.5;
}

.steps li { margin: 0.35rem 0; }
.steps strong { font-weight: 650; }

.examples-line {
  margin: 0.85rem 0 0;
  max-width: 48rem;
}

.panel-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.panel-blurb {
  margin: 0.35rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.panel-blurb.tight { margin-top: 0.55rem; margin-bottom: 0.55rem; }

.answer-label, .notes-label {
  margin: 1rem 0 0.15rem;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.formula-guide {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.formula-guide h3 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 650;
}

.guide {
  margin: 0;
  display: grid;
  gap: 0.55rem;
}

.guide > div {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.4rem 0.75rem;
  align-items: start;
}

.guide dt {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.guide dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.45;
}

@media (max-width: 700px) {
  .guide > div { grid-template-columns: 1fr; gap: 0.15rem; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

a { color: var(--accent); }

main {
  display: grid;
  grid-template-columns: minmax(16rem, 0.95fr) minmax(0, 1.25fr);
  gap: 1rem;
  padding: 1rem 0 2rem;
}

.sheet, aside {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem 1rem 1.1rem;
}

label {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.75rem 0.8rem;
  font: 1.05rem/1.4 ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
}

#expr:focus, #filter:focus {
  outline: 2px solid #fdba74;
  border-color: #fdba74;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 0.2rem;
}

button {
  font: inherit;
  cursor: pointer;
}

.examples button, .row {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.82rem;
}

.examples button:hover, .row:hover { border-color: #fdba74; }

.pretty {
  margin: 0.8rem 0 0.15rem;
  font-size: clamp(2rem, 4vw, 3.1rem);
  letter-spacing: -0.04em;
  color: var(--good);
  font-weight: 640;
}

.magnitude { margin: 0; font-family: ui-monospace, "Cascadia Code", monospace; }

#notes {
  margin: 0.8rem 0 0;
  padding-left: 1.1rem;
}

#notes li { margin: 0.2rem 0; }

.error {
  color: var(--bad);
  font-weight: 650;
}

.hint { font-size: 0.92rem; }

code {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.92em;
}

.aside-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.match-count {
  font-size: 0.78rem;
  white-space: nowrap;
}

.search-hint {
  margin: 0.45rem 0 0.55rem;
  font-size: 0.82rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.chips button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
  font-size: 0.78rem;
}

.chips button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.empty {
  margin: 1rem 0 0;
  font-size: 0.9rem;
}

#catalog {
  margin-top: 0.55rem;
  max-height: 42rem;
  overflow: auto;
  padding-right: 0.2rem;
}

.group {
  margin: 0.9rem 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.row {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: 12px;
  margin: 0.35rem 0;
  padding: 0.45rem 0.6rem;
}

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.row strong {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-weight: 650;
}

.badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: #fff;
}

.detail, .note, .use { display: block; font-size: 0.82rem; }

.use {
  margin-top: 0.35rem;
  color: var(--accent);
  font-size: 0.75rem;
}

.sheet-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.sheet-top .panel-title { margin-bottom: 0; }

aside .aside-top { margin-top: 0.35rem; }

.currency {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.currency button {
  border: 0;
  background: transparent;
  padding: 0.28rem 0.7rem;
  font-size: 0.82rem;
  border-radius: 0;
}

.currency button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

.fx { font-size: 0.88rem; margin: 0.35rem 0 0; }

.terms {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto 1.5rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem 1.1rem 0.4rem;
}

.terms h2 {
  margin: 0 0 0.6rem;
  font-size: 1.15rem;
}

.terms dl {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
}

.terms dt { font-weight: 650; }
.terms dd { margin: 0 0 0.7rem; color: var(--muted); line-height: 1.45; }

@media (max-width: 700px) {
  .terms dl { grid-template-columns: 1fr; }
  .terms dd { margin-top: -0.2rem; }
}

@media (max-width: 800px) {
  main { grid-template-columns: 1fr; }
  #catalog { max-height: 28rem; }
  h1 { font-size: 2rem; }
}
