:root {
  --bg-color: #fcf9f2; /* Updated to match other pages */
  --text-color: #1a1a1a;
  --primary-color: #1a1a1a;
  --ink-color: #1a1a1a;
  --bubble-bg-system: #fff;
  --bubble-bg-user: #95ec69;
}

body {
  margin: 0;
  padding: 0;
  font-family: "Kaiti", "STKaiti", "Songti SC", serif; /* Ink style font */
  background-color: var(--bg-color);
  color: var(--text-color);
  height: 100vh;
  overflow: hidden;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

.step {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0;
  left: 0;
  background: var(--bg-color);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.step.active {
  display: flex;
  opacity: 1;
  z-index: 10;
}

/* Step 1: Animation */
.ink-animation-container {
  font-size: 2rem;
  font-weight: bold;
  color: var(--ink-color);
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.ink-text {
  opacity: 0;
  animation: ink-fade-in 2s forwards;
}

.ink-text:nth-child(1) { animation-delay: 0.5s; }
.ink-text:nth-child(2) { animation-delay: 2.5s; }
.ink-text:nth-child(3) { animation-delay: 4.5s; }

@keyframes ink-fade-in {
  0% { opacity: 0; transform: scale(0.8) blur(2px); }
  100% { opacity: 1; transform: scale(1) blur(0); }
}

/* Step 2: Intro */
.intro-card {
  text-align: center;
  padding: 20px;
}

.intro-img {
  max-width: 80%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.intro-text {
  font-size: 1.2rem;
  color: #666;
  animation: fade-in 1s ease 1s forwards;
  opacity: 0;
}

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

/* Chat Interface (Steps 3, 4, 5, 6) */
.chat-container {
  flex: 1;
  width: 100%;
  padding: var(--chat-container-padding, 12px);
  padding-bottom: 80px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
  justify-content: flex-start;
  padding-top: 60px;
}

.chat-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: var(--chat-max-width, 92%);
}

.chat-message.system {
  align-self: flex-start;
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 40px;
  height: 40px;
  background: #eee;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #555;
  flex-shrink: 0;
}

.bubble {
  background: var(--bubble-bg-system);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  font-size: 16px;
  line-height: 1.5;
  border: 1px solid #e0e0e0;
}

.chat-message.user .bubble {
  background: var(--bubble-bg-user);
  border: none;
}

.input-area {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: #f9f9f9;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 100;
  box-sizing: border-box;
}

#name-input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 20px;
  outline: none;
  font-size: 16px;
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}

/* Water Animation Step 9 */
.water-animation-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fcfcfc;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  z-index: 100;
}

.water-ink-bg {
  position: absolute;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(33, 150, 243, 0.1) 0%, rgba(33, 150, 243, 0.4) 30%, rgba(3, 169, 244, 0.8) 60%, #01579b 100%);
  opacity: 0;
  transform: scale(0.5);
  animation: water-spread 3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.water-text {
  position: relative;
  font-family: "Kaiti", "STKaiti", serif;
  font-size: 2rem;
  color: white;
  z-index: 2;
  opacity: 0;
  animation: fade-in-text 1.5s ease 1s forwards;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

@keyframes water-spread {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: scale(1.5);
  }
}

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

/* Gender Selection */
.gender-selection {
  display: flex;
  gap: 20px;
  padding: 30px;
  width: 100%;
  justify-content: center;
}

.gender-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 15px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  width: 80px;
}

.gender-option:active {
  background: #f0f0f0;
}

.gender-img {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  object-fit: contain;
}

/* Wheel & Location */
.wheel-container, .location-selection {
  width: 100%;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-bottom: 40px;
}

.primary-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

.location-btn {
  background: white;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  padding: 12px 40px;
  border-radius: 30px;
  font-size: 16px;
  width: 80%;
}

/* MBTI Selection */
.mbti-container {
    width: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-bottom: 40px;
}

.mbti-dimensions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 15px;
}

.mbti-row {
    display: flex;
    background: #f5f5f5;
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    /* justify-content: space-between; */
}

.mbti-opt {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 4px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    /* border: 1px solid #ddd; removed */
    max-width: none;
}

.mbti-opt:active {
    transform: scale(0.95);
    background: #e0e0e0;
}

.mbti-opt.selected {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-weight: bold;
}

.mbti-letter {
    font-size: 1.2rem;
    font-weight: bold;
    font-family: sans-serif;
    line-height: 1;
}

.mbti-desc {
    font-size: 0.75rem;
    margin-top: 2px;
    opacity: 0.7;
}

.mbti-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    width: 100%;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 12px 30px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
}

/* Step 7: End Animation */
.end-animation {
  font-size: 2rem;
  color: var(--ink-color);
  animation: fade-in-out 3s forwards;
}

@keyframes fade-in-out {
  0% { opacity: 0; }
  20% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Main Screen (Old Info Card) */
.info-card {
  background: white;
  padding: 20px;
  border-radius: 12px;
  margin-top: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.info-row:last-child {
  border-bottom: none;
}

/* ========================================= */
/* Main Interface Layout (New) */
/* ========================================= */
.main-interface {
  /* display: flex !important; */
  flex-direction: column;
  background: var(--bg-color); /* Updated to use global bg color */
  padding: 0;
  align-items: stretch;
  overflow: hidden;
}

.step.main-interface.active {
    display: flex;
    flex-direction: column;
}

/* Sidebar */
.sidebar {
  display: none; /* Hide sidebar */
}

.sidebar-top {
  margin-bottom: 20px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.back-icon {
  width: 32px;
  height: 32px;
  border: 1px solid #ccc;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #666;
  background: white;
}

.sidebar-tabs {
  display: flex;
  flex-direction: column;
  gap: 15px;
  width: 100%;
}

.tab-btn {
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 4px;
  padding: 15px 12px;
  font-size: 14px;
  color: #333;
  background: #eef2f6;
  border-radius: 0 12px 12px 0;
  border: 1px solid #d0d7de;
  border-left: none;
  cursor: pointer;
  margin-right: 4px;
  box-shadow: 2px 2px 5px rgba(0,0,0,0.05);
  transition: all 0.2s;
}

.tab-btn.active {
  background: #dcebfc;
  color: #1976d2;
  font-weight: bold;
  border-color: #bbdefb;
  transform: translateX(2px);
}

/* Main Content Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 10px;
  padding-bottom: 70px; /* Space for bottom bar */
  position: relative;
}

/* Top Section Layout */
.top-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 10px;
  width: 100%;
}

/* Date Header */
.date-header-card {
  background: white;
  border-radius: 16px;
  padding: 15px; /* Reduced padding */
  text-align: center;
  /* margin-bottom: 10px; removed margin, handled by top-section */
  position: relative;
  /* border: 1px solid #eee; */
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  color: #333;
  flex-shrink: 0;
  /* flex: 1; removed to fix height issue */
}

.ganzhi-container-outside {
    display: flex;
    flex-direction: row;
    gap: 15px;
    align-items: center;
    justify-content: center;
    margin-top: 15px;
    margin-bottom: 5px;
}

.date-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.date-gregorian {
  font-size: 1.1rem;
  font-weight: 500;
  color: #333;
}

.date-lunar {
  font-size: 1rem;
  color: #555;
}

.date-year-info {
  font-size: 0.9rem;
  color: #777;
}

/* Loading */
.loading-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    z-index: 50;
    background: rgba(255,255,255,0.9);
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}


/* Daily Card */
.daily-card-container {
  /* background: #fcfcfc; */
  /* border: 1px solid #eee; */
  /* border-radius: 16px; */
  padding: 0 10px 10px 10px; /* Reduced bottom padding */
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1; /* Fill remaining space */
  gap: 2vh; /* Use vh for responsive gap */
  justify-content: space-evenly; /* Distribute space */
}

/* Score Section */
.score-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-top: 5px; /* Reduced margin */
  flex-shrink: 0;
}

.score-label {
  font-size: 1rem;
  color: #333;
  margin-bottom: 5px;
  font-family: "Kaiti", serif;
}

.score-value {
  font-size: clamp(2rem, 5vh, 2.5rem); /* Adaptive font size */
  font-weight: bold;
  color: #333;
  line-height: 1;
}

/* Almanac */
.almanac-container {
  display: flex;
  justify-content: center;
  width: 100%;
  gap: 20px; /* Reduced gap */
  flex-shrink: 0;
}

.almanac-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 120px;
}

.almanac-circle {
  width: 40px; /* Reduced size */
  height: 40px; /* Reduced size */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem; /* Reduced font size */
  font-weight: bold;
  color: white;
  margin-bottom: 10px; /* Reduced margin */
  font-family: "Kaiti", serif;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.circle-yi { background-color: #4caf50; } /* Green */
.circle-ji { background-color: #e57373; } /* Red */

.almanac-list {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: center;
  font-size: 0.85rem;
  color: #333;
  line-height: 1.5;
}

.almanac-list li {
  margin-bottom: 4px;
}

/* Quote & Elements */
.quote-container {
  text-align: center;
  margin-top: 0; /* Remove auto margin to let flex space-evenly handle it */
  margin-bottom: 10px; /* Reduced margin */
  display: flex;
  flex-direction: column;
  gap: 10px; /* Reduced gap */
  flex-shrink: 0;
}

.element-badges {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.element-badge {
  width: 32px; /* Reduced size */
  height: 32px; /* Reduced size */
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px; /* Reduced font size */
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.element-badge.green { background: #64b5f6; } /* Blue/Water per image 2? Or stick to element color? Image 2 has Blue icons. */
/* Wait, image 2 has Blue icons for element badges? 
   Image 1 had Green (甲) and Red (午).
   Image 2 shows Blue (壬) and Blue (子). 
   The colors should probably follow the element type.
   I'll keep the logic in JS but styling here.
*/

.quote-text {
  font-family: "Kaiti", "STKaiti", serif;
  font-size: 0.95rem; /* Reduced slightly */
  color: #333;
  line-height: 1.5;
  font-weight: 500;
}

/* Footer Button */
.footer-action {
  padding: 5px; /* Reduced padding */
  display: flex;
  justify-content: center;
  width: 100%;
  flex-shrink: 0;
}

.expand-detail-btn {
  background: #1a1a1a;
  border: none;
  color: white;
  padding: 10px 40px; /* Reduced padding */
  border-radius: 30px;
  font-size: 0.95rem; /* Reduced font size */
  font-weight: 500;
  width: auto;
  min-width: 160px; /* Reduced min-width */
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* GanZhi Circles */
.ganzhi-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Five Elements Colors */
.bg-wood { background-color: #4caf50; } /* Green */
.bg-fire { background-color: #f44336; } /* Red */
.bg-earth { background-color: #ff9800; } /* Orange/Brown */
.bg-metal { background-color: #9e9e9e; } /* Grey/Gold */
.bg-water { background-color: #2196f3; } /* Blue */

/* Modal Styles */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: flex-end; /* Bottom sheet on mobile? Or center? User said "new interface", let's do full screen or large modal */
}

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

.modal-content.full-screen {
  width: 100%;
  height: 100%; /* Full screen */
  background: #fcf9f2;
  display: flex;
  flex-direction: column;
  animation: slide-up 0.3s ease-out;
}

@keyframes slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e0e0e0;
  background: white;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  color: #333;
}

.modal-close {
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: #999;
}

.modal-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  font-size: 1rem;
  line-height: 1.8;
  color: #333;
  white-space: pre-wrap; /* Preserve formatting */
}
