/* ===== CSS Variables ===== */
:root {
  /* Khaki olive + gray base */
  --color-bg: #f5f2eb;
  --color-bg-secondary: #eae6db;
  --color-surface: #ffffff;
  --color-text: #3a3a2e;
  --color-text-secondary: #6b6b5a;
  --color-olive: #7a8450;
  --color-olive-light: #a3ad7a;
  --color-olive-dark: #5c6339;
  --color-purple: #9b6bb0;
  --color-purple-light: #c9a5d9;
  --color-purple-bg: #f3ecf7;
  --color-cream: #faf6e9;
  --color-yellow: #f0e5b0;
  --color-yellow-light: #fdf8e0;
  --color-warm: #e8d5b0;
  --color-border: #d9d4c8;
  --color-shadow: rgba(90, 85, 70, 0.08);
  --color-shadow-heavy: rgba(90, 85, 70, 0.15);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --transition: 0.3s ease;
}

/* Dark mode */
[data-theme="dark"] {
  --color-bg: #1a1a1e;
  --color-bg-secondary: #242428;
  --color-surface: #2a2a30;
  --color-text: #e8e6df;
  --color-text-secondary: #a0a097;
  --color-olive: #a3ad7a;
  --color-olive-light: #7a8450;
  --color-olive-dark: #c4ce9e;
  --color-purple: #c9a5d9;
  --color-purple-light: #9b6bb0;
  --color-purple-bg: #2d2535;
  --color-cream: #2a2822;
  --color-yellow: #8a7d4a;
  --color-yellow-light: #33302a;
  --color-warm: #3d3828;
  --color-border: #3d3d42;
  --color-shadow: rgba(0, 0, 0, 0.2);
  --color-shadow-heavy: rgba(0, 0, 0, 0.35);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  transition: background-color var(--transition), color var(--transition);
  min-height: 100vh;
}

/* ===== Dark Mode Toggle (inside header) ===== */
.dark-toggle {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: #fff;
}

.dark-toggle:hover {
  transform: scale(1.1);
  background: rgba(255,255,255,0.25);
}

/* ===== Header (Topbar) ===== */
.header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--color-olive-light) 0%, var(--color-purple-light) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.header-gecko {
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.5);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-text {
  flex: 1;
  min-width: 0;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 4px rgba(0,0,0,0.15);
  line-height: 1.2;
}

.header-greeting {
  font-size: 0.78rem;
  opacity: 0.9;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-date {
  font-size: 0.7rem;
  opacity: 0.75;
}

/* ===== Container ===== */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* ===== Sections ===== */
.section {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 16px var(--color-shadow);
  transition: background-color var(--transition), box-shadow var(--transition);
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--color-olive-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

[data-theme="dark"] .section-title {
  color: var(--color-olive-light);
}

.section-icon {
  font-size: 1.3rem;
}

/* ===== Events Grid (Checkerboard) ===== */
.events-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.event-card {
  aspect-ratio: 1;
  padding: 6px 4px;
  border-radius: 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), opacity var(--transition);
  border: 1px solid var(--color-border);
  background: var(--color-cream);
  min-width: 0;
  overflow: hidden;
}

.event-card:hover {
  transform: translateY(-2px);
}

.event-card.past {
  opacity: 0.4;
  filter: grayscale(0.3);
}

.event-card.upcoming {
  border-color: var(--color-purple);
  background: var(--color-purple-bg);
  box-shadow: 0 1px 8px rgba(155, 107, 176, 0.15);
}

.event-card.next {
  border-color: var(--color-olive);
  background: var(--color-yellow-light);
  box-shadow: 0 1px 8px rgba(122, 132, 80, 0.2);
  position: relative;
}

.event-card.next::after {
  content: 'NEXT';
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--color-olive);
  color: #fff;
  font-size: 0.5rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.event-emoji {
  font-size: 1rem;
  margin-bottom: 2px;
}

.event-name {
  font-weight: 700;
  font-size: 0.6rem;
  margin-bottom: 1px;
  color: var(--color-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.event-date {
  font-size: 0.55rem;
  color: var(--color-text-secondary);
}

.event-dday {
  font-size: 0.55rem;
  font-weight: 700;
  margin-top: 2px;
  color: var(--color-purple);
}

/* ===== 후추 코너 ===== */
.hoochu-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hoochu-profile {
  display: flex;
  align-items: center;
  gap: 20px;
}

.hoochu-avatar {
  font-size: 4rem;
  background: var(--color-cream);
  width: 90px;
  height: 90px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 3px solid var(--color-olive-light);
}

.hoochu-info h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-olive-dark);
  margin-bottom: 6px;
}

[data-theme="dark"] .hoochu-info h3 {
  color: var(--color-olive);
}

.hoochu-stats {
  list-style: none;
  font-size: 0.88rem;
  color: var(--color-text-secondary);
}

.hoochu-stats li {
  margin-bottom: 3px;
}

.hoochu-stats strong {
  color: var(--color-text);
}

.shedding-card {
  background: linear-gradient(135deg, var(--color-yellow-light), var(--color-cream));
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--color-olive-light);
}

.shedding-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.shedding-countdown {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--color-olive-dark);
  line-height: 1;
}

[data-theme="dark"] .shedding-countdown {
  color: var(--color-olive);
}

.shedding-sub {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: 6px;
}

/* ===== 후추 운세 ===== */
.fortune-card {
  text-align: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--color-purple-bg), var(--color-yellow-light));
  border-radius: var(--radius);
  border: 1px solid var(--color-purple-light);
  position: relative;
  overflow: hidden;
}

.fortune-gecko {
  font-size: 3.5rem;
  margin-bottom: 12px;
  display: inline-block;
  transition: transform 0.6s ease;
}

.fortune-gecko.rolling {
  animation: geckoRoll 0.6s ease;
}

@keyframes geckoRoll {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-15deg) scale(1.2); }
  50% { transform: rotate(15deg) scale(1.2); }
  75% { transform: rotate(-10deg) scale(1.1); }
  100% { transform: rotate(0deg) scale(1); }
}

.fortune-stars {
  font-size: 1.5rem;
  margin-bottom: 12px;
  letter-spacing: 4px;
}

.fortune-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.6;
  margin-bottom: 16px;
  padding: 0 8px;
}

.fortune-btn {
  background: linear-gradient(135deg, var(--color-purple), var(--color-olive));
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.fortune-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(155, 107, 176, 0.3);
}

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

/* ===== 후추봇 메시지 ===== */
.bot-message-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.bot-avatar {
  font-size: 2.4rem;
  flex-shrink: 0;
}

.bot-avatar-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-olive-light);
}

.bot-bubble {
  background: var(--color-bg-secondary);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  padding: 16px 20px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text);
  position: relative;
  flex: 1;
}

.bot-bubble::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 12px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid var(--color-bg-secondary);
}

/* ===== Family Grid ===== */
.family-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.family-card {
  background: var(--color-cream);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  border: 1px solid var(--color-border);
  transition: transform var(--transition), box-shadow var(--transition);
}

.family-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 24px var(--color-shadow-heavy);
}

.family-card--mom { border-bottom: 3px solid #ff8c42; }
.family-card--bro { border-bottom: 3px solid #5a9fd4; }
.family-card--sis { border-bottom: 3px solid #9b6bb0; }
.family-card--hoochu { border-bottom: 3px solid #7a8450; }
.family-card--bot { border-bottom: 3px solid #6b7b8d; }

.family-emoji {
  font-size: 2.2rem;
  margin-bottom: 10px;
}

.family-avatar-img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-border);
}

.event-avatar-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-border);
}

.family-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.family-desc {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 32px 20px 40px;
  color: var(--color-text-secondary);
  font-size: 0.82rem;
}

.paw-divider {
  font-size: 1.2rem;
  margin-bottom: 12px;
  letter-spacing: 8px;
  opacity: 0.5;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .header {
    padding: 10px 14px;
    gap: 10px;
  }

  .header-avatar {
    width: 36px;
    height: 36px;
  }

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

  .container {
    padding: 16px 12px;
  }

  .section {
    padding: 22px 18px;
    border-radius: var(--radius);
  }

  .hoochu-profile {
    flex-direction: column;
    text-align: center;
  }

  .family-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .events-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .section {
    padding: 18px 14px;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .family-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ===== Animations ===== */
.section {
  animation: fadeUp 0.5s ease both;
}

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

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
