:root {
  --bg: #0d0d0f;
  --surface: #141416;
  --surface2: #1c1c20;
  --border: #2a2a30;
  --accent: #c8f060;
  --accent2: #60d0f0;
  --text: #e8e8ec;
  --muted: #606068;
  --danger: #f06060;
  --radius: 10px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  font-size: 14px;
}

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.main { flex: 1; padding: 32px 40px; overflow-x: hidden; }

.logo {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.logo h1 {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.logo h1 span { color: var(--accent); }
.logo small { color: var(--muted); font-size: 11px; font-family: 'DM Mono', monospace; }

.nav-section { padding: 0 12px; margin-bottom: 8px; }
.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  padding: 0 12px;
  margin-bottom: 6px;
  font-family: 'DM Mono', monospace;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  transition: all 0.15s;
  font-weight: 400;
  user-select: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--accent); }
.nav-item .count {
  margin-left: auto;
  background: var(--surface2);
  color: var(--muted);
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  padding: 1px 6px;
  border-radius: 20px;
}
.nav-item.active .count { background: var(--bg); }

.add-cat-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius);
  margin: 4px 12px;
  transition: all 0.15s;
}
.add-cat-btn:hover { color: var(--accent); background: var(--surface2); }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.topbar h2 {
  font-family: 'Syne', sans-serif;
  font-size: 26px;
  font-weight: 800;
  flex: 1;
}
.topbar h2 span { color: var(--accent); }

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-wrap input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px 9px 36px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #0d0d0f; }
.btn-primary:hover { background: #d8ff70; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }

.tag-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  align-items: center;
}
.tag-filter {
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  background: none;
}
.tag-filter:hover { border-color: var(--accent); color: var(--accent); }
.tag-filter.active { background: var(--accent); color: #0d0d0f; border-color: var(--accent); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}
.card:hover::before { opacity: 1; }

.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-favicon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  overflow: hidden;
}
.card-favicon img { width: 100%; height: 100%; object-fit: contain; }

.card-title { font-weight: 500; font-size: 14px; line-height: 1.3; flex: 1; }
.card-title a { color: var(--text); text-decoration: none; transition: color 0.15s; }
.card-title a:hover { color: var(--accent); }

.card-url {
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }

.card-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  background: var(--surface2);
  color: var(--accent2);
  border: 1px solid var(--border);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}
.card-cat {
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.card:hover .card-actions { opacity: 1; }
.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--muted);
  font-size: 13px;
  transition: all 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--text); }
.icon-btn.del:hover { color: var(--danger); border-color: var(--danger); }

.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty .emoji { font-size: 48px; margin-bottom: 16px; }
.empty p { font-size: 14px; }

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-bg.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: translateY(16px);
  transition: transform 0.2s;
}
.modal-bg.open .modal { transform: translateY(0); }
.modal h3 { font-family: 'Syne', sans-serif; font-size: 18px; font-weight: 700; }
.modal-row { display: flex; gap: 10px; }
.form-group { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.form-group label {
  font-size: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.form-group input,
.form-group select,
.form-group textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.15s;
  resize: vertical;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group select option { background: var(--surface2); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

.tags-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  cursor: text;
  transition: border-color 0.15s;
  min-height: 42px;
  align-items: center;
}
.tags-input-wrap:focus-within { border-color: var(--accent); }
.tag-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--accent);
  color: #0d0d0f;
  border-radius: 20px;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
}
.tag-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: #0d0d0f;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}
.tags-input-wrap input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  min-width: 80px;
  flex: 1;
  padding: 2px 4px;
}

.cat-modal { max-width: 380px; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 200;
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: var(--danger); }

.stats { display: flex; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-val {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}
.stat-label { font-size: 11px; color: var(--muted); font-family: 'DM Mono', monospace; }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--muted);
  gap: 10px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
}
.spin {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.meta-bar {
  margin-top: auto;
  padding: 16px 20px 8px;
  border-top: 1px solid var(--border);
}
.meta-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  margin-bottom: 4px;
}
.meta-link {
  display: block;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
  color: var(--muted);
  text-decoration: none;
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s;
}
.meta-link:hover { color: var(--accent2); }

@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .main { padding: 20px; }
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; flex-wrap: wrap; padding: 12px; }
  .logo { padding: 0; border: none; margin: 0; }
  .main { padding: 16px; }
}
