/* ─── Custom properties ─────────────────────────────────── */
:root {
  --bg:          #151829;
  --surface:     #1c2038;
  --surface-2:   #232847;
  --surface-3:   #2c3258;
  --border:      rgba(255,255,255,0.08);
  --border-2:    rgba(255,255,255,0.14);
  --text:        #e2e6f8;
  --text-muted:  #7e84b0;
  --text-dim:    #4e5480;
  --accent:      #6366f1;
  --accent-2:    #818cf8;
  --accent-dim:  rgba(99,102,241,0.14);
  --accent-glow: rgba(99,102,241,0.25);
  --green:       #34d399;
  --green-dim:   rgba(52,211,153,0.14);
  --red:         #f87171;
  --red-dim:     rgba(248,113,113,0.14);
  --yellow:      #fbbf24;
  --radius:      10px;
  --radius-sm:   6px;
  --radius-lg:   14px;
  --shadow:      0 4px 32px rgba(0,0,0,0.45);
  --shadow-sm:   0 2px 12px rgba(0,0,0,0.3);
  --transition:  0.18s ease;
  --font:        'Inter', system-ui, sans-serif;
  --mono:        'JetBrains Mono', 'Fira Code', monospace;
}

/* ─── Light mode ─────────────────────────────────────────── */
html.light {
  color-scheme: light;
  --bg:          #e8eaef;
  --surface:     #f0f2f6;
  --surface-2:   #f8f9fb;
  --surface-3:   #ffffff;
  --border:      rgba(0,0,0,0.08);
  --border-2:    rgba(0,0,0,0.14);
  --text:        #1a1d35;
  --text-muted:  #555a80;
  --text-dim:    #9098c0;
  --accent:      #5254d4;
  --accent-2:    #6366f1;
  --accent-dim:  rgba(82,84,212,0.10);
  --accent-glow: rgba(82,84,212,0.18);
  --green:       #059669;
  --green-dim:   rgba(5,150,105,0.10);
  --red:         #dc2626;
  --red-dim:     rgba(220,38,38,0.10);
  --yellow:      #d97706;
  --shadow:      0 4px 24px rgba(0,0,0,0.10);
  --shadow-sm:   0 2px 8px rgba(0,0,0,0.08);
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
img { display: block; }
ul, ol { list-style: none; }

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

/* ─── App shell ──────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: 56px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.brand-icon { width: 22px; height: 22px; color: var(--accent); }
.brand-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand-icon-lg { width: 32px; height: 32px; }
.brand-name-lg { font-size: 22px; }

.header-search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
}

.search-wrap {
  position: relative;
  width: 100%;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
#search-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 12px 7px 34px;
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
#search-input::placeholder { color: var(--text-dim); }

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  overflow: hidden;
  max-height: 380px;
  overflow-y: auto;
}

.search-results-list { padding: 4px 0; }
.search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.search-result:hover, .search-result.focused { background: var(--surface-2); }
.result-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.result-icon svg { width: 14px; height: 14px; }
.result-icon-bookmark { background: var(--accent-dim); color: var(--accent-2); }
.result-icon-snippet  { background: rgba(251,191,36,0.12); color: var(--yellow); }
.result-icon-note     { background: rgba(52,211,153,0.12); color: var(--green); }
.result-body { flex: 1; overflow: hidden; }
.result-title { display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-meta  { display: block; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-action { font-size: 11px; color: var(--accent-2); flex-shrink: 0; }

.header-actions { flex-shrink: 0; display: flex; align-items: center; gap: 6px; }

/* ─── Flash ──────────────────────────────────────────────── */
.flash-bar { padding: 0.5rem 1.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  animation: slideDown 0.2s ease;
}
.flash-error { background: var(--red-dim); border-color: rgba(248,113,113,0.25); color: var(--red); }
.flash-close { background: none; border: none; color: var(--text-muted); font-size: 16px; cursor: pointer; padding: 0 4px; line-height: 1; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Tab nav ────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: 2px;
  padding: 0.75rem 1.5rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 56px;
  z-index: 90;
}
.tab-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn svg { width: 15px; height: 15px; }
.tab-btn:hover { color: var(--text); background: var(--surface); }
.tab-btn.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent);
}

/* ─── Main content ───────────────────────────────────────── */
.app-main { flex: 1; padding: 1.5rem; max-width: 1400px; width: 100%; margin: 0 auto; }

.tab-panel { display: none; animation: fadeIn 0.15s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Toolbar ────────────────────────────────────────────── */
.panel-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.notes-toolbar { }

/* ─── Inline forms ───────────────────────────────────────── */
.inline-form {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease, margin 0.25s ease;
  max-height: 600px;
  opacity: 1;
}
.inline-form.collapsed { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; margin-bottom: 0; pointer-events: none; }
.inline-form-tiny { display: inline; margin: 0; padding: 0; }

/* ─── Categories ─────────────────────────────────────────── */
.categories-list { display: flex; flex-direction: column; gap: 1.25rem; }

.category-group {}
.category-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0.25rem;
  cursor: pointer;
  user-select: none;
}
.category-header-left { display: flex; align-items: center; gap: 8px; }
.category-header-right { display: flex; align-items: center; gap: 4px; opacity: 0; transition: opacity var(--transition); }
.category-header:hover .category-header-right { opacity: 1; }

.category-name { font-weight: 600; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 7px;
}

.chevron { width: 14px; height: 14px; transition: transform 0.2s ease; }
.category-group.collapsed .chevron { transform: rotate(-90deg); }
.category-group.collapsed .category-items { display: none; }
.category-collapse-btn { color: var(--text-muted); padding: 2px; border-radius: 4px; display: flex; align-items: center; }
.category-collapse-btn:hover { color: var(--text); background: var(--surface-2); }

/* ─── Bookmark tiles ─────────────────────────────────────── */
.bookmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
  padding-top: 0.4rem;
}
.bookmark-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
}
.bookmark-tile:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.tile-favicon {
  width: 28px; height: 28px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
}
.favicon-img { width: 20px; height: 20px; object-fit: contain; }
.tile-body { flex: 1; overflow: hidden; }
.tile-title {
  display: block;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition);
}
.tile-title:hover { color: var(--accent-2); }
.tile-meta { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-dim); }
.tile-meta-sep { color: var(--text-dim); }
.tile-clicks::after { content: ' clicks'; }
.tile-indicators { flex-shrink: 0; }
.status-dot {
  display: block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--surface-3);
  transition: background var(--transition);
}
.status-dot.up   { background: var(--green); box-shadow: 0 0 6px rgba(52,211,153,0.5); }
.status-dot.down { background: var(--red); }

.tile-actions {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px 0 24px;
  background: linear-gradient(to right, transparent, var(--surface) 35%);
  border-radius: 0 var(--radius) var(--radius) 0;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.bookmark-tile:hover .tile-actions {
  opacity: 1;
  pointer-events: all;
}

/* ─── Snippet cards ──────────────────────────────────────── */
.snippet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.75rem;
  padding-top: 0.4rem;
}
.snippet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}
.snippet-card:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.snippet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
}
.snippet-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lang-badge {
  font-size: 10.5px;
  font-family: var(--mono);
  color: var(--accent-2);
  background: var(--accent-dim);
  border-radius: 4px;
  padding: 2px 7px;
  flex-shrink: 0;
  margin-left: 8px;
}
.snippet-preview {
  flex: 1;
  margin: 0;
  padding: 10px 14px;
  font-size: 11.5px;
  font-family: var(--mono);
  color: var(--text-muted);
  overflow: hidden;
  max-height: 120px;
  line-height: 1.5;
  background: transparent;
}
.snippet-preview code {
  background: transparent !important;
  padding: 0 !important;
  font-size: inherit;
}
.snippet-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}
.snippet-footer-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* ─── Note cards ─────────────────────────────────────────── */
.note-filters {
  display: flex;
  gap: 4px;
}
.filter-btn {
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: all var(--transition);
}
.filter-btn:hover { color: var(--text); background: var(--surface-2); }
.filter-btn.active {
  color: var(--accent-2);
  background: var(--accent-dim);
  border-color: rgba(99,102,241,0.2);
}

.notes-grid {
  columns: 4;
  column-gap: 0.75rem;
}
.note-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  display: flex;
  break-inside: avoid;
  margin-bottom: 0.75rem;
  width: 100%;
}
.note-card:hover {
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.note-card.note-hidden { display: none; }
.note-accent {
  width: 4px;
  flex-shrink: 0;
  background: var(--note-color, var(--accent));
  border-radius: 0;
}
.note-content { flex: 1; padding: 12px 14px; overflow: hidden; }
.note-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}
.note-title { font-size: 13px; font-weight: 600; line-height: 1.4; }
.note-type-badge {
  font-size: 10px;
  font-weight: 500;
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}
.todo-badge { background: var(--accent-dim); color: var(--accent-2); }
.note-body {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.note-checklist { display: flex; flex-direction: column; gap: 4px; }
.checklist-form { display: block; }
.checklist-item {
  display: flex; align-items: flex-start; gap: 7px;
  font-size: 12.5px; color: var(--text-muted);
  cursor: pointer;
  line-height: 1.4;
}
.checklist-item input[type=checkbox] { flex-shrink: 0; margin-top: 2px; accent-color: var(--accent); }
.checklist-item.item-done span { text-decoration: line-through; opacity: 0.5; }
.more-items { font-size: 11px; color: var(--text-dim); padding-left: 2px; }
.note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.note-meta { font-size: 11px; color: var(--text-dim); }
.note-actions { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity var(--transition); }
.note-card:hover .note-actions { opacity: 1; }
.note-card.note-done .note-content { opacity: 0.55; }
.note-card.note-done {
  position: relative;
  overflow: hidden;
}
.note-card.note-done::after {
  content: 'DONE';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-35deg);
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--green);
  opacity: 0.12;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

/* ─── Color swatches ─────────────────────────────────────── */
.color-swatches { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.swatch {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.swatch:hover { transform: scale(1.15); }
.swatch-active { border-color: white; transform: scale(1.15); }
.swatch-hex { width: 90px !important; font-size: 12px; font-family: var(--mono); }

/* ─── Note filter toggle ─────────────────────────────────── */
.note-add-form {}

/* ─── Data tools ─────────────────────────────────────────── */
.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  align-items: start;
}
.data-card-wide { grid-column: 1 / -1; }
.data-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.data-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.data-card-title svg { width: 16px; height: 16px; color: var(--accent-2); }
.data-card-desc { font-size: 12.5px; color: var(--text-muted); }
.data-empty { font-size: 12.5px; color: var(--text-dim); }
.backup-list { display: flex; flex-direction: column; gap: 0.5rem; }
.backup-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  gap: 1rem;
}
.backup-info { overflow: hidden; }
.backup-name { display: block; font-size: 12.5px; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.backup-meta { display: block; font-size: 11px; color: var(--text-dim); }

/* ─── Buttons ────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
}
.btn-primary:hover { background: #5254e0; box-shadow: 0 0 0 3px var(--accent-glow); transform: translateY(-1px); }
.btn-primary:active { transform: none; }

.btn-outline {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-outline:hover { color: var(--text); border-color: var(--text-muted); background: var(--surface-2); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
}
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
  text-decoration: none;
}
.btn-icon svg { width: 14px; height: 14px; }
.btn-icon:hover { color: var(--text); background: var(--surface-2); }
.btn-icon.btn-danger:hover { color: var(--red); background: var(--red-dim); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; }
.btn-full { width: 100%; justify-content: center; }
.btn-danger-solid { background: var(--red-dim); color: var(--red); border-color: rgba(248,113,113,0.25); }
.btn-danger-solid:hover { background: var(--red); color: #fff; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.form-row-bottom { justify-content: space-between; }
.form-col { display: flex; flex-direction: column; gap: 10px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group-grow { flex: 1; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.form-hint { font-weight: 400; color: var(--text-dim); }

.form-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-width: 0;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-input::placeholder { color: var(--text-dim); }
.form-input-wide { flex: 1; min-width: 200px; }

.form-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.form-textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--mono);
  outline: none;
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-textarea-tall { min-height: 200px; }
.form-textarea::placeholder { color: var(--text-dim); font-family: var(--font); }

.form-actions { display: flex; gap: 8px; align-items: center; }
.form-error { font-size: 12px; color: var(--red); }

.toggle-label {
  display: flex; align-items: center; gap: 7px;
  cursor: pointer; font-size: 13px; color: var(--text-muted);
}
.toggle-label input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.toggle-text { user-select: none; }

/* ─── Drag handles ───────────────────────────────────────── */
.drag-handle {
  color: var(--text-dim);
  cursor: grab;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color var(--transition);
}
.drag-handle:hover { color: var(--text-muted); }
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { box-shadow: 0 0 0 2px var(--accent); }

/* ─── Modals ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: modalIn 0.15s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalSlide 0.18s ease;
}
.modal-sm { max-width: 380px; }
@keyframes modalSlide { from { transform: translateY(12px) scale(0.98); } to { transform: translateY(0) scale(1); } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.modal-title-wrap { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.modal-color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.modal-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 18px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}
.modal-close:hover { color: var(--text); background: var(--surface-2); }
.modal-code {
  padding: 1.25rem;
  font-size: 12.5px;
  font-family: var(--mono);
  overflow-x: auto;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: transparent;
}
.modal-code code { background: transparent !important; }
.modal-note-body {
  padding: 1.25rem;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.modal-desc { font-size: 13px; color: var(--text-muted); padding: 1rem 1.25rem 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 1rem 1.25rem; }

/* ─── Auth pages ─────────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.12) 0%, transparent 60%), var(--bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 0.25rem; }
.auth-subtitle { font-size: 13px; color: var(--text-muted); text-align: center; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-link { font-size: 12.5px; color: var(--text-muted); text-align: center; transition: color var(--transition); }
.auth-link:hover { color: var(--accent-2); }
.pin-input { font-size: 20px; letter-spacing: 0.4em; text-align: center; font-family: var(--mono); }

/* ─── Edit pages ─────────────────────────────────────────── */
.edit-shell {
  min-height: 100vh;
  padding: 2rem;
  background: var(--bg);
}
.edit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 640px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}
.edit-card-wide { max-width: 900px; }
.edit-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.edit-title { font-size: 16px; font-weight: 600; }

/* ─── Favicon in data url ────────────────────────────────── */
.favicon-serving {
  background: var(--surface-3);
  border-radius: 50%;
  padding: 2px;
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-header { padding: 0 1rem; }
  .app-main { padding: 1rem; }
  .tab-nav { padding: 0.5rem 1rem 0; overflow-x: auto; }
  .tab-btn span { display: none; }
  .header-search { max-width: none; }
  .bookmark-grid { grid-template-columns: 1fr 1fr; }
  .snippet-grid { grid-template-columns: 1fr; }
  .notes-grid { columns: 1; }
  .data-grid { grid-template-columns: 1fr; }
  .data-card-wide { grid-column: auto; }
}
@media (max-width: 480px) {
  .bookmark-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 2rem 1.25rem; }
}

/* ─── Snippet tooltip ────────────────────────────────────── */
.snippet-tip {
  position: fixed;
  z-index: 9999;
  max-width: 300px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.6rem 0.85rem;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
  pointer-events: none;
  animation: tipIn 0.12s ease;
}
@keyframes tipIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ─── Highlight.js override ──────────────────────────────── */
.hljs { background: transparent !important; padding: 0 !important; }
