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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: env(safe-area-inset-top, 20px) 20px env(safe-area-inset-bottom, 20px);

  /* Tier color defaults (silver / anonymous) */
  --tier-primary: #C0C0C0;
  --tier-secondary: #A8A9AD;
  --tier-glow: rgba(192,192,192,0.4);
}

body.tier-anonymous {
  --tier-primary: #C0C0C0;
  --tier-secondary: #A8A9AD;
  --tier-glow: rgba(192,192,192,0.4);
}

body.tier-free {
  --tier-primary: #C0C0C0;
  --tier-secondary: #A8A9AD;
  --tier-glow: rgba(192,192,192,0.4);
}

body.tier-bronze {
  --tier-primary: #CD7F32;
  --tier-secondary: #B87333;
  --tier-glow: rgba(205,127,50,0.4);
}

body.tier-pro {
  --tier-primary: #fbbf24;
  --tier-secondary: #f59e0b;
  --tier-glow: rgba(251,191,36,0.4);
}

.container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

/* === Header === */
.ring-icon { width: 64px; height: 64px; margin-top: 48px; margin-bottom: 12px; }

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--tier-primary);
  margin-bottom: 8px;
  text-align: center;
}

.subtitle { color: #64748b; font-size: 0.9rem; margin-bottom: 32px; text-align: center; display: flex; align-items: center; justify-content: center; gap: 6px; }

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  background: none;
  border: none;
  color: #475569;
  cursor: pointer;
  min-height: auto;
  min-width: auto;
  transition: color 0.2s;
}

.info-btn:hover { color: #94a3b8; }
.info-btn svg { display: block; }

/* === Top bar (auth + stats) === */
.top-bar {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  position: relative;
}

.auth-btn {
  font-size: 0.85rem;
  padding: 8px 14px;
  border: 1px solid #C0C0C0;
  border-radius: 8px;
  background: transparent;
  color: #C0C0C0;
  cursor: pointer;
  min-height: auto;
  min-width: auto;
  transition: border-color 0.2s, color 0.2s;
}

.auth-btn:hover { border-color: #A8A9AD; color: #A8A9AD; }

.user-menu {
  position: relative;
}

.user-menu-btn {
  font-size: 0.85rem;
  padding: 8px 14px;
  border: 1px solid var(--tier-primary);
  border-radius: 8px;
  background: transparent;
  color: var(--tier-primary);
  cursor: pointer;
  min-height: auto;
  min-width: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: tierPulse 2s ease-in-out infinite;
}

.user-menu-btn:hover { border-color: var(--tier-secondary); }

@keyframes tierPulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--tier-glow); }
  50% { box-shadow: 0 0 12px 2px var(--tier-glow); }
}

.streak-pip {
  font-size: 0.75rem;
  background: var(--tier-primary);
  color: #0f172a;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

.user-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  min-width: 200px;
  z-index: 100;
  overflow: hidden;
}

.user-dropdown.open { display: block; }

.user-dropdown-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  color: #e2e8f0;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.user-dropdown-item:hover { background: #334155; }
.user-dropdown-item.pro-item { color: #fbbf24; }
.user-dropdown-item.danger { color: #f87171; }

.dropdown-divider { border-top: 1px solid #334155; }

/* === Quota bar === */
.quota-bar {
  width: 100%;
  display: none;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 0.8rem;
  color: #64748b;
}

.quota-bar.visible { display: flex; }

.quota-track {
  flex: 1;
  height: 4px;
  background: #1e293b;
  border-radius: 2px;
  overflow: hidden;
}

.quota-fill {
  height: 100%;
  background: var(--tier-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.quota-fill.warning { background: #f87171; }

/* === Input === */
.input-group { width: 100%; display: flex; gap: 10px; margin-bottom: 32px; }

input[type="text"] {
  flex: 1;
  font-size: 16px;
  padding: 14px 16px;
  border: 2px solid #1e293b;
  border-radius: 12px;
  background: #1e293b;
  color: #e2e8f0;
  outline: none;
  transition: border-color 0.2s;
  min-height: 48px;
}

input[type="text"]:focus { border-color: var(--tier-primary); }
input[type="text"]::placeholder { color: #475569; }

button {
  font-size: 16px;
  font-weight: 600;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--tier-primary), var(--tier-secondary));
  color: #0f172a;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

button:active { transform: scale(0.96); }

button:disabled {
  background: #1e293b;
  color: #475569;
  cursor: not-allowed;
  transform: none;
}

/* === Results === */
.result { width: 100%; display: none; }
.result.visible { display: block; }

.result-text {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 24px;
  overflow: hidden;
}

/* Verdict header */
.verdict-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.verdict-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

/* Answer body */
.verdict-body {
  font-size: 1.1rem;
  line-height: 1.75;
  color: #f1f5f9;
}

/* Product name highlight */
.pick-name {
  color: var(--tier-primary);
  font-weight: 700;
}
a.pick-link {
  text-decoration: underline;
  text-underline-offset: 3px;
}
a.pick-link:hover {
  color: #fcd34d;
}

/* === Why This? reasons === */
.reasons-section {
  margin-top: 14px;
}

.reasons-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  min-height: auto;
  min-width: auto;
  transition: color 0.2s;
}

.reasons-toggle:hover { color: #94a3b8; }

.reasons-chevron {
  transition: transform 0.2s ease;
}

.reasons-section.open .reasons-chevron {
  transform: rotate(180deg);
}

.reasons-list {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  margin: 0;
  padding-left: 20px;
  list-style: decimal;
}

.reasons-section.open .reasons-list {
  max-height: 200px;
  opacity: 1;
  margin-top: 8px;
}

.reasons-list li {
  color: #94a3b8;
  font-size: 0.85rem;
  line-height: 1.6;
  padding: 2px 0;
}

/* Place info card (local results) */
.place-info {
  margin-top: 14px;
  padding: 12px 14px;
  background: #0f172a;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.6;
}

.place-stars .star {
  font-size: 1rem;
}

.place-stars .star.full { color: #fbbf24; }
.place-stars .star.half { color: #fbbf24; opacity: 0.55; }
.place-stars .star.empty { color: #334155; }

.place-rating {
  font-weight: 700;
  color: #f1f5f9;
  margin-left: 6px;
}

.place-reviews {
  color: #64748b;
  margin-left: 4px;
}

.place-price {
  color: #94a3b8;
  font-weight: 600;
}

.place-address {
  color: #475569;
  font-size: 0.8rem;
  margin-top: 4px;
}

/* Smart action buttons */
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #334155;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  color: #94a3b8;
  background: #0f172a;
  border: 1px solid #334155;
  transition: border-color 0.2s, color 0.2s;
}

.action-btn:hover { border-color: #64748b; color: #e2e8f0; }

.action-btn.action-primary {
  background: linear-gradient(135deg, var(--tier-primary), var(--tier-secondary));
  color: #0f172a;
  border: none;
}

.action-btn.action-primary:hover { opacity: 0.9; }

.action-btn.action-buy {
  color: #fbbf24;
  border-color: #fbbf2440;
}

.action-btn.action-buy:hover { background: #fbbf2410; border-color: #fbbf24; }

.unverified-note {
  font-size: 0.75rem;
  color: #f59e0b;
  margin-top: 12px;
  padding: 8px 12px;
  background: #f59e0b10;
  border-radius: 8px;
  border-left: 3px solid #f59e0b40;
}

.affiliate-disclosure {
  font-size: 0.65rem;
  color: #475569;
  margin-top: 8px;
  font-style: italic;
}

/* === Feedback === */
.feedback-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #334155;
}

.feedback-btn {
  font-size: 1.2rem;
  padding: 6px 12px;
  background: #334155;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  min-height: auto;
  min-width: auto;
  color: #94a3b8;
  transition: background 0.2s, border-color 0.2s;
}

.feedback-btn:hover { background: #475569; }

.feedback-btn.selected {
  border-color: #fbbf24;
  background: #fbbf2420;
}

.feedback-btn:disabled {
  cursor: default;
  opacity: 0.6;
  transform: none;
}

.feedback-thanks {
  color: #64748b;
  font-size: 0.85rem;
}

.suggestion-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.suggestion-input {
  flex: 1;
  padding: 6px 10px;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 8px;
  color: #f1f5f9;
  font-size: 0.85rem;
  outline: none;
}

.suggestion-input:focus {
  border-color: #fbbf24;
}

.suggestion-submit, .suggestion-skip {
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
}

.suggestion-submit {
  background: #fbbf24;
  color: #0f172a;
  font-weight: 600;
}

.suggestion-skip {
  background: #334155;
  color: #94a3b8;
}

/* === Share === */
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 6px;
  background: none;
  border: none;
  color: #475569;
  cursor: pointer;
  min-height: auto;
  min-width: auto;
  transition: color 0.2s;
}

.share-btn:hover { color: #e2e8f0; }

.share-btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.share-btn svg { display: block; }

/* === Loading === */
.loading { display: none; flex-direction: column; align-items: center; gap: 16px; padding: 40px 0; }
.loading.visible { display: flex; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #1e293b;
  border-top-color: var(--tier-primary);
  border-right-color: var(--tier-secondary);
  border-radius: 50%;
  animation: spinPulse 0.8s linear infinite;
}

@keyframes spinPulse {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.08); }
  100% { transform: rotate(360deg) scale(1); }
}

.loading-text {
  color: #94a3b8;
  font-size: 0.95rem;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.loading-text.loading-text-fade {
  opacity: 0;
  transform: translateY(4px);
}

/* === Error === */
.error {
  display: none;
  width: 100%;
  background: #7f1d1d;
  color: #fca5a5;
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.error.visible { display: block; }

/* === Install banner === */
.install-banner {
  display: none;
  width: 100%;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: #94a3b8;
  line-height: 1.5;
  text-align: center;
}

.install-banner.visible { display: block; }

.install-banner .install-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, var(--tier-primary), var(--tier-secondary));
  color: #0f172a !important;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none !important;
}

.install-banner .dismiss {
  color: #475569;
  font-size: 0.8rem;
  margin-left: 12px;
  cursor: pointer;
  background: none;
  border: none;
}

/* === Modal (auth, stats, history, upgrade) === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: #64748b;
  font-size: 1.4rem;
  cursor: pointer;
  min-height: auto;
  min-width: auto;
  padding: 4px;
}

.modal h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 16px;
}

.modal p {
  color: #94a3b8;
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 16px;
}

/* === Auth modal === */
.phone-input {
  width: 100%;
  font-size: 16px;
  padding: 14px 16px;
  border: 2px solid #334155;
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  outline: none;
  margin-bottom: 12px;
}

.phone-input:focus { border-color: var(--tier-primary); }

.auth-submit {
  width: 100%;
  padding: 14px;
  font-size: 1rem;
}

.auth-error {
  color: #f87171;
  font-size: 0.85rem;
  margin-top: 8px;
  display: none;
}

.auth-error.visible { display: block; }

.code-input {
  width: 100%;
  font-size: 24px;
  padding: 14px 16px;
  border: 2px solid #334155;
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  outline: none;
  text-align: center;
  letter-spacing: 8px;
  margin-bottom: 12px;
}

.code-input:focus { border-color: var(--tier-primary); }

/* === Stats panel (modal) === */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: #0f172a;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--tier-primary);
}

.stat-label {
  font-size: 0.75rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* === Badges === */
.badges-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #334155;
  color: #94a3b8;
}

.badge.earned {
  background: linear-gradient(135deg, #fbbf2420, #f59e0b20);
  color: #fbbf24;
  border: 1px solid #fbbf2440;
}

/* === History panel === */
.history-item {
  background: #0f172a;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
}

.history-query {
  font-weight: 600;
  color: #e2e8f0;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.history-answer {
  color: #94a3b8;
  font-size: 0.85rem;
  line-height: 1.5;
}

.history-date {
  color: #475569;
  font-size: 0.75rem;
  margin-top: 6px;
}

.history-empty {
  color: #64748b;
  text-align: center;
  padding: 40px 20px;
  font-size: 0.9rem;
}

.load-more-btn {
  width: 100%;
  padding: 10px;
  font-size: 0.85rem;
  background: #334155;
  border-radius: 8px;
  color: #94a3b8;
  border: none;
  cursor: pointer;
  margin-top: 8px;
}

.load-more-btn:hover { background: #475569; }

/* === Upgrade prompt (inline) === */
.upgrade-prompt {
  display: none;
  width: 100%;
  background: linear-gradient(135deg, #fbbf2410, #f59e0b10);
  border: 1px solid #fbbf2440;
  border-radius: 12px;
  padding: 16px 20px;
  text-align: center;
  margin-bottom: 16px;
}

.upgrade-prompt.visible { display: block; }

.upgrade-prompt p { color: #fbbf24; margin-bottom: 12px; }

.upgrade-btn {
  padding: 10px 20px;
  font-size: 0.9rem;
  border-radius: 8px;
}

/* === Toast notifications === */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  border: 1px solid var(--tier-glow);
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--tier-primary);
  font-size: 0.9rem;
  font-weight: 600;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

/* === Upgrade modal === */
.upgrade-subtitle {
  color: #64748b;
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 16px;
}

.plan-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 12px;
}

.plan-card.plan-bronze { border-color: #CD7F3240; }
.plan-card.plan-pro { border-color: #fbbf2440; }

.plan-name {
  font-size: 1rem;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 4px;
}

.plan-bronze .plan-name { color: #CD7F32; }
.plan-pro .plan-name { color: #fbbf24; }

.plan-price {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 12px;
}

.plan-price span { font-size: 0.85rem; font-weight: 400; color: #64748b; }

.plan-features {
  list-style: none;
  padding: 0;
  margin-bottom: 16px;
}

.plan-features li {
  padding: 4px 0;
  color: #94a3b8;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.plan-features li::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.plan-bronze .plan-features li::before { background: #CD7F32; }
.plan-pro .plan-features li::before { background: #fbbf24; }

.plan-btn { width: 100%; padding: 12px; font-size: 0.9rem; }

/* === How To === */
.howto-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.howto-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.howto-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tier-primary), var(--tier-secondary));
  color: #0f172a;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.howto-title {
  font-weight: 600;
  color: #f1f5f9;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.howto-desc {
  color: #94a3b8;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* === SVG ring tier colors === */
body.tier-anonymous .ring-stop-1 { stop-color: #C0C0C0; }
body.tier-anonymous .ring-stop-2 { stop-color: #A8A9AD; }
body.tier-anonymous .ring-stop-3 { stop-color: #808080; }

body.tier-free .ring-stop-1 { stop-color: #C0C0C0; }
body.tier-free .ring-stop-2 { stop-color: #A8A9AD; }
body.tier-free .ring-stop-3 { stop-color: #808080; }

body.tier-bronze .ring-stop-1 { stop-color: #CD7F32; }
body.tier-bronze .ring-stop-2 { stop-color: #B87333; }
body.tier-bronze .ring-stop-3 { stop-color: #8B5A2B; }

body.tier-pro .ring-stop-1 { stop-color: #fbbf24; }
body.tier-pro .ring-stop-2 { stop-color: #f59e0b; }
body.tier-pro .ring-stop-3 { stop-color: #d97706; }
