:root {
  color-scheme: light dark;
  --bg: #f2f2f7; --card: #ffffff; --label: #000000; --secondary: #6c6c70; --chevron: #8e8e93;
  --sep: rgba(60, 60, 67, .22); --seg-bg: #eeeef0; --seg-on: #ffffff; --seg-shadow: 0 1px 3px rgba(0, 0, 0, .15);
  --field-bg: #f2f2f7; --field-border: #c7c7cc; --field-seg: #e3e3e8; --chip-border: #d1d1d6;
  --tint: #8a6a00; --tint-strong: #b8901a; --on-tint: #ffffff; --chart: #b8901a; --up: #1f7a35; --down: #c22a1e;
  --karat-bg: #f6eed8; --karat-fg: #6b5200; --warn-bg: #fbf1d4;
  --press: rgba(0, 0, 0, .06);
  --glow: radial-gradient(70% 40% at 10% 0%, rgba(232, 190, 90, .16), transparent 70%), radial-gradient(55% 35% at 95% 30%, rgba(214, 160, 60, .09), transparent 70%);
  --ease: cubic-bezier(.3, .8, .3, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --card: #1c1c1e; --label: #ffffff; --secondary: #98989f; --chevron: #8e8e93;
    --sep: rgba(84, 84, 88, .6); --seg-bg: #2c2c2e; --seg-on: #636366; --seg-shadow: none;
    --field-bg: #2c2c2e; --field-border: #48484a; --field-seg: #3a3a3c; --chip-border: #3a3a3c;
    --tint: #e0b84a; --tint-strong: #e0b84a; --on-tint: #1a1508; --chart: #e0b84a; --up: #32d74b; --down: #ff6b60;
    --karat-bg: #3a3220; --karat-fg: #e8cb7a; --warn-bg: #2e2614;
    --press: rgba(255, 255, 255, .08);
    --glow: radial-gradient(70% 40% at 10% 0%, rgba(224, 184, 74, .1), transparent 70%), radial-gradient(55% 35% at 95% 30%, rgba(200, 140, 40, .06), transparent 70%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000; --card: #1c1c1e; --label: #ffffff; --secondary: #98989f; --chevron: #8e8e93;
  --sep: rgba(84, 84, 88, .6); --seg-bg: #2c2c2e; --seg-on: #636366; --seg-shadow: none;
  --field-bg: #2c2c2e; --field-border: #48484a; --field-seg: #3a3a3c; --chip-border: #3a3a3c;
  --tint: #e0b84a; --tint-strong: #e0b84a; --on-tint: #1a1508; --chart: #e0b84a; --up: #32d74b; --down: #ff6b60;
  --karat-bg: #3a3220; --karat-fg: #e8cb7a; --warn-bg: #2e2614;
  --press: rgba(255, 255, 255, .08);
  --glow: radial-gradient(70% 40% at 10% 0%, rgba(224, 184, 74, .1), transparent 70%), radial-gradient(55% 35% at 95% 30%, rgba(200, 140, 40, .06), transparent 70%);
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font-family: var(--font); color: var(--label);
  background-color: var(--bg); background-image: var(--glow); background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased; font-size: 17px; line-height: 1.35;
}
a { color: var(--tint); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid rgba(184, 144, 26, .55); outline-offset: 2px; border-radius: 8px; }
.tint { color: var(--tint); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sub { font-size: 13px; color: var(--secondary); }
.sub-lg { font-size: 15px; color: var(--secondary); }
.muted { color: var(--secondary); }
[hidden] { display: none !important; }

.bar-in, .prefs { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.bar-in { display: flex; justify-content: flex-end; gap: 8px; padding-top: calc(8px + env(safe-area-inset-top)); }
.circle, .pill {
  min-height: 44px; border: .5px solid var(--sep); background: var(--card); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.circle { width: 44px; border-radius: 22px; color: var(--tint); padding: 0; }
.pill { padding: 0 14px; border-radius: 22px; font-size: 15px; font-weight: 600; }
.i-sun { display: none; }
.is-dark .i-sun { display: inline; }
.is-dark .i-moon { display: none; }
.prefs { padding-bottom: 16px; display: flex; flex-direction: column; gap: 6px; animation: reveal 260ms var(--ease); }
.cap { font-size: 13px; color: var(--secondary); margin-top: 6px; }

.seg { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); padding: 2px; border-radius: 9px; background: var(--seg-bg); }
.seg::before {
  content: ""; position: absolute; top: 2px; bottom: 2px; left: 2px; border-radius: 7px; background: var(--seg-on); box-shadow: var(--seg-shadow);
  width: calc((100% - 4px) / var(--n, 2)); transform: translateX(calc(var(--i, 0) * 100%)); transition: transform 260ms var(--ease);
}
.seg button { position: relative; z-index: 1; min-height: 36px; border: 0; background: transparent; font-size: 15px; font-weight: 600; cursor: pointer; border-radius: 7px; }
.seg-in { width: 92px; flex-shrink: 0; background: var(--field-seg); }
.seg-in button { min-height: 32px; font-size: 13px; }

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px 40px; display: flex; flex-direction: column; gap: 8px; }
h1 { margin: 0 0 8px; font-size: 34px; line-height: 40px; font-weight: 700; letter-spacing: -.02em; }
.sec { margin: 24px 16px 6px; font-size: 13px; font-weight: 400; text-transform: uppercase; letter-spacing: .02em; color: var(--secondary); }
.group { background: var(--card); border-radius: 12px; overflow: hidden; }
.group.pad { padding: 16px; }
.group.pad p { margin: 0; line-height: 1.45; }
.block { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.sep { border-bottom: .5px solid var(--sep); }
.sep-top { border-top: .5px solid var(--sep); }
.row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; padding: 8px 16px; min-height: 48px; }
.row-btn {
  width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-top: .5px solid var(--sep); background: none; cursor: pointer; color: var(--tint);
}

.price-row { width: 100%; min-height: 60px; padding: 10px 16px; border: 0; background: none; display: flex; align-items: center; gap: 12px; text-align: left; cursor: pointer; }
.price-line { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; }
.price-line > span { white-space: nowrap; }
.up { color: var(--up); }
.down { color: var(--down); }
.nowrap { white-space: nowrap; }
.price-line b { font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
#delta { font-size: 15px; font-weight: 500; }
.chev { flex-shrink: 0; color: var(--chevron); transition: transform 260ms var(--ease); }
[aria-expanded="true"] > .chev { transform: rotate(180deg); }
.chart-box { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; animation: reveal 260ms var(--ease); }
.chart-box .seg button { min-height: 32px; font-size: 13px; }
.chart-wrap { position: relative; height: 150px; }
.chart-wrap canvas { width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: crosshair; }

label, .lbl-row > span:first-child { font-size: 17px; }
.lbl-row { display: flex; align-items: center; gap: 4px; }
.info { width: 44px; height: 44px; margin: -12px -11px; padding: 0; border: 0; background: none; cursor: pointer; color: var(--secondary); display: inline-flex; align-items: center; justify-content: center; }
.tip { margin: 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; line-height: 19px; background: var(--seg-bg); animation: reveal 260ms var(--ease); }
.field {
  display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 6px 0 14px; border-radius: 12px;
  background: var(--field-bg); border: 1px solid var(--field-border); transition: box-shadow 160ms;
}
.field:focus-within { box-shadow: 0 0 0 3px rgba(184, 144, 26, .35); }
.field input {
  flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--label);
  font: inherit; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.karats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.karats button {
  min-height: 44px; border-radius: 10px; border: 1px solid var(--chip-border); background: var(--card);
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.karats button[aria-pressed="true"] { background: var(--tint); border-color: var(--tint); color: var(--on-tint); }
.link {
  align-self: flex-start; min-height: 44px; margin: -6px 0 -10px; padding: 0; border: 0; background: none; cursor: pointer;
  display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; color: var(--tint);
}
.link .chev { color: inherit; }
.result { gap: 2px; padding-bottom: 12px; }
.big { align-self: flex-start; font-size: 40px; line-height: 46px; font-weight: 700; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.big.roll { animation: roll 320ms cubic-bezier(.2, .8, .2, 1); }
.row > * { white-space: nowrap; }
.row b { font-size: 17px; font-weight: 600; margin-left: auto; }
.row + .tip { margin: 0 16px 12px; }

.warn { margin-top: 8px; border-radius: 12px; padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; background: var(--warn-bg); }
.warn svg { flex-shrink: 0; margin-top: 1px; }
.warn div { display: flex; flex-direction: column; gap: 2px; font-size: 15px; line-height: 20px; }
.warn strong { font-weight: 600; }

.items { margin-top: 20px; }
.items-head { width: 100%; min-height: 64px; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 0; background: none; text-align: left; cursor: pointer; }
.items-head b { font-weight: 600; }
.badge { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--karat-bg); color: var(--karat-fg); }
#itemsList { animation: reveal 260ms var(--ease); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding-left: 16px; min-height: 60px; border-top: .5px solid var(--sep); }
.list .k { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 12px; font-weight: 700; background: var(--karat-bg); color: var(--karat-fg); }
.list .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 10px 0; }
.list .del { width: 44px; height: 44px; margin-right: 4px; border: 0; background: none; color: var(--secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.note { margin: 0; padding: 12px 16px; font-size: 13px; line-height: 18px; color: var(--secondary); }
.items .note { border-top: .5px solid var(--sep); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 8px; text-align: left; font-variant-numeric: tabular-nums; }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; text-align: right; }
.table thead th { font-size: 13px; font-weight: 600; color: var(--secondary); padding-top: 12px; padding-bottom: 8px; }
.table tbody tr { border-top: .5px solid var(--sep); }
.table tbody th { font-weight: 600; }
.table td:nth-child(2), .table td:nth-child(3) { color: var(--secondary); }

.faq details + details { border-top: .5px solid var(--sep); }
.faq summary { list-style: none; min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; }
.faq summary::-webkit-details-marker { display: none; }
.faq h3 { flex: 1; margin: 0; font-size: 17px; font-weight: 400; }
.faq details[open] .chev { transform: rotate(180deg); }
.faq p { margin: 0; padding: 0 16px 16px; font-size: 15px; line-height: 21px; color: var(--secondary); }
:root { interpolate-size: allow-keywords; }
.faq details::details-content { height: 0; overflow: clip; transition: height 280ms var(--ease), content-visibility 280ms allow-discrete; }
.faq details[open]::details-content { height: auto; }

.foot { margin-top: 24px; padding: 16px 16px 0; border-top: .5px solid var(--sep); }
.foot .note { padding: 8px 0 0; }

/* feedback bij aanraken, niet pas bij loslaten */
button, summary, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.karats button, .circle, .pill, .info, .del, .link { transition: transform 120ms ease-out, background-color 150ms; }
.karats button:active, .circle:active, .pill:active, .info:active, .del:active, .link:active { transform: scale(.95); transition-duration: 0ms; }
.seg button { transition: opacity 150ms; }
.seg button:active { opacity: .55; transition-duration: 0ms; }
.price-row, .row-btn, .items-head, .faq summary { transition: background-color 200ms; }
.price-row:active, .row-btn:active, .items-head:active, .faq summary:active { background: var(--press); transition-duration: 0ms; }
@media (hover: hover) {
  .price-row:hover, .row-btn:hover, .items-head:hover, .faq summary:hover { background: var(--press); }
  .karats button:not([aria-pressed="true"]):hover, .circle:hover, .pill:hover { background: var(--seg-bg); }
}

@media (prefers-contrast: more) {
  * { --sep: var(--secondary); --chip-border: var(--secondary); --field-border: var(--secondary); }
  .group, .warn { outline: 1px solid var(--secondary); outline-offset: -1px; }
}

@keyframes reveal { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes roll { from { opacity: 0; transform: translateY(10px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::details-content { animation: none !important; transition: none !important; }
}
