:root {
  --bg: #f6efe4;
  --paper: #fffaf2;
  --ink: #2b2118;
  --muted: #8a7867;
  --line: #eadfce;
  --accent: #d9622b;
  --accent-soft: #fbe3d4;
  --butter: #f3c969;
  --sage: #7d9a78;
  --radius: 20px;
  --shadow: 0 1px 0 rgba(43, 33, 24, .04), 0 10px 30px -12px rgba(97, 60, 25, .25);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background:
    radial-gradient(circle at 100% 0, #fde6cf 0, transparent 40%),
    radial-gradient(circle at 0 100%, #efe6c9 0, transparent 45%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

button, input { font: inherit; color: inherit; }

.app {
  max-width: 460px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

/* header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 22px;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
h1 {
  margin: 0;
  font-family: ui-serif, "New York", Georgia, serif;
  font-size: 23px;
  letter-spacing: -.02em;
}
.sub { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }

.swap {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 9px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s ease, background .2s;
}
.swap:active { transform: scale(.95); }
.swap svg { transition: transform .35s cubic-bezier(.5, 1.6, .4, 1); }
.swap.flipped svg { transform: rotate(180deg); }

/* result card */
.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.input-row { display: flex; align-items: center; gap: 10px; }
.amount {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -.03em;
  padding: 2px 0;
  outline: none;
  font-variant-numeric: tabular-nums;
}
.amount::placeholder { color: #cbbcaa; }

.units {
  display: flex;
  background: var(--bg);
  border-radius: 12px;
  padding: 3px;
  flex-shrink: 0;
}
.units button {
  border: 0;
  background: transparent;
  padding: 7px 9px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.units button[aria-checked="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(43, 33, 24, .12);
}

.fractions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.fractions::-webkit-scrollbar { display: none; }
.fractions button {
  flex: 1 0 auto;
  min-width: 44px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 10px;
  padding: 7px 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.fractions button:active { transform: scale(.94); }
.fractions button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.divider {
  position: relative;
  text-align: center;
  margin: 16px 0 6px;
}
.divider::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 50%;
  border-top: 1px dashed var(--line);
}
.divider span {
  position: relative;
  background: var(--paper);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.output { text-align: center; padding: 4px 0 2px; }
.big {
  font-family: ui-serif, "New York", Georgia, serif;
  font-size: 64px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.big-unit { font-size: 26px; margin-left: 5px; color: var(--ink); opacity: .55; }
.big.pop { animation: pop .28s ease; }
@keyframes pop {
  0% { transform: scale(.96); opacity: .6; }
  100% { transform: scale(1); opacity: 1; }
}
.alt { color: var(--muted); font-size: 14px; margin-top: 2px; min-height: 1.3em; }

/* picker */
.picker { margin-top: 20px; }
.picker-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
h2 {
  margin: 0;
  font-family: ui-serif, "New York", Georgia, serif;
  font-size: 19px;
}
.search {
  width: 46%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s, width .25s;
}
.search:focus { border-color: var(--accent); width: 58%; }

.cats {
  display: flex; gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -18px 10px;
  padding: 0 18px;
}
.cats::-webkit-scrollbar { display: none; }
.cats button {
  flex-shrink: 0;
  border: 0;
  background: rgba(255, 250, 242, .7);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.cats button[aria-selected="true"] { background: var(--ink); color: var(--paper); }

.list {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.list li button {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  text-align: left;
  border: 1.5px solid transparent;
  background: var(--paper);
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(43, 33, 24, .04);
  transition: border-color .2s, transform .1s;
  animation: rise .25s ease both;
}
.list li button:active { transform: scale(.97); }
.list li button.on { border-color: var(--accent); background: #fff6ee; }
.list .em { font-size: 22px; line-height: 1; }
.list .nm { font-size: 13.5px; font-weight: 600; line-height: 1.2; }
.list .gpc { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.list .star { margin-left: auto; font-size: 12px; color: var(--butter); }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 24px 0; font-size: 14px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
