* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  overscroll-behavior-y: contain;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-optical-sizing: auto;
  color: var(--text);
  background-color: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn, .chip, .tab, button, [role="button"], a.btn, .card-manual {
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

::selection { background: var(--accent-soft); color: var(--accent-deep); }

a { color: var(--accent); text-decoration: none; transition: color .12s; }
a:hover { color: var(--accent-deep); text-decoration: underline;
          text-decoration-thickness: 1px; text-underline-offset: 3px; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text);
  letter-spacing: var(--track-tight);
  margin: 0 0 var(--s-3);
  font-weight: 700;
  line-height: 1.1;
}
h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 700; }
h2 { font-size: clamp(20px, 2.5vw, 26px); font-weight: 700; }
h3 { font-size: 18px; font-weight: 600; }

input, select, textarea, button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
code, kbd { font-family: var(--font-mono); font-size: 12px; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }

/* --- Topbar: clean, soft shadow, subtle border --- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding:
    max(var(--s-4), env(safe-area-inset-top)) max(var(--s-6), env(safe-area-inset-right))
    var(--s-4) max(var(--s-6), env(safe-area-inset-left));
  display: flex; align-items: center; gap: var(--s-4);
}
.topbar h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: var(--track-tight);
  font-weight: 700;
}
.topbar .grow { flex: 1; }
.topbar .doc-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--track-loose);
  text-transform: uppercase;
  color: var(--text-muted);
}

.container {
  max-width: 1280px; margin: 0 auto;
  padding:
    var(--s-8)
    max(var(--s-6), env(safe-area-inset-right))
    max(var(--s-8), env(safe-area-inset-bottom))
    max(var(--s-6), env(safe-area-inset-left));
}

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 9px 16px;
  min-height: 38px;
  border-radius: var(--r-1);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -.005em;
  text-decoration: none;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s,
              transform .08s;
  box-shadow: var(--shadow-xs);
  touch-action: manipulation;
}
.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text);
}
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: var(--accent-text);
  box-shadow: var(--shadow);
}
.btn-primary:active { transform: translateY(1px); box-shadow: var(--shadow-xs); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #B91C1C; border-color: #B91C1C; color: #fff; }

.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); box-shadow: none; }

/* --- Inputs --- */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%; padding: 9px 12px;
  min-height: 38px;
  border-radius: var(--r-1);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 6px;
}

.mono {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: var(--track-loose);
  text-transform: uppercase;
  color: var(--text-muted);
}
.rule { border-top: 1px solid var(--border); }

/* --- PWA standalone mode --- */
@media (display-mode: standalone), (display-mode: window-controls-overlay),
       (display-mode: fullscreen), (display-mode: minimal-ui) {
  [data-pwa-install] { display: none !important; }
  a.btn { user-select: none; }
  .btn:active { transform: translateY(1px); }
  .chip:active { transform: scale(.97); }
  .card-manual:active { transform: scale(.99); }
  .btn[aria-label="Terug"], .btn[aria-label="terug"] {
    background: var(--text); color: var(--surface);
    border-color: var(--text);
  }
}
