/* ================================================================
   紫微斗數 · Zi Wei Dou Shu — Complete Stylesheet
   Dark theme with traditional Chinese aesthetic
   ================================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg: #0a0e1a;
  --bg-grad-start: #0d1220;
  --bg-grad-end: #0a0e1a;
  --palace-bg: #141929;
  --palace-bg-hover: #1a2138;
  --center-bg: #0f1424;
  --border: #2a3050;
  --border-light: #353d60;
  --gold: #c9a84c;
  --gold-bright: #e8c84c;
  --gold-dim: #8a7430;
  --text: #e8e0d0;
  --text-secondary: #8a8070;
  --text-dim: #5a5470;
  --text-faint: #4a4460;

  /* 四化 colors */
  --lu: #4caf50;       /* 祿 — green */
  --quan: #ffc107;     /* 權 — amber */
  --ke: #42a5f5;       /* 科 — blue */
  --ji: #ef5350;       /* 忌 — red */

  /* Brightness colors */
  --br-miao: #e8c84c;  /* 廟/旺 — gold */
  --br-de: #a0d468;    /* 得 — green */
  --br-ping: #90a4ae;  /* 平 — grey-blue */
  --br-xian: #e07050;  /* 陷/不 — red */

  /* Layout */
  --cell-min: 150px;
  --cell-min-mobile: 95px;
  --panel-width: 420px;
  --radius: 8px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei",
    "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  background: linear-gradient(180deg, var(--bg-grad-start), var(--bg-grad-end));
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ================================================================
   INPUT SECTION
   ================================================================ */
.input-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.input-container {
  width: 100%;
  max-width: 560px;
  background: var(--palace-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

.input-logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  justify-content: center;
}

.logo-symbol {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--gold-bright);
  background: linear-gradient(135deg, var(--gold), var(--gold-bright));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-text h1 {
  font-size: 1.5rem;
  color: var(--gold-bright);
  letter-spacing: 0.15em;
}

.logo-text p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

/* ---------- Form ---------- */
.chart-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  min-width: 120px;
}

.form-group.flex-2 { flex: 2; }

.form-group label {
  font-size: 0.85rem;
  color: var(--gold);
  font-weight: 600;
}

.label-en {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 400;
  margin-left: 0.3em;
}

input[type="text"],
input[type="date"],
select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201,168,76,0.15);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7) sepia(1) saturate(2) hue-rotate(10deg);
  cursor: pointer;
}

/* ---------- Toggle Buttons ---------- */
.toggle-group {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  flex: 1;
  padding: 0.55rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-btn:hover {
  color: var(--text);
  background: var(--palace-bg-hover);
}

.toggle-btn.active {
  background: var(--gold);
  color: var(--bg);
  font-weight: 600;
}

/* ---------- Submit Button ---------- */
.submit-btn {
  margin-top: 0.5rem;
  padding: 0.85rem 2rem;
  background: linear-gradient(135deg, var(--gold), var(--gold-bright));
  border: none;
  border-radius: 6px;
  color: var(--bg);
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  letter-spacing: 0.1em;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 16px rgba(201,168,76,0.25);
}

.submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(201,168,76,0.35);
}

.submit-btn:active { transform: translateY(0); }

.submit-en {
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.7;
}

/* ================================================================
   CHART SECTION
   ================================================================ */
.chart-section {
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-header-left {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.chart-title {
  font-size: 1.5rem;
  color: var(--gold-bright);
  letter-spacing: 0.1em;
}

.chart-name {
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 600;
}

.chart-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.layer-toggles {
  display: flex;
  background: var(--palace-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.layer-btn {
  padding: 0.45rem 1rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.layer-btn:hover {
  color: var(--text);
  background: var(--palace-bg-hover);
}

.layer-btn.active {
  background: var(--gold);
  color: var(--bg);
  font-weight: 600;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--palace-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition);
}

.icon-btn:hover {
  color: var(--gold-bright);
  border-color: var(--gold-dim);
}

/* ================================================================
   PALACE GRID — 4×4 with center 2×2
   ================================================================ */
.chart-wrapper {
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.palace-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(var(--cell-min), 1fr));
  grid-template-rows: repeat(4, minmax(var(--cell-min), auto));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-width: calc(var(--cell-min) * 4);
}

/* ---------- Palace Cell ---------- */
.palace-cell {
  background: var(--palace-bg);
  padding: 0.5rem 0.4rem;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  overflow: hidden;
  min-height: var(--cell-min);
}

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

.palace-cell.is-body {
  box-shadow: inset 0 0 0 2px var(--gold);
}

.palace-cell.is-origin::after {
  content: '來';
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 0.6rem;
  color: var(--gold-dim);
  background: rgba(201,168,76,0.12);
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
}

.palace-cell.is-decade-active {
  box-shadow: inset 0 0 0 2px var(--quan);
}

.palace-header {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.25rem;
  flex-wrap: wrap;
}

.palace-name {
  font-size: 0.82rem;
  color: var(--gold);
  font-weight: 600;
  white-space: nowrap;
}

.palace-name-en {
  font-size: 0.55rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.body-palace-mark {
  font-size: 0.55rem;
  color: var(--gold-bright);
  background: rgba(232,200,76,0.15);
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: auto;
}

.palace-stem-branch {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.palace-stars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.star-row {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  line-height: 1.35;
}

.star-row.major {
  font-size: 0.82rem;
  font-weight: 600;
}

.star-row.minor {
  font-size: 0.72rem;
}

.star-row.adj {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

.star-name {
  color: var(--text);
}

.star-name.major-star { color: var(--gold-bright); }

.star-brightness {
  font-size: 0.6rem;
  margin-left: 0.15rem;
}

.br-miao { color: var(--br-miao); }
.br-de   { color: var(--br-de); }
.br-ping { color: var(--br-ping); }
.br-xian { color: var(--br-xian); }

/* 四化 badge */
.mutagen-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  font-weight: 700;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-left: 0.2rem;
  color: #fff;
  line-height: 1;
}

.mb-lu   { background: var(--lu); }
.mb-quan { background: var(--quan); color: #000; }
.mb-ke   { background: var(--ke); }
.mb-ji   { background: var(--ji); }

/* Layer mutagen badges — larger, with glow, prefixed */
.mutagen-badge.mutagen-layer {
  width: auto;
  min-width: 22px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  font-size: 0.58rem;
  border: 1px solid rgba(255,255,255,0.3);
  animation: mutagenPulse 1.5s ease-in-out infinite;
}
.mutagen-layer.layer-decade {
  box-shadow: 0 0 6px rgba(255,200,80,0.6);
}
.mutagen-layer.layer-annual {
  box-shadow: 0 0 6px rgba(100,200,255,0.6);
}
@keyframes mutagenPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Active layer indicator on palace cells */
.palace-cell.layer-origin .palace-age::before { content: '🐑 '; font-size: 0.5rem; }
.palace-cell.layer-decade .palace-age::before { content: '🔢 '; font-size: 0.5rem; }
.palace-cell.layer-annual .palace-age::before { content: '📅 '; font-size: 0.5rem; }

/* Age / decade range at bottom of cell */
.palace-age {
  margin-top: auto;
  padding-top: 0.25rem;
  font-size: 0.6rem;
  color: var(--text-dim);
  border-top: 1px solid rgba(42,48,80,0.5);
}

/* ---------- Center Info (2×2) ---------- */
.center-info {
  grid-column: 2 / 4;
  grid-row: 2 / 4;
  background: var(--center-bg);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  position: relative;
}

.center-info::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  pointer-events: none;
}

.center-name {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.1em;
}

.center-dates {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.center-date-row {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  justify-content: center;
  font-size: 0.8rem;
}

.center-date-label {
  color: var(--gold-dim);
  font-size: 0.7rem;
  white-space: nowrap;
}

.center-date-val {
  color: var(--text);
}

.center-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.center-tag {
  font-size: 0.72rem;
  background: rgba(201,168,76,0.08);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  color: var(--text);
}

.center-tag strong {
  color: var(--gold-bright);
  margin-left: 0.3rem;
}

.center-soul-body {
  display: flex;
  gap: 1rem;
  font-size: 0.85rem;
}

.center-soul-body span {
  color: var(--gold-dim);
}

.center-soul-body strong {
  color: var(--gold-bright);
}

.center-bazi {
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-align: center;
  letter-spacing: 0.08em;
}

/* ================================================================
   LEGEND
   ================================================================ */
.legend {
  display: flex;
  gap: 2rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--palace-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.legend-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.legend-title {
  font-size: 0.75rem;
  color: var(--gold-dim);
}

.legend-item {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
}

.dot-lu   { background: var(--lu); }
.dot-quan { background: var(--quan); color: #000; }
.dot-ke   { background: var(--ke); }
.dot-ji   { background: var(--ji); }

/* ================================================================
   DETAIL PANEL
   ================================================================ */
.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
  opacity: 1;
  transition: opacity var(--transition);
}

.detail-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--panel-width);
  max-width: 100vw;
  height: 100vh;
  background: var(--bg-grad-start);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(0,0,0,0.4);
  z-index: 100;
  transform: translateX(0);
  transition: transform var(--transition);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-panel.hidden {
  transform: translateX(100%);
}

.detail-header {
  display: flex;
  justify-content: flex-end;
  padding: 0.75rem 1rem;
}

.detail-close {
  background: var(--palace-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition);
}

.detail-close:hover {
  color: var(--ji);
  border-color: var(--ji);
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 1.25rem 1.5rem;
}

/* Detail content sections */
.detail-title {
  font-size: 1.4rem;
  color: var(--gold-bright);
  margin-bottom: 0.15rem;
}

.detail-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.detail-section {
  margin-bottom: 1.5rem;
}

.detail-section-title {
  font-size: 0.8rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-bottom: 0.4rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.detail-star-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detail-star-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  background: var(--palace-bg);
  border-radius: 4px;
  font-size: 0.88rem;
}

.detail-star-item .star-type-label {
  font-size: 0.65rem;
  color: var(--text-faint);
  margin-left: auto;
}

.detail-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(42,48,80,0.4);
  font-size: 0.85rem;
}

.detail-info-label {
  color: var(--text-secondary);
}

.detail-info-value {
  color: var(--text);
  font-weight: 500;
}

.detail-flying {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.flying-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.5rem;
  background: var(--palace-bg);
  border-radius: 4px;
  border-left: 3px solid transparent;
}

.fi-lu   { border-left-color: var(--lu); }
.fi-quan { border-left-color: var(--quan); }
.fi-ke   { border-left-color: var(--ke); }
.fi-ji   { border-left-color: var(--ji); }

.flying-arrow {
  color: var(--text-dim);
  margin: 0 0.2rem;
}

/* ================================================================
   TOAST
   ================================================================ */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--palace-bg);
  border: 1px solid var(--ji);
  color: var(--text);
  padding: 0.7rem 1.5rem;
  border-radius: 6px;
  font-size: 0.85rem;
  z-index: 200;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
  :root {
    --cell-min: var(--cell-min-mobile);
    --panel-width: 100vw;
  }

  .chart-section {
    padding: 0.75rem;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .chart-header-right {
    width: 100%;
    justify-content: space-between;
  }

  .palace-cell {
    padding: 0.3rem 0.2rem;
    min-height: var(--cell-min-mobile);
  }

  .palace-name { font-size: 0.72rem; }
  .palace-stem-branch { font-size: 0.6rem; }
  .star-row.major { font-size: 0.72rem; }
  .star-row.minor { font-size: 0.62rem; }
  .star-row.adj { font-size: 0.55rem; }

  .center-info {
    padding: 0.6rem;
  }

  .center-name { font-size: 1.1rem; }
  .center-date-row { font-size: 0.7rem; }
  .center-tag { font-size: 0.6rem; padding: 0.15rem 0.4rem; }

  .detail-panel {
    width: 100vw;
  }

  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .input-container {
    padding: 1.5rem 1rem;
  }

  .legend {
    font-size: 0.7rem;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .palace-cell {
    padding: 0.25rem 0.15rem;
  }

  .palace-name { font-size: 0.65rem; }
  .star-row.major { font-size: 0.65rem; }
  .star-row.minor { font-size: 0.55rem; }
  .star-row.adj { display: none; }
  .palace-name-en { display: none; }
  .palace-age { font-size: 0.5rem; }
  .center-bazi { font-size: 0.65rem; }
}

/* ================================================================
   CHART SUMMARY
   ================================================================ */
.chart-summary {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--palace-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chart-summary.hidden {
  display: none !important;
}

.summary-block {
  padding: 0.75rem 0.9rem;
  background: rgba(201, 168, 76, 0.05);
  border-left: 3px solid var(--gold-dim);
  border-radius: 0 4px 4px 0;
}

.summary-block-title {
  font-size: 0.85rem;
  color: var(--gold-bright);
  font-weight: 600;
  margin-bottom: 0.4rem;
  letter-spacing: 0.05em;
}

.summary-block-body {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
}

.summary-note {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}

/* ================================================================
   DETAIL INTERPRETATION SECTION
   ================================================================ */
.interpretation-section {
  background: rgba(201, 168, 76, 0.05);
  border-radius: 6px;
  padding: 0.85rem 0.9rem !important;
  margin-top: 0.5rem;
}

.interp-palace-intro {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(42, 48, 80, 0.5);
}

.interp-subtitle {
  font-size: 0.78rem;
  color: var(--gold-bright);
  font-weight: 600;
  margin: 0.6rem 0 0.4rem;
  letter-spacing: 0.05em;
}

.interp-star-card {
  background: var(--palace-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
}

.interp-star-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(42, 48, 80, 0.4);
}

.interp-star-name {
  font-size: 0.9rem;
  color: var(--gold-bright);
  font-weight: 600;
}

.interp-star-brightness {
  font-size: 0.65rem;
  color: var(--gold-dim);
  background: rgba(201, 168, 76, 0.1);
  padding: 1px 5px;
  border-radius: 3px;
}

.interp-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.2rem 0;
  font-size: 0.82rem;
  line-height: 1.5;
}

.interp-label {
  color: var(--gold);
  font-weight: 600;
  flex-shrink: 0;
  min-width: 2.5em;
}

.interp-value {
  color: var(--text);
  flex: 1;
}

.interp-sihua-item {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.4rem 0.5rem;
  background: var(--palace-bg);
  border-radius: 4px;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  line-height: 1.5;
}

.interp-sihua-text {
  color: var(--text);
}

/* ---------- Summary & Interpretation: Mobile ---------- */
@media (max-width: 768px) {
  .chart-summary {
    margin-top: 1rem;
    padding: 0.85rem;
  }

  .summary-block {
    padding: 0.6rem 0.7rem;
  }

  .summary-block-title {
    font-size: 0.8rem;
  }

  .summary-block-body {
    font-size: 0.8rem;
    line-height: 1.55;
  }

  .interp-star-card {
    padding: 0.5rem 0.6rem;
  }

  .interp-star-name {
    font-size: 0.85rem;
  }

  .interp-row {
    font-size: 0.78rem;
  }

  .interp-sihua-item {
    font-size: 0.76rem;
  }
}

@media (max-width: 480px) {
  .summary-block-body {
    font-size: 0.75rem;
  }

  .interp-row {
    font-size: 0.74rem;
  }

  .interp-star-name {
    font-size: 0.8rem;
  }
}

/* ---------- Print: Summary ---------- */
@media print {
  .chart-summary {
    background: #f9f9f9 !important;
    border-color: #ccc !important;
    break-inside: avoid;
  }

  .summary-block {
    background: #f5f5f5 !important;
    border-left-color: #999 !important;
  }

  .summary-block-title {
    color: #333 !important;
  }

  .summary-block-body {
    color: #000 !important;
  }

  .summary-note {
    color: #999 !important;
  }

  .interpretation-section {
    background: #f9f9f9 !important;
  }

  .interp-star-card {
    background: #fff !important;
    border-color: #ccc !important;
  }

  .interp-star-name,
  .interp-subtitle {
    color: #333 !important;
  }

  .interp-value {
    color: #000 !important;
  }
}

/* ================================================================
   PRINT
   ================================================================ */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }

  .chart-section { padding: 0; }
  .chart-header, .legend { break-inside: avoid; }
  .chart-header-right .icon-btn,
  .layer-toggles { display: none !important; }

  .palace-grid {
    border-color: #ccc !important;
    background: #ccc !important;
  }

  .palace-cell {
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
  }

  .palace-cell.is-body {
    box-shadow: inset 0 0 0 2px #333 !important;
  }

  .palace-name, .chart-title, .center-name {
    color: #000 !important;
  }

  .star-name { color: #000 !important; }
  .star-name.major-star { color: #333 !important; }

  .center-info {
    background: #f9f9f9 !important;
  }

  .center-info::before {
    border-color: #ccc !important;
  }

  .palace-stem-branch,
  .palace-age {
    color: #666 !important;
  }

  .detail-panel,
  .detail-overlay,
  .toast {
    display: none !important;
  }

  .hidden { display: block !important; }
  #inputSection { display: none !important; }
}
