/* Catppuccin Latte (licht) en Frappe (donker).
   Alle kleuren lopen via variabelen zodat de themaschakelaar niets anders
   hoeft aan te raken dan het data-theme attribuut op <html>. */

:root,
[data-theme="latte"] {
  --base: #eff1f5;
  --mantle: #e6e9ef;
  --crust: #dce0e8;
  --surface0: #ccd0da;
  --surface1: #bcc0cc;
  --surface2: #acb0be;
  --overlay0: #9ca0b0;
  --text: #4c4f69;
  --subtext1: #5c5f77;
  --subtext0: #6c6f85;
  --blue: #1e66f5;
  --lavender: #7287fd;
  --mauve: #8839ef;
  --red: #d20f39;
  --maroon: #e64553;
  --green: #40a02b;
  --yellow: #df8e1d;
  --peach: #fe640b;
  --teal: #179299;
  --sky: #04a5e5;
  --pink: #ea76cb;
  --shadow: rgba(76, 79, 105, 0.12);
}

[data-theme="frappe"] {
  --base: #303446;
  --mantle: #292c3c;
  --crust: #232634;
  --surface0: #414559;
  --surface1: #51576d;
  --surface2: #626880;
  --overlay0: #737994;
  --text: #c6d0f5;
  --subtext1: #b5bfe2;
  --subtext0: #a5adce;
  --blue: #8caaee;
  --lavender: #babbf1;
  --mauve: #ca9ee6;
  --red: #e78284;
  --maroon: #ea999c;
  --green: #a6d189;
  --yellow: #e5c890;
  --peach: #ef9f76;
  --teal: #81c8be;
  --sky: #99d1db;
  --pink: #f4b8e4;
  --shadow: rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--base);
  color: var(--text);
  font-family: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6rem; font-weight: 650; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8rem; }
small, .small { font-size: .82rem; }
.muted { color: var(--subtext0); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
hr { border: 0; border-top: 1px solid var(--surface0); margin: 1.2rem 0; }

/* ---------- layout ---------- */
.site-header {
  background: var(--mantle);
  border-bottom: 1px solid var(--surface0);
  position: sticky;
  top: 0;
  z-index: 40;
}
.site-header .inner,
.site-footer .inner,
main.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1rem;
}
.site-header .inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 58px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 750;
  font-size: 1.05rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.brand i { color: var(--mauve); }
.brand:hover { text-decoration: none; }
nav.main { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
nav.main a, nav.main button.linklike {
  padding: .35rem .7rem;
  border-radius: 7px;
  color: var(--subtext1);
  font-size: .92rem;
}
nav.main a:hover { background: var(--surface0); text-decoration: none; color: var(--text); }
nav.main a.active { background: var(--surface0); color: var(--text); font-weight: 600; }
nav.main .badge-alert {
  background: var(--red);
  color: var(--base);
  border-radius: 999px;
  padding: 0 .4rem;
  font-size: .72rem;
  margin-left: .25rem;
}

main.wrap { flex: 1; width: 100%; padding-top: 1.4rem; padding-bottom: 2.5rem; }

.site-footer {
  background: var(--mantle);
  border-top: 1px solid var(--surface0);
  color: var(--subtext0);
  font-size: .84rem;
  padding: 1rem 0;
}
.site-footer .inner { display: flex; gap: 1rem; justify-content: space-between; flex-wrap: wrap; }

/* ---------- cards, panels ---------- */
.card {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px var(--shadow);
}
.card.tight { padding: .7rem .8rem; }
.card h2, .card h3 { margin-top: 0; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: .7rem;
}
.card-head h2, .card-head h3 { margin: 0; }

.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row > input[type="text"], .row > input[type="search"], .row > input:not([type]) {
  flex: 1 1 12rem;
  min-width: 0;
}
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .6rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  border: 1px solid var(--surface1);
  background: var(--surface0);
  color: var(--text);
  border-radius: 8px;
  padding: .45rem .85rem;
  font-size: .92rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--surface1); text-decoration: none; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--base); font-weight: 600; }
.btn.primary:hover { background: var(--lavender); border-color: var(--lavender); }
.btn.danger { background: var(--red); border-color: var(--red); color: var(--base); }
.btn.ghost { background: transparent; }
.btn.small { padding: .25rem .55rem; font-size: .82rem; }
.btn.block { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ---------- forms ---------- */
label { display: block; font-size: .84rem; color: var(--subtext1); margin-bottom: .25rem; font-weight: 600; }
/* Ook een <input> zonder type: dat is een tekstveld, en zonder deze regel
   viel de helft van de formulieren buiten de opmaak. `:not([type])` vangt ze
   allemaal in een keer, in plaats van overal type="text" bij te schrijven. */
input:not([type]),
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="search"], input[type="date"], input[type="url"], input[type="tel"],
select, textarea {
  width: 100%;
  background: var(--base);
  border: 1px solid var(--surface1);
  color: var(--text);
  border-radius: 8px;
  padding: .45rem .6rem;
  font-family: inherit;
  font-size: .92rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--lavender);
  outline-offset: -1px;
  border-color: var(--lavender);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }

input[type="file"] {
  width: 100%;
  font-size: .82rem;
  padding: .4rem;
  background: var(--base);
  border: 1px dashed var(--surface1);
  border-radius: 8px;
  color: var(--subtext1);
}
input[type="file"]::file-selector-button {
  border: 1px solid var(--surface1);
  background: var(--surface0);
  color: var(--text);
  border-radius: 6px;
  padding: .25rem .6rem;
  margin-right: .6rem;
  cursor: pointer;
  font-family: inherit;
  font-size: .82rem;
}
input[type="file"]::file-selector-button:hover { background: var(--surface1); }

code {
  background: var(--surface0);
  padding: .1rem .35rem;
  border-radius: 5px;
  font-size: .85em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
pre {
  background: var(--surface0);
  padding: .7rem .8rem;
  border-radius: 9px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.45;
}
.field { margin-bottom: .8rem; }
.field .hint { font-size: .78rem; color: var(--subtext0); margin-top: .2rem; font-weight: 400; }
.inline-check { display: flex; align-items: center; gap: .45rem; font-weight: 400; color: var(--text); margin-bottom: .3rem; }
.inline-check input { width: auto; }
fieldset { border: 1px solid var(--surface0); border-radius: 10px; padding: .8rem; margin: 0 0 1rem; }
legend { padding: 0 .4rem; font-size: .84rem; color: var(--subtext1); font-weight: 600; }

/* ---------- flashes ---------- */
.flashes { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.flash {
  padding: .6rem .85rem;
  border-radius: 9px;
  border-left: 4px solid var(--blue);
  background: var(--mantle);
  display: flex;
  gap: .55rem;
  align-items: flex-start;
}
.flash.success { border-left-color: var(--green); }
.flash.error { border-left-color: var(--red); }
.flash.info { border-left-color: var(--sky); }
.flash i { margin-top: .18rem; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--surface0); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--subtext0); }
tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; }

/* ---------- pills ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--surface0);
  border-radius: 999px;
  padding: .12rem .55rem;
  font-size: .76rem;
  color: var(--subtext1);
  white-space: nowrap;
}
.pill.green { background: color-mix(in srgb, var(--green) 22%, transparent); color: var(--green); }
.pill.red { background: color-mix(in srgb, var(--red) 22%, transparent); color: var(--red); }
.pill.yellow { background: color-mix(in srgb, var(--yellow) 25%, transparent); color: var(--yellow); }
.pill.blue { background: color-mix(in srgb, var(--blue) 20%, transparent); color: var(--blue); }
.pill.mauve { background: color-mix(in srgb, var(--mauve) 20%, transparent); color: var(--mauve); }

/* ---------- bronschakelaars op de regelpagina ---------- */
.zoekbalk { display: flex; flex-direction: column; gap: .5rem; flex: 1 1 26rem; }
.toggles { gap: .35rem; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 999px;
  padding: .18rem .7rem;
  font-size: .8rem;
  color: var(--subtext0);
  cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle i { font-size: .7rem; opacity: .7; }
.toggle:hover { border-color: var(--lavender); }
.toggle:focus-within { outline: 2px solid var(--lavender); outline-offset: 2px; }
.toggle.aan {
  border-color: var(--mauve);
  color: var(--mauve);
  background: color-mix(in srgb, var(--mauve) 14%, var(--mantle));
}
.toggle.aan i { opacity: 1; }

/* ---------- character cards ---------- */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 1rem; }
.char-card {
  background: var(--mantle);
  border: 1px solid var(--surface0);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.char-card:hover { transform: translateY(-2px); border-color: var(--lavender); }
.char-card .portrait {
  height: 150px;
  background: var(--surface0);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.char-card .portrait img { width: 100%; height: 100%; object-fit: cover; }
.char-card .portrait i { font-size: 2.4rem; color: var(--overlay0); }
.char-card .body { padding: .75rem .85rem; flex: 1; display: flex; flex-direction: column; gap: .3rem; }
.char-card .body h3 { margin: 0; font-size: 1.02rem; }
.char-card .foot {
  border-top: 1px solid var(--surface0);
  padding: .5rem .6rem;
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
}

/* ---------- sheet ---------- */
.sheet-top { display: grid; grid-template-columns: 150px 1fr; gap: 1rem; align-items: start; }
.sheet-portrait {
  width: 150px; height: 150px; border-radius: 12px; overflow: hidden;
  background: var(--surface0); display: flex; align-items: center; justify-content: center;
}
.sheet-portrait img { width: 100%; height: 100%; object-fit: cover; }
.sheet-portrait i { font-size: 3rem; color: var(--overlay0); }

.ability-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: .6rem; }
.ability {
  background: var(--mantle); border: 1px solid var(--surface0); border-radius: 12px;
  padding: .6rem .3rem; text-align: center;
}
.ability .name { font-size: .68rem; letter-spacing: .05em; text-transform: uppercase; color: var(--subtext0); }
.ability .mod { font-size: 1.65rem; font-weight: 700; line-height: 1.15; }
.ability .score {
  display: inline-block; font-size: .78rem; color: var(--subtext0);
  background: var(--surface0); border-radius: 999px; padding: 0 .5rem;
}

.ability-points {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .4rem;
}
.ability-points label { margin-bottom: .15rem; font-size: .7rem; text-align: center; }
.ability-points input { text-align: center; padding: .35rem .2rem; }

/* Een blok dat bij een keuze hoort die nu niet aan staat. Met javascript
   verdwijnt het; zonder javascript blijft het gewoon staan en werkt alles nog,
   het is dan alleen wat gedempt. */
.uit { opacity: .45; }
.js .uit { display: none; }
.asi-slot legend { font-weight: 600; }
.asi-slot + .asi-slot { margin-top: .6rem; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: .6rem; }
.stat {
  background: var(--mantle); border: 1px solid var(--surface0); border-radius: 10px;
  padding: .5rem .6rem; text-align: center;
}
.stat .label { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--subtext0); }
.stat .value { font-size: 1.3rem; font-weight: 700; }
.stat .sub { font-size: .74rem; color: var(--subtext0); }

.skill-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .1rem .9rem; }
.skill-line { display: flex; align-items: center; gap: .5rem; padding: .18rem 0; border-bottom: 1px dotted var(--surface0); }
.skill-line .marker { width: 12px; text-align: center; color: var(--overlay0); font-size: .7rem; }
.skill-line .marker.on { color: var(--green); }
.skill-line .marker.exp { color: var(--mauve); }
.skill-line .val { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; padding-left: .5rem; }

/* Waar een bonus vandaan komt: groen, klein, en het mag wegvallen als het
   krap wordt. */
.bonus {
  color: var(--green);
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.skill-line .bonus { margin-left: auto; }
.skill-line .val + .bonus { margin-left: .4rem; }
.ability .herkomst {
  display: flex;
  flex-direction: column;
  gap: .05rem;
  margin-top: .25rem;
  line-height: 1.2;
}
.skill-line .abbr { font-size: .72rem; color: var(--subtext0); }

.hp-bar { height: 12px; background: var(--surface0); border-radius: 999px; overflow: hidden; margin: .35rem 0; }
.hp-bar span { display: block; height: 100%; background: var(--green); transition: width .2s ease; }
.hp-bar.hurt span { background: var(--yellow); }
.hp-bar.danger span { background: var(--red); }

.slot-row { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.slot-pip { width: 15px; height: 15px; border-radius: 4px; border: 1px solid var(--surface2); background: var(--base); }
.slot-pip.used { background: var(--surface2); }

/* ---------- builder ---------- */
.builder { display: grid; grid-template-columns: 210px 1fr; gap: 1.2rem; align-items: start; }
.step-nav { position: sticky; top: 72px; display: flex; flex-direction: column; gap: .2rem; }
.step-nav a {
  display: flex; align-items: center; gap: .55rem;
  padding: .45rem .6rem; border-radius: 8px; color: var(--subtext1); font-size: .9rem;
}
.step-nav a:hover { background: var(--surface0); text-decoration: none; }
.step-nav a.active { background: var(--blue); color: var(--base); font-weight: 600; }
.step-nav a.done .tick { color: var(--green); margin-left: auto; font-size: .78rem; }
.step-nav a.active .tick { color: var(--base); }
.step-nav a i.lead { width: 16px; text-align: center; }

.option-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .6rem; }
.option {
  border: 1px solid var(--surface1); border-radius: 10px; padding: .6rem .7rem;
  cursor: pointer; background: var(--mantle); display: block;
}
.option:hover { border-color: var(--lavender); }
/* De radio zelf is onzichtbaar maar blijft focusbaar: pointer-events of
   display:none zou hem uit de toetsenbordvolgorde halen. */
.option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.option:focus-within { outline: 2px solid var(--lavender); outline-offset: 2px; }
.option .title { font-weight: 650; display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.option .meta { font-size: .78rem; color: var(--subtext0); }
.option.selected { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); background: color-mix(in srgb, var(--blue) 8%, var(--mantle)); }

.detail-block { border-left: 3px solid var(--surface1); padding-left: .8rem; margin: .5rem 0; }
.detail-block h4 { margin: 0 0 .2rem; font-size: .92rem; }
.detail-block p { margin: 0 0 .4rem; font-size: .87rem; color: var(--subtext1); }

.picker { max-height: 420px; overflow-y: auto; border: 1px solid var(--surface0); border-radius: 10px; }
.picker table { font-size: .86rem; }
.picker th { position: sticky; top: 0; background: var(--mantle); z-index: 1; }

/* ---------- AI ---------- */
.ai-panel {
  border: 1px solid var(--mauve);
  border-radius: 11px;
  padding: .8rem .9rem;
  background: color-mix(in srgb, var(--mauve) 7%, var(--mantle));
  margin-top: .7rem;
}
.ai-panel h4 { margin: 0 0 .4rem; font-size: .95rem; display: flex; align-items: center; gap: .4rem; }
.ai-panel h4 i { color: var(--mauve); }
.progress {
  height: 9px; background: var(--surface0); border-radius: 999px; overflow: hidden; margin: .5rem 0 .35rem;
}
.progress span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--mauve), var(--lavender));
  transition: width .4s ease;
}
.progress.indeterminate span { width: 35% !important; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide {
  0% { margin-left: -35%; }
  100% { margin-left: 100%; }
}
.ai-partial {
  font-size: .84rem; color: var(--subtext0); white-space: pre-wrap;
  max-height: 170px; overflow-y: auto; border-left: 2px solid var(--surface1);
  padding-left: .6rem; margin-top: .5rem;
}
.ai-result { white-space: pre-wrap; font-size: .9rem; background: var(--base);
  border: 1px solid var(--surface0); border-radius: 9px; padding: .7rem; margin: .5rem 0; }
.ai-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .45rem; }
.ai-name-btn { text-align: left; }
.ai-locked {
  border: 1px dashed var(--surface2); border-radius: 11px; padding: .8rem .9rem;
  background: var(--mantle); color: var(--subtext0);
}
.spinner { display: inline-block; animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 2.4rem 1rem; color: var(--subtext0); }
.empty i { font-size: 2.2rem; margin-bottom: .6rem; display: block; color: var(--overlay0); }
.section-title { display: flex; align-items: center; gap: .5rem; margin: 1.4rem 0 .7rem; }
.section-title h2 { margin: 0; }
.section-title .line { flex: 1; height: 1px; background: var(--surface0); }
details.info { border: 1px solid var(--surface0); border-radius: 9px; padding: .5rem .7rem; margin-bottom: .6rem; background: var(--mantle); }
details.info summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
details.info[open] summary { margin-bottom: .5rem; }
.scroll-box { max-height: 300px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; font-size: .88rem; }
.kv dt { color: var(--subtext0); }
.kv dd { margin: 0; }

@media (max-width: 900px) {
  .builder { grid-template-columns: 1fr; }
  .step-nav { position: static; flex-direction: row; overflow-x: auto; padding-bottom: .3rem; }
  .step-nav a { white-space: nowrap; }
  .sheet-top { grid-template-columns: 1fr; }
  .ability-row { grid-template-columns: repeat(3, 1fr); }
}

@media print {
  .site-header, .site-footer, .btn, .step-nav, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .card { break-inside: avoid; border-color: #ccc; }
}
