/* 命盤圖表樣式（從主CSS拆分） */
  .chart-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 28px;
  }
  @media (min-width: 900px) {
    .chart-section { grid-template-columns: auto 1fr; }
    .chart-section .info-bar { grid-column: 1 / -1; }
  }

  .palace-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, auto);
    gap: 1px;
    background: var(--border);
    border: 2px solid var(--gold-light);
    border-radius: 6px;
    overflow: hidden;
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1;
  }
  .palace-cell {
    background: var(--card);
    padding: 7px 6px;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }
  .palace-cell.empty { background: var(--bg-soft); }
  .palace-cell .palace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 4px;
    flex-shrink: 0;
  }
  .palace-cell .palace-name {
    color: var(--gold);
    font-weight: 600;
    font-size: 12px;
  }
  .palace-cell .palace-ganzhi {
    color: var(--muted);
    font-size: 11px;
  }
  .palace-cell.body-palace .palace-name::after {
    content: "身";
    color: var(--jade);
    font-size: 9px;
    margin-left: 3px;
    border: 1px solid var(--jade);
    border-radius: 2px;
    padding: 0 3px;
    font-weight: 500;
  }
  .palace-cell.ming-palace { background: var(--ming-bg); }
  .palace-cell.selected {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: var(--ming-bg) !important;
  }

  .palace-cell.ming-palace .palace-name { color: var(--accent); }
  .stars-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 11px;
    overflow: hidden;
  }
  .star-row {
    display: flex;
    align-items: baseline;
    gap: 3px;
    line-height: 1.45;
  }
  .star-name { color: var(--ink); white-space: nowrap; }
  .star-name.major { color: var(--ink); font-weight: 600; }
  .star-name.minor { color: var(--ink-2); }
  .star-name.tough { color: var(--cinnabar); }
  .star-name.helper { color: var(--jade); }
  .star-name.adjective { color: var(--muted); font-size: 10px; }
  .star-name.lucun { color: var(--gold); }
  .star-name.tianma { color: var(--gold); }
  .star-name.flower { color: var(--cinnabar); }
  .star-brightness { font-size: 9px; color: var(--muted); }
  .star-mutagen { font-size: 10px; color: var(--accent); font-weight: 600; }
  .palace-footer {
    display: flex;
    justify-content: space-between;
    font-size: 9px;
    color: var(--faint);
    margin-top: 3px;
    flex-shrink: 0;
  }

  .detail-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 24px;
    box-shadow: 0 1px 4px rgba(58,46,34,0.04);
  }
  .detail-panel h3 {
    font-size: 17px;
    color: var(--ink);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-soft);
    letter-spacing: 2px;
  }
  /* ===== 合盤分頁籤與字體優化 ===== */
  .hp-tabbed { font-size: 14.5px; line-height: 1.8; }
  .hp-tabbed .hp-fly-item { font-size: 13.5px; padding: 9px 13px; }
  .hp-tabbed .hp-fly-chain { font-size: 12.5px; }
  .hp-tabbed .detail-section h4 { font-size: 15.5px; padding: 8px 12px; background: rgba(181,83,63,0.06); border-radius: 6px; }
  .hp-tabbed .hint-text { font-size: 13px; }
  .hp-tabbed .hp-info-bar { font-size: 13.5px; }
  .hp-tab-nav {
    display: flex; gap: 4px; margin: 14px 0 16px;
    overflow-x: auto; padding-bottom: 6px;
    border-bottom: 2px solid var(--border-soft);
    -webkit-overflow-scrolling: touch;
  }
  /* === 頂層大模式切換：個人盤 / 雙人合盤 === */
  .mode-switch { display:flex; gap:10px; margin:6px 0 2px; }
  .mode-btn { flex:1; padding:14px 8px; font-size:16px; font-weight:700; font-family:inherit;
    border:1.5px solid var(--accent-light); background:var(--card-2); color:var(--accent); border-radius:999px; cursor:pointer; }
  .mode-btn.active { background:var(--accent); color:#fff; }
  #result.mode-personal .tabs .tab[data-mode="h"] { display:none !important; }
  #result.mode-hepan .tabs { display:none !important; }
  #result.mode-hepan .tab-content:not(#tab-hepan) { display:none !important; }
  #result.mode-hepan #tab-hepan { display:block !important; }
  #result.mode-personal #tab-hepan { display:none !important; }
  .hp-tab-btn {
    flex-shrink: 0; padding: 9px 18px; border: 1px solid var(--border-soft);
    border-radius: 8px 8px 0 0; background: transparent;
    font-size: 14.5px; font-family: inherit; color: var(--ink-2);
    cursor: pointer; white-space: nowrap; margin-bottom: -2px;
    transition: background .15s, color .15s;
  }
  .hp-tab-btn.active {
    background: var(--accent); color: #fff; border-color: var(--accent);
    font-weight: 600;
  }
  .hp-tab-panel { display: none; }
  .hp-tab-panel.active { display: block; }
  /* 流年流月內部子分頁 */
  .hp-subnav {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin: 4px 0 14px; padding: 10px 12px;
    background: #faf4ea; border: 1px solid var(--border-soft); border-radius: 8px;
    position: sticky; top: 0; z-index: 5;
  }
  .hp-subnav-btns { display: flex; gap: 6px; flex-wrap: wrap; }
  .hp-sub-btn {
    padding: 10px 20px; border: 1.5px solid var(--accent); border-radius: 20px;
    background: #fff; font-size: 15px; font-weight: 600; font-family: inherit; color: var(--accent);
    cursor: pointer; white-space: nowrap; transition: background .15s, color .15s;
  }
  .hp-sub-btn.active {
    background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700;
    box-shadow: 0 2px 6px rgba(139,90,43,.35);
  }
  /* 單人盤飛星疊宮四層分頁籤 */
  .fh-layer-nav {
    display: flex; gap: 6px; margin: 6px 0 14px; flex-wrap: wrap;
  }
  .fh-layer-btn, .school-layer-btn {
    flex: 1 1 auto; min-width: 120px; padding: 10px 12px;
    border: 1px solid var(--border-soft); border-radius: 8px;
    background: var(--card-2, #faf5ee); font-size: 14px; font-family: inherit;
    color: var(--ink-2); cursor: pointer; white-space: nowrap; line-height:1.4;
    transition: background .15s, color .15s;
  }
  .fh-layer-btn.active, .school-layer-btn.active {
    background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600;
  }
  #tab-feihua .detail-section h4 { font-size: 15.5px; }
  #tab-feihua { font-size: 14.5px; line-height: 1.8; }
  .detail-section { margin-bottom: 20px; }
  .detail-section:last-child { margin-bottom: 0; }
  .detail-section h4 {
    font-size: 13px;
    color: var(--accent);
    margin-bottom: 10px;
    letter-spacing: 1px;
    font-weight: 600;
  }
  .detail-list { list-style: none; font-size: 13px; }
  .detail-list li {
    padding: 6px 0;
    border-bottom: 1px dashed var(--border-soft);
    display: flex;
    justify-content: space-between;
    gap: 12px;
  }
  .detail-list li:last-child { border-bottom: none; }
  .detail-list li span:first-child { color: var(--muted); flex-shrink: 0; }
  .detail-list li span:last-child { color: var(--ink); text-align: right; }

  .tabs {
    display: flex;
    gap: 0;
    margin-bottom: 22px;
    border-bottom: 2px solid var(--border-soft);
    flex-wrap: wrap;
  }
  .tab {
    padding: 12px 22px;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    letter-spacing: 2px;
    font-weight: 500;
  }
  .tab.active { color: var(--accent); border-bottom-color: var(--accent); }
  .tab:hover { color: var(--ink-2); }
  .tab-content { display: none; }
  .tab-content.active { display: block; }

  .horoscope-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }
  .horoscope-table th, .horoscope-table td {
    padding: 10px 12px;
    text-align: center;
    border: 1px solid var(--border-soft);
  }
  .horoscope-table th {
    background: var(--card-2);
    color: var(--ink-2);
    font-weight: 600;
    font-size: 12px;
  }
  .horoscope-table td { color: var(--ink); }
  .horoscope-table .age-range { color: var(--accent); font-weight: 600; }
  .horoscope-table .ming-row { background: rgba(160,82,45,0.05); }

  .selector-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
    flex-wrap: wrap;
  }
  .selector-row label { font-size: 14px; color: var(--ink-2); }
  .selector-row input, .selector-row select {
    padding: 8px 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--ink);
    font-size: 15px;
    font-family: inherit;
    min-height: 40px;
    box-sizing: border-box;
  }
  .selector-row input[type="number"] { width: 90px; text-align: center; }

  .export-box {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 18px;
    margin-bottom: 14px;
    max-height: 420px;
    overflow-y: auto;
    font-family: "Courier New", "Noto Serif TC", monospace;
    font-size: 13px;
    line-height: 1.85;
    color: var(--ink-2);
    white-space: pre-wrap;
    word-break: break-all;
  }
  .export-actions { display: flex; gap: 12px; align-items: center; }

  .hint-text {
    font-size: 12px;
    color: var(--muted);
    margin-top: 12px;
    line-height: 1.7;
  }

  footer {
    text-align: center;
    padding: 28px 0;
    margin-top: 44px;
    font-size: 12px;
    color: var(--faint);
    border-top: 1px solid var(--border-soft);
  }

  ::-webkit-scrollbar { width: 7px; height: 7px; }
  ::-webkit-scrollbar-track { background: var(--bg-soft); }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--faint); }

  @media (max-width: 600px) {
    header h1 { font-size: 24px; letter-spacing: 5px; }
    .input-panel { padding: 20px; }
    .palace-grid { max-width: 100%; }
    .palace-cell { padding: 5px 4px; }
    .star-name { font-size: 10px; }
    .star-name.adjective { font-size: 9px; }
    .palace-cell .palace-name { font-size: 11px; }
    .tab { padding: 10px 16px; font-size: 13px; }
    .detail-panel { padding: 18px; }
  }

