/* Designsysteem: donker basisthema, warm goud-accent, bordeauxrood voor primaire acties. */
:root {
  --bg: #14100f;
  --bg-elev: #1d1716;
  --card: #221b1a;
  --card-hi: #2d2321;
  --line: #3a2f2c;
  --text: #f3ece6;
  --muted: #a8998f;
  --gold: #d4a857;
  --gold-soft: rgba(212, 168, 87, 0.14);
  --bordeaux: #8e1f33;
  --bordeaux-hi: #a8283f;
  --danger: #d0544f;
  --rood: #b0303f;
  --wit: #e6d38c;
  --rose: #e79aa6;
  --oranje: #e0954a;
  --dessert: #c98a2e;
  --ok: #7fb069;
  --warn: #e0a43a;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --font-display: 'Fraunces', Georgia, serif;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --tab-w: 152px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(120% 60% at 50% -10%, #2a1418 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font-ui);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}
body.modal-open { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
h1, h2, h3, p { margin: 0; }
.display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); letter-spacing: 0.02em; }
.small { font-size: 12.5px; }
.muted { color: var(--muted); }
.accent { color: var(--gold); }
.error { color: var(--danger); margin-top: 12px; }
.eyebrow { text-transform: uppercase; font-size: 11px; color: var(--gold); letter-spacing: 0.12em; }
.boot { text-align: center; padding: 40vh 0; color: var(--muted); }

#app { max-width: 960px; margin: 0 auto; }

/* Header */
.app-header { padding: calc(14px + env(safe-area-inset-top)) 16px 10px; }
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.app-header h1 { font-size: 30px; line-height: 1.1; }
.header-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-elev); font-size: 17px; display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--gold); }
.sync { display: inline-block; margin-top: 6px; font: 11px var(--font-mono); color: var(--muted); }
.sync-error, .sync-offline { color: var(--warn); }

/* Tabbalk: vaste knoppen links/rechts, tabs met vaste breedte in een scrollbare strook. */
.tabbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px; padding: 8px 16px;
  background: rgba(20, 16, 15, 0.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-fixed {
  flex: 0 0 auto; width: 42px; height: 38px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--bg-elev); font-size: 18px;
}
.nav-add { background: var(--bordeaux); border-color: var(--bordeaux); font-weight: 600; }
.tab-strip {
  flex: 1 1 auto; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.tab-strip::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 0 0 var(--tab-w); width: var(--tab-w); height: 38px; padding: 0 10px;
  border-radius: 11px; border: 1px solid transparent; background: transparent;
  color: var(--muted); font-size: 13.5px; font-weight: 500; white-space: nowrap; scroll-snap-align: start;
}
.tab-btn.active { color: var(--text); background: var(--gold-soft); border-color: rgba(212, 168, 87, 0.4); }

.content { padding: 14px 16px 96px; }
.intro { margin-bottom: 14px; }
.summary { margin: 4px 0 12px; }

/* Filters */
.filters { display: grid; gap: 10px; margin-bottom: 6px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-elev); font-size: 13px; text-transform: capitalize;
}
.chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip-alle::before { background: var(--gold); }
.chip-rood::before { background: var(--rood); }
.chip-wit::before { background: var(--wit); }
.chip-rosé::before { background: var(--rose); }
.chip-oranje::before { background: var(--oranje); }
.chip-dessert::before { background: var(--dessert); }
.chip-mousserend::before { background: linear-gradient(135deg, var(--wit), var(--gold)); }
.chip.active { border-color: var(--gold); background: var(--gold-soft); }
.chip-count { font-size: 11px; color: var(--muted); }
.search-row { display: flex; gap: 8px; }
.input {
  width: 100%; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--text); font: inherit; font-size: 16px;
}
.input:focus { outline: none; border-color: var(--gold); }
.search { flex: 1; }
.sort { width: auto; flex: 0 0 auto; }

/* Navigatie */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 4px 0 12px; }
.crumb { background: none; border: none; padding: 2px 4px; color: var(--gold); font-size: 13.5px; }
.crumb:last-child { color: var(--text); }
.crumb-sep { color: var(--muted); }
.eyebrow + .nav-row { margin-top: 10px; }
.nav-row {
  width: 100%; display: grid; grid-template-columns: 1fr auto 16px; align-items: center; gap: 10px;
  text-align: left; padding: 14px 16px; margin-bottom: 8px;
}
.nav-name { font-size: 18px; }
.chev { color: var(--gold); font-size: 20px; }

/* Kaarten */
.card {
  background: radial-gradient(140% 120% at 0% 0%, var(--card-hi) 0%, var(--card) 55%);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.wine-card { padding: 14px; display: grid; gap: 12px; position: relative; overflow: hidden; }
.wine-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--rood); }
.wine-card.kleur-wit::before { background: var(--wit); }
.wine-card.kleur-rosé::before { background: var(--rose); }
.wine-card.kleur-oranje::before { background: var(--oranje); }
.wine-card.kleur-dessert::before { background: var(--dessert); }
.wine-card.is-empty { opacity: 0.6; }
.wine-main { background: none; border: none; padding: 0; text-align: left; display: grid; gap: 2px; }
.wine-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: none; }
.wine-name { font-size: 19px; line-height: 1.2; margin-top: 4px; overflow-wrap: anywhere; }
.wine-producer { color: var(--gold); font-size: 14px; }
.badge {
  display: inline-block; max-width: 100%; padding: 2px 9px; border-radius: 999px;
  border: 1px solid rgba(212, 168, 87, 0.35); color: var(--gold); font: 11px/1.5 var(--font-mono);
  overflow-wrap: anywhere; /* valkuil 6: vangnet tegen afbreken midden in een woord */
}
.wine-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.step { width: 38px; height: 36px; border: none; background: var(--bg-elev); font-size: 18px; }
.count { min-width: 36px; text-align: center; font-size: 15px; }

/* Rijpingsindicator */
.gauge { display: grid; gap: 5px; }
.gauge-track { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 999px; background: var(--ok); }
.gauge-jong .gauge-fill { background: #6c8fb3; }
.gauge-binnenkort .gauge-fill { background: var(--warn); }
.gauge-over .gauge-fill { background: var(--danger); }
.gauge-label { font-size: 11px; color: var(--muted); }
.gauge-binnenkort .gauge-label { color: var(--warn); }
.gauge-over .gauge-label { color: var(--danger); }

/* Knoppen */
.btn {
  border-radius: 11px; padding: 10px 16px; border: 1px solid var(--line); background: var(--bg-elev); font-weight: 500;
}
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn-primary { background: var(--bordeaux); border-color: var(--bordeaux); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--bordeaux-hi); }
.btn-ghost:hover:not(:disabled) { border-color: var(--gold); }
.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; margin-right: auto; }

/* Historie */
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; }
.history-meta { display: grid; justify-items: end; gap: 6px; }

.empty { padding: 48px 16px; text-align: center; }

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(3px);
}
.modal {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 20px 20px 0 0;
  padding: 0 16px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow);
}
.modal-wide { max-width: 720px; }
@media (min-width: 700px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
}
.modal-head {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 16px 0 12px; background: var(--bg-elev);
}
.modal-head h2 { font-size: 22px; overflow-wrap: anywhere; }
.modal-body { display: grid; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.menu { display: grid; gap: 10px; }
.menu-item { display: flex; align-items: center; gap: 14px; padding: 16px; font-size: 22px; text-align: left; }
.menu-item span { font-size: 15px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 340px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: grid; gap: 4px; }
.field > span { color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--bordeaux); }
textarea.input { resize: vertical; }
.review-item { padding: 14px; margin: 0 0 12px; display: grid; gap: 12px; }
.review-include { font-size: 17px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.facts dt { color: var(--muted); padding-top: 2px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.note { font-family: var(--font-display); font-style: italic; color: var(--gold); }
.research { display: grid; gap: 10px; padding: 14px; border-radius: var(--radius); background: var(--gold-soft); justify-items: start; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pairing-form { display: grid; gap: 10px; }
.pairing-result { display: grid; gap: 10px; }
.rec { display: grid; gap: 3px; padding: 14px; text-align: left; }
hr { border: none; border-top: 1px solid var(--line); margin: 6px 0; }

.loading { display: grid; justify-items: center; gap: 12px; padding: 24px 0; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 60; padding: 10px 16px; border-radius: 12px; background: var(--card-hi);
  border: 1px solid var(--gold); box-shadow: var(--shadow); font-size: 14px; max-width: calc(100% - 32px);
}

/* Pincode */
.pin-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.pin-card { width: 100%; max-width: 340px; text-align: center; display: grid; gap: 12px; }
.brand-mark { font-size: 44px; }
.pin-form { display: grid; gap: 10px; margin-top: 8px; }
.pin-input { text-align: center; font-size: 24px; letter-spacing: 0.4em; }

/* Face ID */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setting h3 { font-size: 17px; }
.btn-faceid { padding: 14px 16px; font-size: 16px; }

/* Vivino */
.badge-vivino-leeg { color: var(--muted); opacity: 0.8; }
.badge-vivino { color: var(--text); border-color: rgba(176, 48, 63, 0.6); background: rgba(176, 48, 63, 0.18); }
.vivino-link { color: var(--gold); justify-self: start; }

/* Rapporten */
.rapport-titel { font-size: 22px; margin: 4px 0 2px; }
.rapport-chips { margin-bottom: 12px; }
.chip-veld { text-transform: none; }
.chip-veld::before { display: none; }
.chip:disabled { opacity: 0.4; }
.rapport-actie { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 12px; border-radius: var(--radius); background: var(--gold-soft); }
.rapport-row { display: grid; gap: 10px; padding: 12px 14px; }
.rapport-wijn { display: grid; gap: 4px; text-align: left; background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; }
.rapport-wijn .tags { margin-top: 4px; }
.rapport-knoppen { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-ontbreekt { color: var(--muted); border-style: dashed; }

.rapport-kiezer { margin-bottom: 14px; }
.rapport-noot { margin: 0 0 10px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat { display: grid; gap: 2px; padding: 12px 14px; }
.stat-value { font-size: 22px; }
.rang { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.rang-row { width: 100%; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px;
  padding: 12px 14px; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.rang-nr { color: var(--gold); font-size: 15px; }
.rang-wijn { display: grid; gap: 2px; min-width: 0; }
.rang-waarde { text-align: right; font-size: 14px; white-space: nowrap; }
.verdeling { display: grid; gap: 8px; padding: 12px 14px; margin-bottom: 10px; }
.verdeling h3 { margin: 0 0 2px; text-transform: uppercase; letter-spacing: 0.08em; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 38%) 1fr 28px; align-items: center; gap: 10px; }
.bar-label { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-label::first-letter { text-transform: uppercase; }
.bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--gold); border-radius: 999px; }
.bar-row .mono { text-align: right; }
.historie-kop { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.historie-kop .intro { margin: 0; }

/* Chat over een wijn */
.chat-log { display: grid; gap: 8px; margin: 10px 0; }
.chat-bericht { margin: 0; padding: 10px 12px; border-radius: 14px; white-space: pre-wrap; line-height: 1.45; max-width: 88%; }
.chat-vraag { justify-self: end; background: var(--bordeaux); color: var(--text); border-bottom-right-radius: 4px; }
.chat-antwoord { justify-self: start; background: var(--card-hi); border-bottom-left-radius: 4px; }
.chat-voorbeelden { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
