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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-900: #111827;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Screens */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; min-height: 100vh; }

/* Loading */
#loading-screen { align-items: center; justify-content: center; gap: 16px; }
.loader {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth Screen */
#auth-screen { align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  background: white;
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 28px; font-weight: 800; margin-bottom: 12px; color: var(--primary); }
.tagline { color: var(--gray-600); margin-bottom: 32px; line-height: 1.6; font-size: 15px; }
.free-note { font-size: 13px; color: var(--gray-400); margin-top: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 24px; border-radius: var(--radius);
  font-size: 16px; font-weight: 600; cursor: pointer;
  border: none; text-decoration: none; transition: all 0.15s;
  width: 100%;
}
.btn-google { background: #4285f4; color: white; }
.btn-google:hover { background: #3367d6; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-upgrade {
  background: #d97706; color: white;
  padding: 10px 20px; width: auto; font-size: 14px; border-radius: 8px;
}
.btn-text {
  background: none; border: none; color: var(--gray-600);
  cursor: pointer; font-size: 14px; text-decoration: underline; padding: 8px;
}

/* Header */
.app-header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
  gap: 12px;
}
.app-name { font-weight: 800; font-size: 17px; color: var(--primary); }
.usage-badge {
  background: var(--gray-100);
  font-size: 12px; color: var(--gray-600);
  padding: 2px 8px; border-radius: 20px; margin-left: 8px;
}
.header-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.location-select {
  border: 1px solid var(--gray-200); border-radius: 8px;
  padding: 6px 10px; font-size: 14px; background: white;
  max-width: 200px;
}

/* Upgrade Banner */
.upgrade-banner {
  background: #fef3c7; border-bottom: 1px solid #fde68a;
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; gap: 12px;
}
.upgrade-banner.hidden { display: none; }

/* Reviews */
.reviews-container { flex: 1; padding: 16px; max-width: 680px; width: 100%; margin: 0 auto; }

.review-card {
  background: white; border-radius: var(--radius);
  padding: 20px; margin-bottom: 12px;
  box-shadow: var(--shadow); border: 1px solid var(--gray-200);
}
.review-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 12px;
}
.reviewer-name { font-weight: 600; font-size: 16px; }
.review-date { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.stars { font-size: 18px; }
.review-text {
  color: var(--gray-600); font-size: 15px; line-height: 1.6; margin-bottom: 16px;
}
.review-text.empty { color: var(--gray-400); font-style: italic; }

.reply-area { position: relative; }
.reply-textarea {
  width: 100%; min-height: 100px; padding: 12px;
  border: 2px solid var(--gray-200); border-radius: 8px;
  font-size: 15px; line-height: 1.6; resize: vertical;
  font-family: inherit; transition: border-color 0.15s;
  background: var(--gray-50);
}
.reply-textarea:focus { outline: none; border-color: var(--primary); background: white; }
.reply-textarea.ai-generated { border-color: #bfdbfe; background: #eff6ff; }

.reply-actions { display: flex; gap: 10px; margin-top: 10px; }
.btn-generate {
  flex: 1; padding: 12px; border-radius: 8px;
  background: var(--gray-100); color: var(--gray-900);
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.15s;
}
.btn-generate:hover:not(:disabled) { background: var(--gray-200); }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-post {
  flex: 1; padding: 12px; border-radius: 8px;
  background: var(--success); color: white;
  font-size: 15px; font-weight: 700; cursor: pointer;
  border: none; transition: all 0.15s;
}
.btn-post:hover:not(:disabled) { background: #15803d; }
.btn-post:disabled { opacity: 0.5; cursor: not-allowed; }

.card-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; color: var(--success); font-weight: 600;
  padding: 8px 0;
}

/* Empty State */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state h2 { font-size: 22px; margin-bottom: 8px; }
.empty-state p { color: var(--gray-600); }

/* Reviews Loading */
.reviews-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 40px; color: var(--gray-400);
}
.reviews-loading.hidden { display: none; }
.loader-small {
  width: 20px; height: 20px;
  border: 2px solid var(--gray-200); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-card {
  background: white; border-radius: var(--radius);
  padding: 32px; max-width: 380px; width: 100%;
  position: relative; z-index: 1; text-align: center;
  box-shadow: var(--shadow-lg);
}
.modal-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 10px; }
.modal-card > p { color: var(--gray-600); margin-bottom: 20px; }
.feature-list { text-align: left; margin-bottom: 24px; list-style: none; }
.feature-list li { padding: 6px 0; color: var(--gray-600); font-size: 15px; }
.price-block { margin-bottom: 20px; }
.price { font-size: 48px; font-weight: 900; }
.price-period { font-size: 18px; color: var(--gray-400); }
.modal-card .btn-text { display: block; margin-top: 12px; }

.hidden { display: none !important; }

@media (max-width: 480px) {
  .auth-card { padding: 28px 20px; }
  .review-card { padding: 16px; }
  .reply-actions { flex-direction: column; }
  .location-select { max-width: 130px; font-size: 13px; }
}
