:root {
  --bg: #0f0f0f;
  --bg2: #1a1a1a;
  --bg3: #242424;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --text2: #888;
  --accent: #6366f1;
  --accent-h: #818cf8;
  --danger: #ef4444;
  --success: #22c55e;
  --warn: #f59e0b;
  --low: #64748b;
  --med: #f59e0b;
  --high: #ef4444;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* Layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
@media (max-width: 680px) { .layout { grid-template-columns: 1fr; } }

/* Sidebar */
.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  padding: 4px 8px 12px;
  letter-spacing: -0.3px;
}
.sidebar-title span { opacity: 0.5; font-weight: 400; font-size: 14px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  color: var(--text2);
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .badge {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}
.nav-section { font-size: 11px; color: var(--text2); padding: 12px 10px 4px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }

.sidebar-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.shortcuts-hint { font-size: 11px; color: var(--text2); padding: 4px 8px; line-height: 1.8; }
kbd { background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 10px; font-family: monospace; }

/* Main */
.main { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-ghost { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid transparent; }
.btn-danger:hover { background: rgba(239,68,68,0.1); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

/* Quick add */
.quick-add {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.quick-add.quick-action-active {
  background: linear-gradient(180deg, rgba(99,102,241,0.14), rgba(99,102,241,0.04));
}
.quick-add-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.quick-add-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 15px;
  color: var(--text);
  font-family: var(--font);
  transition: border-color 0.15s;
}
.quick-add-input:focus { outline: none; border-color: var(--accent); }
.quick-add-input::placeholder { color: var(--text2); }
.quick-add.quick-action-active .quick-add-input {
  border-color: rgba(129,140,248,0.8);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.14);
}

#btn-mic .mic-label { display: none; }

.quick-add.voice-mode #btn-mic {
  min-width: 152px;
  justify-content: center;
  font-weight: 700;
  border-color: rgba(129,140,248,0.8);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.14);
}

.quick-add.voice-mode #btn-mic .mic-label { display: inline; }

.quick-add.voice-mode #btn-mic.listening {
  background: rgba(239,68,68,0.18);
  border-color: rgba(239,68,68,0.75);
  color: #fff;
}

body.voice-screen-active { overflow: hidden; }
body.voice-screen-active .topbar,
body.voice-screen-active .stats-bar,
body.voice-screen-active .filters,
body.voice-screen-active #suggestions-container,
body.voice-screen-active #todo-list,
body.voice-screen-active .sidebar,
body.voice-screen-active .mobile-nav {
  display: none !important;
}

.quick-add.voice-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  border-bottom: 0;
  background:
    radial-gradient(circle at top, rgba(129,140,248,0.18), transparent 48%),
    linear-gradient(180deg, rgba(15,15,15,0.98), rgba(26,26,26,0.98));
}

.quick-add.voice-screen .quick-add-form {
  display: none;
}

.voice-capture.hidden {
  display: none;
}

.voice-capture {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.voice-textarea {
  width: 100%;
  flex: 1;
  min-height: 32vh;
  resize: none;
  border: 1px solid rgba(129,140,248,0.45);
  border-radius: 18px;
  background: rgba(24,24,27,0.96);
  color: var(--text);
  padding: 18px;
  font: inherit;
  font-size: 24px;
  line-height: 1.4;
  box-shadow: 0 12px 40px rgba(0,0,0,0.28);
}

.voice-textarea:focus {
  outline: none;
  border-color: rgba(129,140,248,0.85);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.18);
}

.voice-action-btn {
  width: 100%;
  min-height: min(42vh, 320px);
  border: 0;
  border-radius: 28px;
  padding: 24px;
  background: linear-gradient(180deg, #818cf8, #6366f1);
  color: #fff;
  font: inherit;
  font-size: clamp(28px, 7vw, 42px);
  font-weight: 800;
  letter-spacing: -0.03em;
  box-shadow: 0 24px 50px rgba(79,70,229,0.38);
}

.voice-action-btn.listening {
  background: linear-gradient(180deg, #fb7185, #ef4444);
  box-shadow: 0 24px 50px rgba(239,68,68,0.32);
}

.voice-action-btn.ready {
  background: linear-gradient(180deg, #34d399, #16a34a);
  box-shadow: 0 24px 50px rgba(22,163,74,0.3);
}

.quick-action-panel {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(129,140,248,0.35);
  background: rgba(36,36,36,0.9);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.quick-action-copy { min-width: 0; }

.quick-action-title {
  font-size: 13px;
  font-weight: 700;
  color: #c7d2fe;
  margin-bottom: 2px;
}

.quick-action-text {
  font-size: 13px;
  color: var(--text);
}

.quick-action-panel.error { border-color: rgba(239,68,68,0.45); }
.quick-action-panel.success { border-color: rgba(34,197,94,0.45); }

/* Filters */
.filters {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}
.filter-label { font-size: 12px; color: var(--text2); }
.filter-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  transition: all 0.15s;
}
.filter-chip:hover { border-color: var(--accent); color: var(--accent); }
.filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Todo list */
.todo-list { padding: 16px 24px; display: flex; flex-direction: column; gap: 8px; }

.todo-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  transition: all 0.15s;
  cursor: pointer;
  position: relative;
}
.todo-item:hover { border-color: var(--accent); }
.todo-item.completed { opacity: 0.45; }
.todo-item.completed .todo-title { text-decoration: line-through; color: var(--text2); }
.todo-item.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(99,102,241,0.2); }

.todo-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.todo-check:hover { border-color: var(--accent); }
.todo-check.checked { background: var(--success); border-color: var(--success); }
.todo-check.checked::after { content: '✓'; color: #fff; font-size: 11px; font-weight: 700; }

.todo-body { min-width: 0; }
.todo-title { font-size: 15px; font-weight: 500; margin-bottom: 4px; word-break: break-word; }
.todo-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.todo-desc { font-size: 13px; color: var(--text2); margin-bottom: 6px; }

.badge-cat {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
}
.badge-prio {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.prio-1 { background: rgba(100,116,139,0.2); color: var(--low); }
.prio-2 { background: rgba(245,158,11,0.15); color: var(--med); }
.prio-3 { background: rgba(239,68,68,0.15); color: var(--high); }
.badge-due { font-size: 11px; color: var(--text2); }
.badge-due.overdue { color: var(--danger); font-weight: 600; }
.badge-due.today { color: var(--warn); font-weight: 600; }
.badge-tag {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(99,102,241,0.15);
  color: var(--accent-h);
}
.ai-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.3 } }

.todo-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.todo-item:hover .todo-actions { opacity: 1; }
.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg3); color: var(--text); }
.icon-btn.del:hover { color: var(--danger); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--text2); font-weight: 500; }
.field input, .field textarea, .field select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  font-family: var(--font);
  transition: border-color 0.15s;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 72px; }
.field select option { background: var(--bg2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* AI suggestions */
.suggestions-bar {
  margin: 0 24px 8px;
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.suggestions-title { font-size: 12px; color: var(--accent-h); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.suggestions-list { display: flex; flex-wrap: wrap; gap: 6px; }
.suggestion-chip {
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(99,102,241,0.3);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.suggestion-chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text2);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* Stats */
.stats-bar {
  display: flex;
  gap: 16px;
  padding: 10px 24px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text2);
}
.stat { display: flex; align-items: center; gap: 6px; }
.stat-n { font-weight: 700; color: var(--text); }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 14px;
  z-index: 999;
  animation: slideIn 0.2s ease;
  max-width: 320px;
}
@keyframes slideIn { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.hidden { display: none !important; }

/* Priority colors on left border */
.todo-item[data-prio="3"] { border-left: 3px solid var(--high); }
.todo-item[data-prio="2"] { border-left: 3px solid var(--med); }
.todo-item[data-prio="1"] { border-left: 3px solid var(--low); }

/* Mobile overlay (behind drawer) */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
}
.mobile-overlay.visible { display: block; }

/* Mobile bottom nav */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  z-index: 150;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  font-size: 10px;
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
}
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-icon { font-size: 20px; line-height: 1; }
.mobile-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
  vertical-align: middle;
}
.mobile-badge:empty { display: none; }

/* Hide hamburger on desktop */
.mobile-menu-btn { display: none; }

/* Drag-and-drop */
.todo-item[draggable="true"] { cursor: grab; }
.todo-item[draggable="true"]:active { cursor: grabbing; }
.todo-item.dragging { opacity: 0.35; }
.todo-item.drag-over { border-top: 2px solid var(--accent); }
.todo-item.drag-nest { border: 2px dashed #a855f7; background: rgba(168,85,247,0.07); position: relative; }
.todo-item.drag-nest::after { content: '↳ subtaak'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 11px; color: #a855f7; font-weight: 600; pointer-events: none; }

/* Subtask toggle button */
.subtask-toggle {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text2);
  padding: 3px 9px;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
  font-family: var(--font);
}
.subtask-toggle:hover { border-color: var(--accent); color: var(--accent); }
.subtask-toggle.open { border-color: var(--accent); color: var(--accent); background: rgba(99,102,241,0.1); }

/* Subtask section */
.subtask-section {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.subtask-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.subtask-item.done .subtask-title {
  text-decoration: line-through;
  color: var(--text2);
}
.subtask-check {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.subtask-check:hover { border-color: var(--accent); }
.subtask-check.checked { background: var(--success); border-color: var(--success); }
.subtask-check.checked::after { content: '✓'; color: #fff; font-size: 8px; font-weight: 700; }
.subtask-title { flex: 1; font-size: 13px; color: var(--text); }
.subtask-del {
  width: 18px;
  height: 18px;
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.subtask-item:hover .subtask-del { opacity: 1; }
.subtask-add-form {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.subtask-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 13px;
  color: var(--text);
  font-family: var(--font);
  transition: border-color 0.15s;
}
.subtask-input:focus { outline: none; border-color: var(--accent); }
.subtask-input::placeholder { color: var(--text2); }

/* Mobile */
@media (max-width: 680px) {
  /* Sidebar becomes slide-in drawer */
  .sidebar {
    display: flex;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 260px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }

  /* Hide keyboard shortcuts on mobile */
  .shortcuts-hint { display: none; }

  /* Bottom nav visible */
  .mobile-nav { display: flex; }

  /* Hamburger visible */
  .mobile-menu-btn { display: inline-flex; }

  /* Hide desktop-only elements */
  .desktop-only { display: none !important; }

  /* Push content above bottom nav (60px nav + safe area) */
  .main { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }

  /* Toast above bottom nav */
  .toast { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); right: 12px; left: 12px; max-width: none; }

  /* Padding adjustments */
  .topbar { padding: 12px 16px; }
  .quick-add { padding: 12px 16px; }
  .filters { padding: 8px 16px; }
  .todo-list { padding: 12px 16px; gap: 6px; }
  .stats-bar { padding: 8px 16px; }

  .quick-add-form { flex-wrap: wrap; }
  .quick-add-form .quick-add-input { width: 100%; }
  .quick-add.voice-mode #btn-mic,
  .quick-add-form .btn[type="submit"] { flex: 1 1 calc(50% - 4px); }
  .quick-action-panel { flex-direction: column; align-items: stretch; }
  .quick-add.voice-screen {
    min-height: 100vh;
    padding-left: 14px;
    padding-right: 14px;
  }
  .voice-textarea { font-size: 22px; min-height: 28vh; }
  .voice-action-btn { min-height: 38vh; border-radius: 24px; }

  /* Todo actions always visible on touch */
  .todo-actions { opacity: 1; }

  /* Modal fields stack vertically */
  .field-row { grid-template-columns: 1fr; gap: 10px; }

  /* Modal fills screen on mobile */
  .modal { max-width: 100% !important; border-radius: 12px; padding: 20px 16px; }
}

/* ── Mobile: grotere knoppen + overflow fix ── */
html { overflow-x: hidden; }
body { overflow-x: hidden; max-width: 100vw; }

@media (max-width: 680px) {
  /* Grotere aanraakgebieden (min 44px) */
  .btn         { min-height: 44px; padding: 10px 16px; font-size: 15px; }
  .btn-sm      { min-height: 44px; padding: 10px 14px; font-size: 14px; }
  .filter-chip { min-height: 44px; padding: 8px 16px;  font-size: 14px; }
  .icon-btn    { width: 44px; height: 44px; font-size: 18px; border-radius: 8px; }
  .todo-check  { width: 28px; height: 28px; margin-top: 0; }
  .subtask-check { width: 22px; height: 22px; }
  .quick-add-input { min-height: 44px; padding: 12px 14px; font-size: 16px; }
  .nav-item    { min-height: 44px; font-size: 15px; padding: 10px 12px; }

  /* Bottom nav groter */
  .mobile-nav-item { padding: 10px 4px 8px; font-size: 11px; }
  .mobile-nav-icon { font-size: 22px; }

  /* Zorg dat todo-items niet overflowt */
  .todo-item   { min-width: 0; }
  .todo-title  { overflow-wrap: break-word; word-break: break-word; }
  .todo-list   { overflow-x: hidden; }

  /* Verberg overbodige topbar-knoppen op mobiel */
  #btn-notifications, #btn-export-notion, #btn-suggest { display: none !important; }
}
