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

body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

body::-webkit-scrollbar-track {
  background: var(--scroll-track);
}

body::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

body::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  background-clip: padding-box;
}

.table-scroll,
.chart-wrap,
.days-table .col-ji,
.days-table .col-yi {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

.table-scroll::-webkit-scrollbar,
.chart-wrap::-webkit-scrollbar,
.days-table .col-ji::-webkit-scrollbar,
.days-table .col-yi::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.table-scroll::-webkit-scrollbar-track,
.chart-wrap::-webkit-scrollbar-track,
.days-table .col-ji::-webkit-scrollbar-track,
.days-table .col-yi::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 3px;
}

.table-scroll::-webkit-scrollbar-thumb,
.chart-wrap::-webkit-scrollbar-thumb,
.days-table .col-ji::-webkit-scrollbar-thumb,
.days-table .col-yi::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 3px;
}

.table-scroll::-webkit-scrollbar-thumb:hover,
.chart-wrap::-webkit-scrollbar-thumb:hover,
.days-table .col-ji::-webkit-scrollbar-thumb:hover,
.days-table .col-yi::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(6.5rem, 1fr) auto minmax(6.5rem, 1fr);
  align-items: center;
  column-gap: 0.75rem;
  padding: 0.85rem 1.35rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  position: relative;
  z-index: 2;
}

.top-bar .link-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  height: 2rem;
  padding: 0 0.75rem 0 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb, 47, 111, 237), 0.32);
  background: #fff;
  color: var(--accent, var(--cyan, #2f6fed));
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.top-bar .link-back-arrow {
  font-size: 0.95rem;
  line-height: 1;
}

.top-bar .link-back:hover {
  border-color: rgba(var(--accent-rgb, 47, 111, 237), 0.5);
  background: #fff7f6;
}

.logo {
  justify-self: center;
  text-align: center;
  min-width: 0;
}

.logo-glow {
  display: inline-flex;
  align-items: center;
  height: 2rem;
  padding: 0 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(var(--accent-rgb, 196, 30, 58), 0.32);
  background: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: none;
  line-height: 1;
  white-space: nowrap;
}

.logo-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.18em;
  margin-top: 0.12rem;
}

.top-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.link-ref-book,
.link-swagger {
  display: inline-flex;
  align-items: center;
  height: 2rem;
  padding: 0 0.85rem;
  border-radius: 999px;
  color: var(--cyan);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.link-ref-book:hover,
.link-swagger:hover { box-shadow: var(--glow); }

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem 1.25rem 2rem;
  max-width: 100%;
  margin: 0 auto;
  align-items: start;
}

.form-column {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.form-panel {
  align-self: stretch;
}

.result-panel {
  min-height: 400px;
  min-width: 0;
}

@media (min-width: 901px) {
  .layout {
    padding: 1rem 1.5rem 2rem;
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  }

  .form-column {
    position: sticky;
    top: 0.75rem;
  }

  .form-panel {
    position: static;
  }

  .table-scroll-hint {
    display: block;
    font-size: 0.72rem;
    color: var(--muted);
    text-align: right;
    padding: 0.35rem 0.65rem;
    margin: 0;
    border-bottom: 1px solid var(--border);
  }

  .table-scroll {
    overflow-x: auto;
    max-width: 100%;
  }

  .days-table {
    width: max-content;
    min-width: 1420px;
    table-layout: auto;
  }

  .days-table th,
  .days-table td {
    word-break: keep-all;
    overflow-wrap: anywhere;
    box-sizing: border-box;
    border-right: 1px solid var(--border);
    text-align: center;
    vertical-align: middle;
  }

  .days-table th:last-child,
  .days-table td:last-child {
    border-right: none;
  }

  .days-table th {
    white-space: nowrap;
  }

  .days-table .col-ji,
  .days-table .col-yi,
  .days-table .col-rikeji,
  .days-table .col-zhan-gong,
  .days-table .col-day-pillar {
    text-align: center;
  }

  .days-table .col-day-pillar {
    min-width: 7rem;
    max-width: 13rem;
    color: var(--cyan);
    white-space: normal;
    line-height: 1.45;
  }

  .days-table .col-rikeji {
    min-width: 10rem;
    max-width: 17rem;
  }

  .days-table .col-lunar {
    min-width: 10.5em;
    white-space: nowrap;
  }

  .days-table .col-ji,
  .days-table .col-yi {
    min-width: 9.5em;
    max-width: 15em;
    white-space: normal;
    line-height: 1.5;
    max-height: 5.5em;
    overflow-y: auto;
  }

  .days-table .col-zhan-gong {
    min-width: 9rem;
    max-width: 14rem;
  }

  .days-table .col-guiren {
    min-width: 7em;
    white-space: normal;
    max-width: 10em;
  }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.panel h2 {
  font-size: 0.95rem;
  color: var(--cyan);
  letter-spacing: 0.15em;
  margin-bottom: 1rem;
  font-weight: 600;
}

.field-row {
  margin-bottom: 0.75rem;
}
.field-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.field-row label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.field-row input {
  width: 100%;
  padding: 0.5rem 0.65rem;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.95rem;
}
.field-row input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 90, 158, 111), 0.15);
}

.field-block { margin: 1rem 0; }

.field-label-row .field-label {
  color: var(--muted);
}

.birth-pick-row > label {
  color: var(--muted);
}

.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--text);
}

.radio-label input {
  accent-color: var(--cyan);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn {
  padding: 0.55rem 1rem;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-1px); }

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2, #6db384));
  color: #fff;
  font-weight: 600;
  flex: 1;
  min-width: 140px;
}
.btn.primary:hover:not(:disabled) { box-shadow: 0 2px 12px rgba(var(--accent-rgb, 90, 158, 111), 0.35); }

.btn.secondary {
  background: transparent;
  border-color: var(--gold);
  color: var(--gold);
  width: 100%;
  margin-top: 0.5rem;
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.summary-bar {
  padding: 0.75rem 1rem;
  background: rgba(var(--accent-rgb, 90, 158, 111), 0.08);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  line-height: 1.6;
}

.good-days-wrap {
  margin-bottom: 1rem;
}

.section-title {
  font-size: 0.9rem;
  color: var(--title);
  letter-spacing: 0.12em;
  margin-bottom: 0.65rem;
  font-weight: 600;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-alt);
}

.days-table {
  width: max-content;
  min-width: 1180px;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.days-table th,
.days-table td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  box-sizing: border-box;
}

.days-table th {
  background: rgba(var(--accent-rgb, 90, 158, 111), 0.12);
  color: var(--accent-dark);
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.days-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.jiaqu-ai-btn {
  position: absolute;
  top: 0.35rem;
  right: 0.4rem;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.68rem 0.22rem 0.52rem;
  border: 1px solid rgba(201, 162, 39, 0.48);
  border-radius: 999px;
  background:
    linear-gradient(145deg, #fffdf9 0%, #ffe9e4 42%, #fff3cf 100%);
  color: var(--accent-dark, #9e1830);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.35;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    0 2px 10px rgba(var(--accent-rgb, 196, 30, 58), 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  touch-action: manipulation;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    border-color 0.22s ease,
    color 0.22s ease,
    background 0.22s ease;
  animation: jiaqu-ai-breathe 2.8s ease-in-out infinite;
}

.jiaqu-ai-btn::before {
  content: "";
  width: 0.52rem;
  height: 0.52rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(from 20deg, #c9a227, #c41e3a, #f0c36a, #c9a227);
  box-shadow: 0 0 7px rgba(201, 162, 39, 0.75);
  animation: jiaqu-ai-spark 2s linear infinite;
}

.jiaqu-ai-btn::after {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(255, 255, 255, 0.65) 48%,
    transparent 66%
  );
  transform: translateX(-130%);
  animation: jiaqu-ai-shine 3.8s ease-in-out infinite;
  pointer-events: none;
}

.jiaqu-ai-btn:hover,
.jiaqu-ai-btn:focus {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent, #c41e3a), #d4a017 55%, var(--accent-2, #e04555));
  box-shadow:
    0 4px 16px rgba(var(--accent-rgb, 196, 30, 58), 0.32),
    0 0 18px rgba(201, 162, 39, 0.35);
  transform: translateY(-1px) scale(1.05);
  outline: none;
  animation: none;
}

.jiaqu-ai-btn:hover::before,
.jiaqu-ai-btn:focus::before {
  box-shadow: 0 0 8px rgba(255, 240, 180, 0.95);
}

.jiaqu-ai-btn:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 1px 6px rgba(var(--accent-rgb, 196, 30, 58), 0.22);
}

@keyframes jiaqu-ai-breathe {
  0%, 100% {
    box-shadow:
      0 2px 8px rgba(var(--accent-rgb, 196, 30, 58), 0.12),
      inset 0 1px 0 rgba(255, 255, 255, 0.9),
      0 0 0 0 rgba(201, 162, 39, 0.15);
  }
  50% {
    box-shadow:
      0 3px 14px rgba(var(--accent-rgb, 196, 30, 58), 0.22),
      inset 0 1px 0 rgba(255, 255, 255, 0.95),
      0 0 12px 1px rgba(201, 162, 39, 0.28);
  }
}

@keyframes jiaqu-ai-shine {
  0%, 58% { transform: translateX(-130%); }
  78%, 100% { transform: translateX(130%); }
}

@keyframes jiaqu-ai-spark {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .jiaqu-ai-btn,
  .jiaqu-ai-btn::before,
  .jiaqu-ai-btn::after {
    animation: none;
  }
  .jiaqu-ai-btn:hover,
  .jiaqu-ai-btn:focus {
    transform: none;
  }
}

.days-table tbody tr.day-card-row > .col-date {
  padding-right: 4.6rem;
}

.days-table tbody tr:hover {
  background: rgba(var(--accent-rgb, 90, 158, 111), 0.08);
}

.days-table tbody tr.selected {
  background: rgba(var(--accent-rgb, 90, 158, 111), 0.1);
  outline: 1px solid rgba(var(--accent-rgb, 90, 158, 111), 0.35);
}

.days-table .col-date { color: var(--title); font-weight: 600; white-space: nowrap; }
.days-table .col-pillar { color: var(--accent-dark); white-space: nowrap; font-weight: 500; }
.days-table .col-day-pillar {
  min-width: 6.5rem;
  max-width: 13rem;
  color: var(--accent-dark);
  white-space: normal;
  word-break: break-all;
  overflow-wrap: anywhere;
  line-height: 1.45;
  font-weight: 500;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.days-table .col-day-pillar.col-pillar {
  white-space: normal;
}
.days-table .col-rikeji {
  color: #b45309;
  text-shadow: none;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.45;
  white-space: normal;
  word-break: break-all;
  overflow-wrap: anywhere;
  min-width: 9rem;
  max-width: 16rem;
  position: relative;
  z-index: 0;
}
.days-table .col-zhan-gong {
  color: #9a6700;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: normal;
  min-width: 9rem;
  max-width: 13rem;
}
.days-table .col-taiyang,
.days-table .col-qilin,
.days-table .col-guiren {
  color: #2b6cb0;
  font-size: 0.82rem;
  white-space: nowrap;
  font-weight: 500;
}
.days-table .col-shishen {
  color: #c05621;
  font-size: 0.78rem;
  white-space: nowrap;
  font-weight: 600;
}
.days-table .col-lunar {
  color: var(--text);
  min-width: 9.5em;
  white-space: nowrap;
}
.days-table .col-sanzhu {
  color: var(--accent-dark);
  font-size: 0.82rem;
  white-space: nowrap;
  font-weight: 500;
  min-width: 8.5em;
}
.days-table .col-ji {
  color: #2e7d4a;
  line-height: 1.45;
  min-width: 8em;
  max-width: 14em;
  white-space: normal;
}
.days-table .col-yi {
  color: #4a6fa5;
  line-height: 1.45;
  min-width: 8em;
  max-width: 14em;
  white-space: normal;
}
.days-table .col-level {
  color: var(--title);
  white-space: nowrap;
}

@media (min-width: 901px) {
  .days-table th,
  .days-table td {
    text-align: center;
    vertical-align: middle;
  }
}

.good-days {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.day-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.day-card:hover {
  border-color: var(--cyan);
  background: rgba(var(--accent-rgb, 90, 158, 111), 0.1);
}
.day-card .date { font-weight: 600; color: var(--gold); white-space: nowrap; }
.day-card .gz { color: var(--cyan); font-size: 0.85rem; }
.day-card .level {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  background: rgba(240, 192, 96, 0.15);
  color: var(--gold);
}

.chart-wrap {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #1a0808;
}
.chart-wrap img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

.empty-hint {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-hint .muted { font-size: 0.85rem; margin-top: 0.5rem; }

.day-detail {
  margin: 0 0 1rem;
  padding: 0.95rem 1rem;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.65;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.day-detail.ok { border-color: rgba(var(--accent-rgb, 90, 158, 111), 0.55); }
.day-detail.bad { border-color: rgba(214, 69, 69, 0.55); }
.day-detail h3 { font-size: 0.95rem; margin-bottom: 0.55rem; color: var(--text); }
.day-detail p { margin: 0.35rem 0; }
.day-detail p strong { color: var(--accent-dark); }
.day-detail .tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  margin: 0.15rem 0.25rem 0.15rem 0;
  border-radius: 3px;
  font-size: 0.75rem;
  background: rgba(214, 69, 69, 0.12);
  color: #c53030;
}
.day-detail .tag.good {
  background: rgba(var(--accent-rgb, 90, 158, 111), 0.15);
  color: var(--accent-dark);
}
.day-detail .tag.caution {
  background: rgba(180, 83, 9, 0.12);
  color: #b45309;
}
td.col-caution {
  color: #b45309;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.45;
  white-space: normal;
}

.hidden { display: none !important; }

/* —— 科幻择日加载动画 —— */
.loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.loader-backdrop {
  position: absolute;
  inset: 0;
  background: var(--bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.loader-core {
  position: relative;
  z-index: 1;
  width: 220px;
  height: 220px;
  margin-bottom: 1.5rem;
}

.orbit {
  position: absolute;
  inset: 0;
  animation: spin 12s linear infinite;
}
.orbit-inner {
  inset: 28px;
  animation-direction: reverse;
  animation-duration: 18s;
}

.orbit .stem,
.orbit .branch {
  position: absolute;
  left: 50%;
  top: 0;
  transform-origin: 50% 110px;
  font-size: 0.85rem;
  color: var(--cyan);
  text-shadow: none;
  width: 1.2em;
  margin-left: -0.6em;
  text-align: center;
}
.orbit-inner .branch {
  transform-origin: 50% 82px;
  color: var(--gold);
  text-shadow: none;
  font-size: 0.8rem;
}

.orbit .stem:nth-child(1) { transform: rotate(0deg); }
.orbit .stem:nth-child(2) { transform: rotate(36deg); }
.orbit .stem:nth-child(3) { transform: rotate(72deg); }
.orbit .stem:nth-child(4) { transform: rotate(108deg); }
.orbit .stem:nth-child(5) { transform: rotate(144deg); }
.orbit .stem:nth-child(6) { transform: rotate(180deg); }
.orbit .stem:nth-child(7) { transform: rotate(216deg); }
.orbit .stem:nth-child(8) { transform: rotate(252deg); }
.orbit .stem:nth-child(9) { transform: rotate(288deg); }
.orbit .stem:nth-child(10) { transform: rotate(324deg); }

.orbit-inner .branch:nth-child(1) { transform: rotate(0deg); }
.orbit-inner .branch:nth-child(2) { transform: rotate(30deg); }
.orbit-inner .branch:nth-child(3) { transform: rotate(60deg); }
.orbit-inner .branch:nth-child(4) { transform: rotate(90deg); }
.orbit-inner .branch:nth-child(5) { transform: rotate(120deg); }
.orbit-inner .branch:nth-child(6) { transform: rotate(150deg); }
.orbit-inner .branch:nth-child(7) { transform: rotate(180deg); }
.orbit-inner .branch:nth-child(8) { transform: rotate(210deg); }
.orbit-inner .branch:nth-child(9) { transform: rotate(240deg); }
.orbit-inner .branch:nth-child(10) { transform: rotate(270deg); }
.orbit-inner .branch:nth-child(11) { transform: rotate(300deg); }
.orbit-inner .branch:nth-child(12) { transform: rotate(330deg); }

.loader-center {
  position: absolute;
  inset: 55px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bagua-ring {
  position: absolute;
  inset: 0;
  border: 2px dashed rgba(var(--accent-rgb, 90, 158, 111), 0.35);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
.bagua-ring::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(139, 105, 20, 0.25);
  border-radius: 50%;
}

.loader-icon {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: none;
  animation: glow 1.5s ease-in-out infinite alternate;
  z-index: 1;
}

.scan-line {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: none;
  animation: scan 2.2s ease-in-out infinite;
  top: 50%;
}

.loader-title {
  position: relative;
  z-index: 1;
  font-size: 1.1rem;
  letter-spacing: 0.35em;
  color: var(--cyan);
  margin-bottom: 0.5rem;
}

.loader-status {
  position: relative;
  z-index: 1;
  font-size: 0.85rem;
  color: var(--muted);
  height: 1.4em;
  min-height: 1.4em;
  text-align: center;
  padding: 0 1rem;
  max-width: min(520px, 92vw);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loader-percent {
  position: relative;
  z-index: 1;
  margin-top: 0.35rem;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--gold);
  text-shadow: none;
}

.loader-progress {
  position: relative;
  z-index: 1;
  width: min(320px, 80vw);
  height: 3px;
  background: rgba(var(--accent-rgb, 90, 158, 111), 0.15);
  border-radius: 2px;
  margin-top: 1rem;
  overflow: hidden;
}
.loader-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--title));
  border-radius: 2px;
  transition: width 0.4s ease;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.65rem 1.25rem;
  background: rgba(180, 40, 40, 0.95);
  border: 1px solid #ff6666;
  border-radius: 6px;
  font-size: 0.88rem;
  z-index: 10000;
  max-width: 90vw;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}
@keyframes glow {
  from { text-shadow: none; }
  to { text-shadow: 0 0 28px rgba(240, 192, 96, 1); }
}
@keyframes scan {
  0%, 100% { top: 15%; opacity: 0.3; }
  50% { top: 85%; opacity: 1; }
}

/* —— 参考书籍弹层 —— */
.ref-book-modal {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.ref-book-modal.hidden { display: none; }

.ref-book-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 18, 0.88);
  backdrop-filter: blur(6px);
}

.ref-book-dialog {
  position: relative;
  width: min(520px, 100%);
  max-height: min(92vh, 860px);
  animation: refBookIn 0.35s ease;
}

@keyframes refBookIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ref-book-close {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  z-index: 2;
  width: 2rem;
  height: 2rem;
  border: 1px solid rgba(240, 192, 96, 0.55);
  border-radius: 50%;
  background: rgba(12, 22, 40, 0.95);
  color: var(--gold);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.ref-book-close:hover { box-shadow: 0 0 14px rgba(240, 192, 96, 0.45); }

.ref-book-page {
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(240, 192, 96, 0.65);
  border-radius: 10px;
  padding: 1.5rem 1.35rem 1.25rem;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(240, 192, 96, 0.12), transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(0, 212, 255, 0.08), transparent 50%),
    linear-gradient(165deg, #1a1208 0%, #2a1f10 18%, #1e160c 50%, #120e08 100%);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4) inset,
    0 0 40px rgba(240, 192, 96, 0.15),
    0 20px 50px rgba(0, 0, 0, 0.55);
}

.ref-book-ornament {
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(240, 192, 96, 0.75);
  border-style: solid;
  pointer-events: none;
}
.ref-book-ornament-tl { top: 10px; left: 10px; border-width: 2px 0 0 2px; }
.ref-book-ornament-tr { top: 10px; right: 10px; border-width: 2px 2px 0 0; }
.ref-book-ornament-bl { bottom: 10px; left: 10px; border-width: 0 0 2px 2px; }
.ref-book-ornament-br { bottom: 10px; right: 10px; border-width: 0 2px 2px 0; }

.ref-book-header {
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(240, 192, 96, 0.35);
}

.ref-book-seal {
  display: inline-block;
  margin-bottom: 0.5rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  letter-spacing: 0.35em;
  color: #2a1a08;
  background: linear-gradient(135deg, #e8c878, #c89840);
  border: 1px solid rgba(255, 230, 160, 0.6);
  border-radius: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.ref-book-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #f5d88a;
  letter-spacing: 0.12em;
  text-shadow: 0 0 16px rgba(240, 192, 96, 0.35);
  margin: 0;
}

.ref-book-subtitle {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: rgba(232, 210, 160, 0.65);
  letter-spacing: 0.25em;
}

.ref-book-body {
  max-height: min(62vh, 560px);
  overflow-y: auto;
  padding: 0.25rem 0.15rem;
  text-align: center;
  scrollbar-width: thin;
  scrollbar-color: rgba(240, 192, 96, 0.45) var(--scroll-track);
}

.ref-book-body::-webkit-scrollbar {
  width: 6px;
}

.ref-book-body::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 3px;
}

.ref-book-body::-webkit-scrollbar-thumb {
  background: rgba(240, 192, 96, 0.45);
  border-radius: 3px;
}

.ref-book-body::-webkit-scrollbar-thumb:hover {
  background: rgba(240, 192, 96, 0.65);
}

.ref-book-body p {
  margin: 0;
  padding: 0.38rem 0.5rem;
  font-size: 0.92rem;
  line-height: 1.75;
  color: #f0e4c8;
  letter-spacing: 0.06em;
  text-align: center;
  transition: background 0.2s;
}
.ref-book-body p:nth-child(odd) {
  background: rgba(0, 0, 0, 0.12);
}
.ref-book-body p:hover {
  background: rgba(240, 192, 96, 0.06);
}

.ref-book-footer {
  margin-top: 0.85rem;
  padding-top: 0.65rem;
  text-align: center;
  font-size: 0.72rem;
  color: rgba(232, 210, 160, 0.5);
  letter-spacing: 0.3em;
  border-top: 1px solid rgba(240, 192, 96, 0.25);
}

/* —— 手机端适配 —— */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.table-scroll-hint {
  display: none;
}

@media (max-width: 768px) {
  .top-bar {
    grid-template-columns: auto 1fr auto;
    padding: 0.6rem 0.75rem;
    column-gap: 0.45rem;
  }

  .top-bar .link-back {
    height: 1.85rem;
    padding: 0 0.55rem 0 0.4rem;
    font-size: 0.72rem;
  }

  .logo-glow {
    font-size: 1.02rem;
  }

  .logo-sub {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
  }

  .link-ref-book,
  .link-swagger {
    height: 1.85rem;
    font-size: 0.72rem;
    padding: 0 0.6rem;
  }

  .layout {
    padding: 0.65rem 0.75rem 1.25rem;
    gap: 0.65rem;
  }

  .panel {
    padding: 0.85rem;
    border-radius: 6px;
  }

  .field-card {
    padding: 1rem 0.9rem 0.95rem;
    border-radius: 14px;
  }

  .panel h2 {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
  }

  .field-row {
    margin-bottom: 0.55rem;
  }

  .field-row.two-col {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }

  .field-row label {
    font-size: 0.72rem;
  }

  .field-row input {
    padding: 0.45rem 0.55rem;
    font-size: 16px;
  }

  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
  }

  .btn.primary {
    min-width: 0;
  }

  .summary-bar {
    padding: 0.55rem 0.65rem;
    font-size: 0.78rem;
  }

  .section-title {
    font-size: 0.82rem;
  }

  .result-panel {
    min-height: 240px;
  }

  .empty-hint {
    padding: 1.75rem 0.75rem;
    font-size: 0.85rem;
  }

  .day-detail {
    font-size: 0.78rem;
  }

  .chart-wrap {
    overflow: hidden;
    margin-top: 0.5rem;
  }

  .chart-wrap img {
    width: 100%;
    max-width: 100%;
    height: auto;
  }

  .hide-mobile {
    display: none !important;
  }

  .table-scroll-hint {
    display: block;
    font-size: 0.68rem;
    color: var(--muted);
    text-align: center;
    padding: 0.35rem 0.5rem;
    margin: 0;
    border-bottom: 1px solid var(--border);
  }

  .table-scroll {
    -webkit-overflow-scrolling: touch;
    border: none;
    background: transparent;
  }

  .days-table {
    min-width: 0;
    font-size: 0.78rem;
  }

  .days-table thead {
    display: none;
  }

  .days-table,
  .days-table tbody,
  .days-table tr,
  .days-table td {
    display: block;
    width: 100%;
  }

  .days-table tbody tr {
    margin-bottom: 0.55rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
  }

  .days-table tbody tr.day-card-row {
    padding-top: 2rem;
  }

  .jiaqu-ai-btn {
    top: 0.45rem;
    right: 0.5rem;
  }

  .days-table tbody tr.day-card-row > .col-date {
    padding-right: 0;
  }

  .days-table tbody tr.selected {
    outline: none;
    border-color: var(--accent);
    background: rgba(var(--accent-rgb, 90, 158, 111), 0.06);
  }

  .days-table td {
    padding: 0.2rem 0;
    border-bottom: none;
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    line-height: 1.45;
    color: var(--text);
  }

  .days-table td::before {
    content: attr(data-label);
    flex: 0 0 4.2em;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
  }

  .days-table .col-date::before {
    color: var(--accent-dark);
  }

  .days-table .col-ji,
  .days-table .col-yi,
  .days-table .col-rikeji,
  .days-table .col-zhan-gong,
  .days-table .col-shishen {
    max-width: none;
  }

  .days-table .empty-row td {
    justify-content: center;
    color: var(--muted);
  }

  .days-table .empty-row td::before {
    display: none;
  }

  .loader-core {
    width: 160px;
    height: 160px;
    margin-bottom: 1rem;
  }

  .orbit .stem,
  .orbit .branch {
    font-size: 0.72rem;
    transform-origin: 50% 80px;
  }

  .orbit-inner {
    inset: 22px;
  }

  .orbit-inner .branch {
    transform-origin: 50% 58px;
    font-size: 0.68rem;
  }

  .loader-center {
    inset: 42px;
  }

  .loader-icon {
    font-size: 1.5rem;
  }

  .loader-title {
    font-size: 0.92rem;
    letter-spacing: 0.2em;
  }

  .loader-status {
    font-size: 0.78rem;
  }

  .loader-percent {
    font-size: 1.1rem;
  }

  .ref-book-dialog {
    width: min(100%, 480px);
  }

  .ref-book-page {
    padding: 1.1rem 0.85rem 1rem;
  }

  .ref-book-header h2 {
    font-size: 1rem;
    letter-spacing: 0.08em;
  }

  .ref-book-body {
    max-height: 58vh;
  }

  .ref-book-body p {
    font-size: 0.84rem;
    padding: 0.32rem 0.35rem;
  }

  .toast {
    bottom: 1rem;
    font-size: 0.82rem;
    padding: 0.55rem 1rem;
  }
}

/* AI 评课弹窗 · 对齐嫁娶红金喜庆主题 */
.interpret-modal {
  position: fixed;
  z-index: 140;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.interpret-modal.hidden { display: none; }
.interpret-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(48, 36, 36, 0.28);
  backdrop-filter: blur(3px);
}
.interpret-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(920px, 100%);
  max-height: min(88vh, 860px);
  overflow: hidden;
  border: 1px solid var(--border, #f0d5cc);
  border-radius: 12px;
  background: linear-gradient(180deg, #fffdfb, #fff5f0);
  box-shadow: 0 22px 58px rgba(196, 30, 58, 0.22);
}
.interpret-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #f0c8bc;
  background: linear-gradient(180deg, rgba(255, 252, 250, 0.98), rgba(255, 245, 240, 0.96));
}
.interpret-header-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}
.interpret-header h2 {
  margin: 0;
  color: var(--accent, #c41e3a);
  font-size: 1.15rem;
  line-height: 1.25;
}
.interpret-disclaimer {
  margin: 0;
  color: var(--muted, #9a7575);
  font-size: 0.66rem;
  line-height: 1.35;
}
.interpret-close {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid rgba(var(--accent-rgb, 196, 30, 58), 0.35);
  border-radius: 50%;
  color: var(--accent, #c41e3a);
  background: #fff;
  font-size: 1.3rem;
  cursor: pointer;
}
.interpret-close:hover {
  background: rgba(var(--accent-rgb, 196, 30, 58), 0.08);
  box-shadow: var(--glow);
}
.interpret-body-shell {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.interpret-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1.05rem 1.1rem 1.3rem;
  background:
    radial-gradient(circle at top right, rgba(196, 30, 58, 0.08), transparent 30%),
    radial-gradient(circle at 12% 18%, rgba(201, 162, 39, 0.1), transparent 36%),
    linear-gradient(180deg, #fffdfb, #fff3ee);
}
.interpret-loading {
  display: grid;
  min-height: 240px;
  place-content: center;
  justify-items: center;
  gap: 0.45rem;
  padding: 1.5rem;
  text-align: center;
  color: var(--muted, #9a7575);
}
.interpret-loading strong { color: var(--accent, #c41e3a); font-size: 0.95rem; }
.interpret-loading p { margin: 0; color: var(--muted, #9a7575); font-size: 0.72rem; line-height: 1.6; }
.interpret-loading.is-error strong { color: #a14d4d; }

.ai-scroll-latest {
  position: absolute;
  right: 1rem;
  bottom: 1.05rem;
  z-index: 5;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #fffdfb, #ffe8e4);
  color: var(--accent-dark, #9e1830);
  box-shadow: 0 6px 18px rgba(196, 30, 58, 0.22);
  cursor: pointer;
  display: grid;
  place-items: center;
  animation: ai-scroll-pulse 1.8s ease-in-out infinite;
}
.ai-scroll-latest-icon { width: 1.2rem; height: 1.2rem; }
.ai-scroll-latest.hidden { display: none; }
@keyframes ai-scroll-pulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

.ai-interpret-hero {
  margin: 0 0 1rem;
  padding: 1rem 1.05rem;
  border: 1px solid #f0c8bc;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(196, 30, 58, 0.1), #fff 52%, rgba(201, 162, 39, 0.12));
}
.ai-interpret-hero strong {
  display: block;
  margin: 0.28rem 0 0.35rem;
  color: var(--accent, #c41e3a);
  font-size: 1.12rem;
}
.ai-interpret-hero p {
  margin: 0;
  color: var(--muted, #9a7575);
  font-size: 0.78rem;
  line-height: 1.6;
}
.ai-interpret-content { display: grid; gap: 0.85rem; }
.ai-section-card {
  overflow: hidden;
  border: 1px solid #f0d5cc;
  border-radius: 12px;
  background: #fff;
}
.ai-section-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.72rem 0.85rem;
  border-bottom: 1px solid #f5ddd4;
  background: linear-gradient(180deg, #fff8f5, #fff0ea);
}
.ai-section-index {
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #c41e3a, #c9a227);
  font-size: 0.68rem;
  font-weight: 700;
}
.ai-section-title {
  margin: 0;
  color: var(--title, #b8860b);
  font-size: 1.02rem;
}
.ai-section-body {
  padding: 0.75rem 0.85rem 0.9rem;
  display: grid;
  gap: 0.42rem;
}
.ai-detail-line {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(196, 30, 58, 0.12);
  border-radius: 8px;
  background: #fffdfb;
  font-size: 0.88rem;
  line-height: 1.72;
  color: var(--text, #3d2020);
}
.ai-detail-line b {
  flex: 0 0 auto;
  min-width: 4.6em;
  color: var(--accent-dark, #9e1830);
}
.ai-bullet,
.ai-paragraph {
  margin: 0;
  color: var(--text, #3d2020);
  font-size: 0.88rem;
  line-height: 1.72;
}
.ai-spacer { height: 0.2rem; }
.ai-hr {
  border: 0;
  border-top: 1px solid #f0d5cc;
  margin: 0.35rem 0;
}
.ai-interpret-output.is-streaming .ai-interpret-content:after {
  content: "";
  display: inline-block;
  width: 0.52rem;
  height: 1em;
  margin-left: 0.18rem;
  vertical-align: -0.1em;
  background: var(--accent, #c41e3a);
  animation: ai-caret 0.9s steps(1) infinite;
}
@keyframes ai-caret { 50% { opacity: 0; } }

.jiaqu-ai-loading {
  min-height: 240px;
  padding: 0.35rem 0.15rem 1rem;
  align-content: start;
}
.jiaqu-ai-loading .liang-thinking-panel { width: 100%; max-width: 100%; }
.ai-interpret-wrap { display: grid; gap: 0.75rem; }

/* 思考过程正文：对齐八字解读的灰调字色 */
#jiaquAiModal .liang-thinking-body,
#jiaquAiModal .liang-thinking-result-body {
  color: #6b5a4a;
}
#jiaquAiModal .liang-thinking-body:empty::before {
  color: #a89888;
}

@media (max-width: 860px) {
  .interpret-modal { align-items: end; padding: 0; }
  .interpret-panel {
    width: 100%;
    max-height: 92vh;
    border-radius: 14px 14px 0 0;
  }
}

