/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0D0D1F;
  --panel:       #F7F7F9;
  --card:        #FFFFFF;
  --primary:     #5B4FE8;
  --primary-l:   #EBE9FC;
  --fg:          #0f0f0f;
  --muted:       #8A8A99;
  --border:      #E8E8EE;
  --star:        #F59E0B;
  --danger:      #EF4444;
  --success:     #10B981;
  --radius:      16px;
  --radius-sm:   10px;
  --max:         660px;
  --header-h:    60px;
  --font:        'Inter', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); border: none; background: none; }
input, textarea { font-family: var(--font); }

/* ── Wrapper ─────────────────────────────────────────────────── */
.wrap {
  max-width: var(--max);
  margin: 0 auto;
  background: var(--panel);
  min-height: 100vh;
  position: relative;
}

/* ── Header ─────────────────────────────────────────────────── */
.header {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.logo-text {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--fg);
}

.badge-premium {
  font-size: 10px;
  font-weight: 600;
  color: var(--star);
  background: #FEF3C7;
  border: 1px solid #FDE68A;
  border-radius: 5px;
  padding: 2px 6px;
  letter-spacing: 0.3px;
}

.header-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--muted);
  transition: background 0.15s;
}
.header-btn:hover { background: var(--border); color: var(--fg); }
.header-btn.active { color: var(--primary); background: var(--primary-l); }

/* ── Search bar ──────────────────────────────────────────────── */
.search-wrap {
  padding: 10px 16px 6px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--fg);
  background: var(--panel);
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--primary); }
.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

/* ── Filter tabs ─────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 0;
  padding: 10px 16px 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.filter-tab {
  flex: 1;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  padding-bottom: 2px;
}
.filter-tab:hover { color: var(--fg); }
.filter-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ── Tag bar ─────────────────────────────────────────────────── */
.tag-bar {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tag-bar::-webkit-scrollbar { display: none; }
.tag-bar:empty { display: none; }

.tag-pill {
  flex-shrink: 0;
  height: 26px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  background: var(--primary-l);
  color: var(--primary);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.tag-pill:hover { background: #d9d5fb; }
.tag-pill.active {
  background: var(--primary);
  color: #fff;
}

/* ── Bookmark list ───────────────────────────────────────────── */
.list {
  padding: 12px 0 100px;
}

/* ── Bookmark card ───────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 16px 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s;
}
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.1); }

.card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.card-favicon {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
  background: var(--border);
}
.card-domain {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-time {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
  white-space: nowrap;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.4;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-title a { color: inherit; }
.card-title a:hover { color: var(--primary); }

.card-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.card-tag {
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  background: var(--primary-l);
  color: var(--primary);
}
.card-tag:hover { background: #d9d5fb; cursor: pointer; }

.card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--muted);
  opacity: 0.6;
  transition: background 0.12s, opacity 0.12s;
}
.action-btn:hover { background: var(--panel); opacity: 1; }
.action-btn.star-active { color: var(--star); opacity: 1; }
.action-btn.archive-active { color: var(--primary); opacity: 1; }

.action-spacer { flex: 1; }

.delete-btn {
  width: 36px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--danger);
  opacity: 0.55;
  border-left: 1px solid var(--border);
  padding-left: 4px;
  transition: opacity 0.12s;
}
.delete-btn:hover { opacity: 1; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 80px 24px;
  text-align: center;
  color: var(--muted);
}
.empty svg { opacity: 0.3; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--fg); }
.empty-sub { font-size: 14px; }

/* ── Loading spinner ─────────────────────────────────────────── */
.spinner-wrap {
  display: flex;
  justify-content: center;
  padding: 60px 0;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── FAB ─────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 28px;
  right: calc(50% - var(--max)/2 + 20px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 20px rgba(91,79,232,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
  z-index: 200;
}
.fab:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 24px rgba(91,79,232,0.55);
}
@media (max-width: 660px) {
  .fab { right: 20px; }
}

/* ── Modal ───────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  width: 100%;
  max-width: var(--max);
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 20px 32px;
  transform: translateY(30px);
  transition: transform 0.25s cubic-bezier(0.32,0.72,0,1);
}
.overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.modal-close:hover { background: var(--panel); color: var(--fg); }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.field input,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--fg);
  background: var(--panel);
  outline: none;
  resize: none;
  transition: border-color 0.15s;
}
.field input:focus,
.field textarea:focus { border-color: var(--primary); }

.btn-primary {
  width: 100%;
  height: 48px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1c1c2e;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 500;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Login page ──────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: var(--max);
  background: var(--card);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-logo-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}
.login-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 28px;
  line-height: 1.5;
}

.error-msg {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #DC2626;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 12px;
  display: none;
}
.error-msg.show { display: block; }

.login-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 20px;
  line-height: 1.6;
}
.login-hint a { color: var(--primary); }

/* ── LogoMark SVG ────────────────────────────────────────────── */
.logomark {
  width: 32px;
  height: 32px;
}
