:root {
  --paper: #f1e6d2;
  --ink: #1a1612;
  --muted: #6b5e4e;
  --line: #cbbba0;
  --red: #9e1b2c;
  --up: #1d6a45;
  --board: #1a1612;
  --amber: #e6c27a;
  --focus: #1a1612;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "Iowan Old Style", Palatino, serif;
  line-height: 1.45;
}

.stripe {
  height: 4px;
  background: var(--red);
}

.page {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.mast h1 {
  margin: 0.15rem 0 0.5rem;
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.kicker {
  margin: 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--red);
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 36rem;
}

.board {
  margin: 1.5rem 0;
  padding: 1.1rem 1rem 0.9rem;
  background: var(--board);
  color: var(--amber);
}

.board-top,
.board-eq,
.board-inv,
.board-meta {
  margin: 0;
}

.board-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c4b08a;
}

.board-eq {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.6rem;
  margin-top: 0.7rem;
}

.hero-rate {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: clamp(2.1rem, 8vw, 3.1rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  color: #f3ddaa;
}

.unit,
.eq {
  font-size: 0.95rem;
  color: #c4b08a;
}

.board-inv {
  margin-top: 0.4rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.92rem;
  color: #c4b08a;
}

.chg {
  margin-left: 0.6rem;
}

.chg.up {
  color: #8fceaa;
}

.chg.down {
  color: #e08a8a;
}

.spark {
  display: block;
  width: 100%;
  height: 56px;
  margin-top: 0.7rem;
}

.board-meta {
  margin-top: 0.45rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.75rem;
  color: #9a8a6e;
}

.convert,
.table-head,
.foot {
  border-top: 1px solid var(--line);
  padding-top: 1.1rem;
  margin-top: 0.4rem;
}

.convert-head,
.table-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.table-head p,
.convert-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
}

.seg {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  gap: 0.7rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.82rem;
}

.seg label {
  display: flex;
  gap: 0.28rem;
  align-items: center;
}

.amount-label {
  display: block;
  margin: 0.9rem 0 0.3rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.amount-row {
  display: flex;
  align-items: stretch;
  border-bottom: 2px solid var(--ink);
}

#amount,
#source {
  font: inherit;
  color: inherit;
  background: transparent;
}

#amount {
  flex: 1;
  border: 0;
  padding: 0.45rem 0;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.7rem;
  font-variant-numeric: tabular-nums;
}

#amount:focus,
#source:focus,
button:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.amount-ccy {
  align-self: center;
  font-family: ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.08em;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.presets button,
#refresh {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.8rem;
  padding: 0.28rem 0.55rem;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  border-radius: 2px;
  cursor: pointer;
}

.presets button:hover,
#refresh:hover {
  background: var(--ink);
  color: var(--paper);
}

#source {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  padding: 0.4rem 0;
}

.result {
  margin: 1rem 0 0.25rem;
  font-size: clamp(1.4rem, 4vw, 1.85rem);
  font-variant-numeric: tabular-nums;
}

.result-note,
.foot,
.fail {
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 0.7rem;
  max-width: 100%;
}

.cards {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: right;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th:first-child,
td:first-child,
th:last-child,
td:last-child {
  text-align: left;
}

th {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.name {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.name a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.name small {
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.72rem;
}

.best {
  box-shadow: inset 3px 0 0 var(--red);
}

.num {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.foot p {
  margin: 0 0 0.6rem;
}

#clock {
  margin-left: 0.6rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.8rem;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

th.on,
td.on {
  color: var(--red);
  background: rgba(158, 27, 44, 0.06);
}

th.on {
  font-weight: 700;
}

@media (max-width: 640px) {
  .board-top {
    flex-direction: column;
  }

  .table-wrap {
    display: none;
  }

  .cards {
    display: grid;
    gap: 0.55rem;
    margin-top: 0.7rem;
  }

  .card {
    display: grid;
    gap: 0.35rem;
    width: 100%;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--line);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    border-radius: 2px;
    cursor: pointer;
  }

  .card.best {
    box-shadow: inset 3px 0 0 var(--red);
  }

  .card-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
  }

  .card-top small {
    color: var(--muted);
    font-family: ui-sans-serif, system-ui, sans-serif;
    font-size: 0.72rem;
  }

  .card-main {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 0;
    font-size: 1.05rem;
  }

  .card-main span:first-child {
    color: var(--muted);
    font-family: ui-sans-serif, system-ui, sans-serif;
    font-size: 0.75rem;
  }

  .card-sub {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
  }

  .presets button,
  #refresh {
    min-height: 2.75rem;
    padding: 0.45rem 0.7rem;
  }

  .seg {
    flex-wrap: wrap;
  }

  .seg label {
    min-height: 2.5rem;
  }

  #source {
    min-height: 2.75rem;
    font-size: 16px;
  }
}
