/* ============================================
   Nimbus Nav — Minimal Cold White + Blue-Gray
   ============================================ */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --text: #334155;
  --text-light: #94a3b8;
  --text-dark: #0f172a;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #0ea5e9;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* Top accent line — signature element */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent), transparent);
  z-index: 100;
}

/* ====== Container ====== */
.container {
  margin: 0 auto;
  padding: 40px 20px 72px;
}

/* ====== Header ====== */
.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 36px;
  gap: 16px;
}

.header-left { flex: 1; }

.logo {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-dark);
  letter-spacing: -0.03em;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.subtitle {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--text-light);
}

.header-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

/* ====== Login Button ====== */
.login-btn {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
}

.login-btn:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

/* ====== Auth Modal ====== */
.auth-modal { max-width: 380px; }

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
}

.auth-tab {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
  font-family: inherit;
}

.auth-tab.active { color: var(--text-dark); }

.auth-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 20%;
  width: 60%;
  height: 2px;
  background: var(--primary);
  border-radius: 1px;
}

.auth-forgot {
  text-align: right;
  font-size: 0.78rem;
  color: var(--text-light);
  cursor: pointer;
  margin-top: -6px;
  margin-bottom: 4px;
  transition: color 0.15s;
}

.auth-forgot:hover { color: var(--primary); }

.auth-full-btn {
  width: 100%;
  margin-top: 16px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0;
  font-size: 0.78rem;
  color: var(--text-light);
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-github {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dark);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-github:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.btn-github svg { flex-shrink: 0; }

.btn-passkey {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dark);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  margin-top: 8px;
}

.btn-passkey:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.btn-passkey svg { flex-shrink: 0; }

.passkey-hint {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--text-light);
  text-align: center;
  line-height: 1.4;
}

.auth-hint {
  font-size: 0.82rem;
  color: var(--text-light);
  line-height: 1.5;
  margin-bottom: 18px;
}

.auth-back {
  text-align: center;
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
}

.auth-back:hover { text-decoration: underline; }

.confirm-icon {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 12px;
  line-height: 1;
}

/* ====== User Menu ====== */
.user-menu { position: relative; }

.user-avatar-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  overflow: visible;
  transition: border-color 0.15s;
}

.user-avatar-btn:hover { border-color: var(--primary); }

.user-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.sync-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--bg);
}

.sync-dot.syncing {
  background: var(--primary);
  animation: pulse 1s infinite;
}

.sync-dot.error { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  padding: 6px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  z-index: 60;
}

.user-dropdown.open {
  display: block;
  animation: fadeDown 0.15s ease;
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
  padding: 8px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dark);
}

.dropdown-divider {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  transition: background 0.1s;
  text-align: left;
  font-family: inherit;
}

.dropdown-item:hover { background: var(--surface-hover); }

.dropdown-icon { font-size: 0.95rem; }

/* ====== Search ====== */
.search-wrapper { margin-bottom: 44px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
  color: var(--text-light);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  color: var(--text-dark);
  outline: none;
  min-width: 0;
}

.search-input::placeholder { color: var(--text-light); }

.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration { -webkit-appearance: none; }

.search-btn {
  flex-shrink: 0;
  padding: 9px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}

.search-btn:hover { background: var(--primary-hover); }

.search-engines {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.engine-tag {
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-light);
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  transition: all 0.15s;
  user-select: none;
}

.engine-tag:hover { color: var(--text); }

.engine-tag.active {
  color: var(--primary);
  font-weight: 600;
  background: rgba(59, 130, 246, 0.06);
  border-color: rgba(59, 130, 246, 0.15);
}

/* ====== Category ====== */
.category {
  margin-bottom: 40px;
  animation: fadeSlideIn 0.4s ease forwards;
  opacity: 0;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.category-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.category-title::before {
  content: '';
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: var(--primary);
  flex-shrink: 0;
}

.category-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.category-header:hover .category-actions { opacity: 1; }

.cat-action-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-light);
  font-size: 0.72rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.cat-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Add category */
.add-category-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-light);
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  opacity: 0.5;
}

.add-category-btn:hover {
  opacity: 1;
  color: var(--primary);
  border-color: var(--primary);
}

/* ====== Card Grid ====== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

/* ====== Cards ====== */
.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
  cursor: pointer;
  position: relative;
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  transform: translateY(-2px);
}

.card:active {
  transform: translateY(0);
  box-shadow: none;
}

.card-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  overflow: hidden;
}

.card-icon img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
}

.card-icon.emoji {
  font-size: 1.2rem;
  background: transparent;
}

.card-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dark);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.3;
}

.card-desc {
  font-size: 0.68rem;
  color: var(--text-light);
  text-align: center;
  line-height: 1.3;
}

/* Card actions */
.card .card-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  gap: 3px;
}

.card:hover .card-actions { display: flex; }

.card-action-btn {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-light);
  font-size: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}

.card-action-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* Add bookmark */
.card-add {
  border: 1px dashed var(--border);
  background: transparent;
  opacity: 0.4;
  min-height: auto;
  font-family: inherit;
}

.card-add:hover {
  opacity: 0.8;
  border-color: var(--primary);
  box-shadow: none;
}

/* ====== Footer ====== */
.footer {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
}

.footer-logo-icon {
  width: 22px;
  height: 22px;
}

.footer-tagline {
  font-size: 0.78rem;
  color: var(--text-light);
}

.footer-features {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-feature {
  font-size: 0.75rem;
  color: var(--text-light);
  white-space: nowrap;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding: 12px 0;
  font-size: 0.72rem;
  color: var(--text-light);
  border-top: 1px solid var(--border);
}

.footer-link {
  color: var(--text-light);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.footer-link:hover { color: var(--primary); }

/* ====== Modal ====== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  width: 90%;
  max-width: 400px;
  padding: 28px 24px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 24px;
  text-align: center;
}

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-dark);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.08);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.btn {
  flex: 1;
  padding: 10px 0;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-cancel {
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
}

.btn-cancel:hover { background: var(--surface-hover); }

.btn-confirm {
  color: #fff;
  background: var(--primary);
}

.btn-confirm:hover { background: var(--primary-hover); }

.btn-danger {
  color: #fff;
  background: var(--danger);
}

.btn-danger:hover { background: #dc2626; }

/* ====== Toast ====== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-dark);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  pointer-events: auto;
  animation: toastIn 0.2s ease forwards;
}

.toast.toast-out { animation: toastOut 0.2s ease forwards; }
.toast.success { color: var(--success); }
.toast.error { color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-8px); }
}

/* ====== Theme Toggle ====== */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

/* ====== Animations ====== */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ====== Responsive ====== */
@media (max-width: 768px) {
  .container { padding: 24px 12px 48px; }

  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-right {
    align-self: flex-start;
  }

  .logo { font-size: 1.35rem; }
  .logo-icon { width: 28px; height: 28px; }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 8px;
  }

  .card {
    padding: 14px 8px 12px;
    border-radius: var(--radius-sm);
  }

  .card-icon {
    width: 34px;
    height: 34px;
  }

  .search-box { padding: 12px 14px; }
  .search-btn { padding: 8px 16px; }
  .category { margin-bottom: 28px; }
  .search-wrapper { margin-bottom: 32px; }
  .category-actions { opacity: 1; }
  .card .card-actions { display: flex; }

  .footer-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .footer-features {
    gap: 10px;
  }
}

/* ====== Dark Mode ====== */
body.dark {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --border: #334155;
  --border-hover: #475569;
  --text: #94a3b8;
  --text-light: #64748b;
  --text-dark: #f1f5f9;
}

body.dark .card-action-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
}

body.dark .dropdown-item:hover {
  background: var(--surface-hover);
}

body.dark .search-box:focus-within {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

body.dark .form-input:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
