/* Agent Vault. Kleuren en maten bovenaan; de rest gebruikt alleen deze variabelen. */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --text: #161b26;
  --muted: #5d6475;
  --line: #e1e4ea;
  --accent: #3355dd;
  --accent-text: #ffffff;
  --danger: #c0352b;
  --ok: #1d8a4e;
  --warn-bg: #fff6e0;
  --warn-line: #e8c56a;
  --agent-bg: #f1f2f6;
  --new: #1d8a4e;
  --update: #b4620a;
  --radius: 14px;
  --space: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151d;
    --surface: #1a202b;
    --text: #e9ecf2;
    --muted: #9aa2b3;
    --line: #2b3240;
    --accent: #6d8bff;
    --accent-text: #0d1220;
    --danger: #ff7a6e;
    --ok: #5fd08f;
    --warn-bg: #2e2612;
    --warn-line: #6b5520;
    --agent-bg: #222937;
    --new: #5fd08f;
    --update: #f0a64a;
  }
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) var(--space) 10px;
  background: #161b26; color: #fff;
}
.brand { color: inherit; text-decoration: none; font-weight: 650; display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; }

/* Knop met alleen een icoon (menu, sluiten). Iconen zijn CSS, geen afbeeldingen. */
.icon-button {
  flex: none; width: 40px; height: 40px; padding: 0; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; color: inherit;
}
.icon-button:hover, .icon-button:focus-visible { background: rgba(127, 127, 127, 0.18); }
.burger, .burger::before, .burger::after {
  display: block; width: 20px; height: 2px; border-radius: 2px; background: currentColor; position: relative; content: "";
}
.burger::before { position: absolute; top: -6px; }
.burger::after { position: absolute; top: 6px; }
.close-x { position: relative; width: 18px; height: 18px; display: block; }
.close-x::before, .close-x::after {
  content: ""; position: absolute; left: 0; top: 8px; width: 18px; height: 2px; border-radius: 2px; background: currentColor;
}
.close-x::before { transform: rotate(45deg); }
.close-x::after { transform: rotate(-45deg); }

main { max-width: 640px; margin: 0 auto; padding: var(--space); }
body.has-tabs main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

/* Tabs onderaan */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar[hidden] { display: none; }
.tab {
  flex: 0 1 200px; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px 9px; font-size: 0.75rem; font-weight: 600;
  color: var(--muted); text-decoration: none;
}
.tab[aria-current="page"] { color: var(--accent); }
.tab-icon { width: 24px; height: 22px; display: block; position: relative; }
/* Inbox: bakje */
.tab-icon-inbox { border: 2px solid currentColor; border-radius: 5px; height: 18px; margin-top: 2px; }
.tab-icon-inbox::after { content: ""; position: absolute; left: 3px; right: 3px; top: 6px; height: 2px; background: currentColor; border-radius: 2px; }
/* Agents: hoofd + schouders */
.tab-icon-agents::before { content: ""; position: absolute; left: 7px; top: 1px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; }
.tab-icon-agents::after { content: ""; position: absolute; left: 2px; right: 2px; bottom: 0; height: 8px; border: 2px solid currentColor; border-bottom: 0; border-radius: 10px 10px 0 0; }
.tab-count {
  position: absolute; top: 3px; left: calc(50% + 8px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 0.7rem; line-height: 18px; text-align: center;
}

/* Zijmenu */
.drawer-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(8, 10, 16, 0.45); }
.drawer-backdrop[hidden] { display: none; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 21;
  width: min(380px, 88vw); overflow-y: auto;
  background: var(--bg); border-left: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 10px) var(--space) calc(env(safe-area-inset-bottom) + var(--space));
  transform: translateX(100%); transition: transform 0.2s ease; visibility: hidden;
}
body.drawer-open .drawer { transform: none; visibility: visible; }
body.drawer-open { overflow: hidden; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.drawer-head h2 { margin: 0; font-size: 1.15rem; }
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }

/* Agents */
.agent-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--agent-bg); color: var(--accent); font-weight: 700; text-transform: uppercase;
}
.agent-name { font-weight: 650; overflow-wrap: anywhere; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.dot.live { background: var(--ok); }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 0.875rem; margin: 12px 0 4px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.revoke-box { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.empty { text-align: center; padding: 18px 8px; }

h1 { font-size: 1.35rem; margin: 4px 0 12px; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space);
  margin-bottom: var(--space);
}

.agent-text {
  background: var(--agent-bg);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.agent-text::before {
  content: "Tekst van de agent";
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}

.row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row input[type="checkbox"] { margin-top: 4px; width: 20px; height: 20px; flex: none; }

.badge {
  display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.03em;
  padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; margin-right: 6px; vertical-align: 1px;
}
.badge-new { color: var(--new); }
.badge-update { color: var(--update); }
.badge-muted { color: var(--muted); }

.pairing-code {
  font: 700 2.4rem/1.1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.08em; text-align: center; padding: 18px 0; margin: 8px 0 12px;
  border: 2px dashed var(--line); border-radius: var(--radius);
}

label.field { display: block; margin-bottom: 12px; font-weight: 600; }
label.field span { display: block; font-size: 0.875rem; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="tel"] {
  width: 100%; font: inherit; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
input.code { font: 600 1.5rem ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.15em; text-align: center; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
button, .button {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 12px 16px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none;
  flex: 1 1 auto; text-align: center;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); border-color: var(--danger); }
button:disabled { opacity: 0.55; cursor: default; }

.error { color: var(--danger); font-weight: 600; margin: 8px 0 0; }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.success { color: var(--ok); font-weight: 650; }

.list-link { display: block; color: inherit; text-decoration: none; }
.list-link .row-title::after { content: " ›"; color: var(--muted); }

table.fields { width: 100%; border-collapse: collapse; font-size: 0.875rem; margin: 6px 0 10px; table-layout: fixed; }
table.fields th, table.fields td { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
table.fields th { color: var(--muted); font-weight: 600; width: 28%; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; margin: 6px 0; }
.check input { width: 20px; height: 20px; }
.check.sub { font-weight: 500; margin-left: 30px; color: var(--update); }

/* Brain */
.badge-delete { color: var(--danger); }
.update-text { color: var(--update); }
.brain-section { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 4px; }
pre.diff {
  margin: 0; padding: 8px 0; overflow-x: auto; border-radius: 8px; background: var(--bg);
  font: 0.8rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
pre.diff span { display: block; padding: 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-add { background: rgba(29, 138, 78, 0.14); }
.diff-del { background: rgba(192, 53, 43, 0.14); text-decoration: line-through; text-decoration-color: rgba(192, 53, 43, 0.5); }
.diff-ctx { color: var(--muted); }
.sticky-actions {
  position: sticky; bottom: env(safe-area-inset-bottom); z-index: 5;
  background: var(--bg); padding: 8px 0; margin: 0;
}
body.has-tabs .sticky-actions { bottom: calc(76px + env(safe-area-inset-bottom)); }

.file-card { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.file-card .row-title { overflow-wrap: anywhere; }
.file-excerpt { margin: 6px 0 0; color: var(--muted); max-height: 7.5em; overflow: hidden; }
