:root {
  --canvas: #f3eee6;
  --canvas-deep: #e9ded1;
  --paper: #fffaf4;
  --paper-2: #f8f0e6;
  --paper-3: #efe2d4;
  --ink: #261812;
  --espresso: #2b1812;
  --espresso-2: #43251b;
  --roast: #624438;
  --muted: #7d685d;
  --line: #e5d3c1;
  --line-strong: #d7bda5;
  --copper: #c56f42;
  --copper-deep: #934929;
  --amber: #d7a65f;
  --sage: #64735d;
  --sage-light: #9daf8f;
  --berry: #a55247;
  --foam: #fffdf9;
  --sans: "Outfit", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --shadow-soft: 0 18px 50px rgb(65 37 25 / 0.10), 0 2px 8px rgb(65 37 25 / 0.05);
}

* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  line-height: 1.5;
  background:
    radial-gradient(48rem 22rem at 50% -7rem, rgb(255 252 246 / 0.95), transparent 72%),
    linear-gradient(180deg, var(--canvas-deep) 0, var(--canvas) 15rem, #f8f5ef 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image: radial-gradient(circle at center, rgb(84 49 34 / 0.10) 0 0.7px, transparent 0.8px);
  background-size: 18px 18px;
  mask-image: linear-gradient(to bottom, black, transparent 28rem);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
input {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
  min-width: 0;
  width: 100%;
}
button:focus-visible,
input:focus-visible { outline: none; }

main {
  position: relative;
  z-index: 1;
  width: min(37rem, 100%);
  margin: 0 auto;
  padding: 1.15rem 0.75rem 2rem;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}
.mark {
  width: 2.3rem;
  height: 2.3rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgb(84 42 26 / 0.20);
  border-radius: 0.8rem;
  color: var(--foam);
  background: linear-gradient(145deg, var(--copper) 0%, var(--copper-deep) 100%);
  box-shadow: 0 5px 14px rgb(113 53 31 / 0.20), inset 0 1px 0 rgb(255 255 255 / 0.20);
}
.mark svg { width: 1.18rem; height: 1.18rem; }
h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.95rem;
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1;
}
.brand-accent { color: var(--copper-deep); }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem;
  margin-bottom: 0.7rem;
  padding: 0.25rem;
  border: 1px solid rgb(84 49 34 / 0.09);
  border-radius: 1rem;
  background: rgb(255 250 244 / 0.68);
  box-shadow: 0 3px 12px rgb(67 39 27 / 0.045);
  backdrop-filter: blur(8px);
}
.tabs button {
  height: 2.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.72rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--roast);
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}
.tabs button:hover:not([aria-selected="true"]) { background: rgb(255 255 255 / 0.46); }
.tabs button[aria-selected="true"] {
  color: var(--foam);
  background: var(--espresso);
  box-shadow: 0 5px 12px rgb(43 24 18 / 0.16), inset 0 1px 0 rgb(255 255 255 / 0.08);
}
.tabs button:active { transform: translateY(1px); }
.tabs button:focus-visible { box-shadow: 0 0 0 3px rgb(197 111 66 / 0.28); }
.tabs svg { width: 1rem; height: 1rem; }

.card {
  position: relative;
  overflow: hidden;
  padding: 1rem;
  border: 1px solid rgb(80 46 31 / 0.08);
  border-radius: 1.55rem;
  background: linear-gradient(180deg, rgb(255 252 247 / 0.98), var(--paper));
  box-shadow: var(--shadow-soft);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0.12rem 1.35rem auto;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--copper), var(--amber), transparent);
  opacity: 0.9;
}
.grid { display: grid; gap: 0.82rem; }

label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--roast);
  letter-spacing: 0.01em;
}
.shell {
  display: flex;
  align-items: center;
  min-height: 2.85rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.78rem;
  background: var(--paper-2);
  box-shadow: inset 0 1px 1px rgb(65 37 25 / 0.025);
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}
.shell:hover { border-color: var(--line-strong); }
.shell:focus-within {
  border-color: var(--copper);
  background: var(--foam);
  box-shadow: 0 0 0 3px rgb(197 111 66 / 0.13);
}
.shell input {
  height: 2.75rem;
  padding: 0 0.76rem;
  font-size: 0.98rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.prefix { padding-left: 0.76rem; color: var(--muted); }
.suffix { padding-right: 0.76rem; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.units {
  display: flex;
  flex-shrink: 0;
  gap: 0.15rem;
  padding: 0.24rem;
}
.units button {
  height: 2.28rem;
  min-width: 2.5rem;
  padding: 0 0.62rem;
  border-radius: 0.52rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--roast);
}
.units button:hover:not([aria-checked="true"]) { background: var(--paper-3); }
.units button[aria-checked="true"] {
  color: var(--foam);
  background: var(--espresso);
  box-shadow: 0 2px 5px rgb(43 24 18 / 0.18);
}
.units button:focus-visible { box-shadow: 0 0 0 3px rgb(197 111 66 / 0.25); }

.day {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-top: 0.95rem;
  padding: 0.58rem 0.65rem 0.58rem 0.8rem;
  border: 1px solid rgb(100 74 59 / 0.10);
  border-radius: 0.85rem;
  background: linear-gradient(180deg, #faf5ee, #f6ede3);
}
.day p { margin: 0; }
.day .name { font-size: 0.86rem; font-weight: 650; }
.day .hint { margin-top: 0.08rem; font-size: 0.7rem; color: var(--muted); }
.stepper {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  background: var(--paper);
}
.stepper button {
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 0.55rem;
  color: var(--roast);
  transition: background-color 120ms ease, color 120ms ease;
}
.stepper button:hover:not(:disabled) { background: var(--paper-3); color: var(--espresso); }
.stepper button:focus-visible { box-shadow: inset 0 0 0 2px rgb(197 111 66 / 0.45); }
.stepper button:disabled { opacity: 0.32; }
.stepper svg { width: 0.95rem; height: 0.95rem; }
.count {
  width: 2rem;
  text-align: center;
  font-size: 1.02rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.result {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin-top: 0.95rem;
  padding: 1.05rem 0.75rem 0.82rem;
  border: 1px solid rgb(255 255 255 / 0.06);
  border-radius: 1.15rem;
  color: var(--foam);
  text-align: center;
  background:
    radial-gradient(18rem 10rem at 88% -20%, rgb(197 111 66 / 0.34), transparent 68%),
    linear-gradient(145deg, #3e2219 0%, var(--espresso) 74%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 8px 18px rgb(43 24 18 / 0.11);
}
.result::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 8rem;
  height: 8rem;
  right: -4.5rem;
  bottom: -5rem;
  border: 1px solid rgb(255 255 255 / 0.07);
  border-radius: 50%;
  box-shadow: 0 0 0 1.3rem rgb(255 255 255 / 0.025), 0 0 0 2.6rem rgb(255 255 255 / 0.018);
}
.kicker {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #e0af8e;
}
.cost {
  margin: 0.18rem 0 0;
  font-family: var(--display);
  font-size: 2.9rem;
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.cost.is-empty { color: rgb(255 253 249 / 0.38); }
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.42rem;
  margin: 0.85rem 0 0;
}
.stats div {
  min-width: 0;
  padding: 0.58rem 0.28rem;
  border: 1px solid rgb(255 255 255 / 0.055);
  border-radius: 0.72rem;
  background: rgb(255 255 255 / 0.055);
}
.stats dt {
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.2;
  color: rgb(255 253 249 / 0.58);
}
.stats dd {
  margin: 0.14rem 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #efbd86;
}
.tone-less { color: #adc69d !important; }
.tone-more { color: #e9a29a !important; }
.tone-same { color: #efbd86 !important; }

.scale-head,
.scale-foot {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.scale-head {
  margin: 0.82rem 0 0.36rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.scale-foot {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  margin-top: 0.32rem;
  font-size: 0.67rem;
  font-weight: 500;
}
.scale-foot span:nth-child(2) { text-align: center; color: var(--sage); font-weight: 700; }
.scale-foot span:nth-child(3) { text-align: right; }
.value-scale {
  position: relative;
  height: 0.72rem;
  border: 1px solid rgb(93 66 52 / 0.07);
  border-radius: 999px;
  background: #eadfd3;
  box-shadow: inset 0 1px 2px rgb(55 31 22 / 0.10);
}
.value-scale-fill {
  position: absolute;
  inset: -1px auto -1px -1px;
  width: calc(var(--p) * 100% + 1px);
  border-radius: 999px;
  background-image: linear-gradient(90deg, #68795f 0%, #91a27f 37%, #d1a25b 70%, #ae5e4e 100%);
  background-repeat: no-repeat;
  background-size: calc(100% / var(--p)) 100%;
}
.value-scale-mark {
  position: absolute;
  top: -0.25rem;
  bottom: -0.25rem;
  left: 50%;
  z-index: 1;
  width: 1px;
  transform: translateX(-50%);
  background: rgb(43 24 18 / 0.28);
}
.value-scale-dot {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 1.05rem;
  height: 1.05rem;
  border: 3px solid var(--espresso);
  border-radius: 999px;
  background: var(--foam);
  box-shadow: 0 1px 5px rgb(43 24 18 / 0.30);
  transform: translateY(-50%);
  left: clamp(0px, calc(var(--p) * 100% - 0.525rem), calc(100% - 1.05rem));
}

[hidden] { display: none !important; }

@media (min-width: 640px) {
  main { padding: 1.8rem 1rem 2.8rem; }
  .brand { margin-bottom: 0.9rem; }
  .mark { width: 2.5rem; height: 2.5rem; }
  .mark svg { width: 1.28rem; height: 1.28rem; }
  h1 { font-size: 2.12rem; }
  .pair { grid-template-columns: 1fr 1fr; }
  .card { padding: 1.35rem; border-radius: 1.7rem; }
  .grid { gap: 0.96rem; }
  .result { padding: 1.2rem 0.95rem 0.95rem; }
  .cost { font-size: 3.45rem; }
  .stats dd { font-size: 0.98rem; }
}

@media (max-width: 420px) {
  main { padding: 0.9rem 0.55rem 1.5rem; }
  .brand { margin-bottom: 0.62rem; gap: 0.48rem; }
  .mark { width: 2.05rem; height: 2.05rem; border-radius: 0.68rem; }
  .mark svg { width: 1.05rem; height: 1.05rem; }
  h1 { font-size: 1.72rem; }
  .tabs { margin-bottom: 0.55rem; }
  .tabs button { height: 2.45rem; }
  .card { padding: 0.78rem; border-radius: 1.25rem; }
  .grid { gap: 0.72rem; }
  .shell { min-height: 2.65rem; }
  .shell input { height: 2.55rem; }
  .day { margin-top: 0.78rem; padding: 0.5rem 0.5rem 0.5rem 0.65rem; }
  .day .hint { line-height: 1.25; }
  .stepper button { width: 2.05rem; height: 2.05rem; }
  .result { margin-top: 0.78rem; padding: 0.9rem 0.58rem 0.68rem; border-radius: 1rem; }
  .cost { font-size: 2.65rem; }
  .stats { gap: 0.3rem; margin-top: 0.72rem; }
  .stats div { padding: 0.52rem 0.18rem; }
  .stats dt { font-size: 0.63rem; }
  .stats dd { font-size: 0.78rem; }
  .scale-head { margin-top: 0.68rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
