:root {
  --series-1: #2a78d6;
  --grid: #ebe7e1;
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #efebe6;
  --text: #1d1b19;
  --muted: #6d6760;
  --line: #e2ddd6;
  --accent: #d9482b;
  --accent-ink: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #e3f3ea;
  --warn: #9a6400;
  --warn-bg: #fbf0d9;
  --bad: #b3261e;
  --bad-bg: #fbe4e2;
  --info-bg: #e8eefc;
  --info: #2b4fb3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(30, 25, 20, .06), 0 4px 16px rgba(30, 25, 20, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --surface: #1f1d1b;
    --surface-2: #2a2724;
    --text: #f2eee9;
    --muted: #a59e95;
    --line: #34302c;
    --accent: #f0623f;
    --ok: #6fd3a0;
    --ok-bg: #1b3327;
    --warn: #f2c063;
    --warn-bg: #3a2e14;
    --bad: #ff8a80;
    --bad-bg: #3d1d1b;
    --info-bg: #1d2640;
    --info: #9db4ff;
    --series-1: #3987e5;
    --grid: #2e2b28;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* Knoppen */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  text-decoration: none; color: var(--text); white-space: nowrap; font-weight: 500;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 14px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; display: inline-grid; place-items: center; padding: 0;
}

/* Kop */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 880px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 18px; letter-spacing: -.01em; margin-right: auto; display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; background: var(--accent);
  display: inline-grid; place-items: center; color: #fff;
}
select.filter {
  min-height: 40px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); padding: 0 12px; max-width: 180px;
}

.banner {
  background: var(--warn-bg); color: var(--warn); text-align: center;
  padding: 8px 16px; font-size: 14px; font-weight: 500;
}

main { max-width: 880px; margin: 0 auto; padding: 16px 16px 80px; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin: 4px 0 18px; overflow-x: auto; }
.tab {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 999px;
  color: var(--muted); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.tab[aria-selected="true"] { background: var(--text); color: var(--bg); }
.tab .count { opacity: .7; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* Lijst */
.day { margin-bottom: 22px; }
.day h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin: 0 0 8px; font-weight: 600;
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px; display: grid;
  grid-template-columns: 76px 1fr; gap: 12px; margin-bottom: 10px;
}
.thumb {
  width: 76px; height: 76px; border-radius: 10px; overflow: hidden; background: var(--surface-2);
  position: relative;
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .stack {
  position: absolute; right: 4px; top: 4px; background: rgba(0,0,0,.6); color: #fff;
  font-size: 11px; padding: 1px 6px; border-radius: 999px;
}
.card-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.time { font-weight: 600; font-variant-numeric: tabular-nums; }
.acct { color: var(--muted); }
.badge {
  font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2);
  color: var(--muted); font-weight: 500;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.caption {
  color: var(--text); font-size: 14px; margin: 0;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.caption.empty { color: var(--muted); font-style: italic; }
.error-box {
  background: var(--bad-bg); color: var(--bad); border-radius: 10px;
  padding: 8px 10px; font-size: 13px; overflow-wrap: anywhere;
}
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.empty-state {
  text-align: center; padding: 56px 16px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty-state p { margin: 0 0 16px; }

/* Dialogen */
dialog {
  border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--text);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(20, 16, 12, .45); }
.dlg { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.dlg-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.dlg-head h3 { margin: 0; font-size: 17px; }
.dlg-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.dlg-foot {
  padding: 12px 18px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, textarea.input, select.input {
  width: 100%; min-height: 42px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg);
}
textarea.input { min-height: 110px; resize: vertical; }
.input:focus, .btn:focus-visible, .tab:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.hint { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.hint .over { color: var(--bad); font-weight: 600; }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.segmented button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 4px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px;
}
.segmented button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--surface); font-weight: 600; }

.drop {
  border: 1.5px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center;
  color: var(--muted); cursor: pointer; background: var(--bg);
}
.drop.over { border-color: var(--accent); color: var(--accent); }
.drop strong { color: var(--text); }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.preview { position: relative; border-radius: 10px; overflow: hidden; aspect-ratio: 1; background: var(--surface-2); }
.preview img, .preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview .pos {
  position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.6); color: #fff;
  font-size: 11px; padding: 1px 6px; border-radius: 999px;
}
.preview .tools { position: absolute; inset: auto 4px 4px 4px; display: flex; justify-content: space-between; }
.preview .tools button {
  width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer;
}
.form-errors { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.form-errors ul { margin: 0; padding-left: 18px; }

.acc-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.acc-row:last-child { border-bottom: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); object-fit: cover;
  display: grid; place-items: center; font-weight: 700; color: var(--muted); flex: none;
}
.acc-row .grow { flex: 1; min-width: 0; }
.acc-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

/* Weergave-schakelaar en statistieken */
.segment { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; }
.segment button { border: 0; background: transparent; border-radius: 999px; padding: 6px 12px; cursor: pointer; color: var(--muted); font-weight: 500; white-space: nowrap; }
.segment button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.stats-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.stats-bar #stats-refresh { margin-left: auto; }
.stats-meta { display: block; margin: 0 0 16px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.tile-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin: 2px 0; }
.tile-sub { font-size: 12px; color: var(--muted); }
.tile-sub.up { color: var(--ok); }
.tile-sub.down { color: var(--bad); }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 10px; margin-bottom: 14px; box-shadow: var(--shadow); }
.stat-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.stat-card-head h3 { margin: 0; font-size: 15px; }
.viz { position: relative; }
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-svg .grid { stroke: var(--grid); stroke-width: 1; }
.viz-svg .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-svg .label { fill: var(--text); font-size: 12px; font-weight: 600; }
.viz-svg .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-svg .area { fill: var(--series-1); opacity: .1; }
.viz-svg .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.viz-svg .cross { stroke: var(--muted); stroke-width: 1; }
.viz-svg .bar { fill: var(--series-1); opacity: .55; }
.viz-svg .bar.peak, .viz-svg .bar.hover { opacity: 1; }
.viz-tip {
  position: absolute; pointer-events: none; background: var(--text); color: var(--bg); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.18); z-index: 2;
}
.viz-tip .k { opacity: .75; }
.viz-tip .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-table { margin-top: 6px; font-size: 13px; }
.viz-table summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
.viz-table table { border-collapse: collapse; width: 100%; max-width: 420px; margin-top: 6px; }
.viz-table td, .viz-table th { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.viz-table td:last-child, .viz-table th:last-child { text-align: right; }
.top-posts { display: flex; flex-direction: column; gap: 8px; }
.top-post { display: grid; grid-template-columns: 64px 1fr; gap: 12px; text-decoration: none; color: var(--text); padding: 8px; border-radius: 12px; border: 1px solid var(--line); }
.top-post:hover { background: var(--surface-2); }
.top-post .thumb { width: 64px; height: 64px; }
.tp-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tp-nums { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.tp-nums b { color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Bijsnijden */
.crop-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.crop-stage { align-items: center; justify-content: center; background: var(--surface-2); }
#crop-canvas { display: block; border-radius: 6px; cursor: grab; touch-action: none; box-shadow: 0 0 0 1px var(--line); background: #000; }
#crop-canvas:active { cursor: grabbing; }
#crop-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.crop-zoom { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); width: min(360px, 100%); }
.crop-zoom input { flex: 1; accent-color: var(--accent); }
.crop-dialog .dlg { height: auto; max-height: calc(100dvh - 24px); }
.preview .tools .crop { width: auto; padding: 0 8px; border-radius: 999px; font-size: 12px; }
.preview .cropped {
  position: absolute; left: 4px; bottom: 34px; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 999px;
}

/* NAS-verkenner */
dialog.wide { width: min(880px, calc(100vw - 24px)); }
dialog.wide .dlg { height: min(720px, calc(100dvh - 24px)); }
dialog.wide .dlg-body { flex: 1; }
#btn-nas { align-self: flex-start; }
.nas-bar { display: flex; gap: 8px; align-items: center; padding: 10px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.nas-root { width: auto; min-height: 36px; padding: 6px 10px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 14px; min-width: 0; }
.crumbs button { border: 0; background: none; padding: 4px 6px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.crumbs button:hover { background: var(--surface-2); color: var(--text); }
.crumbs button[aria-current="page"] { color: var(--text); font-weight: 600; cursor: default; }
.crumbs .sep { color: var(--muted); }
.nas-body { gap: 12px; }
.nas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.nas-folder, .nas-file {
  border: 1px solid var(--line); background: var(--bg); border-radius: 12px; cursor: pointer;
  text-align: left; padding: 0; overflow: hidden; position: relative; color: var(--text);
}
.nas-folder { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 14px; min-height: 48px; }
.nas-folder:hover, .nas-file:hover { border-color: var(--muted); }
.nas-folder span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nas-file .pic { aspect-ratio: 1; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.nas-file .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nas-file .name { font-size: 12px; padding: 6px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nas-file[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.nas-file .check {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0,0,0,.45); border: 2px solid #fff; color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.nas-file[aria-pressed="true"] .check { background: var(--accent); }
.nas-file[disabled] { opacity: .45; cursor: not-allowed; }
.nas-file .tag {
  position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 999px;
}
.nas-empty { color: var(--muted); text-align: center; padding: 40px 0; }
.nas-count { margin-right: auto; align-self: center; }
.preview .src-badge {
  position: absolute; right: 4px; top: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 999px;
}
.preview .ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 50; max-width: calc(100vw - 32px); font-size: 14px;
}
.toast.bad { background: var(--bad); color: #fff; }

/* Inlogpagina */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
}
.login-card h1 { margin: 0; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.login-card p { margin: 0; color: var(--muted); font-size: 14px; }
.login-error { color: var(--bad); font-size: 14px; min-height: 1.2em; }

@media (max-width: 520px) {
  .topbar-inner { gap: 8px; }
  .brand { flex: 1; }
  .segment.views { order: 4; width: 100%; }
  .segment.views button { flex: 1; }
  #btn-new { order: 1; }
  select.filter { order: 2; flex: 1 1 60%; max-width: none; }
  #btn-accounts { order: 3; }
  #dlg-post .dlg-foot .btn.ghost { display: none; }
  .dlg-foot .btn { flex: 1; padding: 0 10px; }
  .card { grid-template-columns: 64px 1fr; }
  .thumb { width: 64px; height: 64px; }
  .segmented button span.lbl { font-size: 12px; }
}
