:root {
  --bg: #0B0F1E;
  --bg-alt: #12172C;
  --surface: rgba(255,255,255,0.055);
  --surface-strong: rgba(255,255,255,0.09);
  --border: rgba(255,255,255,0.10);
  --text: #F1F5F9;
  --muted: #8B93A7;
  --accent1: #8B5CF6;
  --accent2: #22D3EE;
  --gradient: linear-gradient(135deg, #8B5CF6 0%, #22D3EE 100%);
  --green: #34D399;
  --red: #FB7185;
  --blue: #38BDF8;
  --purple: #C084FC;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ---------- Animated background blobs ---------- */
.bg-blobs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.35;
  animation: drift 22s ease-in-out infinite;
}
.blob1 { width: 320px; height: 320px; background: #8B5CF6; top: -80px; left: -60px; animation-delay: 0s; }
.blob2 { width: 280px; height: 280px; background: #22D3EE; bottom: -60px; right: -60px; animation-delay: -7s; }
.blob3 { width: 220px; height: 220px; background: #F472B6; top: 40%; left: 50%; animation-delay: -14s; opacity: 0.22; }

@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.08); }
  66% { transform: translate(-20px, 25px) scale(0.95); }
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* ---------- Header ---------- */
.app-header {
  padding: 18px 20px 10px;
  flex-shrink: 0;
}
.header-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.header-title .grad {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.header-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ---------- Screens ---------- */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.screen.active { display: flex; }

/* ---------- Chat screen ---------- */
.inbox-pill {
  margin: 0 16px 10px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #FCD34D;
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 0.82rem;
  text-align: center;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FCD34D;
  box-shadow: 0 0 0 0 rgba(252,211,77,0.7);
  animation: pulse 1.8s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(252,211,77,0.55); }
  70% { box-shadow: 0 0 0 8px rgba(252,211,77,0); }
  100% { box-shadow: 0 0 0 0 rgba(252,211,77,0); }
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  align-self: flex-end;
  background: var(--gradient);
  color: #fff;
  padding: 12px 16px;
  border-radius: 18px 18px 4px 18px;
  max-width: 82%;
  font-size: 0.92rem;
  line-height: 1.45;
  word-break: break-word;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.25);
}
.bubble.unsorted {
  background: var(--surface-strong);
  color: var(--text);
  border: 1px dashed var(--accent2);
  box-shadow: none;
}
.bubble.status-archived { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.bubble.status-task { background: rgba(52, 211, 153, 0.14); color: #6EE7B7; border: 1px solid rgba(52,211,153,0.35); box-shadow: none; }
.bubble a { color: inherit; text-decoration: underline; }
.bubble img { max-width: 100%; border-radius: 12px; display: block; margin-top: 4px; }
.bubble .meta { font-size: 0.68rem; opacity: 0.75; margin-top: 6px; }
.bubble .tag-chip { display:inline-block; font-size:0.68rem; background:rgba(255,255,255,0.15); padding:1px 8px; border-radius:8px; margin-top:6px; }

.inline-tag {
  color: var(--accent2);
  font-weight: 700;
  cursor: pointer;
}
.inline-tag:hover { text-decoration: underline; }
.inline-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(34, 211, 238, 0.16);
  border: 1px solid rgba(34, 211, 238, 0.4);
  color: inherit;
  text-decoration: none;
  padding: 1px 8px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.link-count {
  background: rgba(255,255,255,0.25);
  color: inherit;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  line-height: 15px;
  border-radius: 8px;
  padding: 0 4px;
  text-align: center;
}

/* ---------- Link chooser popover ---------- */
.link-menu {
  position: absolute;
  z-index: 60;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  min-width: 220px;
  max-width: 280px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
  backdrop-filter: blur(16px);
}
.link-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.link-menu-item:hover { background: var(--surface-strong); }
.link-menu-empty {
  padding: 10px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- Composer (Twitter-style) ---------- */
.composer { padding: 10px 16px 16px; flex-shrink: 0; }
.composer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 14px 16px 10px;
  backdrop-filter: blur(12px);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer-card:focus-within {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(34,211,238,0.15);
}
#text-input {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.5;
  font-family: inherit;
  min-height: 24px;
  max-height: 240px;
}
#text-input::placeholder { color: var(--muted); }

.preview-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.preview-chips:empty { margin-top: 0; }
.chip {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 10px;
  font-weight: 600;
}
.chip.chip-tag { background: rgba(34,211,238,0.14); color: var(--accent2); border: 1px solid rgba(34,211,238,0.3); }
.chip.chip-link { background: rgba(139,92,246,0.16); color: #C4B5FD; border: 1px solid rgba(139,92,246,0.35); }

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.composer-tools { display: flex; gap: 4px; }
.tool-btn {
  border: none;
  background: none;
  color: var(--accent2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.05rem;
  cursor: pointer;
}
.tool-btn:hover { background: var(--surface-strong); }
.tool-btn.recording { background: var(--red); color: #fff; }

.composer-actions { display: flex; align-items: center; gap: 10px; }
.char-count { font-size: 0.7rem; color: var(--muted); }
.post-btn {
  border: none;
  background: var(--gradient);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 9px 18px;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 14px rgba(139,92,246,0.35);
}
.post-btn:active { transform: scale(0.96); }

/* ---------- Swipe screen ---------- */
.swipe-progress {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 6px 0 0;
  font-weight: 600;
}
.swipe-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 10px;
  flex-shrink: 0;
}
.swipe-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card-stack {
  position: relative;
  width: 84%;
  height: 62%;
}
.card {
  position: absolute;
  inset: 0;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  padding: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.12rem;
  line-height: 1.5;
  cursor: grab;
  touch-action: none;
  user-select: none;
  word-break: break-word;
  backdrop-filter: blur(16px);
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 26px;
  padding: 1px;
  background: var(--gradient);
  opacity: 0.5;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.card img { max-width: 100%; max-height: 100%; border-radius: 14px; object-fit: contain; }
.card.dragging { cursor: grabbing; transition: none; }
.card.returning { transition: transform 0.25s ease; }
.card.exiting { transition: transform 0.35s ease, opacity 0.35s ease; }

.edge-glow {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  border-radius: 12px;
  z-index: 5;
}
.edge-top { top: 8px; left: 50%; transform: translateX(-50%); color: var(--blue); }
.edge-bottom { bottom: 8px; left: 50%; transform: translateX(-50%); color: var(--purple); }
.edge-left { left: 8px; top: 50%; transform: translateY(-50%); color: var(--red); font-size: 1.4rem; }
.edge-right { right: 8px; top: 50%; transform: translateY(-50%); color: var(--green); }
.edge-glow.show { opacity: 1; }

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 1.05rem;
}
.empty-emoji { font-size: 2.4rem; margin-bottom: 8px; }

/* ---------- Archive screen ---------- */
.archive-search { padding: 4px 16px 4px; }
.archive-search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 16px;
  font-size: 0.95rem;
  outline: none;
  color: var(--text);
}
.archive-search input::placeholder { color: var(--muted); }
.archive-search input:focus { border-color: var(--accent2); }

.filter-block { padding: 8px 16px 0; }
.filter-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.tag-cloud {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.tag-pill {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px;
  padding: 6px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}
.tag-pill.active { background: var(--gradient); border-color: transparent; color: #fff; }
.hashtag-cloud .tag-pill { color: var(--accent2); }
.hashtag-cloud .tag-pill.active { color: #fff; }
.no-tags { font-size: 0.8rem; color: var(--muted); padding: 4px 2px; }

.timeline {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 16px 12px;
}
.bucket-header {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 16px 0 8px;
}
.archive-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 13px 15px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  scroll-margin-top: 20px;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
  overflow-wrap: break-word;
  word-break: break-word;
}
.archive-item .meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 8px;
}
.archive-item img { max-width: 100%; border-radius: 10px; }
.archive-item.is-task { border-left: 3px solid var(--green); }
.archive-item.is-inbox { border-style: dashed; border-color: var(--accent2); }
.archive-item.flash {
  border-color: var(--accent2);
  box-shadow: 0 0 0 3px rgba(34,211,238,0.25);
}

.no-results { text-align: center; color: var(--muted); padding: 40px 0; font-size: 0.9rem; }

/* ---------- Floating dock nav ---------- */
.dock {
  position: relative;
  display: flex;
  margin: 0 16px 16px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 6px;
  backdrop-filter: blur(16px);
  flex-shrink: 0;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.dock-indicator {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: calc(50% - 4px);
  background: var(--gradient);
  border-radius: 16px;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 0;
  box-shadow: 0 4px 14px rgba(139,92,246,0.4);
}
.dock-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  border: none;
  background: none;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 600;
  transition: color 0.2s ease;
}
.dock-btn.active { color: #fff; }
.dock-icon { font-size: 1.15rem; }
.badge {
  position: absolute;
  top: 2px;
  right: 18%;
  background: var(--red);
  color: #fff;
  font-size: 0.62rem;
  min-width: 15px;
  height: 15px;
  line-height: 15px;
  border-radius: 8px;
  padding: 0 3px;
}

/* ---------- Tag modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(5,7,15,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 24px;
  width: 85%;
  max-width: 340px;
  text-align: center;
}
.modal-card h3 { margin: 0 0 16px; font-size: 1rem; color: var(--text); }
.tag-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.tag-options button {
  padding: 13px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}
.tag-options button:hover { border-color: var(--accent2); }
.modal-cancel {
  border: none;
  background: none;
  color: var(--muted);
  padding: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

/* ---------- Checklist / taken ---------- */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}
.task-item input[type="checkbox"] {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  accent-color: var(--accent2);
  cursor: pointer;
}
.task-item.done span { text-decoration: line-through; opacity: 0.55; }
.task-item.readonly { cursor: default; opacity: 0.9; }
.task-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  flex-shrink: 0;
}
.task-item.single { margin-top: 8px; font-weight: 600; }
.chip.chip-task { background: rgba(52,211,153,0.16); color: var(--green); border: 1px solid rgba(52,211,153,0.35); }

/* ---------- Archief: swipe-to-delete ---------- */
.archive-row {
  position: relative;
  margin-bottom: 8px;
}
.archive-row .archive-item { margin-bottom: 0; }
.archive-delete-bg {
  position: absolute;
  inset: 0;
  background: var(--red);
  color: #fff;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 20px;
  font-weight: 700;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.archive-delete-bg.show { opacity: 1; }
.archive-item {
  position: relative;
  z-index: 1;
  touch-action: pan-y;
  transition: transform 0.2s ease;
}
.archive-item.dragging { transition: none; }
.del-btn {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 0 0 6px;
  vertical-align: middle;
}
.del-btn:hover { color: var(--red); }

/* ---------- Icoon-uitlijning (flat SVG i.p.v. emoji) ---------- */
.dock-icon svg,
.tool-btn svg,
.del-btn svg,
.post-btn svg,
.empty-icon {
  display: block;
}
.edge-glow span {
  display: flex;
  align-items: center;
  gap: 5px;
}
.inbox-pill svg { flex-shrink: 0; }
.tag-options button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.post-btn { gap: 6px; }
.chip svg { vertical-align: -2px; margin-right: 2px; }
.empty-icon { color: var(--accent2); margin-bottom: 10px; }
.empty-state { display: flex; flex-direction: column; align-items: center; }

/* ---------- Zwevende scrollknop (FAB) ---------- */
.fab {
  position: absolute;
  right: 16px;
  bottom: 92px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(139, 92, 246, 0.45);
  z-index: 30;
  opacity: 1;
  transform: scale(1);
  transition: opacity 0.2s ease, transform 0.2s ease, bottom 0.15s ease;
}
.fab.hidden {
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
}
.fab svg { display: block; }

/* ---------- Toast (foutmeldingen) ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%) translateY(16px);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 80;
  max-width: 85%;
  text-align: center;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error {
  border-color: rgba(251, 113, 133, 0.5);
  color: #FCA5A5;
  background: #1E1420;
}

/* ---------- Pin ---------- */
.archive-item.pinned {
  border-color: #FBBF24;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.3);
}
.bubble.pinned {
  box-shadow: 0 0 0 2px #FBBF24, 0 4px 16px rgba(139, 92, 246, 0.25);
}
.card.pinned::before {
  background: linear-gradient(135deg, #FBBF24, #F59E0B);
  opacity: 0.8;
}
.bucket-header.pinned-header {
  color: #FBBF24;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bucket-header.pinned-header svg { display: block; }

/* ---------- Archief: pin/bewerk/verwijder-knoppen ---------- */
.meta-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-action {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
.icon-action:hover { color: var(--text); }
.icon-action.pin-btn.active { color: #FBBF24; }
.icon-action.del-btn:hover { color: var(--red); }

/* ---------- Basis markdown ---------- */
.bubble strong,
.archive-item strong { font-weight: 800; }
.bubble em,
.archive-item em { font-style: italic; }
.bubble del,
.archive-item del { opacity: 0.65; }
.auto-link {
  color: var(--accent2);
  text-decoration: underline;
  word-break: break-all;
}
.bubble code,
.archive-item code {
  background: rgba(255,255,255,0.12);
  padding: 1px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
}

/* ---------- Bewerk-modal ---------- */
.modal-card-wide { max-width: 420px; text-align: left; }
.modal-card-wide h3 { text-align: center; }
#edit-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.5;
  font-family: inherit;
  resize: none;
  min-height: 90px;
  max-height: 240px;
  outline: none;
}
#edit-textarea::placeholder { color: var(--muted); }
#edit-textarea:focus { border-color: var(--accent2); }
#edit-preview-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
#edit-preview-chips:empty { margin-top: 0; }
.edit-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}
