:root {
  --bg: #f4efe5;
  --bg-soft: rgba(255, 251, 245, 0.78);
  --surface: rgba(255, 250, 242, 0.92);
  --surface-strong: #fffdf9;
  --ink: #1f2f2d;
  --ink-soft: #536662;
  --line: rgba(25, 71, 66, 0.14);
  --brand: #174a43;
  --brand-soft: #e4efe9;
  --accent: #b7793f;
  --shadow: 0 20px 60px rgba(24, 50, 46, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --gua-liu-shen-width: 52px;
  --gua-liu-fu-gap: 14px;
  --gua-fu-width: 140px;
  --gua-fu-main-gap: 0px;
  --gua-main-width: 288px;
  --gua-main-changed-gap: 10px;
  --gua-changed-width: 240px;
  --gua-symbol-width: 96px;
  --gua-text-width: 140px;
  --gua-marker-width: 22px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(225, 199, 160, 0.28), transparent 30%),
    radial-gradient(circle at top right, rgba(23, 74, 67, 0.12), transparent 26%),
    linear-gradient(180deg, #f8f3ea 0%, var(--bg) 50%, #efe7da 100%);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 32px auto 88px;
  display: grid;
  gap: 24px;
}

.hero-card,
.panel-card,
.result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-card {
  padding: 28px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
}

.hero-mark {
  width: 78px;
  height: 78px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1f5a52 0%, #123c37 100%);
  color: #f6efdd;
  font-size: 38px;
  font-family: "Songti SC", "STSong", serif;
  letter-spacing: 2px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.eyebrow,
.section-kicker {
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-copy h1,
.section-head h2,
.subsection-head h3 {
  font-family: "Songti SC", "STSong", serif;
}

.hero-copy h1 {
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.1;
  margin-top: 6px;
}

.hero-text {
  margin-top: 10px;
  max-width: 720px;
  color: var(--ink-soft);
}

.hero-tags {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero-tags span,
.muted-text {
  color: var(--ink-soft);
}

.hero-tags span {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(23, 74, 67, 0.08);
  border: 1px solid rgba(23, 74, 67, 0.08);
  font-size: 13px;
}

.panel-card,
.result-card {
  padding: 26px;
}

.section-head,
.subsection-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.section-head {
  margin-bottom: 20px;
}

.section-head h2 {
  font-size: 28px;
  line-height: 1.2;
  margin-top: 4px;
}

.section-desc,
.subsection-head p,
.note-card p {
  color: var(--ink-soft);
}

.section-desc {
  max-width: 340px;
}

.result_back_button {
  white-space: nowrap;
}

.note-card,
.form-card,
.data-card,
.result-keyword,
.meta-item,
.gua {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.note-card,
.form-card,
.data-card {
  padding: 18px 20px;
}

.note-card {
  display: grid;
  gap: 4px;
  margin-bottom: 18px;
}

.note-card strong,
.meta-item strong,
.pai_pan_box strong,
.shen_sha_box strong {
  color: var(--brand);
}

.form-shell {
  display: grid;
  gap: 18px;
}

.field-grid,
.pillars-grid,
.yao-grid,
.result-meta {
  display: grid;
  gap: 16px;
}

.field-grid--two,
.result-meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.field-block,
.ganzhi-group,
.yao-item {
  display: grid;
  gap: 8px;
}

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

.field-label {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

input[type="text"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(23, 74, 67, 0.18);
  background: #fffdf8;
  padding: 12px 14px;
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(23, 74, 67, 0.45);
  box-shadow: 0 0 0 4px rgba(23, 74, 67, 0.1);
}

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

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

.subsection-head h3 {
  font-size: 22px;
  line-height: 1.2;
}

.designate_button,
.now_button,
.primary-btn,
.secondary-btn,
.fun {
  appearance: none;
  border: none;
  cursor: pointer;
}

.designate_button {
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid rgba(23, 74, 67, 0.12);
}

.now_button {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(23, 74, 67, 0.08);
  color: var(--brand);
  border: 1px solid rgba(23, 74, 67, 0.12);
  white-space: nowrap;
}

.qi_gua {
  display: grid;
  gap: 18px;
}

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

.yao-item span {
  font-size: 14px;
  color: var(--ink-soft);
}

.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn {
  min-width: 148px;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 14px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.primary-btn {
  background: linear-gradient(135deg, #1d6058 0%, #154640 100%);
  color: #f7f1e6;
  box-shadow: 0 16px 30px rgba(21, 70, 64, 0.18);
}

.secondary-btn {
  background: rgba(23, 74, 67, 0.08);
  color: var(--brand);
  border: 1px solid rgba(23, 74, 67, 0.12);
}

.secondary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary-btn:hover,
.secondary-btn:hover,
.designate_button:hover,
.now_button:hover,
.fun:hover {
  transform: translateY(-1px);
}

.gua_box {
  display: none;
}

.result-keyword {
  margin-bottom: 12px;
  padding: 10px 14px;
}

.result-meta {
  margin-bottom: 18px;
}

.meta-item {
  padding: 16px 18px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.meta-item--full {
  align-items: center;
}

.meta-divider {
  margin-left: 10px;
}

.gz_span {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.gz_span span,
.xunkong,
.xunkong span,
.gua {
  font-family: "Songti SC", "STSong", serif;
}

.shen_sha_box {
  position: relative;
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.shen_sha_box p {
  margin: 0;
  line-height: 1.8;
}

.need_more {
  display: none;
  width: fit-content;
  margin-top: 4px;
  color: var(--brand);
  font-size: 14px;
  cursor: pointer;
}

.pai_pan_box {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-bottom: 18px;
}

.gua-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 18px;
}

.gua {
  min-width: 860px;
  padding: 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  display: grid;
  gap: 6px;
}

.span1,
.span2,
.span3,
.span4,
.span5,
.span6,
.span7,
.span8 {
  display: grid;
  grid-template-columns:
    var(--gua-liu-shen-width)
    var(--gua-liu-fu-gap)
    var(--gua-fu-width)
    var(--gua-fu-main-gap)
    var(--gua-main-width)
    var(--gua-main-changed-gap)
    var(--gua-changed-width);
  align-items: center;
  min-height: 34px;
}

.span1 > span,
.span2 > span,
.span3 > span,
.span4 > span,
.span5 > span,
.span6 > span,
.span7 > span,
.span8 > span {
  min-width: 0;
  white-space: nowrap;
}

.span1,
.span2 {
  font-weight: 700;
}

.span1 > :nth-child(1) {
  grid-column: 3;
  justify-self: center;
  text-align: center;
}

.span1 > :nth-child(2) {
  grid-column: 5;
  justify-self: center;
  text-align: center;
}

.span1 > :nth-child(3) {
  grid-column: 7;
  justify-self: center;
  text-align: center;
}

.span2 > :nth-child(2),
.span3 > :nth-child(2),
.span4 > :nth-child(2),
.span5 > :nth-child(2),
.span6 > :nth-child(2),
.span7 > :nth-child(2),
.span8 > :nth-child(2) {
  grid-column: 3;
  justify-self: center;
}

.span2 > :nth-child(3),
.span2 > :nth-child(4) {
  justify-self: center;
  text-align: center;
}

.span2 > :nth-child(3) {
  grid-column: 5;
}

.span2 > :nth-child(4) {
  grid-column: 7;
}

.span3 > :nth-child(3),
.span4 > :nth-child(3),
.span5 > :nth-child(3),
.span6 > :nth-child(3),
.span7 > :nth-child(3),
.span8 > :nth-child(3) {
  grid-column: 5;
  justify-self: center;
}

.span3 > :nth-child(4),
.span4 > :nth-child(4),
.span5 > :nth-child(4),
.span6 > :nth-child(4),
.span7 > :nth-child(4),
.span8 > :nth-child(4) {
  grid-column: 7;
  justify-self: center;
}

.main_group > .yinyang_gua,
.changed_group > .yinyang_gua {
  flex: 0 0 var(--gua-symbol-width);
}

.main_group,
.changed_group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  flex-wrap: nowrap;
}

.main_group > .ben_yaochen,
.changed_group > .bian_yaochen {
  flex: 0 0 auto;
  min-width: 0;
}

.main_group > .ben_shi,
.main_group > .symbol,
.changed_group > .bian_shi {
  flex: 0 0 var(--gua-marker-width);
  text-align: center;
}

.gua .ben_yaochen span,
.gua .bian_yaochen span,
.gua .fu_yaochen span {
  display: inline;
}

.red {
  color: #a33a2b;
  font-weight: 700;
}

.fun {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 84px;
  height: 104px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
  background: linear-gradient(180deg, #194e47 0%, #123b36 100%);
  color: #f8f2e7;
  box-shadow: 0 24px 36px rgba(17, 47, 43, 0.22);
}

.fun span {
  text-align: center;
  line-height: 1.4;
  font-family: "Songti SC", "STSong", serif;
}

.fun strong {
  color: #d6b17c;
}

body.has-result .fun {
  display: flex;
}

.case-library {
  display: grid;
  gap: 16px;
}

.case_status {
  color: var(--ink-soft);
}

.case-action-row {
  justify-content: flex-end;
}

.case_note_input {
  line-height: 1.7;
}

.case-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.case-list-head strong {
  font-family: "Songti SC", "STSong", serif;
  font-size: 18px;
}

.case-list-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.case-export-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.case_count_badge,
.case-item-badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(23, 74, 67, 0.08);
  color: var(--brand);
  font-size: 12px;
  white-space: nowrap;
}

.case_list {
  display: grid;
  gap: 12px;
}

.case-empty {
  color: var(--ink-soft);
}

.case-item {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border: 1px solid rgba(23, 74, 67, 0.12);
  border-radius: 16px;
  background: #fffdf8;
}

.case-item.is-active {
  border-color: rgba(23, 74, 67, 0.3);
  box-shadow: inset 0 0 0 1px rgba(23, 74, 67, 0.08);
}

.case-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.case-item-main {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.case-item-title {
  font-family: "Songti SC", "STSong", serif;
  font-size: 18px;
  line-height: 1.35;
}

.case-item-meta,
.case-item-note {
  color: var(--ink-soft);
  line-height: 1.7;
}

.case-item-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.case-item-chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(23, 74, 67, 0.06);
  border: 1px solid rgba(23, 74, 67, 0.08);
  color: var(--brand);
  font-size: 12px;
  line-height: 1.2;
}

.case-item-note {
  word-break: break-word;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(23, 74, 67, 0.04);
  border: 1px solid rgba(23, 74, 67, 0.06);
}

.case-item-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.case-item-actions .secondary-btn {
  min-width: 96px;
  min-height: 42px;
  padding: 10px 14px;
}

.case-export-actions .secondary-btn {
  min-width: 72px;
  min-height: 38px;
  padding: 8px 12px;
}

.danger-btn {
  color: #9f3a2a;
  border-color: rgba(159, 58, 42, 0.16);
  background: rgba(159, 58, 42, 0.06);
}

@media (max-width: 960px) {
  .hero-card,
  .section-head,
  .subsection-head {
    grid-template-columns: 1fr;
  }

  .hero-card {
    grid-template-columns: auto 1fr;
  }

  .hero-tags {
    justify-content: flex-start;
    grid-column: 1 / -1;
  }

  .field-grid--two,
  .result-meta,
  .pillars-grid,
  .yao-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1120px);
    margin-top: 16px;
    margin-bottom: 84px;
  }

  .hero-card,
  .panel-card,
  .result-card {
    padding: 20px;
    border-radius: 22px;
  }

  .hero-card {
    grid-template-columns: 1fr;
  }

  .hero-mark {
    width: 64px;
    height: 64px;
    font-size: 32px;
  }

  .section-head h2 {
    font-size: 24px;
  }

  .action-row {
    flex-direction: column;
  }

  .primary-btn,
  .secondary-btn,
  .designate_button,
  .result_back_button {
    width: 100%;
  }

  .datetime-row {
    grid-template-columns: 1fr;
  }

  .now_button {
    width: 100%;
  }

  .subsection-head {
    flex-direction: column;
  }

  .case-action-row {
    width: 100%;
  }

  .case-list-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .case-list-tools {
    width: 100%;
    justify-content: flex-start;
  }

  .case-export-actions {
    width: 100%;
  }

  .gua {
    min-width: 860px;
  }

  .fun {
    width: 72px;
    height: 92px;
    border-radius: 20px;
    right: 12px;
    bottom: 12px;
  }
}
