/* =====================================================
   MDT Notes — Main Stylesheet
   Dark theme, tablet-optimised, floating sidebar
   ===================================================== */

:root {
  --bg-primary:   #0f172a;
  --bg-secondary: #1e293b;
  --bg-card:      #1e293b;
  --bg-input:     #0f172a;
  --accent:       #6366f1;
  --accent-hover: #4f46e5;
  --accent-dim:   rgba(99,102,241,.15);
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --border:       rgba(255,255,255,.08);
  --border-hover: rgba(255,255,255,.15);
  --danger:   #ef4444;
  --success:  #22c55e;
  --warning:  #f59e0b;
  --info:     #3b82f6;
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --sidebar-w:  62px;
  --sidebar-ew: 224px;
  --shadow:  0 4px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.5);
  --transition: .25s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* ── Floating Sidebar ───────────────────────────────── */
.sidebar {
  position: fixed;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 200;
  width: var(--sidebar-w);
  background: rgba(15,23,42,.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,.06);
  overflow: hidden;
  transition: width var(--transition);
  display: flex;
  flex-direction: column;
  padding: 6px 0 8px;
}
.sidebar.expanded { width: var(--sidebar-ew); }

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 46px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  transition: color var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--text-primary); }

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 14px;
}

.sidebar-nav { display: flex; flex-direction: column; flex: 1; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 17px;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
  font-size: .9rem;
  font-weight: 500;
  min-height: 44px;
}
.sidebar-item:hover { color: var(--text-primary); background: rgba(255,255,255,.06); }
.sidebar-item.active { color: var(--accent); background: var(--accent-dim); }
.sidebar-item-danger { color: #f87171; }
.sidebar-item-danger:hover { color: var(--danger); background: rgba(239,68,68,.1); }

.sidebar-icon { width: 28px; min-width: 28px; text-align: center; font-size: 1.05rem; }

.sidebar-drag-handle {
  margin-left: auto;
  padding-left: 8px;
  opacity: 0;
  pointer-events: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  transition: opacity var(--transition);
}

.sidebar-item-muted {
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  color: var(--text-secondary);
}
.sidebar-item-muted:hover { color: var(--text-primary); background: rgba(255,255,255,.06); }

.sidebar.reorder-mode .sidebar-item[data-nav-key] { cursor: grab; }
.sidebar.reorder-mode .sidebar-drag-handle { opacity: 1; }
.sidebar-item[data-nav-key].dragging { opacity: 0.35; }
.sidebar-item[data-nav-key].drag-over { box-shadow: inset 0 2px 0 var(--accent); }

.sidebar-label {
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.sidebar.expanded .sidebar-label { opacity: 1; }

/* Backdrop when sidebar is expanded */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  z-index: 190;
  background: rgba(0,0,0,.35);
}
.sidebar-backdrop.visible { display: block; }

/* ── Main Content ───────────────────────────────────── */
.main-content {
  min-height: 100vh;
  padding: 28px 28px 28px 96px;
}
.main-content.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 14px;
}
.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}
.page-subtitle {
  font-size: .95rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Flash Messages ─────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideIn .3s ease;
}
@keyframes slideIn {
  from { opacity:0; transform: translateX(40px); }
  to   { opacity:1; transform: translateX(0); }
}
.flash-success { background: #166534; border: 1px solid #15803d; color: #bbf7d0; }
.flash-danger  { background: #7f1d1d; border: 1px solid #991b1b; color: #fecaca; }
.flash-warning { background: #78350f; border: 1px solid #92400e; color: #fef3c7; }
.flash-info    { background: #1e3a5f; border: 1px solid #1d4ed8; color: #bfdbfe; }
.flash-close {
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: .7; font-size: 1.1rem;
  padding: 2px 4px; line-height: 1;
}
.flash-close:hover { opacity: 1; }

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--border-hover); }
.card-link:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-meta {
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.card-excerpt {
  font-size: .875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* ── Grid layouts ───────────────────────────────────── */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.grid-cards-lg {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), box-shadow var(--transition),
              border-color var(--transition), transform .1s;
  text-decoration: none;
  white-space: nowrap;
  min-height: 42px;
  line-height: 1;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--bg-secondary); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--border-hover); background: #334155; }
.btn-danger    { background: rgba(239,68,68,.15); color: var(--danger); border-color: rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.25); border-color: var(--danger); }
.btn-ghost { background: none; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: rgba(255,255,255,.06); }
.btn-sm { padding: 6px 14px; font-size: .82rem; min-height: 34px; }
.btn-icon { padding: 9px; min-width: 42px; justify-content: center; }

/* ── Forms ──────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: .95rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 44px;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 180px; line-height: 1.6; }
select.form-control { cursor: pointer; padding-right: 32px; }
.form-control.code-area {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: .88rem;
  min-height: 280px;
  tab-size: 4;
}
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: 5px; }

/* ── Auth Pages ─────────────────────────────────────── */
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo-icon {
  width: 56px; height: 56px;
  background: var(--accent-dim);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 14px;
}
.auth-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.auth-subtitle {
  text-align: center;
  font-size: .9rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}
.auth-footer {
  text-align: center;
  margin-top: 22px;
  font-size: .875rem;
  color: var(--text-secondary);
}

/* ── Tag Badges ─────────────────────────────────────── */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-decoration: none;
  color: #fff;
  opacity: .9;
  transition: opacity var(--transition);
}
.tag-badge:hover { opacity: 1; color: #fff; }
.tags-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ── Tag Picker (in forms) ──────────────────────────── */
.tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 54px;
}
.tag-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 20px;
  border: 2px solid var(--tag-color, var(--accent));
  color: var(--tag-color, var(--accent));
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  transition: all var(--transition);
  user-select: none;
}
.tag-option input[type="checkbox"] { display: none; }
.tag-option.selected {
  background: var(--tag-color, var(--accent));
  color: #fff;
}
.tag-option:hover { filter: brightness(1.1); }

/* ── Tag Cloud ──────────────────────────────────────── */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 10px; padding: 8px 0; }

.tag-cloud-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  transition: transform var(--transition), box-shadow var(--transition);
}
.tag-cloud-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  color: #fff;
}
.tag-cloud-item .tag-count {
  background: rgba(0,0,0,.25);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: .72rem;
}

/* ── Tags Management Cards ──────────────────────────── */
.tag-manage-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 14px;
  transition: border-color var(--transition);
}
.tag-manage-card:hover { border-color: var(--border-hover); }
.tag-manage-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.tag-color-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.tag-manage-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Stats ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  text-align: center;
}
.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}
.stat-label {
  font-size: .82rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}

/* ── Section Headings ───────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* ── Search Bar ─────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}
.search-bar input {
  flex: 1;
  padding: 10px 14px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: .95rem;
  min-height: 44px;
  outline: none;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar button {
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: .95rem;
  min-height: 44px;
  transition: color var(--transition);
}
.search-bar button:hover { color: var(--text-primary); }

/* ── Filters Bar ────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: .82rem;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}
.filter-chip:hover { border-color: var(--border-hover); color: var(--text-primary); }
.filter-chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ── Pagination ─────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 28px;
  flex-wrap: wrap;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: all var(--transition);
}
.page-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn.disabled { opacity: .35; pointer-events: none; }

/* ── Note & Snippet View ────────────────────────────── */
.content-view {
  max-width: 860px;
}
.view-header {
  margin-bottom: 24px;
}
.view-title {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 10px;
}
.view-meta {
  font-size: .82rem;
  color: var(--text-muted);
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
}
.view-body {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  line-height: 1.75;
  font-size: .97rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--text-primary);
}
.view-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.badge-lang {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: rgba(99,102,241,.15);
  color: var(--accent);
  border: 1px solid rgba(99,102,241,.3);
}

/* ── Code Block (snippet view) ──────────────────────── */
.code-wrapper {
  position: relative;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid var(--border);
  font-size: .8rem;
  color: var(--text-muted);
}
.code-block {
  margin: 0;
  padding: 20px;
  overflow-x: auto;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: .875rem;
  line-height: 1.65;
}
.code-block code { background: none; padding: 0; border-radius: 0; }
.code-block.word-wrap { white-space: pre-wrap; overflow-x: hidden; }
.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .78rem;
  cursor: pointer;
  transition: all var(--transition);
}
.copy-btn:hover { color: var(--text-primary); background: rgba(255,255,255,.12); }
.copy-btn.copied { color: var(--success); border-color: var(--success); }
.copy-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(99,102,241,.12); }

/* ── Modals ─────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .25s ease;
}
@keyframes fadeUp {
  from { opacity:0; transform: translateY(16px); }
  to   { opacity:1; transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text-secondary); cursor: pointer; font-size: 1.1rem;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: rgba(255,255,255,.08); color: var(--text-primary); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ── Color Picker ───────────────────────────────────── */
.color-picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.color-swatch {
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform var(--transition), border-color var(--transition);
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: #fff; transform: scale(1.15); }

/* ── 2FA Setup ──────────────────────────────────────── */
.qr-container {
  text-align: center;
  padding: 20px;
  background: #fff;
  border-radius: var(--radius);
  display: inline-block;
  margin: 0 auto 20px;
}
.qr-container img { display: block; }
.otp-secret {
  font-family: monospace;
  font-size: .85rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  letter-spacing: .1em;
  color: var(--text-secondary);
  word-break: break-all;
}

/* ── Related Tags View ──────────────────────────────── */
.related-tags { display: flex; flex-wrap: wrap; gap: 10px; }
.related-tag-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color var(--transition), transform var(--transition);
}
.related-tag-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  color: var(--text-primary);
}
.related-shared {
  font-size: .72rem;
  color: var(--text-muted);
  background: rgba(255,255,255,.06);
  border-radius: 10px;
  padding: 1px 7px;
}

/* ── Empty State ────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: .4;
}
.empty-state-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.empty-state-text { font-size: .9rem; }

/* ── Tag view header ────────────────────────────────── */
.tag-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
}
.tag-hero-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tag-hero-name {
  font-size: 1.6rem;
  font-weight: 700;
}
.tag-hero-stats {
  margin-left: auto;
  display: flex;
  gap: 20px;
  text-align: center;
}
.tag-hero-stat-value { font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.tag-hero-stat-label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

/* ── Responsive Tablet ──────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}
@media (max-width: 640px) {
  .main-content { padding: 20px 16px 20px 88px; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .stat-value { font-size: 1.6rem; }
  .page-title { font-size: 1.3rem; }
  .view-title { font-size: 1.4rem; }
  .auth-card { padding: 28px 22px; }
  .tag-hero { flex-wrap: wrap; }
  .tag-hero-stats { margin-left: 0; }
}

/* ── Touch input optimisations ──────────────────────── */

/* Eliminate the 300 ms tap delay on interactive elements */
a, button, [role="button"],
.sidebar-item, .btn, .tag-option, .filter-chip,
.color-swatch, .page-btn, .copy-btn, .flash-close,
.modal-close, .card-link, .kanban-task,
.img-preview-remove, .img-existing-del,
.tag-cloud-item, .related-tag-card {
  touch-action: manipulation;
}

/* Momentum scrolling for overflow containers */
.kanban-board,
.kanban-col-body {
  -webkit-overflow-scrolling: touch;
}

/* Ghost element created during touch-drag operations */
.touch-drag-ghost {
  position: fixed !important;
  pointer-events: none !important;
  z-index: 9999;
  opacity: 0.85;
  transform: rotate(2deg) scale(1.02);
  box-shadow: var(--shadow-lg);
  transition: none !important;
}

/* ── Coarse pointer (touch screen) overrides ─────────── */
@media (pointer: coarse) {

  /* Always show kanban task action buttons — hover doesn't exist on touch */
  .kanban-task-actions { opacity: 1; }

  /* Increase tap target for small buttons */
  .btn-sm { min-height: 40px; padding: 8px 16px; }
  .btn-icon.btn-sm { min-height: 40px; min-width: 40px; padding: 8px; }
  .copy-btn { min-height: 40px; padding: 8px 14px; }
  .modal-close { width: 44px; height: 44px; font-size: 1.2rem; }
  .flash-close { padding: 8px 12px; font-size: 1.2rem; }
  .page-btn { width: 44px; height: 44px; }
  .filter-chip { padding: 9px 16px; }
  .tag-option { padding: 9px 16px; }

  /* Larger image delete / remove buttons */
  .img-preview-remove,
  .img-existing-del { width: 30px; height: 30px; font-size: .9rem; top: 4px; right: 4px; }

  /* Bigger colour swatches */
  .color-swatch { width: 38px; height: 38px; }

  /* Wider scrollbars for touch scrolling */
  ::-webkit-scrollbar { width: 8px; height: 8px; }

  /* Slightly more generous kanban task padding */
  .kanban-task { padding: 12px 14px; }

  /* Sidebar drag handle: bigger tap zone */
  .sidebar-drag-handle { padding: 8px 10px; font-size: .9rem; opacity: 1; }

  /* Show drag handles in reorder mode clearly */
  .sidebar.reorder-mode .sidebar-drag-handle { opacity: 1; }

  /* Widget toolbar buttons: larger tap area */
  .widget-toolbar-btn { padding: 8px 12px; }
  .widget-drag-handle { padding: 6px 10px; font-size: .95rem; }
}

/* ── Dashboard Widget Grid ──────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.dashboard-widget {
  min-width: 0;
  position: relative;
}

/* Full-width widgets span both columns */
.dashboard-widget[data-col-span="2"] {
  grid-column: span 2;
}

/* Hidden widgets are invisible in normal mode */
.dashboard-widget.widget-hidden {
  display: none;
}

/* ── Widget edit mode ───────────────────────────────── */
.dashboard-grid.edit-mode .dashboard-widget {
  border-radius: var(--radius);
  outline: 2px dashed var(--border-hover);
  outline-offset: 2px;
  padding: 14px;
  background: var(--bg-card);
  cursor: grab;
}

.dashboard-grid.edit-mode .dashboard-widget:active {
  cursor: grabbing;
}

/* Show hidden widgets as ghosts in edit mode */
.dashboard-grid.edit-mode .dashboard-widget.widget-hidden {
  display: block;
  opacity: 0.38;
}

/* Drag states */
.dashboard-widget.widget-dragging {
  opacity: 0.35;
}

.dashboard-widget.widget-drop-before {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px;
  box-shadow: -5px 0 0 var(--accent);
}

.dashboard-widget.widget-drop-after {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px;
  box-shadow: 5px 0 0 var(--accent);
}

/* ── Widget toolbar (shown in edit mode) ────────────── */
.widget-toolbar {
  display: none;
  position: absolute;
  top: -1px;
  right: 0;
  z-index: 10;
  align-items: center;
  gap: 2px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-hover);
  border-radius: 0 var(--radius-sm) 0 var(--radius-sm);
  padding: 4px 6px;
  pointer-events: auto;
}

.dashboard-grid.edit-mode .widget-toolbar {
  display: flex;
}

.widget-name-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 3px 8px 3px 4px;
  border-right: 1px solid var(--border);
  margin-right: 2px;
  white-space: nowrap;
}

.widget-drag-handle {
  color: var(--text-muted);
  cursor: grab;
  padding: 4px 7px;
  display: flex;
  align-items: center;
  font-size: .85rem;
}
.widget-drag-handle:active { cursor: grabbing; }

.widget-toolbar-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: color var(--transition), background var(--transition);
}
.widget-toolbar-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,.08);
}
.widget-toolbar-btn.btn-hide-active {
  color: var(--warning);
}

@media (max-width: 700px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-widget[data-col-span="2"] { grid-column: span 1; }
  .dashboard-grid.edit-mode .dashboard-widget { padding: 10px; }
}

/* ── Highlight.js theme tweaks ──────────────────────── */
.hljs { background: transparent !important; padding: 0 !important; }

/* ── CodeMirror overrides ───────────────────────────── */
.CodeMirror {
  height: 320px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace !important;
  font-size: .9rem !important;
}
.cm-lang-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: .8rem;
  color: var(--text-muted);
}

/* ── Edit Layout (two-column: form | images) ────────── */
.edit-layout {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .edit-layout { grid-template-columns: 1fr; }
}

.img-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: sticky;
  top: 24px;
}
.img-panel-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 14px;
}

/* ── Image drop zone ────────────────────────────────── */
.img-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 22px 14px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .875rem;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  user-select: none;
}
.img-drop-zone:hover,
.img-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text-secondary);
}
.img-drop-zone-icon { font-size: 1.6rem; margin-bottom: 7px; opacity: .45; }
.img-drop-zone p { margin: 0; line-height: 1.5; }

/* ── New-file preview grid ──────────────────────────── */
.img-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-top: 12px;
}
.img-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-input);
}
.img-preview-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.img-preview-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,.72);
  border: none; border-radius: 50%;
  color: #fff; font-size: .8rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
  line-height: 1;
}
.img-preview-remove:hover { background: var(--danger); }

/* ── Existing images (edit page) ────────────────────── */
.img-existing-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-bottom: 14px;
}
.img-existing-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-input);
}
.img-existing-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  transition: opacity var(--transition);
}
.img-existing-item img:hover { opacity: .85; }
.img-existing-del {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,.72);
  border: none; border-radius: 50%;
  color: #fff; font-size: .75rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.img-existing-del:hover { background: var(--danger); }
.img-count-badge {
  font-size: .72rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── View Layout with images ────────────────────────── */
.view-with-images {
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 900px) {
  .view-with-images { grid-template-columns: 1fr; }
}

/* ── View image gallery ─────────────────────────────── */
.view-img-panel {
  position: sticky;
  top: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.view-img-panel-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 14px;
}
.view-img-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}
.view-img-gallery-item {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-input);
  cursor: zoom-in;
  transition: border-color var(--transition), transform var(--transition);
}
.view-img-gallery-item:hover {
  border-color: var(--accent);
  transform: scale(1.03);
}
.view-img-gallery-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* ── Lightbox ───────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.9);
  z-index: 600;
  align-items: center;
  justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox-img-wrap {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-img-wrap img {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 48px rgba(0,0,0,.7);
  display: block;
}
.lightbox-close {
  position: fixed; top: 18px; right: 20px;
  width: 44px; height: 44px;
  background: rgba(255,255,255,.12);
  border: none; border-radius: 50%;
  color: #fff; font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
  z-index: 601;
}
.lightbox-close:hover { background: rgba(255,255,255,.22); }
.lightbox-caption {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.65);
  color: #e2e8f0; font-size: .82rem;
  padding: 6px 18px; border-radius: 20px;
  max-width: 80vw; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  z-index: 601;
}


/* -- Kanban ------------------------------------------- */
.kanban-board {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 20px;
  min-height: 60vh;
}

.kanban-col {
  flex: 0 0 280px;
  width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
  transition: border-color var(--transition), background var(--transition);
}
.kanban-col.drag-over {
  border-color: var(--accent);
  background: rgba(99,102,241,.06);
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.kanban-col-title {
  font-weight: 600;
  font-size: .9rem;
  color: var(--text-primary);
}
.kanban-col-count {
  font-size: .75rem;
  color: var(--text-muted);
  background: var(--bg-primary);
  border-radius: 20px;
  padding: 1px 8px;
}

.kanban-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

.kanban-task {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: grab;
  transition: box-shadow var(--transition), border-color var(--transition);
  user-select: none;
}
.kanban-task:hover { border-color: var(--border-hover); box-shadow: var(--shadow); }
.kanban-task.dragging { opacity: .4; cursor: grabbing; }

.kanban-task-title {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.kanban-task-desc {
  font-size: .78rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}
.kanban-task-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.kanban-task-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  opacity: 0;
  transition: opacity var(--transition);
}
.kanban-task:hover .kanban-task-actions { opacity: 1; }

.kanban-col-footer {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.kanban-add-col {
  flex: 0 0 240px;
  width: 240px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 8px;
  transition: border-color var(--transition);
  align-self: stretch;
  min-height: 120px;
}
.kanban-add-col:hover { border-color: var(--accent); }

.drop-placeholder {
  height: 44px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  flex-shrink: 0;
}

/* -- Kanban task updates ------------------------------ */
.update-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.update-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.update-card-time {
  font-size: .78rem;
  color: var(--text-muted);
}
.update-card-body {
  font-size: .875rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* -- Quill rich text editor � dark theme overrides --- */
.ql-toolbar.ql-snow {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 8px 10px;
}
.ql-container.ql-snow {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  color: var(--text-primary);
  font-size: .9375rem;
  min-height: 320px;
}
.ql-editor {
  min-height: 320px;
  padding: 16px 18px;
  line-height: 1.75;
  overflow-wrap: break-word;
  word-break: break-word;
}
.ql-editor.ql-blank::before {
  color: var(--text-muted);
  font-style: normal;
  left: 18px;
}
/* Toolbar icons */
.ql-toolbar.ql-snow .ql-stroke { stroke: var(--text-secondary); }
.ql-toolbar.ql-snow .ql-fill   { fill:   var(--text-secondary); }
.ql-toolbar.ql-snow .ql-picker  { color: var(--text-secondary); }
.ql-toolbar.ql-snow button:hover .ql-stroke,
.ql-toolbar.ql-snow button.ql-active .ql-stroke { stroke: var(--accent); }
.ql-toolbar.ql-snow button:hover .ql-fill,
.ql-toolbar.ql-snow button.ql-active .ql-fill   { fill:   var(--accent); }
.ql-toolbar.ql-snow .ql-picker-label:hover,
.ql-toolbar.ql-snow .ql-picker-label.ql-active  { color: var(--accent); }
.ql-toolbar.ql-snow .ql-picker-label:hover .ql-stroke,
.ql-toolbar.ql-snow .ql-picker-label.ql-active .ql-stroke { stroke: var(--accent); }
/* Dropdowns */
.ql-toolbar.ql-snow .ql-picker-options {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.ql-toolbar.ql-snow .ql-picker-item:hover { color: var(--accent); }
.ql-toolbar.ql-snow .ql-picker-item.ql-selected { color: var(--accent); }
/* Separator */
.ql-toolbar.ql-snow .ql-formats { margin-right: 10px; }
/* Editor content: headings */
.ql-editor h1 { font-size: 1.65rem; font-weight: 700; margin-bottom: .5em; }
.ql-editor h2 { font-size: 1.3rem;  font-weight: 600; margin-bottom: .5em; }
.ql-editor h3 { font-size: 1.1rem;  font-weight: 600; margin-bottom: .4em; }
.ql-editor p  { margin-bottom: .6em; }
.ql-editor p:last-child { margin-bottom: 0; }
.ql-editor ul, .ql-editor ol { padding-left: 1.6em; margin-bottom: .6em; }
.ql-editor li { margin-bottom: .2em; }
.ql-editor blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1em;
  color: var(--text-secondary);
  margin: .75em 0;
}
.ql-editor pre.ql-syntax {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  overflow-x: auto;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: .85rem;
  color: #e2e8f0;
}
.ql-editor a { color: var(--accent); }
/* Quill toolbar header picker label width */
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="1"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="1"]::before  { content: 'Heading 1'; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="2"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="2"]::before  { content: 'Heading 2'; }
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value="3"]::before,
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value="3"]::before  { content: 'Heading 3'; }
.ql-snow .ql-picker.ql-header .ql-picker-label:not([data-value])::before,
.ql-snow .ql-picker.ql-header .ql-picker-item:not([data-value])::before { content: 'Normal'; }

/* -- Rich content view (notes) ------------------------- */
.view-body-html {
  white-space: normal;
}
.view-body-html p { margin-bottom: .75em; }
.view-body-html p:last-child { margin-bottom: 0; }
.view-body-html h1 { font-size: 1.65rem; font-weight: 700; margin-bottom: .5em; line-height: 1.2; }
.view-body-html h2 { font-size: 1.3rem;  font-weight: 600; margin-bottom: .5em; line-height: 1.3; }
.view-body-html h3 { font-size: 1.1rem;  font-weight: 600; margin-bottom: .4em; line-height: 1.3; }
.view-body-html ul, .view-body-html ol { padding-left: 1.6em; margin-bottom: .75em; }
.view-body-html li { margin-bottom: .25em; }
.view-body-html li > ul, .view-body-html li > ol { margin-top: .25em; margin-bottom: 0; }
.view-body-html strong { font-weight: 700; }
.view-body-html em { font-style: italic; }
.view-body-html u  { text-decoration: underline; }
.view-body-html s  { text-decoration: line-through; }
.view-body-html a  { color: var(--accent); text-decoration: underline; }
.view-body-html a:hover { color: var(--accent-hover); }
.view-body-html blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1em;
  color: var(--text-secondary);
  margin: .75em 0;
}
.view-body-html pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  overflow-x: auto;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: .85rem;
  color: #e2e8f0;
  margin-bottom: .75em;
}
.view-body-html.word-wrap pre { white-space: pre-wrap; overflow-x: hidden; }
.view-body-html code {
  background: var(--bg-secondary);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: .875em;
}

/* -- Dashboard kanban widget --------------------------- */
.dashboard-boards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.db-board-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.db-board-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}
.db-board-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.db-board-title {
  font-weight: 600;
  font-size: .95rem;
  color: var(--text-primary);
  text-decoration: none;
  flex: 1;
}
.db-board-title:hover { color: var(--accent); }
.db-board-date {
  font-size: .75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.db-board-desc {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ── Note Sections (editor) ─────────────────────────── */
.note-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 14px;
  background: var(--bg-secondary);
}
.note-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.note-section-title {
  flex: 1 1 0;
  min-width: 0;
  font-weight: 600;
  font-size: .95rem;
  width: auto;
}
.note-section-lang {
  flex: 0 0 150px;
  width: 150px;
  min-width: 0;
  max-width: 150px;
}
.note-section-editor { min-height: 200px; }

/* ── Note Sections (view) ───────────────────────────── */
.note-section-view + .note-section-view { margin-top: 24px; }
.note-section-view-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.note-section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ── Snippet Section Chips (preview cards) ──────────── */
.snippet-sec-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.snippet-sec-chip {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: .72rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ── Snippet Sections (view) ────────────────────────── */
.snippet-section-view + .snippet-section-view { margin-top: 4px; }

.db-board-cols {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.db-board-col {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: .78rem;
}
.db-board-col-name {
  color: var(--text-secondary);
}
.db-board-col-count {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 10px;
  padding: 0 6px;
  font-weight: 600;
  font-size: .72rem;
  min-width: 18px;
  text-align: center;
}
.db-board-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: auto;
}

/* ── Diagrams ───────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card-body { /* used inside .card for diagram index */ }

.diagram-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.diagram-type-flowchart {
  background: rgba(99,102,241,.18);
  color: #a5b4fc;
  border: 1px solid rgba(99,102,241,.3);
}
.diagram-type-network {
  background: rgba(13,148,136,.18);
  color: #5eead4;
  border: 1px solid rgba(13,148,136,.3);
}

/* Diagram attach card (shown on note/snippet view) */
.diagram-attach-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-primary);
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.diagram-attach-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(0,0,0,.3);
  color: var(--text-primary);
}
