:root {
  --bg: #f4f2ec;
  --card: #ffffff;
  --ink: #16161a;
  --soft: rgba(22, 22, 26, 0.56);
  --line: rgba(22, 22, 26, 0.1);
  --accent: #2f6bff;
  --own-a: color-mix(in srgb, var(--accent) 34%, #ffffff);
  --own-b: color-mix(in srgb, var(--accent) 66%, #ffffff);
  --own-c: var(--accent);
  --owe-a: #26262c;
  --owe-b: #8a8a93;
  --hatch: color-mix(in srgb, var(--accent) 55%, #ffffff);
  --hatch-bg: color-mix(in srgb, var(--accent) 10%, #ffffff);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 10px 12px;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; outline: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.nw { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); width: min(344px, 100%); padding: 14px 16px 10px; border-radius: 26px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line), 0 1px 0 rgba(255, 255, 255, 0.9), 0 34px 50px -34px rgba(22, 22, 26, 0.4), 0 30px 60px -44px color-mix(in srgb, var(--accent) 70%, transparent); }

.nw__head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; height: 30px; }
.nw__lab { display: block; height: 16px; overflow: hidden; font-size: 12.500px; line-height: 16px; font-weight: 640; color: var(--soft); white-space: nowrap; }
.nw__lab span { display: block; overflow: hidden; text-overflow: ellipsis; }
.nw__when { position: relative; display: grid; grid-template-columns: auto auto; height: 30px; padding: 3px; border-radius: 15px; background: rgba(22, 22, 26, 0.06); }
.nw__when button { position: relative; z-index: 1; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 11.500px; font-weight: 680; color: var(--soft); white-space: nowrap; transition: color 0.25s; }
.nw__when button[aria-selected="true"] { color: var(--ink); }
.nw__when button:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.nw__pill { position: absolute; left: 0; top: 3px; width: 60px; height: 24px; border-radius: 12px; background: #ffffff; box-shadow: 0 0 0 1px rgba(22, 22, 26, 0.06), 0 4px 8px -4px rgba(22, 22, 26, 0.35); }

.nw__sum { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; height: 42px; margin-top: 4px; }
.nw__sum strong { font-size: 36px; line-height: 42px; font-weight: 760; font-stretch: 90%; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nw__chip { display: block; height: 22px; margin-bottom: 8px; padding: 0 8px; border-radius: 11px; overflow: hidden; background: color-mix(in srgb, var(--accent) 10%, #ffffff); color: color-mix(in srgb, var(--accent) 80%, #16161a); font-size: 10.500px; line-height: 22px; font-weight: 720; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nw__chip span { display: block; }

.nw__bar { position: relative; height: 46px; margin-top: 10px; }
.nw__bar svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; }
.nw__seg { cursor: pointer; }
.nw__seg[data-seg="0"] { fill: var(--own-a); }
.nw__seg[data-seg="1"] { fill: var(--own-b); }
.nw__seg[data-seg="2"] { fill: var(--own-c); }
.nw__seg[data-seg="3"] { fill: var(--owe-a); }
.nw__seg[data-seg="4"] { fill: var(--owe-b); }

.nw__rows { list-style: none; display: grid; margin-top: 8px; }
.nw__rows li + li { box-shadow: inset 0 1px 0 var(--line); }
.nw__rows button { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 10px; width: calc(100% + 16px); height: 29px; margin: 0 -8px; padding: 0 8px; border-radius: 9px; font-size: 13px; font-weight: 620; text-align: left; transition: background-color 0.2s; }
.nw__rows button b { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nw__rows button.is-on { background: color-mix(in srgb, var(--tone, var(--accent)) 12%, #ffffff); }
.nw__rows button:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

.live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ghost { position: absolute; left: 0; top: 0; width: 24px; height: 24px; margin: -3px 0 0 -5px; transform-origin: 20% 15%; pointer-events: none; opacity: 0; fill: #16161a; stroke: #ffffff; stroke-width: 1.300; stroke-linejoin: round; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)); z-index: 6; }

@media (max-width: 350px) { .nw__sum strong { font-size: 30px; } .nw__chip { font-size: 10px; padding: 0 7px; } }
@media (max-height: 360px) { .nw__rows button { height: 25px; font-size: 12.500px; } .nw__bar { margin-top: 6px; } }
@media (prefers-reduced-motion: reduce) { .nw__when button, .nw__rows button { transition: none; } }
