:root {
  --bg: #FBF7F0;
  --bg-card: #FFFFFF;
  --bg-warm: #FFF9F0;
  --text: #3B2C1E;
  --text-secondary: #7A6652;
  --text-muted: #A89880;
  --red: #C5303A;
  --red-dark: #9B2028;
  --red-light: #FFF0F0;
  --green: #2D6A4F;
  --green-light: #EDF7F0;
  --gold: #C8963E;
  --gold-light: #FFF8EC;
  --blue: #3B6FB6;
  --blue-dark: #2C5A9E;
  --blue-light: #EEF4FB;
  --border: #E8DFD0;
  --border-light: #F0EBE3;
  --shadow-sm: 0 1px 3px rgba(59, 44, 30, 0.04);
  --shadow: 0 2px 12px rgba(59, 44, 30, 0.06);
  --shadow-lg: 0 8px 30px rgba(59, 44, 30, 0.08);
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 16px;
  --font: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ===== Toolbar ===== */
#toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  gap: 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.toolbar-left .app-title {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--red) 0%, var(--gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 3px;
}

.toolbar-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

#datePicker, #cityInput {
  padding: 7px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  background: var(--bg-warm);
  color: var(--text);
  outline: none;
  transition: all 0.2s;
}

#datePicker:hover, #cityInput:hover {
  border-color: var(--text-muted);
}

#datePicker:focus, #cityInput:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(197, 48, 58, 0.08);
  background: #fff;
}

#cityInput { width: 130px; }

button {
  padding: 7px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text);
  transition: all 0.2s;
  letter-spacing: 0.5px;
}

button:hover {
  background: var(--red-light);
  border-color: var(--red);
  color: var(--red-dark);
}

button:active {
  transform: scale(0.96);
}

/* ===== Loading ===== */
#loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
}

.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border: 3px solid var(--border-light);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

#loading p {
  font-size: 14px;
  letter-spacing: 1px;
}

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

/* ===== Main Content ===== */
#content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#huangliPanel {
  flex: 55;
  padding: 24px 28px;
  overflow-y: auto;
}

#weatherPanel {
  flex: 45;
  padding: 24px 28px 24px 0;
  overflow-y: auto;
}

.panel-header {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--red);
  color: var(--red);
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== Huangli Core ===== */
.huangli-core {
  text-align: center;
  margin-bottom: 18px;
  padding: 20px 16px 14px;
  background: linear-gradient(180deg, var(--bg-warm) 0%, #fff 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  position: relative;
  overflow: hidden;
}

.huangli-core::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--red) 0%, var(--gold) 100%);
}

.lunar-date {
  font-size: 30px;
  font-weight: 800;
  color: var(--red);
  margin-bottom: 6px;
  letter-spacing: 2px;
}

.ganzhi {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.zodiac-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

#solarTerms {
  background: var(--red-light);
  color: var(--red);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

#festivals {
  margin-top: 10px;
}

.festival-tag {
  display: inline-block;
  background: var(--gold-light);
  color: var(--gold);
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin: 3px 4px;
  border: 1px solid rgba(200, 150, 62, 0.2);
}

/* Jieqi box */
#jieqiBox {
  text-align: center;
  margin-bottom: 14px;
  padding: 8px 12px;
  background: var(--bg-warm);
  border-radius: var(--radius);
  font-size: 12px;
  border: 1px solid var(--border-light);
}

#jieqiBox .label {
  color: var(--text-muted);
  margin-right: 8px;
  font-weight: 600;
  font-size: 11px;
}

/* Meta row */
.meta-row {
  text-align: center;
  margin-bottom: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

#chongDesc {
  color: var(--red);
  font-weight: 600;
  background: var(--red-light);
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px;
}

.meta-tag {
  background: var(--bg-warm);
  color: var(--text-secondary);
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-light);
}

/* ===== Actions: suit & taboo ===== */
.huangli-actions {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
}

.action-box {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: box-shadow 0.2s;
}

.action-box:hover {
  box-shadow: var(--shadow);
}

.action-box h3 {
  font-size: 15px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  letter-spacing: 2px;
}

.suit-box h3 { color: var(--green); }
.taboo-box h3 { color: var(--red); }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  transition: transform 0.15s;
}

.tag:hover {
  transform: translateY(-1px);
}

.suit-box .tag {
  background: var(--green-light);
  color: var(--green);
  border: 1px solid rgba(45, 106, 79, 0.12);
}

.taboo-box .tag {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid rgba(197, 48, 58, 0.1);
}

/* ===== Calendar ===== */
.calendar-section {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: 5px;
}

.calendar-header #calTitle {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  min-width: 60px;
  text-align: center;
}

.cal-nav {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-light);
  border-radius: 50%;
  background: var(--bg-warm);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  padding: 0;
  transition: all 0.15s;
  line-height: 1;
}

.cal-nav:hover {
  background: var(--red-light);
  border-color: var(--red);
  color: var(--red);
}

.cal-today {
  font-size: 9px !important;
  padding: 1px 6px !important;
  margin-left: 2px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  text-align: center;
}

.cal-day-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 0;
  margin-bottom: 0;
}

.cal-weekend { color: var(--red) !important; }

.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  transition: all 0.15s;
  position: relative;
  padding: 8px 2px;
  line-height: 1.3;
  overflow: hidden;
  min-height: 52px;
}

.cal-cell:hover {
  background: var(--bg-warm);
}

.cal-cell.today {
  background: #FFD6D6;
  color: var(--red-dark);
  font-weight: 700;
  box-shadow: none;
}
.cal-cell.today .lunar-day { color: var(--red); opacity:0.8; }

.cal-cell.selected {
  background: #FFE8E8;
  color: var(--red-dark);
  font-weight: 700;
  outline: 1px solid var(--red);
  outline-offset: -1px;
}
.cal-cell.selected .lunar-day { color: var(--red); opacity:0.7; }

.cal-cell.other-month {
  color: var(--text-muted);
  opacity: 0.3;
  cursor: default;
}

.cal-cell .lunar-day {
  font-size: 11px;
  margin-top: 2px;
  opacity: 0.6;
  white-space: nowrap;
  line-height: 1.2;
}

.cal-cell .festival-dot {
  font-size: 10px;
  color: #ff6b6b;
  display: block;
  line-height: 1.2;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.jieqi-dot {
  font-size: 10px;
  color: var(--red-dark);
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.2;
  margin-top: 1px;
  opacity: 0.85;
}

/* ===== Detail rows ===== */
.huangli-details {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.detail-row {
  display: flex;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light);
  align-items: baseline;
}

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

.detail-label {
  flex-shrink: 0;
  width: 85px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
}

/* ===== Weather Panel ===== */
.weather-current {
  background: linear-gradient(160deg, #4B8BDB 0%, #3A6FC4 50%, #2C5A9E 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  text-align: center;
  margin-bottom: 12px;
  box-shadow: 0 3px 14px rgba(59, 111, 182, 0.2);
  position: relative;
  overflow: hidden;
}

.weather-current::after {
  content: '';
  position: absolute;
  top: -60%;
  right: -40%;
  width: 120px;
  height: 120px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
}

.weather-placeholder {
  opacity: 0.8;
  font-size: 13px;
}

.weather-temp {
  font-size: 32px;
  font-weight: 300;
  line-height: 1;
  margin: 2px 0;
  letter-spacing: -1px;
}

.weather-temp sup {
  font-size: 14px;
  font-weight: 300;
}

.weather-desc {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.weather-meta {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-size: 11px;
  opacity: 0.9;
}

.source-badge {
  background: rgba(255,255,255,0.2);
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 1px;
}

.weather-icon {
  width: 60px;
  height: 60px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

/* ===== Forecast ===== */
.forecast-section { margin-top: 4px; }

.forecast-section h3 {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 1px;
}

.forecast-list {
  display: flex;
  gap: 6px;
}

.forecast-item {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 8px 4px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all 0.2s;
  font-size: 10px;
}

.forecast-item:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.forecast-item .day {
  font-weight: 700;
  margin-bottom: 3px;
  font-size: 13px;
}

.forecast-item .date-label {
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 6px;
}

.forecast-item img {
  width: 42px;
  height: 42px;
}

.forecast-item .temps {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
}

.forecast-item .hi { color: var(--red); font-weight: 600; }
.forecast-item .lo { color: var(--blue); font-weight: 600; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid var(--border-light);
  font-weight: 500;
}

.toast.error {
  background: #FFF5F5;
  color: var(--red-dark);
  border-color: rgba(197, 48, 58, 0.15);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(30, 20, 10, 0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: modalFade 0.2s;
}

@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 400px;
  box-shadow: var(--shadow-lg);
  animation: modalSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(-20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-content h2 {
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--red);
  font-weight: 700;
  letter-spacing: 1px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  background: var(--bg-warm);
  color: var(--text);
  outline: none;
  transition: all 0.2s;
}

.form-group input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(197, 48, 58, 0.08);
  background: #fff;
}

.form-group small {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.form-group a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}

.form-group a:hover {
  text-decoration: underline;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.btn-primary {
  background: var(--red) !important;
  color: #fff !important;
  border-color: var(--red) !important;
  font-weight: 600 !important;
}

.btn-primary:hover {
  background: var(--red-dark) !important;
  border-color: var(--red-dark) !important;
  color: #fff !important;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== Detail Tooltip ===== */
.detail-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
  cursor: help;
  position: relative;
  vertical-align: middle;
  line-height: 1;
}

.detail-tip:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  width: 200px;
  padding: 8px 10px;
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 50;
  pointer-events: none;
  white-space: normal;
}

.detail-tip:hover::before {
  content: '';
  position: absolute;
  left: 6px;
  bottom: calc(100% + 2px);
  border: 4px solid transparent;
  border-top-color: var(--text);
  z-index: 50;
  pointer-events: none;
}

/* ===== Glossary ===== */
.glossary-section{margin-top:16px;padding-top:12px;border-top:1px solid var(--border)}
.glossary-section .section-label{font-size:13px;font-weight:700;color:var(--text);margin-bottom:8px}
.glossary-box{background:var(--bg-warm);border-radius:8px;padding:10px 12px;min-height:40px;font-size:13px;color:var(--text-muted)}
.glossary-empty{font-size:12px;color:var(--text-muted);opacity:0.6;font-style:italic}
.glossary-item{display:flex;flex-direction:column;gap:2px}

/* ===== Clickable god names ===== */
.god-link{cursor:pointer;text-decoration:underline;text-decoration-style:dotted;text-underline-offset:3px;transition:all .15s}
.good-god:hover{color:var(--green);background:rgba(0,255,100,0.08);padding:1px 2px;border-radius:3px}
.bad-god:hover{color:var(--red);background:rgba(255,0,0,0.08);padding:1px 2px;border-radius:3px}

/* ===== Bazi ===== */
.bazi-section{margin-top:16px;padding-top:12px;border-top:1px solid var(--border)}
.bazi-section .section-label{font-size:13px;font-weight:700;color:var(--text);margin-bottom:8px}
.bazi-form{margin-bottom:8px}
.bazi-inputs{display:flex;gap:6px;flex-wrap:wrap}
.bazi-inputs select{flex:1;min-width:60px;padding:6px 4px;background:var(--bg);border:1px solid var(--border);border-radius:6px;font-size:12px;color:var(--text);font-family:inherit}
.bazi-calc-btn{flex:0 0 auto;padding:6px 16px;background:var(--red-dark);color:#fff;border:none;border-radius:6px;font-size:12px;font-weight:600;cursor:pointer;transition:all .15s}
.bazi-calc-btn:hover{background:var(--red);transform:translateY(-1px)}
.bazi-result{margin-top:10px;background:var(--bg-warm);border-radius:8px;padding:12px}
/* ===== Vertical Bazi Table ===== */
.bazi-vt-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;margin-bottom:8px}
.bazi-vt{width:100%;border-collapse:collapse;background:var(--bg-card);border-radius:8px;overflow:hidden}
.bazi-vt td,.bazi-vt .vt-label{padding:6px 8px;text-align:center;border-bottom:1px solid var(--border);vertical-align:middle;font-size:13px}
.bazi-vt .vt-label{background:rgba(197,48,58,0.06);color:var(--red-dark);font-weight:700;font-size:12px;white-space:nowrap;width:56px;letter-spacing:1px}
.bazi-vt .vt-big{font-size:20px;font-weight:700;font-family:'KaiTi','STKaiti',serif}
.bazi-vt .vt-small{font-size:11px}
.bazi-vt .vt-xs{font-size:10px;color:var(--text-muted)}
.bazi-vt .vt-wx{font-size:9px;margin-left:2px;color:var(--text-muted)}
.bazi-vt .vt-line{padding:1px 0;line-height:1.3}
.bazi-vt td:first-child{border-left:none}.bazi-vt td:last-child{border-right:none}
.bazi-dm{font-size:14px;text-align:center;margin-bottom:8px;padding:6px;background:var(--bg);border-radius:6px}
.bazi-wx{font-size:12px;text-align:center;color:var(--text-muted);margin-bottom:8px}
.bazi-readings p{font-size:13px;line-height:1.7;margin:4px 0;color:var(--text)}
.bazi-error{color:var(--red);font-size:13px;text-align:center;padding:12px}

/* ===== Selection ===== */
::selection {
  background: rgba(197, 48, 58, 0.12);
  color: var(--red-dark);
}
