
:root {
  --bg-1: #f5ebdc;
  --bg-2: #ddc39b;
  --ink: #22180f;
  --muted: #6c5f50;
  --line: rgba(91, 61, 31, 0.16);
  --panel: rgba(255, 250, 243, 0.84);
  --panel-strong: rgba(255, 251, 245, 0.95);
  --accent: #9f3d1e;
  --accent-soft: rgba(159, 61, 30, 0.12);
  --water: #2d5f82;
  --good: #2d6a52;
  --warn: #9f3d1e;
  --shadow: 0 18px 58px rgba(58, 37, 18, 0.14);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Source Han Sans SC", "PingFang SC", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 240, 214, 0.88), transparent 28%),
    radial-gradient(circle at 85% 20%, rgba(208, 138, 54, 0.22), transparent 22%),
    radial-gradient(circle at 78% 82%, rgba(45, 95, 130, 0.16), transparent 30%),
    linear-gradient(145deg, var(--bg-1) 0%, #ead6b5 52%, var(--bg-2) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(105, 76, 45, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(105, 76, 45, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 40%, transparent 92%);
}

.page {
  position: relative;
  max-width: 1420px;
  margin: 0 auto;
  padding: 24px 16px 36px;
}

.hero {
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(255, 249, 240, 0.9), rgba(248, 235, 212, 0.78)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0));
  box-shadow: var(--shadow);
  display: block;
}

.eyebrow {
  display: inline-flex;
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-weight: 700;
}

.hero h1 {
  margin: 14px 0 8px;
  font-family: "Source Han Serif SC", "Songti SC", serif;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1;
}

.hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.72;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 20px;
  position: sticky;
  top: 16px;
  height: fit-content;
}

.panel-title,
.section-head,
.result-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.panel-title h2,
.result-top h2,
.section-head h3 {
  margin: 0;
}

.panel-title p,
.result-top p,
.helper,
.field small,
.empty-hint {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.9rem;
}

.badge-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(45, 95, 130, 0.1);
  color: var(--water);
  font-size: 0.82rem;
  font-weight: 700;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.mode-chip,
.tab-chip,
.ghost-btn,
.tool-btn,
.history-item {
  font: inherit;
}

.history-toggle {
  border: 1px dashed rgba(111, 74, 39, 0.26);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 251, 245, 0.64);
  color: var(--muted);
  cursor: pointer;
}

.mode-chip,
.tab-chip {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 10px;
  background: rgba(255, 252, 247, 0.72);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.mode-chip.active,
.tab-chip.active {
  border-color: rgba(159, 61, 30, 0.42);
  background: linear-gradient(135deg, rgba(159, 61, 30, 0.12), rgba(208, 138, 54, 0.16));
}

.mode-chip:hover,
.tab-chip:hover,
.history-item:hover,
.ghost-btn:hover,
.tool-btn:hover,
.submit-btn:hover {
  transform: translateY(-1px);
}

.fields,
.control-section,
.history-list,
.result-stack,
.analysis-grid,
.tab-row {
  display: grid;
  gap: 12px;
}

.fields { margin-top: 16px; }

.field { display: grid; gap: 7px; }

.field-label {
  font-size: 0.9rem;
  font-weight: 700;
}

.input-note-box {
  display: grid;
  gap: 4px;
  min-height: 100%;
  border: 1px solid rgba(91, 61, 31, 0.14);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 249, 240, 0.78);
}

.input-note-box strong {
  font-size: 0.92rem;
}

.input-note-box span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(111, 74, 39, 0.18);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 252, 247, 0.86);
  font: inherit;
}

textarea { min-height: 96px; resize: vertical; }

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(159, 61, 30, 0.42);
  box-shadow: 0 0 0 4px rgba(159, 61, 30, 0.08);
}

.advanced {
  margin-top: 4px;
  border: 1px dashed rgba(111, 74, 39, 0.25);
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(255, 251, 246, 0.65);
}

.advanced summary {
  cursor: pointer;
  font-weight: 700;
}

.submit-row {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.submit-btn {
  border: none;
  border-radius: 16px;
  padding: 14px;
  color: #fff7ec;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, #aa4726, #d08a36);
  box-shadow: 0 12px 26px rgba(159, 61, 30, 0.22);
}

.submit-btn:disabled {
  cursor: wait;
  opacity: 0.76;
}

.status {
  min-height: 1.4em;
  color: var(--muted);
  font-size: 0.9rem;
}
.status.ok { color: var(--good); }
.status.warn { color: var(--warn); }

.control-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.history-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 252, 247, 0.75);
  cursor: pointer;
}

.history-item strong { display: block; margin: 4px 0; }
.history-item span { color: var(--muted); font-size: 0.88rem; }

.history-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.history-label {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(45, 95, 130, 0.1);
  color: var(--water);
  font-size: 0.76rem;
  font-weight: 700;
}

.ghost-btn,
.tool-btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  background: rgba(255, 252, 247, 0.72);
  color: var(--ink);
  cursor: pointer;
}

.input-preview {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  border: 1px dashed rgba(111, 74, 39, 0.24);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 251, 245, 0.72);
}

.input-preview strong {
  font-size: 0.85rem;
}

.input-preview span {
  color: var(--muted);
  font-size: 0.88rem;
}

.ghost-btn:disabled,
.tool-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.result-panel {
  min-height: 680px;
  padding: 20px;
}

.result-top { align-items: end; }
.result-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: end;
}

.result-meta { margin: 14px 0; }
.ai-status-shell {
  margin-bottom: 12px;
}
.ai-status-card {
  display: grid;
  gap: 6px;
  border: 1px dashed rgba(45, 95, 130, 0.22);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(248, 252, 255, 0.6);
}
.ai-status-card span,
.ai-status-card small {
  color: var(--muted);
}
.meta-shell {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(159, 61, 30, 0.08), rgba(208, 138, 54, 0.08)), rgba(255, 251, 245, 0.9);
}

.meta-shell h3 { margin: 0; }
.meta-shell p { margin: 8px 0 0; color: var(--muted); }

.tab-row {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 12px;
}

.result-card,
.empty-state,
.raw-output {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
  overflow: hidden;
}

.result-card.accent {
  background: linear-gradient(135deg, rgba(159, 61, 30, 0.08), rgba(208, 138, 54, 0.08)), var(--panel-strong);
}

.result-card.soft {
  background: linear-gradient(135deg, rgba(45, 95, 130, 0.06), rgba(45, 106, 82, 0.06)), var(--panel-strong);
}

.card-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}

.card-head h3 { margin: 0; font-size: 1.02rem; }
.card-head p { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }
.card-body { padding: 14px 16px 16px; }

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  border-radius: 999px;
  padding: 8px 10px;
  background: rgba(111, 74, 39, 0.08);
  font-size: 0.86rem;
  font-weight: 600;
}

.tag.good {
  background: rgba(45, 106, 82, 0.12);
  color: var(--good);
}

.tag.water {
  background: rgba(45, 95, 130, 0.12);
  color: var(--water);
}

.tag.accent {
  background: rgba(159, 61, 30, 0.12);
  color: var(--accent);
}

.analysis-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.analysis-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 251, 245, 0.82);
}

.analysis-item strong { display: block; }
.analysis-item span { color: var(--muted); font-size: 0.9rem; line-height: 1.55; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.stat-metric {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 251, 245, 0.8);
}

.stat-metric small,
.timeline-item span,
.pillar-facts span {
  color: var(--muted);
  display: block;
  line-height: 1.55;
}

.stat-metric strong {
  display: block;
  margin-top: 6px;
  font-size: 1rem;
}

.pillar-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pillar-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 251, 245, 0.84);
  display: grid;
  gap: 10px;
}

.pillar-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.pillar-top span {
  color: var(--muted);
  font-size: 0.84rem;
}

.pillar-facts {
  display: grid;
  gap: 6px;
}

.timeline-list {
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 4px solid rgba(159, 61, 30, 0.3);
  border-radius: 0 14px 14px 0;
  padding: 10px 12px;
  background: rgba(255, 249, 240, 0.78);
}

.wuxing-bars {
  display: grid;
  gap: 10px;
}

.wuxing-bar-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 30px;
  gap: 10px;
  align-items: center;
}

.wuxing-bar-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(111, 74, 39, 0.08);
  overflow: hidden;
}

.wuxing-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(135deg, #9f3d1e, #d08a36);
}

.source-note {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px dashed rgba(91, 61, 31, 0.22);
  border-radius: 14px;
  background: rgba(255, 249, 240, 0.62);
}

.source-note strong {
  font-size: 0.88rem;
}

.source-note-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-note-list span {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 9px;
  background: rgba(45, 95, 130, 0.08);
  color: var(--water);
  font-size: 0.8rem;
}

.hexagram-showcase {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(220px, 0.8fr);
  gap: 12px;
}

.hexagram-panel,
.hexagram-sidepanel {
  display: grid;
  gap: 10px;
}

.hexagram-panel-head,
.hexagram-mini-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 251, 245, 0.78);
}

.hexagram-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.hexagram-panel-head span,
.hexagram-mini-card span {
  color: var(--muted);
  font-size: 0.88rem;
}

.hexagram-mini-card {
  display: grid;
  gap: 4px;
}

.hexagram-lines {
  display: grid;
  gap: 10px;
}

.hexagram-board-head {
  display: grid;
  grid-template-columns: 110px minmax(140px, auto) minmax(0, 1fr) auto;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 0 4px;
}

.line-card {
  display: grid;
  grid-template-columns: 110px minmax(140px, auto) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 251, 245, 0.86);
}

.line-card.changing {
  border-color: rgba(159, 61, 30, 0.32);
  background: linear-gradient(135deg, rgba(159, 61, 30, 0.08), rgba(255, 251, 245, 0.92));
}

.line-card-index strong {
  display: block;
}

.line-card-index span {
  color: var(--muted);
  font-size: 0.82rem;
}

.line-card-side strong {
  display: block;
}

.line-card-side span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.line-visual-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.line-visual,
.line-transform {
  display: flex;
  align-items: center;
  gap: 6px;
}

.line-transform {
  color: var(--muted);
  font-size: 0.8rem;
}

.yao {
  display: inline-block;
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #8f3619, #d08a36);
}

.yao.yang.wide {
  width: 54px;
}

.yao.yin {
  width: 24px;
}

.line-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: end;
}

.ziwei-chart {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(150px, auto));
  gap: 10px;
}

.ziwei-palace,
.ziwei-center {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  background: rgba(255, 251, 245, 0.88);
}

.ziwei-palace {
  display: grid;
  gap: 8px;
}

.ziwei-palace.soul {
  border-color: rgba(159, 61, 30, 0.42);
  box-shadow: inset 0 0 0 1px rgba(159, 61, 30, 0.18);
}

.ziwei-palace.body {
  background: linear-gradient(135deg, rgba(45, 95, 130, 0.08), rgba(255, 251, 245, 0.9));
}

.ziwei-palace.origin {
  background: linear-gradient(135deg, rgba(45, 106, 82, 0.07), rgba(255, 251, 245, 0.9));
}

.ziwei-palace-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.ziwei-palace-head strong {
  font-family: "Source Han Serif SC", "Songti SC", serif;
  font-size: 1rem;
}

.ziwei-palace-head span,
.ziwei-foot,
.ziwei-center small {
  color: var(--muted);
  font-size: 0.82rem;
}

.ziwei-stars,
.ziwei-labels,
.ziwei-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ziwei-stars span,
.ziwei-labels span {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(111, 74, 39, 0.08);
  font-size: 0.8rem;
}

.ziwei-stars.major span {
  background: rgba(159, 61, 30, 0.12);
  color: var(--accent);
  font-weight: 700;
}

.ziwei-stars.minor span {
  background: rgba(45, 95, 130, 0.1);
  color: var(--water);
}

.ziwei-stars.adjective span {
  background: rgba(45, 106, 82, 0.1);
  color: var(--good);
}

.ziwei-center {
  grid-row: 2 / span 2;
  grid-column: 2 / span 2;
  display: grid;
  align-content: center;
  gap: 8px;
  text-align: center;
  background:
    radial-gradient(circle at center, rgba(208, 138, 54, 0.16), rgba(255, 251, 245, 0.92) 58%),
    rgba(255, 251, 245, 0.92);
}

.ziwei-center h4 {
  margin: 0;
  font-family: "Source Han Serif SC", "Songti SC", serif;
  font-size: 1.4rem;
}

.ziwei-center p,
.ziwei-center small {
  margin: 0;
}

.ziwei-center-eyebrow {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.ziwei-mobile-list {
  display: none;
  margin-top: 12px;
  gap: 12px;
}

.fengshui-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(110px, auto));
  gap: 10px;
}

.fengshui-cell {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 251, 245, 0.82);
}

.fengshui-cell span,
.fengshui-cell small {
  color: var(--muted);
}

.empty-state {
  padding: 24px 20px;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.quote {
  border-left: 4px solid rgba(208, 138, 54, 0.68);
  background: rgba(208, 138, 54, 0.11);
  padding: 12px 14px;
  border-radius: 0 12px 12px 0;
  color: #544230;
}

.code-block,
.raw-output pre {
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 14px;
  padding: 12px 14px;
  background: #2a231c;
  color: #f3e8d7;
  font-family: "JetBrains Mono", "Sarasa Mono SC", "SFMono-Regular", monospace;
  font-size: 0.86rem;
  line-height: 1.6;
}

.raw-output {
  margin-top: 14px;
  padding: 12px;
}

.raw-output summary { cursor: pointer; font-weight: 700; }
.raw-output pre { margin-top: 10px; }

code {
  font-family: "JetBrains Mono", "Sarasa Mono SC", "SFMono-Regular", monospace;
  font-size: 0.92em;
  background: rgba(111, 74, 39, 0.08);
  border-radius: 7px;
  padding: 0.15em 0.4em;
}

@media (max-width: 1120px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .control-panel { position: static; }
}

@media (max-width: 780px) {
  .page { padding: 14px 10px 24px; }
  .hero, .panel, .control-panel, .result-panel { border-radius: 18px; padding: 16px; }
  .mode-grid,
  .field-row,
  .analysis-grid,
  .tab-row,
  .metric-grid,
  .pillar-grid {
    grid-template-columns: 1fr;
  }
  .panel-title,
  .section-head,
  .result-top,
  .result-tools {
    flex-direction: column;
    align-items: start;
  }
  .hexagram-showcase,
  .line-card,
  .hexagram-board-head,
  .fengshui-grid {
    grid-template-columns: 1fr;
  }
  .line-flags {
    justify-content: start;
  }
  .ziwei-chart {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }
  .ziwei-palace {
    display: none;
  }
  .ziwei-center {
    grid-column: auto;
    grid-row: auto;
  }
  .ziwei-mobile-list {
    display: grid;
  }
}
