/* ============================================
   StarWeaver v2 - Astrology Web App
   Dark Starry Sky Theme · Mobile-First
   ============================================ */

:root {
  --bg-deep: #0a0a1a;
  --bg-dark: #10102a;
  --bg-card: rgba(16, 16, 42, 0.85);
  --bg-card-hover: rgba(26, 26, 56, 0.9);
  --gold: #d4af37;
  --gold-light: #f0d060;
  --gold-dark: #b8960f;
  --purple: #9b59b6;
  --purple-light: #c084fc;
  --purple-dark: #7c3aed;
  --blue-glow: #4a90d9;
  --text-primary: #e8e0f0;
  --text-secondary: #a89bb5;
  --text-muted: #6b5f7a;
  --border-subtle: rgba(212, 175, 55, 0.15);
  --border-glow: rgba(212, 175, 55, 0.3);
  --shadow-glow: 0 0 20px rgba(212, 175, 55, 0.1);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --nav-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-height: auto;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.6;
  position: relative;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 8px);
}

/* ===== Canvas Star Background ===== */
#star-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gold-dark); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ===== Loading Screen ===== */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-star {
  font-size: 4rem;
  animation: pulse-glow 2s ease-in-out infinite;
}

.loading-text {
  margin-top: 1.5rem;
  font-size: 1.2rem;
  color: var(--gold);
  letter-spacing: 0.3em;
  animation: fade-in-up 1.5s ease;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); text-shadow: 0 0 20px var(--gold); }
  50% { transform: scale(1.1); text-shadow: 0 0 40px var(--gold), 0 0 60px var(--purple); }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== App Container ===== */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px;
  padding-bottom: 20px;
}

/* ===== Header ===== */
.header {
  text-align: center;
  padding: 1.2rem 0.5rem 0.8rem;
  position: relative;
}

.header-title {
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold), var(--gold-light), var(--purple-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.12em;
  text-shadow: none;
  position: relative;
}

.header-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  letter-spacing: 0.4em;
}

.language-toggle {
  position: absolute;
  top: 1rem;
  right: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.language-toggle:hover {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: var(--shadow-glow);
}

/* ===== Cosmic Quote ===== */
.cosmic-quote {
  text-align: center;
  padding: 0.6rem 1rem;
  margin: 0.3rem auto 1rem;
  max-width: 700px;
  min-height: 2.5rem;
  position: relative;
}

.cosmic-quote-text {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
  transition: opacity 0.6s ease;
}

.cosmic-quote-text::before { content: '\201C'; color: var(--gold); font-size: 1.2rem; }
.cosmic-quote-text::after { content: '\201D'; color: var(--gold); font-size: 1.2rem; }

.cosmic-quote-author {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: normal;
}

/* ===== Navigation Tabs (Desktop) ===== */
.nav-tabs {
  display: none;
}

/* ===== Bottom Navigation (Mobile-First) ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(10, 10, 30, 0.92);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 6px 4px calc(6px + var(--safe-bottom));
  height: calc(var(--nav-height) + var(--safe-bottom));
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  flex: 1;
  max-width: 70px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

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

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

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

.bottom-nav-item .nav-label {
  font-size: 0.6rem;
  line-height: 1;
  white-space: nowrap;
  transition: var(--transition);
}

.bottom-nav-item.active {
  color: var(--gold);
}

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--gold);
  border-radius: 0 0 2px 2px;
  box-shadow: 0 0 8px var(--gold);
}

/* Bottom nav indicator glow */
.bottom-nav-item.active .nav-icon {
  filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.4));
}

/* ===== Sections ===== */
.section {
  display: none;
  animation: section-fade-in 0.4s ease;
}

.section.active {
  display: block;
}

@keyframes section-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: var(--transition);
}

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

.card-title {
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .icon { font-size: 1.2rem; }

/* ===== Form ===== */
.form-group {
  margin-bottom: 0.8rem;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.form-input, .form-select {
  width: 100%;
  padding: 12px 14px;
  background: rgba(10, 10, 30, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
  min-height: 44px;
}

.form-input:focus, .form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.15);
}

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

.form-select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23d4af37' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

/* ===== Button ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: var(--bg-deep);
  width: 100%;
}

.btn-primary:hover {
  box-shadow: 0 6px 25px rgba(212, 175, 55, 0.3);
}

.btn-secondary {
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid var(--border-subtle);
  color: var(--gold);
}

.btn-secondary:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold);
}

.btn-purple {
  background: linear-gradient(135deg, var(--purple-dark), var(--purple));
  color: white;
}

.btn-purple:hover {
  box-shadow: 0 6px 25px rgba(155, 89, 182, 0.3);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ===== Natal Chart Section ===== */
.chart-container {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.chart-container svg {
  width: 100%;
  height: auto;
}

.chart-controls {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

/* ===== Reading Output ===== */
.reading-output {
  background: rgba(10, 10, 30, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-top: 0.8rem;
  min-height: 80px;
  line-height: 1.7;
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.reading-output.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.reading-output.loading::after {
  content: '';
  width: 18px;
  height: 18px;
  border: 2px solid var(--gold);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 8px;
}

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

/* ===== Horoscope ===== */
.horoscope-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem;
}

.zodiac-card {
  background: rgba(10, 10, 30, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.zodiac-card:active {
  transform: scale(0.95);
  border-color: var(--gold);
}

.zodiac-card .zodiac-icon {
  font-size: 2rem;
  margin-bottom: 0.3rem;
}

.zodiac-card .zodiac-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.zodiac-card .zodiac-dates {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.zodiac-card .zodiac-horoscope {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Zodiac Detail ===== */
.zodiac-detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.zodiac-detail-overlay.active {
  display: flex;
}

.zodiac-detail-card {
  background: var(--bg-dark);
  border: 1px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 500px;
  width: 100%;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 0 40px rgba(212, 175, 55, 0.2);
  animation: modal-slide-up 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modal-slide-up {
  from { opacity: 0; transform: translateY(40px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.zodiac-detail-card .close-btn {
  float: right;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  padding: 4px 8px;
}

.zodiac-detail-card .close-btn:active { color: var(--gold); }

.zodiac-detail-card h2 {
  font-size: 1.5rem;
  color: var(--gold);
  margin-bottom: 0.8rem;
}

.zodiac-detail-card .info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.zodiac-detail-card .info-label { color: var(--text-muted); font-size: 0.8rem; }
.zodiac-detail-card .info-value { color: var(--text-primary); font-size: 0.85rem; }

/* ===== Compatibility ===== */
.compat-inputs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.compat-result {
  text-align: center;
  padding: 1.5rem;
}

.compat-score {
  font-size: 3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--gold), var(--purple-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.compat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ===== AI Chat ===== */
.ai-chat-container {
  max-width: 700px;
  margin: 0 auto;
}

.ai-chat-messages {
  max-height: 350px;
  overflow-y: auto;
  padding: 0.8rem;
  background: rgba(10, 10, 30, 0.3);
  border-radius: var(--radius-sm);
  margin-bottom: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  -webkit-overflow-scrolling: touch;
}

.ai-message, .user-message {
  max-width: 90%;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.6;
  animation: msg-in 0.3s ease;
}

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

.ai-message {
  align-self: flex-start;
  background: rgba(155, 89, 182, 0.12);
  border: 1px solid rgba(155, 89, 182, 0.2);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.ai-message .msg-sender {
  font-size: 0.7rem;
  color: var(--purple-light);
  margin-bottom: 0.2rem;
  display: block;
}

.user-message {
  align-self: flex-end;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.2);
  color: var(--gold-light);
  border-bottom-right-radius: 4px;
}

.ai-chat-input-area {
  display: flex;
  gap: 0.5rem;
}

.ai-chat-input-area .form-input {
  flex: 1;
  min-height: 44px;
}

.ai-chat-input-area .btn {
  flex-shrink: 0;
  padding: 12px 18px;
}

/* Typing effect cursor */
.typing-cursor::after {
  content: '|';
  animation: blink 0.8s infinite;
  color: var(--gold);
}

@keyframes blink { 50% { opacity: 0; } }

/* ===== API Key Input ===== */
.api-key-area {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.05), rgba(155, 89, 182, 0.05));
  border: 1px dashed var(--border-glow);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

.api-key-area .form-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.api-key-area .form-input {
  flex: 1;
}

.api-key-status {
  font-size: 0.75rem;
  margin-top: 0.3rem;
}

.api-key-status.connected { color: #22c55e; }
.api-key-status.disconnected { color: var(--text-muted); }

.model-selector {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.model-selector select {
  background: rgba(10, 10, 30, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  min-height: 44px;
  width: 100%;
}

.model-selector select:focus {
  border-color: var(--gold);
}

/* ===== Fortune / Divination ===== */
.fortune-container {
  text-align: center;
  padding: 1rem;
}

.fortune-btn {
  font-size: 2.5rem;
  background: none;
  border: 2px solid var(--gold);
  border-radius: 50%;
  width: 70px;
  height: 70px;
  cursor: pointer;
  transition: var(--transition);
  animation: float 3s ease-in-out infinite;
}

.fortune-btn:active {
  transform: scale(0.9);
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.fortune-result {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(10, 10, 30, 0.4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.fortune-result .fortune-card-name {
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 0.3rem;
}

.fortune-result .fortune-card-meaning {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ===== Moon Phase ===== */
.moon-phase {
  text-align: center;
  padding: 1rem;
}

.moon-svg {
  width: 100px;
  height: 100px;
  margin: 0 auto 0.8rem;
}

.moon-name {
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 0.2rem;
}

.moon-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Cosmic Weather ===== */
.cosmic-weather {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem;
}

.weather-item {
  text-align: center;
  padding: 0.8rem 0.5rem;
  background: rgba(10, 10, 30, 0.4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.weather-item .weather-icon {
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
}

.weather-item .weather-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.weather-item .weather-value {
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-top: 0.1rem;
}

/* ===== Astro Dice ===== */
.dice-container {
  text-align: center;
  padding: 0.8rem;
}

.dice-btn {
  font-size: 2.5rem;
  background: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: inline-block;
  min-width: 44px;
  min-height: 44px;
}

.dice-btn:active {
  transform: scale(0.9);
}

.dice-btn.rolling {
  animation: dice-roll 0.6s ease;
}

@keyframes dice-roll {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(90deg) scale(1.2); }
  50% { transform: rotate(180deg) scale(1); }
  75% { transform: rotate(270deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}

.dice-result {
  margin-top: 0.6rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  min-height: 1.8rem;
}

/* 3-dice astro dice display */
.dice-3-results {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.dice-result-item {
  background: rgba(212,175,55,0.08);
  border: 1px solid rgba(212,175,55,0.2);
  border-radius: 12px;
  padding: 0.6rem 1rem;
  text-align: center;
  min-width: 100px;
}
.dice-label {
  display: block;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  margin-bottom: 0.3rem;
}
.dice-value {
  display: block;
  font-size: 1.1rem;
  color: #d4af37;
  font-weight: 600;
}
.dice-reading {
  margin-top: 1rem;
  padding: 0.8rem;
  background: rgba(212,175,55,0.05);
  border-left: 3px solid #d4af37;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.85);
}

/* ===== Home / Landing ===== */
.home-greeting {
  text-align: center;
  padding: 1.2rem 0.5rem;
}

.home-greeting h2 {
  font-size: 1.4rem;
  color: var(--gold-light);
  margin-bottom: 0.3rem;
}

.home-greeting p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 1.5rem 0 0.8rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: 1.5rem;
}

/* ============================================
   Tablet Styles (≥ 600px)
   ============================================ */
@media (min-width: 600px) {
  body {
    padding-bottom: 0;
  }

  .app-container {
    padding: 20px;
  }

  .header {
    padding: 2rem 1rem 1rem;
  }

  .header-title {
    font-size: 2.5rem;
    letter-spacing: 0.15em;
  }

  .header-subtitle {
    font-size: 0.95rem;
    letter-spacing: 0.5em;
  }

  /* Show desktop tabs, hide bottom nav */
  .bottom-nav {
    display: none;
  }

  .nav-tabs {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    margin-bottom: 2rem;
    flex-wrap: wrap;
  }

  .nav-tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
  }

  .nav-tab:hover {
    color: var(--text-primary);
    background: rgba(212, 175, 55, 0.08);
  }

  .nav-tab.active {
    color: var(--gold);
    background: rgba(212, 175, 55, 0.12);
    box-shadow: inset 0 -2px 0 var(--gold);
  }

  .nav-tab .icon { font-size: 1.1rem; }

  .card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
  }

  .card:active {
    transform: none;
  }

  .card-title {
    font-size: 1.3rem;
    margin-bottom: 1rem;
  }

  .card-title .icon { font-size: 1.4rem; }

  .form-row {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .form-group {
    margin-bottom: 1.2rem;
  }

  .btn {
    padding: 12px 28px;
    width: auto;
  }

  .btn-primary {
    width: auto;
  }

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

  .zodiac-card {
    padding: 1.2rem;
  }

  .zodiac-card .zodiac-icon {
    font-size: 2.5rem;
  }

  .zodiac-card:hover {
    border-color: var(--gold);
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(212, 175, 55, 0.15);
  }

  .cosmic-weather {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
  }

  .compat-inputs {
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }

  .compat-score {
    font-size: 4rem;
  }

  .zodiac-detail-card {
    padding: 2rem;
    max-height: 80vh;
  }

  @keyframes modal-slide-up {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
  }

  .zodiac-detail-overlay {
    align-items: center;
  }

  .chart-container {
    max-width: 500px;
  }

  .moon-svg {
    width: 120px;
    height: 120px;
  }

  .fortune-btn {
    width: 80px;
    height: 80px;
    font-size: 3rem;
  }

  .fortune-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
  }

  .ai-chat-messages {
    max-height: 400px;
  }

  .api-key-area .form-row {
    flex-direction: row;
    align-items: end;
  }

  .home-greeting h2 {
    font-size: 1.8rem;
  }

  .language-toggle {
    top: 1.5rem;
    right: 1rem;
  }

  .dice-btn:hover {
    transform: scale(1.2);
  }

  .ai-message, .user-message {
    max-width: 85%;
    padding: 0.8rem 1.2rem;
  }
}

/* ============================================
   Desktop Styles (≥ 1024px)
   ============================================ */
@media (min-width: 1024px) {
  .app-container {
    padding: 30px;
  }

  .header-title {
    font-size: 2.8rem;
  }

  .header-subtitle {
    font-size: 1rem;
  }

  .cosmic-quote-text {
    font-size: 1.05rem;
  }

  .home-greeting {
    padding: 2rem 1rem;
  }

  .home-greeting h2 {
    font-size: 2rem;
  }
}

/* ===== Numerology / 生命灵数 ===== */
.numerology-results {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 0.5rem 0;
}

.numerology-item {
  background: rgba(10, 10, 30, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.2rem 1rem;
  text-align: center;
  animation: numerology-fade-in 0.5s ease backwards;
  transition: all 0.3s ease;
}

.numerology-item:nth-child(1) { animation-delay: 0.1s; }
.numerology-item:nth-child(2) { animation-delay: 0.2s; }
.numerology-item:nth-child(3) { animation-delay: 0.3s; }
.numerology-item:nth-child(4) { animation-delay: 0.4s; }

@keyframes numerology-fade-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.numerology-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.5rem;
}

.numerology-number {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.numerology-digit {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--num-color, var(--gold));
  text-shadow:
    0 0 20px color-mix(in srgb, var(--num-color, var(--gold)) 50%, transparent),
    0 0 40px color-mix(in srgb, var(--num-color, var(--gold)) 30%, transparent),
    0 0 80px color-mix(in srgb, var(--num-color, var(--gold)) 15%, transparent);
  line-height: 1;
  transition: text-shadow 0.3s ease;
}

.numerology-number.master .numerology-digit {
  font-size: 4rem;
  background: linear-gradient(135deg, var(--num-color, var(--gold)), #fff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.numerology-master-badge {
  font-size: 0.6rem;
  padding: 2px 8px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: var(--bg-deep);
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  animation: numerology-badge-glow 2s ease-in-out infinite;
}

@keyframes numerology-badge-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(212, 175, 55, 0.3); }
  50% { box-shadow: 0 0 20px rgba(212, 175, 55, 0.6); }
}

.numerology-icon {
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
}

.numerology-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}

.numerology-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 320px;
  margin: 0 auto;
}

@media (min-width: 600px) {
  .numerology-results {
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
  }

  .numerology-item {
    padding: 1.5rem;
  }

  .numerology-item:hover {
    border-color: var(--border-glow);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  }

  .numerology-digit {
    font-size: 4.5rem;
  }

  .numerology-number.master .numerology-digit {
    font-size: 5rem;
  }

  .numerology-icon {
    font-size: 2.2rem;
  }
}

@media (min-width: 1024px) {
  .numerology-results {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ===== Tarot Styles ===== */
.spread-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
}

.spread-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.8rem 0.5rem;
  background: rgba(10, 10, 30, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.8rem;
  min-height: 70px;
}

.spread-btn:active {
  transform: scale(0.95);
}

.spread-btn.active {
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.1);
  color: var(--gold);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.15);
}

.spread-btn .spread-icon { font-size: 1.4rem; }
.spread-btn .spread-name { font-weight: 600; font-size: 0.85rem; }
.spread-btn .spread-desc { font-size: 0.65rem; color: var(--text-muted); }

/* Tarot Cards Display */
.tarot-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  padding: 1rem 0;
}

.tarot-card {
  width: 100px;
  background: linear-gradient(145deg, rgba(20, 20, 50, 0.9), rgba(10, 10, 30, 0.9));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.4rem;
  text-align: center;
  animation: card-deal 0.5s ease backwards;
  cursor: default;
  transition: var(--transition);
}

.tarot-card:nth-child(1) { animation-delay: 0.1s; }
.tarot-card:nth-child(2) { animation-delay: 0.2s; }
.tarot-card:nth-child(3) { animation-delay: 0.3s; }
.tarot-card:nth-child(4) { animation-delay: 0.4s; }
.tarot-card:nth-child(5) { animation-delay: 0.5s; }
.tarot-card:nth-child(6) { animation-delay: 0.6s; }
.tarot-card:nth-child(7) { animation-delay: 0.7s; }
.tarot-card:nth-child(8) { animation-delay: 0.8s; }
.tarot-card:nth-child(9) { animation-delay: 0.9s; }
.tarot-card:nth-child(10) { animation-delay: 1.0s; }

@keyframes card-deal {
  from { opacity: 0; transform: translateY(-30px) rotate(-10deg) scale(0.8); }
  to { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}

.tarot-card.reversed {
  border-color: rgba(239, 68, 68, 0.3);
}

.tarot-card .card-position {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tarot-card .card-symbol {
  font-size: 2rem;
  margin-bottom: 0.2rem;
}

.tarot-card .card-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.tarot-card .card-meaning {
  font-size: 0.65rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  line-height: 1.3;
}

.tarot-card .card-rev-badge {
  display: inline-block;
  font-size: 0.55rem;
  padding: 1px 6px;
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-radius: 4px;
  margin-top: 0.2rem;
}

.tarot-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(212, 175, 55, 0.15);
}

/* Tablet+ tarot cards */
@media (min-width: 600px) {
  .spread-selector {
    grid-template-columns: repeat(5, 1fr);
  }
  .tarot-card {
    width: 120px;
    padding: 0.8rem 0.5rem;
  }
  .tarot-card .card-symbol { font-size: 2.5rem; }
  .tarot-card .card-name { font-size: 0.85rem; }
}

/* ===== IChing / 周易 Styles ===== */
.iching-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.iching-hexagram-box {
  text-align: center;
  background: rgba(10, 10, 30, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1rem 1.5rem;
  min-width: 140px;
}

.iching-hexagram-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.iching-hexagram-lines {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 0.5rem;
}

.iching-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 22px;
}

.iching-line-bar {
  display: block;
  height: 4px;
  border-radius: 2px;
}

.iching-line .yang-bar {
  width: 80px;
  background: var(--gold);
  box-shadow: 0 0 6px rgba(212, 175, 55, 0.4);
}

.iching-line .yin-bar {
  display: flex;
  gap: 10px;
  width: 80px;
}

.iching-line .yin-left,
.iching-line .yin-right {
  display: block;
  height: 4px;
  width: 35px;
  background: var(--gold);
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(212, 175, 55, 0.4);
}

.iching-line .yin-gap {
  display: block;
  width: 10px;
}

.iching-change-mark {
  font-size: 0.7rem;
  color: #ef4444;
  font-weight: bold;
  opacity: 0;
  transition: opacity 0.3s;
}

.iching-line.changing .iching-change-mark {
  opacity: 1;
}

.iching-line.changing .yang-bar,
.iching-line.changing .yin-left,
.iching-line.changing .yin-right {
  background: linear-gradient(90deg, var(--gold), #ef4444, var(--gold));
  animation: iching-pulse 1.5s ease-in-out infinite;
}

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

.iching-line-num {
  font-size: 0.6rem;
  color: var(--text-muted);
  width: 12px;
  text-align: center;
}

.iching-hexagram-name {
  font-size: 0.85rem;
  color: var(--gold);
  font-weight: 600;
  margin-top: 0.3rem;
}

.iching-change-arrow {
  font-size: 1.5rem;
  color: var(--text-muted);
  padding: 0 0.5rem;
}

.iching-moving-lines {
  text-align: center;
  padding: 0.5rem;
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
}

/* ===== Dream Input ===== */
textarea.dream-input {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  line-height: 1.6;
}

@media (min-width: 600px) {
  .iching-display {
    gap: 2rem;
  }
  .iching-hexagram-box {
    min-width: 180px;
    padding: 1.5rem 2rem;
  }
  .iching-line .yang-bar {
    width: 100px;
  }
  .iching-line .yin-left,
  .iching-line .yin-right {
    width: 45px;
  }
}

/* ===== Footer ===== */
  body {
    padding-top: env(safe-area-inset-top, 0px);
  }
}

/* ============================================
   Mobile Styles (≤ 768px) - Touch Target & iOS Fixes
   ============================================ */
@media (max-width: 768px) {
  /* iOS Safari auto-zoom fix: inputs with font-size < 16px
     cause page zoom on focus. Force 16px on all form inputs. */
  .form-input,
  .form-select {
    font-size: 16px;
  }

  /* AI chat input area spans full width */
  .ai-chat-input-area {
    width: 100%;
  }

  /* Prevent send button text from wrapping on small screens */
  .ai-chat-input-area .btn {
    white-space: nowrap;
  }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  #loading-screen {
    display: none;
  }
}


/* ===== Lucky Guide / 每日幸运指南 ===== */
#lucky-guide-card {
  margin-top: 0;
}

.lucky-guide-results {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin-top: 0.8rem;
}

.lucky-guide-item {
  background: rgba(10, 10, 30, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
  text-align: center;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.lucky-guide-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lucky-guide-value {
  font-size: 0.95rem;
  color: var(--gold);
  font-weight: 600;
  line-height: 1.4;
}

.color-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  vertical-align: middle;
  margin-right: 4px;
}

@media (min-width: 600px) {
  .lucky-guide-results {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }

  .lucky-guide-item {
    padding: 1rem;
    min-height: 80px;
  }

  .lucky-guide-item:hover {
    border-color: var(--border-glow);
  }

  .lucky-guide-value {
    font-size: 1rem;
  }
}

/* ============================================
   User System — Auth Modal, Premium, Profile
   ============================================ */

/* ---- Modal Overlay ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: modal-fade-in 0.3s ease;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: linear-gradient(160deg, rgba(16, 16, 42, 0.98), rgba(10, 10, 30, 0.98));
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  max-width: 420px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 0 60px rgba(212, 175, 55, 0.15), 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modal-card-in 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

@keyframes modal-card-in {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  padding: 4px 8px;
  line-height: 1;
  z-index: 1;
}

.modal-close:hover,
.modal-close:active {
  color: var(--gold);
}

.modal-title {
  font-size: 1.3rem;
  color: var(--gold);
  text-align: center;
  margin-bottom: 0.3rem;
  line-height: 1.4;
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 1.2rem;
}

/* ---- Auth Toggle ---- */
.auth-toggle-text {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.8rem;
}

.auth-toggle-text a {
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
}

.auth-toggle-text a:hover {
  color: var(--gold);
}

/* ---- User Button (Header) ---- */
.user-btn {
  position: absolute;
  top: 1rem;
  left: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.2);
}

.user-btn.logged-in {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(155, 89, 182, 0.2));
  border-color: var(--gold);
  font-weight: 700;
  font-size: 0.85rem;
}

/* ---- Premium Badge ---- */
.premium-badge {
  display: inline-block;
  background: linear-gradient(135deg, #D4AF37, #f0d060, #D4AF37);
  background-size: 200% 100%;
  animation: premium-shimmer 3s ease-in-out infinite;
  color: #1a1a2e;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes premium-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.premium-badge-sm {
  font-size: 0.6rem;
  padding: 2px 8px;
}

/* ---- Premium Modal Specific ---- */
.premium-card {
  max-width: 380px;
  text-align: center;
}

.premium-price {
  margin: 1rem 0 0.5rem;
}

.premium-price-amount {
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.premium-price-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.premium-divider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1.2rem 0;
  color: var(--text-muted);
  font-size: 0.75rem;
}

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

.premium-error {
  color: #ef4444;
  font-size: 0.8rem;
  margin-top: 0.5rem;
  text-align: center;
}

/* ---- WeChat Pay Box ---- */
.wechat-pay-box {
  background: rgba(10, 10, 30, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  margin: 1rem 0;
  text-align: center;
}

.wechat-pay-icon {
  font-size: 2rem;
  margin-bottom: 0.3rem;
}

.wechat-pay-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.8rem;
}

.wechat-pay-qr {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.qr-placeholder {
  width: 120px;
  height: 120px;
  background: white;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 0.85rem;
}

.wechat-pay-note {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---- Usage Counter ---- */
.usage-counter {
  position: fixed;
  top: 60px;
  right: 10px;
  z-index: 100;
  background: rgba(10, 10, 30, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  display: none;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.usage-counter .usage-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}

.usage-counter .usage-dot.low {
  background: #f97316;
}

.usage-counter .usage-dot.empty {
  background: #ef4444;
}

/* ---- Upsell Overlay ---- */
.upsell-overlay {
  position: relative;
}

.upsell-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 30, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: var(--radius-sm);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.upsell-overlay .upsell-cta {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  text-align: center;
  pointer-events: auto;
}

/* ---- Profile Avatar ---- */
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--bg-deep);
  margin: 0 auto 0.8rem;
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
}

.profile-usage {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0.5rem 0;
}

/* ---- Mobile modal adjustments ---- */
@media (max-width: 480px) {
  .modal-card {
    padding: 1.5rem 1.2rem;
    max-width: 95vw;
    border-radius: var(--radius-md);
  }

  .modal-title {
    font-size: 1.1rem;
  }

  .user-btn {
    top: 0.8rem;
    left: 0.3rem;
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .usage-counter {
    top: 52px;
    right: 6px;
    font-size: 0.65rem;
    padding: 3px 10px;
  }
}

@media (min-width: 600px) {
  .user-btn {
    top: 1.5rem;
    left: 1rem;
    width: 40px;
    height: 40px;
    font-size: 1.05rem;
  }

  .modal-card {
    padding: 2rem;
  }
}

/* ===== History Button (Header) ===== */
.history-btn {
  position: absolute;
  top: 1rem;
  left: 3.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
  backdrop-filter: blur(10px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.2);
}

/* ===== History Modal ===== */
.history-card {
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  margin: 0.5rem 0;
  min-height: 100px;
}

.history-item {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.8rem;
  background: rgba(10, 10, 30, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  transition: var(--transition);
}

.history-item:hover {
  border-color: var(--border-glow);
}

.history-item-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.history-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item-type {
  font-size: 0.85rem;
  color: var(--gold);
  font-weight: 600;
}

.history-item-date {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.history-item-preview {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .history-btn {
    top: 0.8rem;
    left: 2.8rem;
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
}

@media (min-width: 600px) {
  .history-btn {
    top: 1.5rem;
    left: 3.2rem;
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .history-item {
    padding: 1rem;
  }
}

/* ===== Share Button ===== */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--gold, #D4AF37);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
  margin-top: 12px;
}
.share-btn:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold, #D4AF37);
  transform: translateY(-1px);
}
.share-btn .share-icon {
  font-size: 18px;
}

/* ===== Daily Horoscope Badge ===== */
.daily-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 3px 12px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #22c55e;
  border-radius: 20px;
  margin-bottom: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  animation: daily-badge-in 0.4s ease;
}

@keyframes daily-badge-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Share Preview Modal ===== */
#share-preview-modal .modal-card {
  max-width: 360px;
  text-align: center;
}
#share-preview-image {
  width: 100%;
  max-width: 300px;
  border-radius: 12px;
  margin: 12px 0;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.share-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
}
.share-actions button {
  flex: 1;
  padding: 10px 16px;
  border-radius: 24px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}
.btn-download {
  background: linear-gradient(135deg, #D4AF37, #B8860B);
  color: #fff;
}
.btn-moments {
  background: rgba(7, 193, 96, 0.15);
  color: #07C160;
  border: 1px solid rgba(7, 193, 96, 0.3) !important;
}
.btn-moments:hover {
  background: rgba(7, 193, 96, 0.25);
}
