/* 羽宸紫微斗數 HTML5 RWD CSS 設計系統 */
:root {
  --ziwei-primary: #D4AF37;
  --ziwei-bg: #0F172A;
  --ziwei-card: #1E293B;
  --ziwei-card-border: rgba(212, 175, 55, 0.3);
  --ziwei-text: #F8FAFC;
  --ziwei-muted: #94A3B8;
  --ziwei-star-main: #FACC15;
  --ziwei-sihua-lu: #22C55E;
  --ziwei-sihua-quan: #3B82F6;
  --ziwei-sihua-ke: #A855F7;
  --ziwei-sihua-ji: #EF4444;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft JhengHei", sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--ziwei-bg);
  color: var(--ziwei-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--ziwei-primary);
  text-decoration: none;
}

header.site-header {
  background-color: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--ziwei-card-border);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ziwei-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.main-container {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
}

/* 4x4 紫微命盤 Grid 佈局 (標準 12 宮位) */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, minmax(140px, auto));
  gap: 8px;
  background-color: var(--ziwei-bg);
  border: 2px solid var(--ziwei-primary);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 2rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

/* 12 宮位 Card 樣式 */
.palace-card {
  background-color: var(--ziwei-card);
  border: 1px solid var(--ziwei-card-border);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  cursor: pointer;
  transition: all 0.25 ease;
}

.palace-card:hover {
  transform: scale(1.02);
  border-color: var(--ziwei-primary);
  background-color: #26354A;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.4);
}

/* 宮位頂部 (宮名與地支) */
.palace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.25rem;
  margin-bottom: 0.5rem;
}

.palace-name {
  font-weight: 700;
  color: var(--ziwei-primary);
  font-size: 1rem;
}

.dizhi-tag {
  font-size: 0.85rem;
  color: var(--ziwei-muted);
  font-weight: 600;
}

/* 星曜呈現列表 */
.stars-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.star-item {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sihua-tag {
  font-size: 0.75rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  color: #000;
  font-weight: 700;
}

.sihua-祿 { background: var(--ziwei-sihua-lu); }
.sihua-權 { background: var(--ziwei-sihua-quan); color: #FFF; }
.sihua-科 { background: var(--ziwei-sihua-ke); color: #FFF; }
.sihua-忌 { background: var(--ziwei-sihua-ji); color: #FFF; }

/* 中央命主資訊區塊 (佔據中庭 2x2 空間) */
.center-info-card {
  grid-column: 2 / 4;
  grid-row: 2 / 4;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 2px dashed var(--ziwei-primary);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.center-title {
  font-size: 1.6rem;
  color: var(--ziwei-primary);
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.center-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
  max-width: 320px;
  font-size: 0.95rem;
}

.info-item {
  background: rgba(0,0,0,0.3);
  padding: 0.5rem;
  border-radius: 6px;
}

/* 表單與控制項 */
.form-card {
  background-color: var(--ziwei-card);
  border: 1px solid var(--ziwei-card-border);
  border-radius: 12px;
  padding: 2rem;
  max-width: 600px;
  margin: 2rem auto;
}

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

.form-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.form-control, .form-select {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: #0F172A;
  border: 1px solid var(--ziwei-card-border);
  border-radius: 6px;
  color: var(--ziwei-text);
  font-size: 1rem;
}

.btn-gold {
  background: linear-gradient(135deg, #D4AF37 0%, #B59226 100%);
  color: #000;
  font-weight: 700;
  padding: 0.85rem 2rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.btn-gold:hover {
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.4);
}

/* Modal 彈窗 (點擊宮位展開詳細評語) */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

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

.modal-content {
  background-color: var(--ziwei-card);
  border: 2px solid var(--ziwei-primary);
  border-radius: 12px;
  padding: 2rem;
  max-width: 650px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

/* 響應式斷點 */
@media (max-width: 768px) {
  .chart-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }
  .center-info-card {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

/* ===== 排盤紀錄清單 ===== */
.record-empty {
  color: var(--ziwei-muted);
  font-size: 0.9rem;
  padding: 0.75rem 0;
}
.record-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem 1rem;
  border: 1px solid var(--ziwei-card-border);
  border-radius: 8px;
  margin-bottom: 0.6rem;
  background: rgba(255, 255, 255, 0.02);
}
.record-item:hover { border-color: var(--ziwei-primary); }
.record-main { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.record-name { color: var(--ziwei-text); font-weight: 700; font-size: 1.05rem; }
.record-meta { color: var(--ziwei-muted); font-size: 0.85rem; }
.record-note {
  color: var(--ziwei-primary);
  font-size: 0.82rem;
  background: rgba(255, 215, 0, 0.08);
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  align-self: flex-start;
}
.record-time { color: var(--ziwei-muted); font-size: 0.75rem; }
.record-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.record-btn {
  cursor: pointer;
  border: 1px solid var(--ziwei-card-border);
  background: #1E293B;
  color: var(--ziwei-text);
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.85rem;
}
.record-btn.load { color: var(--ziwei-primary); border-color: var(--ziwei-primary); }
.record-btn.del:hover { color: #F87171; border-color: #F87171; }
