/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #111827;
  background: #f9fafb;
  line-height: 1.6;
  min-height: 100dvh;
}
a { color: #5c6bc0; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── Top nav ───────────────────────────────────────────── */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #1e1e2e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 56px;
  gap: .75rem;
}
.nav-logo {
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.nav-logo span { color: #818cf8; }
.nav-title {
  color: #e5e7eb;
  font-size: .95rem;
  font-weight: 600;
  flex: 1;
  text-align: center;
}
.nav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #5c6bc0;
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-decoration: none;
}

/* ── Main content area ─────────────────────────────────── */
.app-main {
  padding: 1rem 1rem 5.5rem; /* bottom pad clears tab bar */
  max-width: 640px;
  margin: 0 auto;
}

/* ── Bottom tab bar ────────────────────────────────────── */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #1e1e2e;
  border-top: 1px solid #2d2d3f;
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #6b7280;
  font-size: .7rem;
  font-weight: 500;
  text-decoration: none;
  transition: color .15s;
}
.tab-item svg { width: 22px; height: 22px; }
.tab-item.active { color: #818cf8; }
.tab-item:hover { color: #c4b5fd; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .7rem 1.4rem;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 600;
  transition: background .15s, opacity .15s;
  cursor: pointer;
}
.btn-primary {
  background: #5c6bc0;
  color: #fff;
  border: none;
}
.btn-primary:hover { background: #4f5eaf; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  color: #5c6bc0;
  border: 1.5px solid #5c6bc0;
}
.btn-outline:hover { background: #eef2ff; }
.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
  border: none;
}
.btn-danger:hover { background: #fecaca; }
.btn-full { width: 100%; }
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  width: 100%;
  padding: .85rem 1.25rem;
  border-radius: 12px;
  border: 1.5px solid #e5e7eb;
  background: #fff;
  color: #111827;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
.btn-google:hover { background: #f9fafb; box-shadow: 0 2px 8px rgba(0,0,0,.1); }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}

/* ── Save cards (library) ──────────────────────────────── */
.save-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  margin-bottom: .75rem;
  overflow: hidden;
  transition: box-shadow .15s;
}
.save-card-header {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .875rem 1rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.save-card-header:active { background: #f9fafb; }
.save-card-meta { flex: 1; min-width: 0; }
.save-card-title {
  font-size: .9rem;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.save-card-sub {
  font-size: .78rem;
  color: #9ca3af;
  margin-top: 2px;
}
.save-chevron {
  width: 18px;
  height: 18px;
  color: #9ca3af;
  flex-shrink: 0;
  margin-top: 2px;
  transition: transform .2s;
}
.save-card.expanded .save-chevron { transform: rotate(180deg); }
.save-delete-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.save-delete-btn:hover { background: #fee2e2; color: #b91c1c; }
.save-delete-btn svg { width: 16px; height: 16px; }

.save-card-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid #f3f4f6;
}
.save-selected {
  font-size: .83rem;
  color: #6b7280;
  font-style: italic;
  background: #f9fafb;
  border-radius: 8px;
  padding: .6rem .75rem;
  margin-bottom: .75rem;
  line-height: 1.5;
}
.save-section { margin-bottom: .75rem; }
.save-section strong {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .25rem;
}
.save-section p {
  font-size: .875rem;
  color: #374151;
  line-height: 1.6;
}
.save-source {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .8rem;
  color: #5c6bc0;
  margin-top: .25rem;
}

/* ── Mode badges ───────────────────────────────────────── */
.mode-badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  flex-shrink: 0;
  margin-top: 2px;
}
.mode-eli5    { background: #fff7ed; color: #c2410c; }
.mode-normal  { background: #eef2ff; color: #3730a3; }
.mode-deep    { background: #faf5ff; color: #7c3aed; }
.mode-why     { background: #f0fdf4; color: #15803d; }

/* ── Search ────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  margin-bottom: .875rem;
}
.search-wrap svg.search-icon {
  position: absolute;
  left: .875rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #9ca3af;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: .7rem 2.5rem .7rem 2.75rem;
  border-radius: 12px;
  border: 1.5px solid #e5e7eb;
  background: #fff;
  font-size: .9rem;
  font-family: inherit;
  color: #111827;
  transition: border-color .15s;
  -webkit-appearance: none;
}
.search-input:focus { outline: none; border-color: #818cf8; }
.search-clear {
  position: absolute;
  right: .75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  display: none;
  align-items: center;
  justify-content: center;
}
.search-clear.visible { display: flex; }
.search-clear svg { width: 12px; height: 12px; }

/* ── Filter chips ──────────────────────────────────────── */
.filter-chips {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: .125rem;
  margin-bottom: 1rem;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: .4rem .875rem;
  border-radius: 20px;
  border: 1.5px solid #e5e7eb;
  background: #fff;
  font-size: .82rem;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.chip.active { border-color: #5c6bc0; background: #eef2ff; color: #5c6bc0; }

/* ── Usage bars ────────────────────────────────────────── */
.usage-section { margin-top: 1.25rem; }
.usage-section h3 {
  font-size: .85rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .875rem;
}
.usage-bar-wrap { margin-bottom: .875rem; }
.usage-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  color: #374151;
  font-weight: 500;
  margin-bottom: .35rem;
}
.usage-bar-label span:last-child { color: #9ca3af; font-weight: 400; }
.usage-track {
  height: 8px;
  background: #f3f4f6;
  border-radius: 99px;
  overflow: hidden;
}
.usage-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .4s ease;
}
.bar-green  { background: #22c55e; }
.bar-orange { background: #f97316; }
.bar-red    { background: #ef4444; }
.usage-reset {
  font-size: .75rem;
  color: #9ca3af;
  margin-top: .5rem;
}

/* ── Tier badge ────────────────────────────────────────── */
.tier-badge {
  display: inline-flex;
  align-items: center;
  padding: .25rem .65rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.tier-free    { background: #f3f4f6; color: #6b7280; }
.tier-pro     { background: #eef2ff; color: #4338ca; }
.tier-premium { background: linear-gradient(135deg, #fef3c7, #ede9fe); color: #7c3aed; }

/* ── Profile section ───────────────────────────────────── */
.profile-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5c6bc0, #818cf8);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-info { flex: 1; min-width: 0; }
.profile-email {
  font-size: .88rem;
  color: #374151;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .3rem;
}

/* ── Feature list ──────────────────────────────────────── */
.feature-grid {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.feature-grid h3 {
  font-size: .85rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .75rem;
}
.feature-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .4rem 0;
  font-size: .875rem;
  color: #374151;
  border-bottom: 1px solid #f9fafb;
}
.feature-row:last-child { border-bottom: none; }
.feature-check { color: #22c55e; flex-shrink: 0; }
.feature-check.locked { color: #d1d5db; }
.feature-row span { flex: 1; }
.feature-locked-label {
  font-size: .72rem;
  color: #9ca3af;
  background: #f3f4f6;
  padding: .15rem .45rem;
  border-radius: 4px;
}

/* ── Plan cards (upgrade) ──────────────────────────────── */
.plans-wrap {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.plan-card {
  background: #fff;
  border-radius: 16px;
  border: 2px solid #e5e7eb;
  padding: 1.25rem;
  position: relative;
  transition: border-color .2s, box-shadow .2s;
}
.plan-card.featured {
  border-color: #818cf8;
  box-shadow: 0 0 0 4px rgba(129,140,248,.12);
}
.plan-card.current-plan { border-color: #22c55e; }
.plan-badge {
  position: absolute;
  top: -.7rem;
  left: 50%;
  transform: translateX(-50%);
  background: #818cf8;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: .2rem .75rem;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: .03em;
}
.plan-badge.badge-save { background: #22c55e; }
.plan-badge.badge-current { background: #6b7280; }
.plan-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #111827;
  margin-bottom: .2rem;
}
.plan-tagline {
  font-size: .82rem;
  color: #6b7280;
  margin-bottom: .875rem;
}
.plan-price {
  display: flex;
  align-items: baseline;
  gap: .25rem;
  margin-bottom: .25rem;
}
.plan-amount {
  font-size: 1.75rem;
  font-weight: 800;
  color: #111827;
}
.plan-currency {
  font-size: .9rem;
  font-weight: 600;
  color: #6b7280;
}
.plan-period { font-size: .82rem; color: #9ca3af; }
.plan-usd {
  font-size: .8rem;
  color: #9ca3af;
  margin-bottom: .875rem;
}
.plan-features {
  list-style: none;
  margin-bottom: 1.1rem;
}
.plan-features li {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  font-size: .85rem;
  color: #374151;
  padding: .25rem 0;
}
.plan-features li svg {
  width: 16px;
  height: 16px;
  color: #22c55e;
  flex-shrink: 0;
  margin-top: 2px;
}
.plan-divider {
  height: 1px;
  background: #f3f4f6;
  margin-bottom: .875rem;
}

/* ── Provider toggle ───────────────────────────────────── */
.provider-row {
  display: flex;
  gap: .5rem;
  background: #f3f4f6;
  border-radius: 10px;
  padding: .3rem;
  margin-bottom: 1.25rem;
}
.provider-btn {
  flex: 1;
  padding: .55rem .5rem;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 600;
  color: #6b7280;
  transition: background .15s, color .15s, box-shadow .15s;
}
.provider-btn.active {
  background: #5c6bc0;
  color: #fff;
  box-shadow: 0 2px 8px rgba(92,107,192,.35);
}

/* ── Loading skeletons ─────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 8px;
}
.skeleton-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  padding: .875rem 1rem;
  margin-bottom: .75rem;
  display: flex;
  gap: .75rem;
  align-items: center;
}
.skeleton-badge { width: 48px; height: 22px; flex-shrink: 0; }
.skeleton-lines { flex: 1; }
.skeleton-line { height: 13px; margin-bottom: 6px; border-radius: 6px; }
.skeleton-line.short { width: 55%; }

/* ── Empty / error states ──────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  color: #9ca3af;
}
.empty-state svg {
  width: 52px;
  height: 52px;
  margin: 0 auto .875rem;
  color: #d1d5db;
}
.empty-state h3 { font-size: 1rem; font-weight: 700; color: #374151; margin-bottom: .4rem; }
.empty-state p  { font-size: .875rem; line-height: 1.5; }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e1e2e;
  color: #fff;
  padding: .65rem 1.25rem;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 200;
  max-width: calc(100vw - 2rem);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Login page ────────────────────────────────────────── */
.login-page {
  background: #1e1e2e;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 1.5rem;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 2rem 1.75rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.logo-text {
  font-size: 1.6rem;
  font-weight: 800;
  color: #111827;
}
.logo-accent { color: #5c6bc0; }
.login-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #111827;
  text-align: center;
  margin-bottom: .5rem;
}
.login-sub {
  font-size: .875rem;
  color: #6b7280;
  text-align: center;
  margin-bottom: 1.75rem;
  line-height: 1.5;
}
.login-divider {
  height: 1px;
  background: #f3f4f6;
  margin: 1.25rem 0;
}
.login-footer {
  font-size: .8rem;
  color: #9ca3af;
  text-align: center;
  line-height: 1.7;
}
.login-footer a { color: #5c6bc0; }

/* ── Callback / spinner page ───────────────────────────── */
.spinner-page {
  background: #1e1e2e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  gap: 1.25rem;
  color: #9ca3af;
  font-size: .9rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #2d2d3f;
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.spinner-logo {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
}
.spinner-logo span { color: #818cf8; }

/* ── Section headers ───────────────────────────────────── */
.section-header {
  font-size: .85rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 1.25rem 0 .75rem;
}

/* ── Upgrade page hero ─────────────────────────────────── */
.upgrade-hero {
  text-align: center;
  padding: 1.5rem 0 .75rem;
  margin-bottom: .5rem;
}
.upgrade-hero h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #111827;
  margin-bottom: .4rem;
}
.upgrade-hero p {
  font-size: .88rem;
  color: #6b7280;
  line-height: 1.5;
}
.trust-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: .78rem;
  color: #9ca3af;
  margin: 1.25rem 0;
}
.trust-row span { display: flex; align-items: center; gap: .3rem; }
.trust-row svg { width: 14px; height: 14px; color: #22c55e; }

/* ── Load more ─────────────────────────────────────────── */
.load-more-wrap { text-align: center; margin-top: .5rem; }

/* ── Success banner ────────────────────────────────────── */
.success-banner {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  border-radius: 14px;
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1.25rem;
  display: none;
}
.success-banner.show { display: block; }
.success-banner h3 { font-size: 1rem; font-weight: 700; color: #166534; margin-bottom: .3rem; }
.success-banner p { font-size: .875rem; color: #166534; }

.fail-banner {
  background: #fff7ed;
  border: 1.5px solid #fed7aa;
  border-radius: 14px;
  padding: 1.25rem;
  text-align: center;
  margin-bottom: 1.25rem;
  display: none;
}
.fail-banner.show { display: block; }
.fail-banner p { font-size: .875rem; color: #9a3412; }

/* ── Polling indicator ─────────────────────────────────── */
.polling-indicator {
  display: none;
  align-items: center;
  gap: .5rem;
  font-size: .82rem;
  color: #6b7280;
  justify-content: center;
  margin: .75rem 0;
}
.polling-indicator.show { display: flex; }
.poll-dot {
  width: 8px;
  height: 8px;
  background: #818cf8;
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ── Responsive ────────────────────────────────────────── */
@media (min-width: 600px) {
  .plans-wrap { flex-direction: row; flex-wrap: wrap; }
  .plan-card  { flex: 1 1 calc(50% - .5rem); min-width: 220px; }
  .app-main   { padding: 1.5rem 1.5rem 5.5rem; }
}
