:root {
  --color-primary: #b3251e;
  --color-primary-dark: #8a1c17;
  --color-gold: #d4a537;
  --color-bg: #fdfaf5;
  --color-surface: #ffffff;
  --color-border: #e8ddc9;
  --color-text: #2c2622;
  --color-text-muted: #6b625a;
  --color-sunday: #b3251e;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Be Vietnam Pro", Roboto, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}

a {
  color: var(--color-primary);
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ------------------------------ Header ------------------------------ */
.site-header {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #fff;
  padding: 20px 0;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.site-title {
  font-size: 1.5rem;
  margin: 0;
  font-weight: 700;
}

.site-title a {
  color: #fff;
  text-decoration: none;
}

.site-tagline {
  margin: 2px 0 0;
  font-size: 0.9rem;
  color: #f4dede;
}

/* ------------------------------ Main layout ------------------------------ */
main {
  padding: 24px 0 48px;
}

.today-banner {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 24px;
  display: grid;
  gap: 6px;
}

.today-banner .label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#detail-weekday {
  font-weight: 600;
  color: var(--color-primary);
}

#detail-solar {
  font-size: 1.4rem;
  font-weight: 700;
}

#detail-lunar {
  font-size: 1.05rem;
  color: var(--color-text);
}

.canchi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.92rem;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ------------------------------ Calendar ------------------------------ */
.calendar-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 28px;
}

.calendar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.calendar-nav-buttons {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 420px;
}

.nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
}

.nav-btn:hover {
  background: var(--color-gold);
  color: #fff;
  border-color: var(--color-gold);
}

.nav-btn.nav-btn-today {
  background: var(--color-gold);
  color: #fff;
  border-color: var(--color-gold);
  font-weight: 600;
}

.nav-btn.nav-btn-today:hover {
  background: #b8891f;
  border-color: #b8891f;
}

#month-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  text-align: center;
}

#year-can-chi {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin: 2px 0 12px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-weekday {
  text-align: center;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  padding: 6px 0;
}

.cal-weekday.sunday {
  color: var(--color-sunday);
}

.cal-day {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  padding: 2px;
  gap: 2px;
}

.cal-day:hover {
  background: #f6ede0;
}

.cal-day .cal-day-solar {
  font-size: 0.95rem;
  font-weight: 600;
}

.cal-day .cal-day-lunar {
  font-size: 0.68rem;
  color: var(--color-text-muted);
}

.cal-day .cal-day-lunar.new-lunar-month {
  color: var(--color-primary);
  font-weight: 700;
}

.cal-day.outside {
  opacity: 0.35;
}

.cal-day.sunday .cal-day-solar {
  color: var(--color-sunday);
}

.cal-day.today {
  border-color: var(--color-gold);
  background: #fdf3df;
}

.cal-day.selected {
  background: var(--color-primary);
}

.cal-day.selected .cal-day-solar,
.cal-day.selected .cal-day-lunar {
  color: #fff;
}

/* ------------------------------ Lookup forms ------------------------------ */
#result-panel {
  scroll-margin-top: 16px;
}

.lookup-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

@media (max-width: 700px) {
  .lookup-section {
    grid-template-columns: 1fr;
  }
}

.lookup-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.lookup-card h2 {
  font-size: 1.05rem;
  margin: 0 0 12px;
}

.lookup-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

.field-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.field input[type="date"],
.field input[type="number"] {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 8px;
  font-size: 1rem;
  width: 100%;
  min-height: 44px;
}

.field-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.field-checkbox input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  min-height: 44px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-block {
  width: 100%;
}

.form-error {
  width: 100%;
  color: var(--color-primary);
  font-size: 0.85rem;
  margin-top: 6px;
}

/* ------------------------------ SEO content ------------------------------ */
.info-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 24px;
}

.info-section h2 {
  font-size: 1.2rem;
  margin-top: 0;
}

.info-section h3 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.info-section p {
  color: var(--color-text);
  margin-top: 0;
}

.faq-item {
  margin-bottom: 14px;
}

/* ------------------------------ Footer ------------------------------ */
footer {
  background: #2c2622;
  color: #cfc6ba;
  padding: 24px 0;
  font-size: 0.85rem;
  text-align: center;
}

footer a {
  color: #f0d98c;
}

/* ------------------------------ Mobile ------------------------------ */
@media (max-width: 600px) {
  :root {
    font-size: 15px;
  }

  .site-header {
    padding: 16px 0;
  }

  .site-header .container {
    justify-content: center;
    text-align: center;
  }

  .site-title {
    font-size: 1.25rem;
  }

  .site-tagline {
    font-size: 0.8rem;
  }

  main {
    padding: 16px 0 36px;
  }

  .today-banner,
  .calendar-section,
  .lookup-card,
  .info-section {
    padding: 14px 16px;
  }

  .today-banner {
    text-align: center;
  }

  .canchi-row {
    justify-content: center;
    gap: 10px 14px;
  }

  #detail-solar {
    font-size: 1.25rem;
  }

  .calendar-nav-buttons {
    max-width: none;
  }

  .nav-btn {
    padding: 8px 4px;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .cal-day .cal-day-lunar {
    font-size: 0.6rem;
  }
}

@media (max-width: 360px) {
  .nav-btn {
    font-size: 0.78rem;
    padding: 8px 2px;
  }

  .field-group {
    gap: 6px;
  }
}
