/* ============================================
   AI Knowledge Hub — Industry-Standard Design
   Inter + system fonts, clean professional feel
   ============================================ */

/* --- Palette (light-first, clean professional) ---- */
:root {
  --bg:            #f8fafc;
  --bg-elevated:   #ffffff;
  --bg-surface:    #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --text:          #0f172a;
  --text-muted:    #475569;
  --text-dim:      #94a3b8;
  --accent:        #4f46e5;
  --accent-hover:  #4338ca;
  --accent-muted:  rgba(79, 70, 229, 0.08);
  --accent-glow:   rgba(79, 70, 229, 0.15);
  --accent-light:  #eef2ff;
  --accent-gradient: linear-gradient(135deg, #4f46e5, #7c3aed);
  --btn-on-accent: #fff;
  --border:        #e2e8f0;
  --border-light:  #f1f5f9;
  --radius:        10px;
  --radius-lg:     16px;
  --shadow:        0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md:     0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-hover:  0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-card:   0 1px 3px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.02);
  --nav-height:    56px;
  --touch-target:  44px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --success:       #059669;
  --warning:       #d97706;
  --danger:        #dc2626;
}

[data-theme="dark"] {
  --bg:            #0c0f1a;
  --bg-elevated:   #151929;
  --bg-surface:    #1e2336;
  --bg-surface-hover: #272d42;
  --text:          #f1f5f9;
  --text-muted:    #94a3b8;
  --text-dim:      #64748b;
  --accent:        #818cf8;
  --accent-hover:  #a5b4fc;
  --accent-muted:  rgba(129, 140, 248, 0.1);
  --accent-glow:   rgba(129, 140, 248, 0.18);
  --accent-light:  #1e1b4b;
  --accent-gradient: linear-gradient(135deg, #818cf8, #a78bfa);
  --btn-on-accent: #fff;
  --border:        #1e293b;
  --border-light:  #1e2336;
  --shadow:        0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:     0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-hover:  0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-card:   0 1px 3px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.03);
}

/* --- Reset ---------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 1rem);
}

body.has-niche-toc {
  scroll-padding-top: calc(var(--nav-height) + 3.5rem);
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "cv11", "ss01";
  font-variation-settings: "opsz" 32;
}

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Skip link ------------------------------ */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 1000;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--btn-on-accent);
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 1rem;
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Offline banner ------------------------- */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1200;
  padding: 0.6rem 1rem;
  padding-top: calc(0.6rem + var(--safe-area-top));
  background: #1a1816;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  pointer-events: none;
}
.offline-banner.visible {
  transform: translateY(0);
  opacity: 1;
}
.offline-banner-icon {
  margin-right: 0.35rem;
}

/* --- Top bar -------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  padding-top: var(--safe-area-top);
  transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

[data-theme="dark"] .topbar {
  background: rgba(12, 15, 26, 0.88);
  border-bottom-color: var(--border);
}

.topbar-scrolled {
  box-shadow: 0 1px 0 var(--border-light), 0 4px 20px rgba(26, 24, 22, 0.06);
}

[data-theme="dark"] .topbar-scrolled {
  box-shadow: 0 1px 0 var(--border-light), 0 4px 24px rgba(0, 0, 0, 0.25);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: "Inter", system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}

.logo:hover {
  opacity: 0.92;
}

/* Login/auth in upper left, right after logo */
.auth-nav-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.logo-icon {
  color: var(--accent);
  font-size: 1.2rem;
  line-height: 1;
}

/* Nav tabs */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: auto;
  flex-wrap: wrap;
}

.nav-tabs-auth {
  margin-left: 0;
  gap: 0.25rem;
}

.nav-group {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.nav-group + .nav-group::before {
  content: '';
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 0.5rem;
  flex-shrink: 0;
  opacity: 0.6;
}

.nav-group-label {
  display: none;
}

.nav-tab {
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 6px;
  transition: color 0.2s ease, background 0.2s ease;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--bg-surface);
}

.nav-tab.active {
  color: var(--accent);
  background: var(--accent-muted);
  font-weight: 600;
}

/* Top bar actions */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  flex-shrink: 0;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target);
  height: var(--touch-target);
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--bg-surface);
}

/* Profile switcher */
.profile-switcher {
  position: relative;
}

.profile-switcher-trigger {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.profile-switcher-trigger:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.profile-switcher-icon {
  font-size: 0.9rem;
  opacity: 0.9;
}

.profile-switcher-name {
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-switcher-chevron {
  font-size: 0.6rem;
  opacity: 0.7;
}

.profile-switcher-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 160px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.35rem;
  z-index: 200;
}

.profile-switcher-dropdown.hidden {
  display: none;
}

.profile-switcher-option {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  min-height: var(--touch-target);
  font-size: 0.9rem;
  text-align: left;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.profile-switcher-option:hover {
  background: var(--bg-surface);
}

.profile-switcher-option.active {
  color: var(--accent);
  font-weight: 600;
}

.profile-switcher-manage {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 0.35rem;
  transition: color 0.15s;
}

.profile-switcher-manage:hover {
  color: var(--accent);
}

/* Profiles page */
.profiles-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.profile-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.profile-item.active {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.profile-item-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-item-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
}

.profile-item-actions {
  display: flex;
  gap: 0.5rem;
}

.profile-item-switch,
.profile-item-delete {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  transition: background 0.15s, color 0.15s;
}

.profile-item-switch {
  background: var(--accent);
  color: var(--btn-on-accent);
}

.profile-item-switch:hover {
  background: var(--accent-hover);
}

.profile-item-delete {
  background: transparent;
  color: var(--text-muted);
}

.profile-item-delete:hover {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
}

.profile-item-rename {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.profile-item-rename:hover {
  color: var(--accent);
  background: var(--accent-muted);
}

.profile-rename-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

.profile-rename-form input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text);
}

.profile-rename-save,
.profile-rename-cancel {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
}

.profile-rename-save {
  background: var(--accent);
  color: var(--btn-on-accent);
}

.profile-rename-cancel {
  background: transparent;
  color: var(--text-muted);
}

.profile-delete-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.profile-delete-confirm {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.profile-delete-confirm.hidden {
  display: none;
}

.profile-item-delete.hidden {
  display: none;
}

.profile-delete-msg {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.profile-delete-yes,
.profile-delete-no {
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
}

.profile-delete-yes {
  background: #e74c3c;
  color: #fff;
}

.profile-delete-no {
  background: var(--bg-surface);
  color: var(--text);
}

.profile-form {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.profile-form-title {
  font-size: 1rem;
  margin: 0 0 0.75rem;
  color: var(--text);
}

.profile-form-row {
  display: flex;
  gap: 0.5rem;
}

.profile-form-row input {
  flex: 1;
  padding: 0.6rem 1rem;
  font-size: 16px;
  font-family: inherit;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  min-height: var(--touch-target);
}

.profile-form-row input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.profile-form-btn {
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--btn-on-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.profile-form-btn:hover {
  background: var(--accent-hover);
}

.data-export-import {
  margin-bottom: 2rem;
  padding: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
.data-import-label {
  cursor: pointer;
  margin: 0;
}
.data-import-label input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}
.data-feedback {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--accent);
}
.data-feedback-error {
  color: #e74c3c;
}

/* --- Auth pages ------------------------------ */
.auth-main {
  min-height: calc(100vh - var(--nav-height) - 8rem);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1.25rem 4rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.auth-title {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.auth-local-notice {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  margin-bottom: 0;
}
.auth-local-notice a {
  color: var(--accent);
  font-weight: 600;
}

.auth-intro {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.auth-form label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 0.75rem;
  color: var(--text);
}

.auth-form label:first-of-type {
  margin-top: 0;
}

.auth-form input {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 16px;
  font-family: inherit;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  margin-top: 0.35rem;
  min-height: var(--touch-target);
}

.auth-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.auth-form input::placeholder {
  color: var(--text-dim);
}

.auth-btn {
  margin-top: 1.25rem;
  padding: 0.65rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--btn-on-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
  min-height: var(--touch-target);
}

.auth-btn:hover {
  background: var(--accent-hover);
}

.auth-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.auth-success-msg {
  font-size: 0.95rem;
  color: var(--accent);
  margin: 0 0 1rem;
}

.auth-error {
  color: #e74c3c;
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

.auth-error-block {
  padding: 1rem;
  background: rgba(231, 76, 60, 0.1);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.auth-success {
  padding: 1rem 0;
}

.auth-success p {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.auth-reset-link-wrap {
  margin: 0.75rem 0 !important;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-reset-url-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.auth-reset-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.auth-link-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}

.auth-link-btn:hover {
  text-decoration: underline;
}

.auth-copy-btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--btn-on-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.auth-copy-btn:hover {
  background: var(--accent-hover);
}

.auth-copy-btn:disabled {
  opacity: 0.8;
  cursor: default;
}

.auth-reset-hint {
  font-size: 0.85rem !important;
  color: var(--text-dim) !important;
}

.auth-password-wrap {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.auth-password-wrap input {
  flex: 1;
  min-width: 0;
}

.auth-password-toggle {
  flex-shrink: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.auth-password-toggle:hover {
  color: var(--text);
  border-color: var(--border);
}

.auth-hint {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.auth-hint-valid {
  color: var(--accent);
  font-weight: 500;
}

.auth-links {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.auth-divider {
  position: relative;
  margin: 1.2rem 0 1rem;
  text-align: center;
}

.auth-divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px solid var(--border);
}

.auth-divider span {
  position: relative;
  padding: 0 0.55rem;
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.auth-google {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
}

.auth-google-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.auth-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
}

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

.auth-link-sep {
  color: var(--text-dim);
  margin: 0 0.35rem;
}

.auth-user-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.auth-user-email {
  font-size: 0.8rem;
  color: var(--text-dim);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-expiry-note {
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 500;
}

.nav-tab-btn {
  background: none;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.nav-tab-btn:hover {
  color: var(--text);
}

/* Theme icons */
[data-theme="dark"] .icon-sun  { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun  { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* --- Search bar ----------------------------- */
.search-bar {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  border-bottom: 1px solid transparent;
}

.search-bar.open {
  max-height: 72px;
  opacity: 1;
  border-bottom-color: var(--border-light);
}

.search-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  min-height: var(--touch-target);
  height: 52px;
  gap: 0.75rem;
}

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

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  min-height: var(--touch-target);
}

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

.search-results {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Search bar always open (search results page) */
.search-bar-always-open {
  max-height: none !important;
  opacity: 1 !important;
  overflow: visible;
}

.search-bar-always-open .search-bar-inner {
  padding-bottom: 0.5rem;
}

.search-bar-inner {
  position: relative;
}

.search-bar-inner-with-suggestions {
  position: relative;
}

/* Search suggestions dropdown */
.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  padding: 0.5rem 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
  max-height: 280px;
  overflow-y: auto;
}

.search-suggestions-section {
  padding: 0 0.5rem;
}

.search-suggestions-section + .search-suggestions-section {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-light);
}

.search-suggestions-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 0.25rem 0.5rem;
}

.search-suggestion {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.search-suggestion:hover,
.search-suggestion:focus-visible {
  background: var(--accent-muted);
  outline: none;
}

/* Search results page */
.search-results-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.search-empty-hint {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0;
}

.search-results-loading .card-grid {
  padding: 0;
}

.search-results-section {
  margin-bottom: 2.5rem;
}

.search-results-section:last-child {
  margin-bottom: 0;
}

.search-results-section-title {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--text);
}

.search-results-section-count {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.9em;
}

.search-result-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
}

.search-result-card .card-body {
  flex: 1;
}

.search-result-category {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 500;
}

.search-result-category:hover {
  text-decoration: underline;
}

/* --- Hero ----------------------------------- */
.hero {
  position: relative;
  padding: 4rem 1.5rem 3.25rem;
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, var(--accent-light) 0%, transparent 100%);
}

[data-theme="dark"] .hero-bg {
  background: linear-gradient(180deg, rgba(45, 37, 34, 0.6) 0%, transparent 100%);
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
}

.hero-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.85rem;
  opacity: 0.92;
  animation: heroFadeIn 0.6s ease both;
}

.hero-title {
  font-family: "Inter", system-ui, sans-serif;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 0.9rem;
  color: var(--text);
  animation: heroFadeIn 0.6s ease 0.08s both;
}

.hero-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 1.25rem;
  font-weight: 430;
  letter-spacing: 0.005em;
  animation: heroFadeIn 0.6s ease 0.16s both;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  animation: heroFadeIn 0.6s ease 0.24s both;
}

.hero-stat {
  transition: color 0.2s ease;
}

.hero-stat strong {
  color: var(--accent);
  font-weight: 600;
}

.hero-stat-sep {
  color: var(--text-dim);
  opacity: 0.4;
}

/* --- Features strip ------------------------- */
.features-strip {
  padding: 0.65rem 1.25rem 0.85rem;
  max-width: 1200px;
  margin: 0 auto;
  overflow: hidden;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}

.features-strip-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem 0.6rem;
}

.feature-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid transparent;
  border-radius: 6px;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
}

.feature-chip:hover {
  color: var(--accent);
  background: var(--accent-muted);
}

.feature-chip-icon {
  font-size: 0.85em;
  line-height: 1;
  opacity: 0.9;
}

.feature-chip kbd {
  display: inline-block;
  padding: 0.08rem 0.3rem;
  font-size: 0.75em;
  font-family: inherit;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

/* --- Featured banner ------------------------ */
.featured {
  padding: 1.25rem 1.25rem 0.5rem;
  max-width: 1200px;
  margin: 0 auto;
  overflow: hidden;
}

.featured-heading {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin: 0 0 0.65rem;
}

/* Featured loading skeletons */
.featured-loading-wrap {
  display: contents;
}

.featured-skeleton {
  flex: 0 0 auto;
  width: 320px;
  height: 140px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  scroll-snap-align: start;
}

.featured-empty {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 200px;
  padding: 1rem 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.featured-inner {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0.5rem;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
}

.featured-inner::-webkit-scrollbar { display: none; }

.featured-card {
  flex: 0 0 auto;
  width: 320px;
  height: 140px;
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  scroll-snap-align: start;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

@media (hover: hover) {
  .featured-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
  }
}

.featured-card-bg {
  position: absolute;
  inset: 0;
  opacity: 0.85;
}

.featured-card-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  padding: 1rem 1.25rem;
  background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 100%);
}

.featured-card-icon {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}

.featured-card-title {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  margin: 0;
}

.featured-card-desc {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.75);
  margin: 0.15rem 0 0;
  line-height: 1.35;
}

/* --- Main layout ---------------------------- */
/* Niche AI — sticky category nav */
.niche-toc {
  position: sticky;
  top: calc(var(--nav-height) + var(--safe-area-top));
  z-index: 50;
  background: rgba(250, 248, 245, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1.25rem;
  margin: 0 -1.25rem 0 -1.25rem;
}

[data-theme="dark"] .niche-toc {
  background: rgba(26, 24, 22, 0.95);
}

.niche-toc-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.niche-toc-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.niche-toc-toggle {
  display: none;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--accent-muted);
  color: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.niche-toc-toggle:hover {
  background: var(--accent);
  color: var(--bg);
}

.niche-toc-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}

.niche-toc-links::-webkit-scrollbar {
  display: none;
}

.niche-toc-links a {
  font-size: 0.88rem;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 0.25rem 0;
  transition: color 0.15s;
}

.niche-toc-links a:hover {
  color: var(--accent);
}

.niche-toc-links a.active {
  color: var(--accent);
  font-weight: 600;
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 4rem;
  transition: opacity 0.25s ease-out;
}

.main.main-loading {
  opacity: 0.92;
}

.main:not(.main-loading) {
  opacity: 1;
}

/* Category hub (index) */
.category-hub {
  padding: 2rem 0 3rem;
}

.category-hub-heading {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1.25rem 0;
  color: var(--text);
}

.category-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.category-hub-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.25s ease, border-color 0.2s ease;
}

@media (hover: hover) {
  .category-hub-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow), var(--shadow-hover);
  }
}

.category-hub-icon {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.category-hub-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.category-hub-count {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.category-hub-count-loading {
  opacity: 0.6;
  min-width: 1ch;
}

.section {
  padding: 2rem 0 1rem;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-sort-wrap { flex-shrink: 0; }

.section-sort {
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  font-family: inherit;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
}

.section-sort:hover { color: var(--text); border-color: var(--border); }
.section-sort:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

.section-title {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.section-count {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-dim);
}

.section-intro {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: -0.5rem 0 1rem 0;
  line-height: 1.45;
}

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

/* Poster card */
.card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  transition: transform 0.2s ease, box-shadow 0.25s ease, border-color 0.2s ease;
  color: inherit;
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-4px) scale(1.015);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow), var(--shadow-hover);
  }
  .card:hover .card-cover-icon { transform: scale(1.12); }
  .card:hover .freq-badge,
  .card:hover .level-badge,
  .card:hover .direct-use-badge,
  .card:hover .want-to-try-badge { transform: scale(1.05); }
}

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card.hidden { display: none; }
.section.niche-section-hidden { display: none; }

.search-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Loading skeleton */
.card-skeleton {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
  aspect-ratio: 2/3;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.main-loading .card-skeleton {
  display: block;
}

.main-loading .card-skeleton:nth-child(n+7) {
  display: none;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Poster cover (top half) */
.card-cover {
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.card-cover-icon {
  font-size: 2.5rem;
  z-index: 1;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
  transition: transform 0.25s ease;
}


/* Frequency badge on poster cover (top-left) */
.freq-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.1);
  transition: transform 0.2s ease;
}


/* Level badge on poster cover (top-right) */
.level-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.15);
  transition: transform 0.2s ease;
}

.card:hover .level-badge { transform: scale(1.1); }

.level-beginner     { background: rgba(34,197,94,0.85); }
.level-intermediate { background: rgba(59,130,246,0.85); }
.level-advanced     { background: rgba(245,158,11,0.85); }
.level-expert       { background: rgba(239,68,68,0.85); }
.level-worldclass   { background: rgba(168,85,247,0.85); }

/* Direct-use badge on poster cover (bottom-left) */
.direct-use-badge {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(0,224,84,0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.2);
  transition: transform 0.2s ease;
}

/* Want to Try badge on poster cover (bottom-right) */
.want-to-try-badge {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1;
  backdrop-filter: blur(6px);
  background: rgba(245, 158, 11, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.2s ease;
}

/* Subtle noise texture on poster */
.card-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
}

/* Card body (bottom half) */
.card-body {
  padding: 0.7rem 0.85rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.card-title {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.005em;
  color: inherit;
  text-decoration: none;
}
.card-title:hover {
  color: var(--accent);
}

.card-link:focus-visible,
.card-title:focus-visible,
.star:focus-visible,
.icon-btn:focus-visible,
.nav-tab:focus-visible,
.direct-use-btn:focus-visible,
.want-to-try-btn:focus-visible,
.stack-btn:focus-visible,
.search-bar input:focus-visible,
.profile-switcher-trigger:focus-visible,
.stack-sort:focus-visible,
.bottom-nav-item:focus-visible,
.auth-btn:focus-visible,
.hero-cta-btn:focus-visible,
.category-hub-card:focus-visible,
.auth-password-toggle:focus-visible,
.pwa-install-btn:focus-visible,
.pwa-install-dismiss:focus-visible,
.footer-link:focus-visible,
.auth-link:focus-visible,
.rating-clear-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-trust-signals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.15rem;
}

.trust-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.25;
  white-space: nowrap;
  transition: transform 0.15s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.trust-badge-official {
  color: #1f6feb;
  border-color: rgba(31, 111, 235, 0.25);
  background: rgba(31, 111, 235, 0.08);
}

.trust-badge-oss {
  color: #1a8f4b;
  border-color: rgba(26, 143, 75, 0.24);
  background: rgba(26, 143, 75, 0.09);
}

.trust-badge-docs {
  color: #7b42d1;
  border-color: rgba(123, 66, 209, 0.22);
  background: rgba(123, 66, 209, 0.09);
}

.trust-badge-evidence {
  color: #9a3a1e;
  border-color: rgba(154, 58, 30, 0.22);
  background: rgba(154, 58, 30, 0.09);
}

.trust-badge-secure {
  color: #008a6e;
  border-color: rgba(0, 138, 110, 0.24);
  background: rgba(0, 138, 110, 0.09);
}

.freshness-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.25;
  white-space: nowrap;
  margin-bottom: 0.25rem;
}

.freshness-new {
  color: #059669;
  border: 1px solid rgba(5, 150, 105, 0.3);
  background: rgba(5, 150, 105, 0.1);
}

.freshness-recent {
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.25);
  background: rgba(37, 99, 235, 0.08);
}

.freshness-stale {
  color: #d97706;
  border: 1px solid rgba(217, 119, 6, 0.3);
  background: rgba(217, 119, 6, 0.08);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: auto;
  padding-top: 0.25rem;
}

.card-tag {
  font-size: 0.65rem;
  font-weight: 500;
  padding: 0.15rem 0.45rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 6px;
  letter-spacing: 0.01em;
}

/* --- Star rating ----------------------------- */
.card-rating {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0.3rem 0 0.1rem;
  position: relative;
  z-index: 2;
}

.star {
  position: relative;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  border-radius: 4px;
}
@media (pointer: coarse) {
  .star {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}

.star-half {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 1;
}

.star-left  { left: 0; }
.star-right { right: 0; }

.star-icon {
  display: block;
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  transition: color 0.15s ease, transform 0.15s ease, filter 0.15s ease;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .star-icon {
    transition: none;
  }
}

.star.filled .star-icon,
.star.half-filled .star-icon {
  color: var(--accent);
}

.card-rating.hovering .star .star-icon {
  color: var(--text-dim);
}

.card-rating.hovering .star.preview .star-icon {
  color: var(--accent);
  filter: brightness(1.15);
  transform: scale(1.13);
}

.card-rating.hovering .star.preview-half .star-icon {
  color: var(--accent);
  filter: brightness(1.15);
  transform: scale(1.13);
}
@media (prefers-reduced-motion: reduce) {
  .card-rating.hovering .star.preview .star-icon,
  .card-rating.hovering .star.preview-half .star-icon {
    transform: none;
  }
}

.star:active .star-icon {
  transform: scale(0.82);
}
@media (prefers-reduced-motion: reduce) {
  .star:active .star-icon {
    transform: none;
  }
}

/* Just-rated feedback flash */
.card-rating.just-rated .star.filled .star-icon,
.card-rating.just-rated .star.half-filled .star-icon {
  animation: star-rated-pulse 0.5s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@media (prefers-reduced-motion: reduce) {
  .card-rating.just-rated .star .star-icon {
    animation: none;
  }
}
@keyframes star-rated-pulse {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  35% { transform: scale(1.26); filter: brightness(1.32); }
  65% { transform: scale(1.1); filter: brightness(1.12); }
}

.rating-value {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-left: 0.38rem;
  min-width: 1.4em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  padding: 0.08rem 0.34rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  transition: color 0.15s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.card-rating.just-rated .rating-value {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
  transform: translateY(-1px);
}

.rating-value.previewing {
  color: var(--accent);
  border-color: rgba(211, 35, 35, 0.25);
  background: rgba(211, 35, 35, 0.08);
}

/* --- Empty state ----------------------------- */
.section-empty {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  grid-column: 1 / -1;
}

.section-empty-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.75rem;
  opacity: 0.7;
}

.section-empty-cta {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  transition: background 0.2s, color 0.2s;
}

.section-empty-cta:hover {
  background: var(--accent-muted);
  color: var(--accent);
}

.section-empty-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.section-empty-link:hover {
  text-decoration: underline;
}

/* --- Footer --------------------------------- */
.footer {
  text-align: center;
  padding: 2.5rem 1.25rem calc(2rem + var(--safe-area-bottom));
  color: var(--text-dim);
  font-size: 0.8rem;
  border-top: 1px solid var(--border-light);
  max-width: 1200px;
  margin: 0 auto;
}

.footer-logo {
  color: var(--accent);
  font-size: 1.1rem;
  display: block;
  margin-bottom: 0.4rem;
}

.footer-links {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.footer-link {
  padding: 0.5rem 0.35rem;
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.2s;
}

.footer-link-sep {
  color: var(--text-dim);
  opacity: 0.6;
}

.footer-link:hover {
  opacity: 0.85;
}

/* --- Pull-to-refresh indicator (mobile) --- */
.pull-to-refresh-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -40px);
  z-index: 150;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pull-to-refresh-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.pull-to-refresh-indicator.at-threshold .pull-to-refresh-spinner {
  opacity: 1;
  animation: ptr-spin 0.6s linear infinite;
}

.pull-to-refresh-indicator.refreshing .pull-to-refresh-spinner {
  opacity: 1;
  animation: ptr-spin 0.6s linear infinite;
}

@keyframes ptr-spin {
  to { transform: rotate(360deg); }
}

.pull-to-refresh-arrow {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.9rem;
  line-height: 1;
}

.pull-to-refresh-indicator.at-threshold .pull-to-refresh-arrow {
  transform: rotate(180deg);
}

.pull-to-refresh-indicator.refreshing .pull-to-refresh-arrow {
  display: none;
}

.pull-to-refresh-indicator.at-threshold .pull-to-refresh-text::before {
  content: "Release to refresh";
}

.pull-to-refresh-indicator.refreshing .pull-to-refresh-text::before {
  content: "Refreshing\2026";
}

.pull-to-refresh-indicator:not(.at-threshold):not(.refreshing) .pull-to-refresh-text::before {
  content: "Pull to refresh";
}

.pull-to-refresh-text {
  font-weight: 500;
}

/* --- Back to top ---------------------------- */
.back-to-top {
  position: fixed;
  bottom: calc(1.5rem + var(--safe-area-bottom));
  right: calc(1.5rem + var(--safe-area-right));
  z-index: 50;
  width: 48px;
  height: 48px;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--btn-on-accent);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, opacity 0.3s ease, visibility 0.3s ease;
  touch-action: manipulation;
}
.back-to-top:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.back-to-top:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.back-to-top.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* --- PWA install banner ------------------- */
.pwa-install-banner {
  position: fixed;
  bottom: calc(1.5rem + var(--safe-area-bottom));
  left: 1rem;
  right: 1rem;
  max-width: 360px;
  margin: 0 auto;
  z-index: 90;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}
.pwa-install-banner.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.pwa-install-banner-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.pwa-install-banner-text {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 140px;
}
.pwa-install-banner-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.pwa-install-btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--btn-on-accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}
.pwa-install-btn:hover {
  background: var(--accent-hover);
}
.pwa-install-dismiss {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
}
.pwa-install-dismiss:hover {
  color: var(--text);
}
@media (max-width: 768px) {
  .pwa-install-banner {
    bottom: calc(4.5rem + var(--safe-area-bottom));
  }
}
@media (max-width: 640px) {
  .pwa-install-banner {
    bottom: calc(5rem + var(--safe-area-bottom));
  }
}

/* --- Mobile bottom navigation bar ---------- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(250, 248, 245, 0.95);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-top: 1px solid var(--border-light);
  padding: 0.35rem 0.5rem calc(0.35rem + var(--safe-area-bottom));
  touch-action: manipulation;
}

[data-theme="dark"] .bottom-nav {
  background: rgba(26, 24, 22, 0.95);
  border-top-color: rgba(61, 56, 52, 0.6);
}

.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: 500px;
  margin: 0 auto;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.35rem 0.5rem;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease, transform 0.1s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  border-radius: 8px;
}

.bottom-nav-item:active {
  transform: scale(0.92);
}

@media (prefers-reduced-motion: reduce) {
  .bottom-nav-item:active {
    transform: none;
  }
}

.bottom-nav-item.active {
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-muted);
  position: relative;
  box-shadow: 0 0 0 1.5px var(--accent), 0 2px 8px var(--accent-glow);
}

[data-theme="dark"] .bottom-nav-item.active {
  box-shadow: 0 0 0 1.5px var(--accent), 0 2px 10px var(--accent-glow);
}

.bottom-nav-item.active .bottom-nav-icon {
  transform: scale(1.15);
  filter: drop-shadow(0 0 4px var(--accent-glow));
  transition: transform 0.2s ease, filter 0.2s ease;
}

.bottom-nav-item.active::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}

.bottom-nav-icon {
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.bottom-nav-label {
  display: block;
  line-height: 1;
  letter-spacing: 0.01em;
}

/* --- Mobile nav overlay/backdrop ------------ */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 89;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-backdrop.visible {
  opacity: 1;
}

/* Body scroll lock when nav open */
body.nav-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  touch-action: none;
}

/* --- More menu overlay (auth pages, search page) --- */
.more-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0.2s ease;
}

.more-menu-overlay.visible {
  pointer-events: auto;
  visibility: visible;
}

.more-menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.more-menu-overlay.visible .more-menu-backdrop {
  opacity: 1;
}

.more-menu-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1.5rem 1.5rem calc(1.5rem + var(--safe-area-bottom));
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.more-menu-overlay.visible .more-menu-panel {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .more-menu-overlay .more-menu-backdrop,
  .more-menu-overlay .more-menu-panel {
    transition: none;
  }
}

.more-menu-link {
  display: block;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius);
  transition: background 0.15s ease;
  min-height: var(--touch-target);
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

.more-menu-link:hover {
  background: var(--bg-surface);
}

.more-menu-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body.more-menu-open {
  overflow: hidden;
}

/* --- Card action buttons -------------------- */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
}
.card-actions button:focus-visible,
.card-actions a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.rating-clear-btn {
  font-size: 0.7rem;
  color: var(--text-dim);
  background: none;
  border: none;
  padding: 0.2rem 0.35rem;
  cursor: pointer;
  margin-left: 0.25rem;
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.rating-clear-btn:hover {
  color: var(--text-muted);
  text-decoration: underline;
}

.direct-use-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  min-height: var(--touch-target);
  font-size: 0.65rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: var(--touch-target);
  touch-action: manipulation;
}
.direct-use-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}
.direct-use-btn.using {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}

.want-to-try-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  min-height: var(--touch-target);
  font-size: 0.65rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: var(--touch-target);
  touch-action: manipulation;
}
.want-to-try-btn:hover {
  color: #f59e0b;
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
}
.want-to-try-btn.flagged {
  color: #f59e0b;
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
}

.stack-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.65rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: var(--touch-target);
  touch-action: manipulation;
}
.stack-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}
.stack-btn.in-stack {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: var(--touch-target);
  touch-action: manipulation;
}
.share-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}
.share-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.visit-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s ease;
  min-height: var(--touch-target);
  touch-action: manipulation;
}
.visit-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}
.visit-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-category-link {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s ease;
  min-height: var(--touch-target);
  touch-action: manipulation;
}
.card-category-link:hover {
  color: var(--accent);
}
.card-category-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-shared-highlight {
  animation: card-shared-pulse 2.5s ease-out;
}
@keyframes card-shared-pulse {
  0% { box-shadow: 0 0 0 0 var(--accent-glow); }
  20% { box-shadow: 0 0 0 6px var(--accent-glow); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* --- No results message -------------------- */
.search-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.95rem;
}

/* --- Mobile nav hamburger ------------------- */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--touch-target);
  height: var(--touch-target);
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: auto;
  touch-action: manipulation;
}
.nav-toggle:hover {
  color: var(--text);
  background: var(--bg-surface);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}
.nav-toggle-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-toggle-bar + .nav-toggle-bar {
  margin-top: 4px;
}

@media (min-width: 1024px) {
  :root {
    --desktop-sidebar-width: 220px;
  }

  .topbar {
    padding-left: var(--desktop-sidebar-width);
  }

  .topbar-inner,
  .search-bar-inner,
  .hero,
  .features-strip,
  .featured,
  .main,
  .footer {
    width: calc(100% - var(--desktop-sidebar-width));
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }

  .nav-tabs {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--desktop-sidebar-width);
    height: 100vh;
    margin-left: 0;
    padding: calc(0.85rem + var(--safe-area-top)) 0.7rem 1rem calc(0.7rem + var(--safe-area-left));
    border-right: 1px solid var(--border);
    background: var(--bg-elevated);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    overflow-y: auto;
    z-index: 120;
  }

  .nav-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
  }

  .nav-group + .nav-group::before {
    display: none;
  }

  .nav-group + .nav-group {
    border-top: 1px solid var(--border-light);
    padding-top: 0.7rem;
  }

  .nav-group-label {
    display: block;
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-dim);
    padding: 0.15rem 0.45rem 0.3rem;
  }

  .nav-tab {
    display: block;
    border-radius: 10px;
    padding: 0.5rem 0.7rem;
  }

  .featured-inner {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
  }
}

/* --- Responsive ----------------------------- */
@media (max-width: 900px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 0.75rem;
  }

  .featured-card,
  .featured-skeleton {
    width: 280px;
    height: 125px;
  }
}

@media (max-width: 768px) {
  /* Show bottom nav and hide desktop top-nav items */
  .bottom-nav {
    display: block;
  }

  .nav-backdrop {
    display: block;
  }

  .nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
  }

  .nav-tabs {
    position: fixed;
    top: calc(var(--nav-height) + var(--safe-area-top));
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem calc(1rem + var(--safe-area-right)) calc(5rem + var(--safe-area-bottom)) calc(1rem + var(--safe-area-left));
    gap: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
  }

  .nav-tabs.open {
    transform: translateX(0);
  }

  .nav-group {
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
  }

  .nav-group + .nav-group {
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--border-light);
  }

  .nav-group + .nav-group::before {
    display: none;
  }

  .nav-group-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-dim);
    padding: 0.15rem 1rem 0.35rem;
  }

  .nav-tab {
    padding: 0.85rem 1rem;
    font-size: 1rem;
    border-radius: var(--radius);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  }

  .nav-tab:active {
    transform: scale(0.98);
    background: var(--bg-surface);
  }

  /* Push footer down to account for bottom nav */
  .footer {
    padding-bottom: calc(5rem + var(--safe-area-bottom));
  }

  /* Push main content to account for bottom nav */
  .main {
    padding-bottom: calc(5rem + var(--safe-area-bottom));
  }

  /* Back-to-top above bottom nav */
  .back-to-top {
    bottom: calc(4.5rem + var(--safe-area-bottom));
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    padding: 0 calc(0.75rem + var(--safe-area-right)) 0 calc(0.75rem + var(--safe-area-left));
    gap: 0.75rem;
  }

  .logo {
    font-size: 0.95rem;
  }

  .hero {
    padding: 2.5rem 1rem 2rem;
  }

  .hero-label {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    margin-bottom: 0.75rem;
  }

  .hero-desc {
    font-size: 0.95rem;
  }

  .hero-stats {
    font-size: 0.8rem;
  }

  .features-strip {
    padding: 0.6rem 1rem 0.75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    touch-action: pan-x;
    position: relative;
  }

  .features-strip::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 2.5rem;
    height: 100%;
    background: linear-gradient(to left, var(--bg) 45%, transparent 100%);
    pointer-events: none;
  }

[data-theme="dark"] .features-strip::after {
  background: linear-gradient(to left, var(--bg) 45%, transparent 100%);
}

  .features-strip-inner {
    flex-wrap: nowrap;
    justify-content: flex-start;
    min-width: max-content;
    padding-right: 1rem;
  }

  .features-strip::-webkit-scrollbar {
    display: none;
  }

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

  .section {
    padding-top: 1.35rem;
  }

  .featured { padding: 1.25rem calc(0.75rem + var(--safe-area-right)) 0.25rem calc(0.75rem + var(--safe-area-left)); }
  .featured-card,
  .featured-skeleton { width: 250px; height: 115px; }

  .main { padding: 0.25rem calc(0.75rem + var(--safe-area-right)) calc(5rem + var(--safe-area-bottom)) calc(0.75rem + var(--safe-area-left)); }

  .star {
    width: var(--touch-target);
    height: var(--touch-target);
    min-width: var(--touch-target);
    min-height: var(--touch-target);
  }
  .star-icon {
    width: 22px;
    height: 22px;
  }
  .search-bar input {
    font-size: 16px;
  }

  /* Card action buttons: wrap and space evenly on small screens */
  .card-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
  }

  .card-actions > button,
  .card-actions > a {
    flex: 1 1 auto;
    justify-content: center;
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    font-size: 0.68rem;
    padding: 0.35rem 0.5rem;
    white-space: nowrap;
  }

  /* Category hub grid: 2-col on small */
  .category-hub-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .category-hub-card {
    min-height: 100px;
    padding: 1rem;
  }

  /* Auth pages: tighter on small screens */
  .auth-main {
    padding: 2rem 1rem calc(3rem + var(--safe-area-bottom));
  }

  .auth-card {
    padding: 1.5rem;
  }

  .card-body {
    padding: 0.52rem 0.62rem 0.66rem;
    gap: 0.22rem;
  }

  .card-title {
    font-size: 0.82rem;
    line-height: 1.25;
  }

  .card-desc {
    font-size: 0.7rem;
    line-height: 1.34;
    -webkit-line-clamp: 1;
  }

  .card-trust-signals {
    gap: 0.22rem;
    margin-top: 0.1rem;
  }

  .trust-badge {
    font-size: 0.56rem;
    padding: 0.1rem 0.34rem;
  }

  .card-rating {
    padding-top: 0.2rem;
  }

  .rating-value {
    font-size: 0.58rem;
    margin-left: 0.26rem;
  }
}

@media (max-width: 400px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  /* Back-to-top: more clearance above bottom nav on small viewports */
  .back-to-top {
    bottom: calc(5rem + var(--safe-area-bottom));
  }

  .card-cover-icon { font-size: 2rem; }

  .card-body {
    padding: 0.46rem 0.56rem 0.62rem;
  }

  .card-title {
    font-size: 0.76rem;
  }

  .card-desc {
    font-size: 0.66rem;
    -webkit-line-clamp: 1;
  }

  .trust-badge {
    font-size: 0.54rem;
    padding: 0.08rem 0.3rem;
  }

  /* Card actions: stack vertically on very narrow screens */
  .card-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .card-actions > button,
  .card-actions > a {
    min-width: 100%;
    padding: 0.35rem 0.4rem;
    font-size: 0.64rem;
  }
}

/* --- Touch interaction enhancements ---------- */
.card {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.card:active {
  transform: scale(0.98);
}

@media (prefers-reduced-motion: reduce) {
  .card:active {
    transform: none;
  }
}

.category-hub-card {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.category-hub-card:active {
  transform: scale(0.97);
}

@media (prefers-reduced-motion: reduce) {
  .category-hub-card:active {
    transform: none;
  }
}

.featured-card {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.featured-card:active {
  transform: scale(0.97);
}

@media (prefers-reduced-motion: reduce) {
  .featured-card:active {
    transform: none;
  }
}

/* Ensure all buttons and interactive elements have proper touch targets */
button,
[role="button"],
a.nav-tab,
a.footer-link,
a.auth-link,
.card-link,
.visit-btn,
.share-btn,
.stack-btn,
.direct-use-btn,
.want-to-try-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Active press feedback for action buttons */
.stack-btn:active,
.direct-use-btn:active,
.want-to-try-btn:active,
.share-btn:active,
.visit-btn:active,
.auth-btn:active,
.profile-form-btn:active,
.admin-copy-btn:active {
  transform: scale(0.96);
}

@media (prefers-reduced-motion: reduce) {
  .stack-btn:active,
  .direct-use-btn:active,
  .want-to-try-btn:active,
  .share-btn:active,
  .visit-btn:active,
  .auth-btn:active,
  .profile-form-btn:active,
  .admin-copy-btn:active {
    transform: none;
  }
}

/* Improve horizontal scroll containers for touch */
.featured-inner,
.niche-toc-links {
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
}

/* --- Mobile input font-size fix ------------- */
/* Prevents iOS auto-zoom on input focus (must be >= 16px) */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* Niche TOC: horizontal scroll + collapsible on mobile */
@media (max-width: 768px) {
  .niche-toc-toggle {
    display: block;
  }
  .niche-toc-links {
    flex-wrap: nowrap;
    max-height: 2.5rem;
  }
  .niche-toc-links.collapsed {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
  }
  .niche-toc-links a {
    scroll-snap-align: start;
    flex-shrink: 0;
  }
}

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

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

.card {
  animation: fadeInUp 0.35s ease both;
}

.card:nth-child(1)  { animation-delay: 0s; }
.card:nth-child(2)  { animation-delay: 0.04s; }
.card:nth-child(3)  { animation-delay: 0.08s; }
.card:nth-child(4)  { animation-delay: 0.12s; }
.card:nth-child(5)  { animation-delay: 0.16s; }
.card:nth-child(6)  { animation-delay: 0.2s; }
.card:nth-child(7)  { animation-delay: 0.24s; }
.card:nth-child(8)  { animation-delay: 0.28s; }
.card:nth-child(9)  { animation-delay: 0.32s; }
.card:nth-child(10) { animation-delay: 0.36s; }

.featured-card {
  animation: fadeInUp 0.4s ease both;
}

.featured-card:nth-child(1) { animation-delay: 0s; }
.featured-card:nth-child(2) { animation-delay: 0.06s; }
.featured-card:nth-child(3) { animation-delay: 0.12s; }
.featured-card:nth-child(4) { animation-delay: 0.18s; }

/* --- Reduced motion (accessibility) --------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  .hero-label, .hero-title, .hero-desc, .hero-stats {
    animation: none !important;
  }
}

/* ============================================
   Industry-Standard Redesign — 2026
   Clean, professional design matching G2/PH/Capterra
   ============================================ */

/* --- Body background: subtle gradient mesh --- */
body {
  background:
    radial-gradient(ellipse 60% 40% at 10% -10%, rgba(79, 70, 229, 0.04), transparent),
    radial-gradient(ellipse 50% 30% at 90% 5%, rgba(124, 58, 237, 0.025), transparent),
    var(--bg);
}

[data-theme="dark"] body {
  background:
    radial-gradient(ellipse 60% 40% at 10% -10%, rgba(79, 70, 229, 0.06), transparent),
    radial-gradient(ellipse 50% 30% at 90% 5%, rgba(124, 58, 237, 0.04), transparent),
    var(--bg);
}

/* --- Max width containers ------------------- */
.topbar-inner,
.search-bar-inner,
.hero,
.features-strip,
.featured,
.main,
.footer {
  max-width: 1280px;
}

/* --- Topbar: cleaner, professional ---------- */
.topbar-scrolled {
  box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .topbar-scrolled {
  box-shadow: 0 1px 0 var(--border), 0 2px 12px rgba(0, 0, 0, 0.2);
}

/* --- Logo & Nav: modern sans-serif ---------- */
.logo,
.section-title,
.category-hub-heading,
.stack-hero-title,
.about-hero-title,
.about-section-title,
.auth-title,
.hero-title,
.dash-title,
.recs-heading,
.search-results-section-title {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  letter-spacing: -0.025em;
}

.logo {
  font-size: 1.05rem;
  font-weight: 700;
}

.logo-icon {
  color: var(--accent);
  font-size: 1.05rem;
}

.nav-tab {
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 8px;
  padding: 0.42rem 0.7rem;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-tab.active {
  color: var(--accent);
  background: var(--accent-muted);
  font-weight: 600;
}

/* --- Search bar: refined -------------------- */
.search-bar.open {
  border-bottom-color: var(--border);
}

/* --- Hero: left-aligned, confident ---------- */
.hero {
  text-align: left;
  padding-top: 3rem;
  padding-bottom: 2.5rem;
}

.hero-bg {
  background: none;
}

[data-theme="dark"] .hero-bg {
  background: none;
}

.hero-inner {
  margin: 0;
  max-width: 720px;
}

.hero-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.75rem;
  background: var(--accent-muted);
  border: 1px solid rgba(79, 70, 229, 0.12);
  border-radius: 999px;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1rem;
}

[data-theme="dark"] .hero-label {
  border-color: rgba(129, 140, 248, 0.18);
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.035em;
  color: var(--text);
}

.hero-desc {
  max-width: 54ch;
  font-size: 1.02rem;
  line-height: 1.65;
  color: var(--text-muted);
  font-weight: 400;
}

.hero-stats {
  justify-content: flex-start;
  font-size: 0.85rem;
  gap: 0.35rem 0.5rem;
  margin-top: 0.35rem;
}

.hero-stat strong {
  color: var(--accent);
  font-weight: 700;
}

/* --- Hero CTA buttons: industry standard ---- */
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.25rem 0 0.5rem;
}

.hero-shortcut-hint {
  margin: 0.75rem 0 0;
  font-size: 0.76rem;
  color: var(--text-dim);
}

.hero-shortcut-hint kbd {
  padding: 0.1em 0.38em;
  font-size: 0.82em;
  font-family: inherit;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
  color: var(--text-muted);
}

.hero-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.55rem 1.35rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hero-cta-btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.3), 0 4px 12px rgba(79, 70, 229, 0.15);
}

.hero-cta-btn.secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow);
}

@media (hover: hover) {
  .hero-cta-btn:hover {
    transform: translateY(-1px);
  }

  .hero-cta-btn.primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.35), 0 8px 20px rgba(79, 70, 229, 0.2);
  }

  .hero-cta-btn.secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-muted);
  }
}

[data-theme="dark"] .hero-cta-btn.primary {
  box-shadow: 0 1px 3px rgba(129, 140, 248, 0.25), 0 4px 12px rgba(129, 140, 248, 0.12);
}

/* --- Features strip: pill chips ------------- */
.features-strip {
  border-top: none;
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 1.25rem 0.85rem;
}

.feature-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.28rem 0.65rem;
  transition: all 0.15s ease;
}

.feature-chip:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-muted);
}

/* --- Featured section: clean cards ---------- */
.featured-heading {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

.featured-card {
  border: none;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
}

.featured-card-content {
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0.1) 60%, transparent 100%);
}

/* --- Section headers: clean, no borders ----- */
.section {
  padding-top: 2rem;
}

.section-header {
  border-bottom: none;
  margin-bottom: 1.15rem;
  padding-bottom: 0;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.section-intro {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.section-sort {
  border-radius: 8px;
  font-size: 0.82rem;
  padding: 0.38rem 0.6rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.section-sort:hover {
  border-color: var(--accent);
}

/* --- Card grid: tighter, professional ------- */
.card-grid {
  gap: 0.85rem;
}

/* --- Cards: elevated, clean borders --------- */
.category-hub-card,
.card,
.stack-card,
.auth-card,
.profile-item,
.data-export-import {
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}

.card {
  border-radius: var(--radius);
  transition: all 0.2s ease;
}

@media (hover: hover) {
  .category-hub-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
  }

  .card:hover {
    border-color: rgba(79, 70, 229, 0.25);
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.06), 0 2px 8px rgba(0, 0, 0, 0.03);
    transform: translateY(-2px) scale(1.01);
  }

  .card:hover .card-cover-icon {
    transform: scale(1.08);
  }

  .stack-card:hover {
    border-color: rgba(79, 70, 229, 0.25);
    box-shadow: var(--shadow-hover);
  }
}

[data-theme="dark"] .card:hover {
  border-color: rgba(129, 140, 248, 0.25);
  box-shadow: 0 8px 24px rgba(129, 140, 248, 0.05), 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* --- Card cover: reduced height, cleaner ---- */
.card-cover {
  aspect-ratio: 16 / 9;
}

.card-cover-icon {
  font-size: 2.2rem;
}

/* --- Card body: tighter spacing ------------- */
.card-body {
  padding: 0.65rem 0.8rem 0.75rem;
  gap: 0.25rem;
}

.card-title,
.stack-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-desc,
.stack-card-desc {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.card-tag,
.stack-card-tag {
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.12rem 0.4rem;
}

/* --- Trust badges: refined pills ------------ */
.trust-badge {
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 0.6rem;
  border-radius: 4px;
}

.trust-badge-official {
  color: #4f46e5;
  border-color: rgba(79, 70, 229, 0.15);
  background: rgba(79, 70, 229, 0.06);
}

.trust-badge-oss {
  color: #059669;
  border-color: rgba(5, 150, 105, 0.15);
  background: rgba(5, 150, 105, 0.06);
}

.trust-badge-docs {
  color: #7c3aed;
  border-color: rgba(124, 58, 237, 0.15);
  background: rgba(124, 58, 237, 0.06);
}

.trust-badge-evidence {
  color: #dc2626;
  border-color: rgba(220, 38, 38, 0.15);
  background: rgba(220, 38, 38, 0.06);
}

.trust-badge-secure {
  color: #0891b2;
  border-color: rgba(8, 145, 178, 0.15);
  background: rgba(8, 145, 178, 0.06);
}

/* --- Action buttons: polished, consistent --- */
.direct-use-btn,
.want-to-try-btn,
.stack-btn,
.share-btn,
.visit-btn,
.stack-visit-btn,
.stack-share-btn {
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.66rem;
  border-color: var(--border);
  transition: all 0.15s ease;
}

.visit-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.visit-btn:hover {
  background: var(--accent-hover);
  color: #fff;
  border-color: var(--accent-hover);
}

/* --- Star rating: amber tones --------------- */
.star.filled .star-icon,
.star.half-filled .star-icon {
  color: #f59e0b;
}

.card-rating.hovering .star.preview .star-icon,
.card-rating.hovering .star.preview-half .star-icon {
  color: #f59e0b;
  filter: brightness(1.1);
}

.rating-value.previewing {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.2);
  background: rgba(245, 158, 11, 0.06);
}

.card-rating.just-rated .rating-value {
  color: #f59e0b;
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}

/* --- Level badges: refined colors ----------- */
.level-beginner     { background: rgba(16, 185, 129, 0.88); }
.level-intermediate { background: rgba(59, 130, 246, 0.88); }
.level-advanced     { background: rgba(245, 158, 11, 0.88); }
.level-expert       { background: rgba(239, 68, 68, 0.88); }
.level-worldclass   { background: rgba(139, 92, 246, 0.88); }

/* --- Category hub: professional grid -------- */
.category-hub-heading {
  font-size: 1.25rem;
  font-weight: 800;
}

.category-hub-grid {
  gap: 1rem;
}

.category-hub-card {
  border-radius: var(--radius);
  transition: all 0.2s ease;
  min-height: 110px;
}

@media (hover: hover) {
  .category-hub-card:hover .category-hub-icon {
    transform: scale(1.08);
  }

  .category-hub-card:hover .category-hub-label {
    color: var(--accent);
  }
}

.category-hub-icon {
  transition: transform 0.2s ease;
}

.category-hub-label {
  font-weight: 600;
  font-size: 0.9rem;
  transition: color 0.15s ease;
}

/* --- Bottom nav: refined -------------------- */
.bottom-nav {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

[data-theme="dark"] .bottom-nav {
  background: rgba(12, 15, 26, 0.92);
}

.bottom-nav-item.active {
  color: var(--accent);
  background: var(--accent-muted);
  box-shadow: 0 0 0 1.5px var(--accent), 0 2px 6px var(--accent-glow);
}

.bottom-nav-item.active::after {
  background: var(--accent);
  box-shadow: 0 0 4px var(--accent-glow);
}

/* --- Footer: clean -------------------------- */
.footer {
  border-top-color: var(--border);
}

.footer-logo {
  color: var(--accent);
}

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

/* --- More menu: refined --------------------- */
.more-menu-panel {
  background: var(--bg-elevated);
}

.more-menu-link:hover {
  background: var(--accent-muted);
  color: var(--accent);
}

/* --- Auth pages: refined -------------------- */
.auth-card {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.auth-title {
  font-weight: 700;
}

.auth-btn {
  background: var(--accent);
  border-radius: 8px;
  font-weight: 600;
}

.auth-btn:hover {
  background: var(--accent-hover);
}

/* --- Back to top: refined ------------------- */
.back-to-top {
  background: var(--accent);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  font-size: 1.1rem;
}

.back-to-top:hover {
  background: var(--accent-hover);
}

/* --- Toast: modern pill shape --------------- */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 0.75rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg-elevated);
  font-size: 0.83rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  max-width: min(90vw, 300px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Search: refined dropdowns -------------- */
.search-suggestions {
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  border-color: var(--border);
}

.search-suggestion:hover,
.search-suggestion:focus-visible {
  background: var(--accent-muted);
  color: var(--accent);
}

/* --- Profile switcher: refined -------------- */
.profile-switcher-trigger {
  border-radius: 8px;
}

.profile-switcher-trigger:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.profile-switcher-dropdown {
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
}

/* --- PWA install: refined ------------------- */
.pwa-install-banner {
  border-color: var(--border);
  border-radius: var(--radius);
}

.pwa-install-btn {
  background: var(--accent);
  border-radius: 8px;
}

.pwa-install-btn:hover {
  background: var(--accent-hover);
}

/* --- Selection styling ---------------------- */
::selection {
  background: rgba(79, 70, 229, 0.12);
  color: var(--text);
}

[data-theme="dark"] ::selection {
  background: rgba(129, 140, 248, 0.2);
}

/* --- Mobile responsive: hero & cards -------- */
@media (max-width: 900px) {
  .card-grid {
    gap: 0.7rem;
  }
}

@media (max-width: 768px) {
  .hero {
    padding-top: 2.25rem;
    padding-bottom: 1.75rem;
  }

  .hero-title {
    font-size: clamp(1.65rem, 7vw, 2.25rem);
  }

  .hero-desc {
    font-size: 0.95rem;
  }

  .hero-cta {
    gap: 0.5rem;
  }

  .hero-cta-btn {
    flex: 1 1 auto;
    min-width: 130px;
  }

  .nav-tabs {
    background: var(--bg);
  }
}

@media (max-width: 640px) {
  .hero-label {
    font-size: 0.64rem;
    padding: 0.22rem 0.55rem;
  }

  .hero-cta-btn {
    padding: 0.5rem 0.9rem;
    font-size: 0.82rem;
    border-radius: 8px;
  }

  .card-cover {
    aspect-ratio: 3 / 2;
  }

  .card-body {
    padding: 0.5rem 0.6rem 0.6rem;
    gap: 0.2rem;
  }

  .card-title {
    font-size: 0.8rem;
  }

  .card-desc {
    font-size: 0.7rem;
    -webkit-line-clamp: 1;
  }
}

/* --- Sidebar (desktop): clean --------------- */
@media (min-width: 1024px) {
  .nav-tabs {
    background: var(--bg-elevated);
    border-right-color: var(--border);
  }

  .nav-group-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
  }

  .nav-tab {
    border-radius: 8px;
    padding: 0.48rem 0.7rem;
    font-size: 0.84rem;
  }

  .nav-tab.active {
    background: var(--accent-muted);
    color: var(--accent);
    font-weight: 600;
  }
}

/* --- Card animation: subtler entrance ------- */
.card {
  animation: fadeInUp 0.3s ease both;
}

@media (hover: hover) {
  .card:hover {
    box-shadow: var(--shadow-hover);
  }
}

/* --- Page transitions ----------------------- */
body.page-entering { opacity: 0; }
body.page-entered { opacity: 1; transition: opacity 0.25s ease; }

.reveal-on-scroll {
  opacity: 0; transform: translateY(16px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  transition-delay: var(--reveal-delay, 0ms);
}
.reveal-on-scroll.revealed { opacity: 1; transform: none; }

.ripple-effect {
  position: absolute; border-radius: 50%;
  width: 0; height: 0;
  background: rgba(255,255,255,0.25);
  transform: translate(-50%, -50%);
  animation: rippleExpand 0.5s ease-out forwards;
  pointer-events: none;
}
@keyframes rippleExpand {
  to { width: 280px; height: 280px; opacity: 0; }
}

/* ============================================
   COMMAND PALETTE
   ============================================ */
.cp-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: none; align-items: flex-start; justify-content: center;
  padding-top: min(20vh, 160px);
}
.cp-overlay.cp-open { display: flex; }
.cp-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  animation: cpFadeIn 0.15s ease;
}
.cp-container {
  position: relative; z-index: 1;
  width: min(640px, 90vw);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
  overflow: hidden;
  animation: cpSlideIn 0.2s ease;
}
.cp-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
}
.cp-search-icon { color: var(--text-muted); flex-shrink: 0; }
.cp-input {
  flex: 1; border: none; background: transparent;
  font-size: 1.1rem; color: var(--text);
  font-family: inherit; outline: none;
}
.cp-input::placeholder { color: var(--text-dim); }
.cp-esc {
  font-size: 0.7rem; padding: 2px 6px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text-muted);
}
.cp-results {
  list-style: none; margin: 0; padding: 0.5rem 0;
  max-height: 400px; overflow-y: auto;
}
.cp-result {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem; cursor: pointer;
  transition: background 0.1s;
}
.cp-result-selected { background: var(--accent-muted); }
.cp-result:hover { background: var(--accent-muted); }
.cp-result-icon { font-size: 1.2rem; flex-shrink: 0; width: 28px; text-align: center; }
.cp-result-text { flex: 1; min-width: 0; }
.cp-result-title { display: block; font-weight: 500; color: var(--text); }
.cp-result-title mark { background: var(--accent-muted); color: var(--accent); border-radius: 2px; padding: 0 2px; }
.cp-result-desc { display: block; font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-result-type { font-size: 0.72rem; color: var(--text-dim); padding: 2px 6px; background: var(--bg-surface); border-radius: 4px; flex-shrink: 0; }
.cp-footer {
  display: flex; gap: 1.5rem; padding: 0.5rem 1rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.75rem; color: var(--text-dim);
}
.cp-hint kbd { font-size: 0.7rem; padding: 1px 4px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 3px; margin: 0 2px; }
@keyframes cpFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes cpSlideIn { from { opacity: 0; transform: translateY(-20px) scale(0.97); } to { opacity: 1; transform: none; } }

/* ============================================
   ONBOARDING TOUR
   ============================================ */
.tour-overlay { position: fixed; inset: 0; z-index: 10000; pointer-events: none; opacity: 0; transition: opacity 0.3s; }
.tour-overlay.tour-active { pointer-events: auto; opacity: 1; }
.tour-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); }
.tour-spotlight {
  position: absolute; z-index: 1;
  border-radius: var(--radius);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.6);
  transition: all 0.4s cubic-bezier(0.4,0,0.2,1);
}
.tour-tooltip {
  position: absolute; z-index: 2;
  width: min(380px, 85vw);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.3);
  animation: cpSlideIn 0.3s ease;
}
.tour-progress { display: flex; gap: 6px; margin-bottom: 1rem; }
.tour-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: background 0.2s; }
.tour-dot.active { background: var(--accent); transform: scale(1.2); }
.tour-dot.done { background: var(--accent-hover); }
.tour-title { font-family: "Inter", system-ui, sans-serif; font-size: 1.3rem; margin: 0 0 0.5rem; color: var(--text); }
.tour-text { font-size: 0.92rem; color: var(--text-muted); margin: 0 0 1.25rem; line-height: 1.5; }
.tour-actions { display: flex; justify-content: space-between; align-items: center; }
.tour-skip { border: none; background: none; color: var(--text-dim); cursor: pointer; font-size: 0.85rem; padding: 0.4rem 0; }
.tour-skip:hover { color: var(--text); }
.tour-nav { display: flex; gap: 0.5rem; }
.tour-prev, .tour-next {
  padding: 0.5rem 1.2rem; border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 500; cursor: pointer; border: 1px solid var(--border);
  background: var(--bg-surface); color: var(--text);
  transition: all 0.15s;
}
.tour-prev:disabled { opacity: 0.4; cursor: not-allowed; }
.tour-next { background: var(--accent); color: var(--btn-on-accent); border-color: var(--accent); }
.tour-next:hover { background: var(--accent-hover); }

/* ============================================
   QUICK PREVIEW MODAL
   ============================================ */
.qp-overlay { position: fixed; inset: 0; z-index: 9998; display: none; }
.qp-overlay.qp-open { display: flex; align-items: center; justify-content: center; }
.qp-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); animation: cpFadeIn 0.15s ease; }
.qp-panel {
  position: relative; z-index: 1;
  width: min(520px, 90vw); max-height: 85vh; overflow-y: auto;
  background: var(--bg-elevated); border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,0.3);
  animation: cpSlideIn 0.25s ease;
}
.qp-close {
  position: absolute; top: 0.75rem; right: 0.75rem; z-index: 2;
  width: 32px; height: 32px; border: none; background: rgba(0,0,0,0.4);
  color: #fff; font-size: 1.4rem; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.qp-close:hover { background: rgba(0,0,0,0.6); }
.qp-hero {
  padding: 2.5rem 2rem 2rem; text-align: center;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.qp-icon { font-size: 3rem; display: block; margin-bottom: 0.75rem; }
.qp-title { font-family: "Inter", system-ui, sans-serif; font-size: 1.6rem; color: #fff; margin: 0; text-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.qp-category { display: inline-block; margin-top: 0.5rem; padding: 2px 10px; background: rgba(255,255,255,0.2); border-radius: 12px; font-size: 0.78rem; color: rgba(255,255,255,0.9); text-transform: capitalize; }
.qp-body { padding: 1.5rem 2rem 2rem; }
.qp-desc { font-size: 1rem; line-height: 1.6; color: var(--text-muted); margin: 0 0 1rem; }
.qp-meta { font-size: 0.88rem; color: var(--text-dim); margin-bottom: 0.5rem; }
.qp-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1rem 0; }
.qp-tag { padding: 3px 10px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 12px; font-size: 0.78rem; color: var(--text-muted); }
.qp-actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
.qp-visit-btn, .qp-stack-btn {
  flex: 1; padding: 0.6rem 1rem; border-radius: var(--radius);
  font-size: 0.9rem; font-weight: 500; text-align: center;
  cursor: pointer; border: 1px solid var(--border); transition: all 0.15s;
}
.qp-visit-btn { background: var(--accent); color: var(--btn-on-accent); border-color: var(--accent); text-decoration: none; }
.qp-visit-btn:hover { background: var(--accent-hover); }
.qp-stack-btn { background: var(--bg-surface); color: var(--text); }
.qp-stack-btn:hover { border-color: var(--accent); }
.qp-stack-btn.in-stack { background: var(--accent-muted); border-color: var(--accent); color: var(--accent); }

/* ============================================
   KEYBOARD SHORTCUTS OVERLAY
   ============================================ */
.ks-overlay { position: fixed; inset: 0; z-index: 9997; display: none; }
.ks-overlay.ks-open { display: flex; align-items: center; justify-content: center; }
.ks-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); animation: cpFadeIn 0.15s; }
.ks-panel {
  position: relative; z-index: 1;
  width: min(480px, 90vw); max-height: 80vh; overflow-y: auto;
  background: var(--bg-elevated); border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,0.3);
  animation: cpSlideIn 0.2s ease;
}
.ks-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-light);
}
.ks-title { font-family: "Inter", system-ui, sans-serif; font-size: 1.3rem; margin: 0; }
.ks-close { width: 32px; height: 32px; border: none; background: var(--bg-surface); border-radius: 50%; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); display: flex; align-items: center; justify-content: center; }
.ks-body { padding: 1rem 1.5rem 1.5rem; }
.ks-group { margin-bottom: 1.25rem; }
.ks-group-title { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin: 0 0 0.5rem; }
.ks-row { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0; }
.ks-desc { font-size: 0.9rem; color: var(--text); }
.ks-keys { display: flex; gap: 0.35rem; }
.ks-key {
  display: inline-block; padding: 3px 8px; min-width: 28px; text-align: center;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 5px; font-size: 0.78rem; font-family: inherit;
  color: var(--text-muted); box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* ============================================
   ADVANCED FILTERS
   ============================================ */
.af-bar {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  padding: 0.5rem 0; margin-bottom: 0.5rem;
}
.af-toggle {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-surface);
  color: var(--text); font-size: 0.85rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.af-toggle:hover { border-color: var(--accent); color: var(--accent); }
.af-toggle svg { color: var(--text-muted); }
.af-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--accent); color: var(--btn-on-accent);
  border-radius: 9px; font-size: 0.7rem; font-weight: 700;
}
.af-active-filters { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.af-pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 3px 10px; background: var(--accent-muted);
  border: 1px solid var(--accent); border-radius: 12px;
  font-size: 0.78rem; color: var(--accent);
}
.af-pill-x { border: none; background: none; color: var(--accent); cursor: pointer; font-size: 1rem; padding: 0; line-height: 1; }
.af-clear {
  border: none; background: none; color: var(--text-dim);
  font-size: 0.8rem; cursor: pointer; padding: 0.3rem 0;
}
.af-clear:hover { color: var(--accent); }
.af-panel {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.25rem;
  margin-bottom: 1rem; animation: cpSlideIn 0.2s ease;
}
.af-section { margin-bottom: 0.75rem; }
.af-section:last-child { margin-bottom: 0; }
.af-section-title { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin: 0 0 0.4rem; }
.af-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.af-chips-scrollable { max-height: 120px; overflow-y: auto; }
.af-chip {
  padding: 4px 12px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--bg-elevated);
  font-size: 0.8rem; color: var(--text-muted);
  cursor: pointer; transition: all 0.15s;
}
.af-chip:hover { border-color: var(--accent); color: var(--accent); }
.af-chip.active { background: var(--accent-muted); border-color: var(--accent); color: var(--accent); font-weight: 500; }

/* ============================================
   ANIMATIONS & MICRO-INTERACTIONS
   ============================================ */
body.page-entering { opacity: 0; }
body.page-entered { opacity: 1; transition: opacity 0.3s ease; }

.reveal-on-scroll {
  opacity: 0; transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  transition-delay: var(--reveal-delay, 0ms);
}
.reveal-on-scroll.revealed { opacity: 1; transform: none; }

.ripple-effect {
  position: absolute; border-radius: 50%;
  width: 0; height: 0;
  background: rgba(255,255,255,0.3);
  transform: translate(-50%, -50%);
  animation: rippleExpand 0.6s ease-out forwards;
  pointer-events: none;
}
@keyframes rippleExpand {
  to { width: 300px; height: 300px; opacity: 0; }
}

.card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  box-shadow: var(--shadow-hover);
}

/* ============================================
   COMPARISON MODE
   ============================================ */
.cmp-bar {
  position: fixed; bottom: -80px; left: 50%; transform: translateX(-50%);
  z-index: 999; transition: bottom 0.3s cubic-bezier(0.4,0,0.2,1);
  width: min(700px, 94vw);
}
.cmp-bar.cmp-bar-visible { bottom: calc(20px + var(--safe-area-bottom, 0px)); }
@media (max-width: 768px) {
  .cmp-bar.cmp-bar-visible { bottom: calc(80px + var(--safe-area-bottom, 0px)); }
}
.cmp-bar-inner {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.cmp-bar-label { font-size: 0.85rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.cmp-bar-count { color: var(--accent); }
.cmp-bar-items { flex: 1; display: flex; gap: 0.4rem; flex-wrap: wrap; min-width: 0; overflow: hidden; }
.cmp-bar-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 3px 10px; background: var(--bg-surface);
  border-radius: 12px; font-size: 0.78rem; color: var(--text);
  white-space: nowrap;
}
.cmp-bar-chip-x { border: none; background: none; color: var(--text-dim); cursor: pointer; font-size: 1rem; padding: 0; line-height: 1; }
.cmp-bar-go, .cmp-bar-clear {
  padding: 0.45rem 1rem; border-radius: var(--radius);
  font-size: 0.82rem; font-weight: 500; cursor: pointer; border: none;
  white-space: nowrap; transition: all 0.15s;
}
.cmp-bar-go { background: var(--accent); color: var(--btn-on-accent); }
.cmp-bar-go:disabled { opacity: 0.5; cursor: not-allowed; }
.cmp-bar-go:not(:disabled):hover { background: var(--accent-hover); }
.cmp-bar-clear { background: var(--bg-surface); color: var(--text-muted); }
.cmp-bar-clear:hover { color: var(--text); }

.cmp-add-btn {
  padding: 0.3rem 0.65rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-surface);
  font-size: 0.78rem; color: var(--text-muted); cursor: pointer;
  transition: all 0.15s;
}
.cmp-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.cmp-add-btn.cmp-active { background: var(--accent-muted); border-color: var(--accent); color: var(--accent); }

.cmp-modal { position: fixed; inset: 0; z-index: 9998; display: none; }
.cmp-modal.cmp-modal-open { display: flex; align-items: center; justify-content: center; }
.cmp-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); }
.cmp-modal-panel {
  position: relative; z-index: 1;
  width: min(900px, 94vw); max-height: 85vh; overflow-y: auto;
  background: var(--bg-elevated); border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,0.3);
  animation: cpSlideIn 0.25s ease;
}
.cmp-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-light);
}
.cmp-modal-header h2 { font-family: "Inter", system-ui, sans-serif; margin: 0; font-size: 1.3rem; }
.cmp-modal-close { width: 32px; height: 32px; border: none; background: var(--bg-surface); border-radius: 50%; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); }
.cmp-modal-body { padding: 1.5rem; overflow-x: auto; }
.cmp-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.cmp-table th, .cmp-table td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border-light); vertical-align: top; }
.cmp-table th { background: var(--bg-surface); font-weight: 600; }
.cmp-th-inner { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; text-align: center; }
.cmp-th-icon { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; font-size: 1.3rem; }
.cmp-th-name { font-size: 0.85rem; }
.cmp-label { font-weight: 600; color: var(--text-muted); white-space: nowrap; width: 120px; }
.cmp-tag { display: inline-block; padding: 2px 6px; background: var(--bg-surface); border-radius: 8px; font-size: 0.75rem; margin: 1px; }
.cmp-desc { font-size: 0.82rem; line-height: 1.45; color: var(--text-muted); }

/* ============================================
   GAMIFICATION / ACHIEVEMENTS
   ============================================ */
.achievement-toast {
  position: fixed; top: -80px; left: 50%; transform: translateX(-50%);
  z-index: 10001; transition: top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.achievement-toast.visible { top: calc(20px + var(--safe-area-top, 0px)); }
.achievement-toast-inner {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(245, 158, 11, 0.35);
  color: #1a1816;
}
.achievement-toast-icon { font-size: 1.5rem; }
.achievement-toast-text { display: flex; flex-direction: column; }
.achievement-toast-text strong { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.7; }
.achievement-toast-text span { font-size: 1rem; font-weight: 600; }

/* ============================================
   DASHBOARD PAGE
   ============================================ */
.dash-hero {
  text-align: center; padding: 3rem 1.5rem 2rem;
  max-width: 600px; margin: 0 auto;
}
.dash-title { font-family: "Inter", system-ui, sans-serif; font-size: 2.2rem; margin: 0 0 0.5rem; color: var(--text); }
.dash-subtitle { font-size: 1rem; color: var(--text-muted); margin: 0; }
.dash-section {
  max-width: 900px; margin: 0 auto 2rem;
  padding: 0 1.5rem;
}
.dash-section-title { font-family: "Inter", system-ui, sans-serif; font-size: 1.4rem; margin: 0 0 1rem; color: var(--text); }
.dash-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}
.dash-stat-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 1.5rem 1rem; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  text-align: center; transition: transform 0.15s, box-shadow 0.15s;
}
.dash-stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.dash-stat-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }
.dash-stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1; }
.dash-stat-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.3rem; }
.dash-progress-bar {
  width: 100%; height: 8px; background: var(--bg-surface);
  border-radius: 4px; overflow: hidden; margin-bottom: 0.5rem;
}
.dash-progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), #fbbf24);
  border-radius: 4px; transition: width 0.6s ease;
}
.dash-progress-text { font-size: 0.82rem; color: var(--text-muted); margin: 0 0 1rem; }
.dash-achievements-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}
.dash-achievement {
  display: flex; flex-direction: column; align-items: center;
  padding: 1rem; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius);
  text-align: center; transition: all 0.2s;
}
.dash-achievement.locked { opacity: 0.45; filter: grayscale(1); }
.dash-achievement.unlocked { border-color: var(--accent); background: var(--accent-muted); }
.dash-achievement-icon { font-size: 1.5rem; margin-bottom: 0.3rem; }
.dash-achievement-title { font-weight: 600; font-size: 0.85rem; color: var(--text); }
.dash-achievement-desc { font-size: 0.75rem; color: var(--text-muted); }
.dash-empty { color: var(--text-dim); font-style: italic; font-size: 0.9rem; }
.dash-interests { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.dash-interest-tag {
  padding: 6px 16px; background: var(--accent-muted);
  border: 1px solid var(--accent); border-radius: 20px;
  font-size: 0.9rem; color: var(--accent); font-weight: 500;
  text-transform: capitalize;
}
.dash-recs { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0.75rem; }
.dash-rec-card {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: all 0.15s; text-decoration: none;
}
.dash-rec-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.dash-rec-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.dash-rec-info { min-width: 0; }
.dash-rec-info strong { display: block; font-size: 0.9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-rec-reason { display: block; font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-chart { max-width: 500px; }
.dash-bar-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.dash-bar-label { font-size: 0.82rem; color: var(--text-muted); min-width: 60px; text-align: right; }
.dash-bar-track { flex: 1; height: 24px; background: var(--bg-surface); border-radius: 12px; overflow: hidden; }
.dash-bar-fill { height: 100%; background: var(--accent); border-radius: 12px; transition: width 0.6s ease; min-width: 2px; }
.dash-bar-count { font-size: 0.82rem; font-weight: 600; color: var(--text); min-width: 24px; }
.dash-categories { max-width: 600px; }
.dash-cat-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; }
.dash-cat-icon { font-size: 1.1rem; }
.dash-cat-name { font-size: 0.88rem; color: var(--text); min-width: 100px; text-transform: capitalize; }
.dash-cat-bar { flex: 1; height: 10px; background: var(--bg-surface); border-radius: 5px; overflow: hidden; }
.dash-cat-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #fbbf24); border-radius: 5px; transition: width 0.6s ease; }
.dash-cat-pct { font-size: 0.78rem; color: var(--text-dim); min-width: 80px; text-align: right; }

/* ============================================
   HOME PAGE RECOMMENDATIONS
   ============================================ */
.recs-section {
  max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.5rem 0;
}
.recs-heading {
  font-family: "Inter", system-ui, sans-serif; font-size: 1.4rem;
  margin: 0 0 1rem; color: var(--text);
}
.recs-row {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}
.rec-card {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius);
  transition: all 0.15s; text-decoration: none;
}
.rec-card:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.rec-card-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.rec-card-body { min-width: 0; }
.rec-card-body strong { display: block; font-size: 0.9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-card-reason { display: block; font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================
   BREADCRUMB NAVIGATION
   ============================================ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 1.5rem 0;
  max-width: 1200px;
  margin: 0 auto;
  font-size: 0.8rem;
}
.breadcrumb-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}
.breadcrumb-link:hover {
  color: var(--text);
  text-decoration: underline;
}
.breadcrumb-sep {
  color: var(--text-dim);
  font-size: 0.75rem;
}
.breadcrumb-current {
  color: var(--text-muted);
  font-weight: 500;
}

/* ============================================
   DASHBOARD CLICKABLE STAT CARDS
   ============================================ */
a.dash-stat-link {
  text-decoration: none;
  cursor: pointer;
  transition: all 0.18s ease;
}
a.dash-stat-link:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
a.dash-stat-link:hover .dash-stat-label {
  color: var(--accent);
}

/* ============================================
   DASHBOARD EMPTY STATE CTAs
   ============================================ */
.dash-empty-cta {
  text-align: center;
  padding: 0.5rem 0;
}
.dash-empty-btn {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.5rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.15s;
}
.dash-empty-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* ============================================
   STACK/WANT-TO-TRY EMPTY STATE CTAs
   ============================================ */
.stack-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: center;
}
.stack-empty-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 1.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.15s;
}
.stack-empty-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.stack-empty-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.stack-empty-btn.primary:hover {
  opacity: 0.9;
  color: #fff;
}

/* ============================================
   SEARCH BROWSE GRID (empty state)
   ============================================ */
.search-empty-text {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0 0 1.5rem;
}
.search-browse-links {
  margin-top: 1.5rem;
}
.search-browse-label {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}
.search-browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.6rem;
}
.search-browse-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.15s;
}
.search-browse-card:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.search-browse-icon {
  font-size: 1.2rem;
}

/* ============================================
   FEATURE CHIPS AS LINKS
   ============================================ */
a.feature-chip {
  text-decoration: none;
  cursor: pointer;
}

/* ============================================
   RECOMMENDED NEXT STEPS
   ============================================ */
.next-steps-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 0.5rem;
}
.next-steps-heading {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  color: var(--text);
}
.next-steps-subtitle {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0 0 1.25rem;
}
.next-steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
}
.next-step-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: all 0.18s ease;
  cursor: pointer;
}
.next-step-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.next-step-card:active {
  transform: translateY(0);
}
.next-step-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-muted);
  border-radius: 10px;
}
.next-step-body {
  flex: 1;
  min-width: 0;
}
.next-step-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.15rem;
}
.next-step-desc {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.4;
}
.next-step-arrow {
  font-size: 1.1rem;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.15s, color 0.15s;
}
.next-step-card:hover .next-step-arrow {
  color: var(--accent);
  transform: translateX(3px);
}

@media (max-width: 600px) {
  .next-steps-grid {
    grid-template-columns: 1fr;
  }
  .next-steps-section {
    padding: 1.5rem 1rem 0.5rem;
  }
}

/* ============================================
   NOTES / ANNOTATIONS
   ============================================ */
.note-btn {
  padding: 0.3rem 0.65rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-surface);
  font-size: 0.78rem; color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.3rem;
  transition: all 0.15s;
}
.note-btn:hover { border-color: var(--accent); color: var(--accent); }
.note-btn.has-note { border-color: var(--accent); color: var(--accent); background: var(--accent-muted); }
.note-area {
  max-height: 0; overflow: hidden; transition: max-height 0.3s ease;
  padding: 0 0.75rem;
}
.note-area.open { max-height: 200px; padding: 0.5rem 0.75rem; }
.note-textarea {
  width: 100%; min-height: 60px; padding: 0.5rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-surface); color: var(--text);
  font-family: inherit; font-size: 0.85rem; resize: vertical;
}
.note-textarea:focus { border-color: var(--accent); outline: none; }
.note-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 0.3rem; }
.note-char-count { font-size: 0.72rem; color: var(--text-dim); }
.note-char-count.at-limit { color: #ef4444; font-weight: 600; }
.note-clear-btn { border: none; background: none; color: var(--text-dim); font-size: 0.75rem; cursor: pointer; padding: 0; }
.note-clear-btn:hover { color: #ef4444; }
.note-indicator {
  position: absolute; top: 6px; right: 6px;
  font-size: 0.65rem; background: var(--accent);
  color: var(--btn-on-accent); padding: 1px 5px;
  border-radius: 8px; pointer-events: none;
}

/* ============================================
   ACTIVITY FEED
   ============================================ */
.af-timeline { }
.af-event {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.6rem 0; border-bottom: 1px solid var(--border-light);
}
.af-event:last-child { border-bottom: none; }
.af-event-icon {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-surface); display: flex; align-items: center;
  justify-content: center; font-size: 0.9rem; flex-shrink: 0;
}
.af-event-body { min-width: 0; flex: 1; }
.af-event-text { font-size: 0.88rem; color: var(--text); display: block; }
.af-event-text strong { font-weight: 600; }
.af-event-time { font-size: 0.75rem; color: var(--text-dim); }
.af-empty { font-size: 0.88rem; color: var(--text-dim); font-style: italic; padding: 1rem 0; }

/* ============================================
   DRAG & DROP (STACK)
   ============================================ */
.stack-card[draggable="true"] { cursor: grab; }
.stack-card[draggable="true"]:active { cursor: grabbing; }
.stack-card.dragging { opacity: 0.5; transform: scale(0.97); }
.drag-indicator {
  height: 3px; background: #3b82f6; border-radius: 2px;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.5);
  margin: -1.5px 0; transition: opacity 0.15s;
}

/* ============================================
   SHAREABLE LISTS (injected styles supplement)
   ============================================ */
.shared-banner {
  background: var(--accent-muted); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 1rem 1.5rem;
  margin-bottom: 1rem; display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 0.75rem;
}
.shared-banner-text { font-size: 0.92rem; color: var(--text); }
.shared-banner-btn {
  padding: 0.5rem 1.2rem; border-radius: var(--radius);
  background: var(--accent); color: var(--btn-on-accent);
  border: none; font-weight: 500; cursor: pointer;
  transition: background 0.15s;
}
.shared-banner-btn:hover { background: var(--accent-hover); }

/* ============================================
   FILTER PRESETS
   ============================================ */
.af-save-preset, .af-load-preset {
  padding: 0.4rem 0.8rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-surface);
  font-size: 0.8rem; color: var(--text-muted); cursor: pointer;
  transition: all 0.15s;
}
.af-save-preset:hover, .af-load-preset:hover { border-color: var(--accent); color: var(--accent); }
.af-preset-menu {
  position: absolute; top: 100%; left: 0; z-index: 50;
  min-width: 180px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 0.25rem 0;
  margin-top: 4px;
}
.af-preset-menu-item {
  display: block; width: 100%; padding: 0.5rem 1rem;
  border: none; background: none; text-align: left;
  font-size: 0.85rem; color: var(--text); cursor: pointer;
}
.af-preset-menu-item:hover { background: var(--accent-muted); }
.af-preset-menu-empty { padding: 0.5rem 1rem; font-size: 0.82rem; color: var(--text-dim); font-style: italic; }
.af-preset-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.25rem; }
.af-preset-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 4px 12px; background: var(--accent-light);
  border: 1px solid var(--accent); border-radius: 14px;
  font-size: 0.8rem; color: var(--accent); cursor: pointer;
  transition: all 0.15s;
}
.af-preset-chip:hover { background: var(--accent-muted); }
.af-preset-chip-x { border: none; background: none; color: var(--accent); cursor: pointer; font-size: 1rem; padding: 0; line-height: 1; }

/* ============================================
   COMPARISON EXPORT BUTTONS
   ============================================ */
.cmp-modal-actions {
  display: flex; gap: 0.5rem; margin-left: auto; margin-right: 1rem;
}
.cmp-export-btn {
  padding: 0.4rem 0.8rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-surface);
  font-size: 0.78rem; color: var(--text-muted); cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.cmp-export-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ============================================
   SW UPDATE BANNER
   ============================================ */
.sw-update-banner {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 9990; padding: 0.75rem 1.5rem;
  background: var(--bg-elevated); border: 1px solid var(--accent);
  border-radius: var(--radius-lg); box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  display: flex; align-items: center; gap: 1rem;
  font-size: 0.9rem; color: var(--text);
  animation: cpSlideIn 0.3s ease;
}
.sw-update-banner button {
  padding: 0.4rem 1rem; border-radius: var(--radius);
  background: var(--accent); color: var(--btn-on-accent);
  border: none; font-weight: 500; cursor: pointer;
}
