:root {
  --ink: #14213d;
  --paper: #f3f5f9;
  --panel: #ffffff;
  --line: #c9d1e0;
  --muted: #4a5670;
  --yellow: #ffcb05;
  --yellow-ink: #14213d;
  --own: #17703f;
  --own-bg: #dff3e7;
  --missing: #8a93a6;
  --danger: #b3261e;
  --focus: #1a56db;
  --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef1f8;
    --paper: #0f1626;
    --panel: #19233b;
    --line: #2f3d5c;
    --muted: #aab4cc;
    --own: #5fd48f;
    --own-bg: #17372a;
    --missing: #7b869f;
    --danger: #ff8a80;
    --focus: #8ab4ff;
  }
}
* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 16px);
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--ink); color: var(--paper);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  border-bottom: 5px solid var(--yellow);
}
@media (prefers-color-scheme: dark) { .top { background: #0a0f1c; color: #eef1f8; } }
.top h1 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: .01em; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; outline: none; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  min-height: var(--tabs-h); border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; cursor: pointer;
  border-top: 4px solid transparent;
}
.tab[aria-current="page"] { color: var(--ink); border-top-color: var(--yellow); background: var(--paper); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 52px; padding: 0 20px; border-radius: 12px;
  border: 2px solid var(--ink); background: var(--panel); color: var(--ink);
  font: inherit; font-weight: 700; cursor: pointer;
}
.btn.primary { background: var(--yellow); color: var(--yellow-ink); border-color: var(--yellow); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack > * + * { margin-top: 12px; }

input[type="search"], input[type="text"] {
  width: 100%; min-height: 52px; padding: 0 14px; font: inherit;
  border: 2px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink);
}

.muted { color: var(--muted); }
.notice { padding: 14px 16px; border-radius: 12px; background: var(--panel); border: 2px solid var(--line); }
.notice.error { border-color: var(--danger); }

/* Set list */
.set-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.set-item {
  display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center;
  width: 100%; min-height: 76px; padding: 10px 14px; text-align: left;
  background: var(--panel); color: var(--ink); border: 2px solid var(--line); border-radius: 14px;
  font: inherit; cursor: pointer;
}
.set-item img { width: 64px; height: 40px; object-fit: contain; }
.set-item .name { font-weight: 700; }
.set-item .meta { color: var(--muted); font-size: .85rem; }

/* Progress as binder-page slots */
.bar { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--own); }
.stat { font-weight: 700; }
.stat-big { font-size: 1.6rem; font-weight: 800; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 48px; padding: 0 18px; border-radius: 24px; border: 2px solid var(--line);
  background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* Card grid: each tile is a sleeve in a binder page */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 14px; }
.tile {
  position: relative; background: var(--panel); border: 3px solid var(--line); border-radius: 12px;
  padding: 8px; text-align: center;
}
.tile.owned { border-color: var(--own); background: var(--own-bg); }
.tile .pick {
  display: block; width: 100%; padding: 0; border: 0; background: transparent; color: inherit;
  font: inherit; cursor: pointer; min-height: 48px;
}
.tile img { width: 100%; aspect-ratio: 5 / 7; object-fit: contain; display: block; border-radius: 6px; background: var(--line); }
.tile:not(.owned) img { filter: grayscale(1); opacity: .45; }
.tile .num { font-size: .8rem; color: var(--muted); margin-top: 6px; }
.tile .nm { font-weight: 700; font-size: .9rem; overflow-wrap: anywhere; }
.tile .badge {
  position: absolute; top: 4px; left: 4px; min-width: 32px; height: 32px; padding: 0 8px;
  border-radius: 16px; background: var(--own); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: .9rem;
}
.tile .info {
  width: 100%; min-height: 48px; margin-top: 6px; border-radius: 10px;
  border: 2px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
.tile .photo-flag { font-size: .8rem; color: var(--muted); }

/* Lists */
.list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.list li { background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
h2 { font-size: 1.3rem; margin: 0 0 8px; }
h3 { font-size: 1.05rem; margin: 22px 0 6px; }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 20; background: rgba(8, 12, 24, .72);
  display: flex; align-items: flex-end; justify-content: center; overflow-y: auto;
}
.modal[hidden], .toast[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 560px; max-height: 100%; overflow-y: auto;
  background: var(--paper); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 20px; } }
.sheet img.big { width: min(260px, 70%); display: block; margin: 0 auto 12px; border-radius: 10px; }
.counter { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 12px 0; }
.counter .btn { min-width: 64px; font-size: 1.5rem; }
.counter output { font-size: 2rem; font-weight: 800; min-width: 2ch; text-align: center; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 14px); z-index: 30;
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 12px; font-weight: 600;
  max-width: 90%;
}

/* Waarden en prijzen */
.values { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 14px; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; }
.values .stat-big { font-size: 1.35rem; }
.tile .price { font-weight: 700; font-size: .9rem; color: var(--ink); margin-top: 2px; }
.chips .muted { margin-right: 4px; }

pre#diag { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; padding: 12px 14px; font-size: .85rem; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; }

/* Vier tabbladen */
.tabs { grid-template-columns: repeat(4, 1fr); }
.tab { font-size: .85rem; padding: 0 2px; }
.usd { color: var(--muted); font-weight: 600; }

.tile .noimg { width: 100%; aspect-ratio: 5 / 7; border-radius: 6px; background: var(--line); }

a.btn { text-decoration: none; }

/* Vijf tabbladen, formulieren en handelslijsten */
.tabs { grid-template-columns: repeat(5, 1fr); }
.tab { font-size: .75rem; }
input[type="number"], input[type="date"], select {
  width: 100%; min-height: 52px; padding: 0 14px; font: inherit;
  border: 2px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink);
}
.ok { color: var(--own); font-weight: 700; }
.list li.trade-item { flex-direction: column; align-items: stretch; }
.tbtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

/* Links als knoppen, instellingen */
a.chip { display: inline-flex; align-items: center; text-decoration: none; }
details summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; }
.cfg-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.cfg-row span:first-child { flex: 1; }
.cfg-row input { width: 110px; min-height: 48px; }

/* Accountknop in de kop */
.top { display: flex; align-items: center; gap: 12px; }
.top h1 { flex: 1; min-width: 0; }
.acct {
  min-height: 44px; padding: 0 16px; border-radius: 22px; border: 2px solid var(--yellow);
  background: transparent; color: inherit; font: inherit; font-weight: 700; cursor: pointer;
  max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

textarea { width: 100%; padding: 12px 14px; font: inherit; border: 2px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); }
