:root {
  --ink: #211d16;
  --muted: #70685d;
  --paper: #f6efe2;
  --card: #fffaf0;
  --panel: #e8dfcf;
  --red: #9d3328;
  --gold: #b79255;
  --green: #2f4d43;
  --line: rgba(47, 39, 27, .16);
  --shadow: 0 28px 70px rgba(44, 35, 19, .14);
  --yao-height: 9px;
  --yao-gap: 22px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #fbf7ef, var(--paper));
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Serif SC", serif;
  line-height: 1.7;
  overflow-x: hidden;
}
button, input, select { font: inherit; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

.site-header {
  max-width: 1180px;
  height: 82px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.seal {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  color: var(--red);
}
.brand strong { display: block; font-size: 21px; letter-spacing: .12em; }
.brand small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .16em; }
nav { display: flex; gap: 34px; color: var(--muted); font-size: 14px; }
nav a:hover { color: var(--red); }
.auth-trigger {
  border: 0;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  padding: 0;
  letter-spacing: .08em;
}

.hero {
  max-width: 1180px;
  min-height: calc(100vh - 82px);
  margin: 0 auto;
  padding: 78px 24px 88px;
  display: grid;
  place-items: center;
  text-align: center;
  position: relative;
}
.hero-title {
  width: min(620px, 88vw);
  height: 230px;
  display: grid;
  place-items: center;
  position: relative;
}
.hero-visual {
  width: min(520px, 82vw);
  padding: 28px 0;
  display: grid;
  gap: 18px;
  opacity: .16;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.hero-visual span {
  height: 12px;
  background: var(--ink);
}
.hero-visual span:nth-child(2),
.hero-visual span:nth-child(5) {
  background: linear-gradient(90deg, var(--ink) 0 42%, transparent 42% 58%, var(--ink) 58%);
}
.eyebrow { margin: 0 0 14px; color: var(--red); font-size: 12px; font-weight: 700; letter-spacing: .28em; }
h1 { margin: 0; font-size: clamp(44px, 7vw, 82px); line-height: 1.1; font-weight: 500; letter-spacing: .08em; }
.hero-title .eyebrow {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
}
.hero-title h1 {
  position: relative;
  z-index: 1;
  transform: translateY(8px);
  white-space: nowrap;
}
.hero p:not(.eyebrow) { max-width: 590px; margin: 24px auto 34px; color: var(--muted); font-size: 17px; }
.hero-notes {
  width: min(820px, 100%);
  margin: 18px auto 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 16px;
  position: relative;
  z-index: 1;
}
.hero-notes article {
  padding: 0 0 0 12px;
  background: transparent;
  border-left: 2px solid rgba(157, 51, 40, .42);
  text-align: left;
}
.hero-notes h3 { margin: 0 0 2px; font-size: 15px; line-height: 1.35; }
.hero-notes p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.button {
  min-height: 46px;
  padding: 0 28px;
  border: 0;
  border-radius: 4px;
  background: var(--red);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  letter-spacing: .08em;
}
.button:hover { filter: brightness(.96); }
.button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--ink); }

.cast-section {
  padding: 74px max(24px, calc((100vw - 1180px)/2)) 86px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.46);
}
.section-title { text-align: center; margin-bottom: 34px; }
.section-title h2, .about h2 { margin: 0; font-size: 36px; letter-spacing: .16em; font-weight: 500; }
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(410px, .98fr);
  background: #fff;
  box-shadow: var(--shadow);
}
.cast-form { padding: 38px 42px; background: var(--card); border-right: 1px solid var(--line); }
.field { margin-bottom: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; margin-bottom: 7px; color: #4b4235; font-size: 13px; font-weight: 700; letter-spacing: .06em; }
input, select {
  width: 100%;
  height: 44px;
  border: 1px solid #d8ccb8;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
  border-radius: 4px;
}
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(183,146,85,.14); }
.method-panel {
  margin: 18px 0;
  padding: 18px;
  background: #f7f0e4;
  border: 1px solid rgba(183, 146, 85, .26);
  border-left: 4px solid var(--gold);
  border-radius: 6px;
}
.hint { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.strong-hint {
  color: #4b3322;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.8;
}
.manual-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.manual-grid label { margin: 0; }
.actions { display: grid; grid-template-columns: minmax(0,1fr) 126px; gap: 12px; margin-top: 24px; }

.shake-preview {
  padding: 14px;
  background: rgba(255,255,255,.54);
  border: 1px solid rgba(47,39,27,.1);
}
#shakeStatus { margin: 0 0 14px; color: var(--red); font-size: 13px; }
.preview-lines { display: grid; grid-template-rows: repeat(6, 28px); row-gap: 8px; }
.preview-line {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
  align-items: center;
  min-height: 28px;
}
.preview-line:empty { border-bottom: 1px dashed rgba(47,39,27,.16); }
.preview-yao { display: block; height: 8px; background: var(--ink); border-radius: 2px; }
.preview-yao.yin { background: linear-gradient(90deg, var(--ink) 0 42%, transparent 42% 58%, var(--ink) 58%); }
.preview-line em { color: var(--muted); font-size: 12px; font-style: normal; text-align: left; }

.result { min-height: 620px; padding: 34px 40px; background: var(--panel); position: relative; overflow: visible; }
.result::before {
  content: "卦";
  position: absolute;
  right: -34px;
  bottom: -120px;
  font-size: 320px;
  color: rgba(255,255,255,.22);
  line-height: 1;
}
.empty {
  min-height: 520px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  position: relative;
  z-index: 1;
}
.mini-hex { width: 84px; opacity: .32; }
.mini-hex i { display: block; height: 8px; margin: 12px 0; background: var(--ink); }
.mini-hex .broken { background: linear-gradient(90deg, var(--ink) 0 42%, transparent 42% 58%, var(--ink) 58%); }
.empty h3 { margin: 20px 0 6px; font-size: 24px; letter-spacing: .2em; font-weight: 500; }
.empty p, .meta { color: var(--muted); font-size: 13px; }
.ganzhi-meta {
  margin: 6px 0 10px;
  color: var(--red);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
}
#resultBody { position: relative; z-index: 1; }
.question { margin: 12px 0 28px; padding-left: 12px; border-left: 3px solid var(--red); color: var(--muted); }
.hex-layout { display: grid; grid-template-columns: 1fr 46px 1fr; gap: 18px; align-items: start; text-align: center; }
.hex-box > span { color: var(--red); font-size: 13px; letter-spacing: .16em; }
.hex-box h3 { margin: 6px 0 22px; font-size: 23px; font-weight: 500; }
.zhi {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  display: grid;
  place-items: center;
  margin-top: 36px;
}
.marker-column { display: flex; flex-direction: column; align-items: center; }
.marker-lines, .hex-lines {
  display: grid;
  grid-template-rows: repeat(6, var(--yao-height));
  row-gap: var(--yao-gap);
}
.marker-lines { margin-top: 22px; }
.move-marker {
  height: var(--yao-height);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--red);
  font-size: 15px;
  line-height: 1;
}
.yao { height: var(--yao-height); background: var(--ink); border-radius: 2px; }
.yao.yin { background: linear-gradient(90deg, var(--ink) 0 42%, transparent 42% 58%, var(--ink) 58%); }
.moving { margin-top: 28px; padding: 14px; background: rgba(255,255,255,.5); color: var(--muted); text-align: center; font-size: 13px; }
.shensha,
.najiainfo {
  margin-top: 14px;
  text-align: left;
  background: rgba(255,255,255,.56);
  border: 1px solid rgba(122, 33, 25, .12);
  padding: 12px;
  overflow-x: auto;
}
.shensha h4,
.najiainfo h4 { margin: 0 0 8px; color: var(--red); font-size: 14px; letter-spacing: .08em; }
.shensha-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: #3f382d;
  font-size: 13px;
  line-height: 1.8;
}
.shensha-list span {
  white-space: nowrap;
}
.shensha-list b {
  color: var(--red);
  font-weight: 600;
}
.najiainfo .summary { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.najiainfo table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.najiainfo th, .najiainfo td { border-bottom: 1px solid rgba(40, 34, 26, .12); padding: 7px 5px; }
.najiainfo th { color: var(--muted); font-weight: 500; }
.najiainfo td strong { color: var(--red); font-weight: 600; }
.ai-box { margin-top: 18px; display: grid; gap: 10px; }
.ai-button { width: 100%; }
.ai-button.dark { background: var(--green); }
.ai-button.save { background: #7a5a28; }
.ai-button:disabled { opacity: .68; cursor: wait; }
.ai-answer {
  padding: 16px;
  background: rgba(255,255,255,.62);
  border-left: 3px solid var(--gold);
  color: #3f382d;
  font-size: 14px;
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
  box-sizing: border-box;
  text-align: left;
}
.membership-box {
  white-space: normal;
}
.membership-box h3 {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 18px;
}
.membership-box p {
  margin: 0 0 12px;
}
.membership-options {
  display: grid;
  gap: 10px;
}
.membership-note {
  margin-top: 12px !important;
  font-size: 13px;
  color: var(--muted);
}

.notes {
  max-width: 1180px;
  margin: 0 auto;
  padding: 82px 24px;
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 22px;
}
.notes article { padding: 28px; background: rgba(255,250,240,.74); border: 1px solid var(--line); border-radius: 6px; }
.notes b { color: var(--red); font-size: 26px; font-weight: 400; }
.notes h3 { margin: 12px 0 8px; }
.notes p, .about p { color: var(--muted); margin: 0; }
.about { padding: 72px max(24px, calc((100vw - 960px)/2)); background: #2d302a; color: #f8f0df; text-align: center; }
.about p:last-child { max-width: 760px; margin: 18px auto 0; color: #cbc2b2; }
footer { padding: 28px 24px; color: var(--muted); text-align: center; font-size: 13px; }

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(33, 29, 22, .42);
  backdrop-filter: blur(4px);
}
.auth-dialog {
  width: min(420px, 100%);
  position: relative;
  padding: 30px;
  background: var(--card);
  border: 1px solid rgba(47, 39, 27, .18);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.auth-close {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(47, 39, 27, .08);
  color: var(--ink);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.auth-dialog h2 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: .08em;
}
.auth-desc {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}
.auth-field { margin-bottom: 14px; }
.auth-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 10px;
  align-items: end;
}
.auth-code-row .button {
  height: 44px;
  min-height: 44px;
  padding: 0 12px;
  font-size: 14px;
}
.auth-submit {
  width: 100%;
  margin-top: 8px;
}
.auth-submit.dark {
  background: var(--green);
}
.auth-message {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}
.auth-message.error { color: var(--red); }
.auth-message.success { color: var(--green); }

@media (max-width: 900px) {
  nav a { display: none; }
  nav { display: block; }
  .auth-trigger {
    padding: 7px 10px;
    border: 1px solid rgba(157, 51, 40, .3);
    border-radius: 999px;
    font-size: 12px;
  }
  .workspace { grid-template-columns: 1fr; }
  .cast-form { border-right: 0; border-bottom: 1px solid var(--line); }
  .result { min-height: 460px; }
  .empty { min-height: 360px; }
  .notes { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  :root { --yao-height: 8px; --yao-gap: 19px; }
  .site-header { height: 72px; padding: 0 16px; }
  .brand strong { font-size: 18px; }
  .brand small { font-size: 10px; }
  .seal { width: 38px; height: 38px; }
  h1 { font-size: 42px; letter-spacing: .04em; }
  .hero { min-height: auto; padding: 54px 20px 58px; }
  .hero-title {
    width: min(100%, 420px);
    height: 238px;
  }
  .hero-title .eyebrow {
    top: 58px;
    font-size: 11px;
    letter-spacing: .24em;
  }
  .hero-title h1 {
    transform: translateY(4px);
  }
  .hero-visual {
    width: min(86vw, 380px);
    gap: 14px;
  }
  .hero-notes {
    margin: 18px auto 18px;
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .hero-notes article {
    padding-left: 10px;
  }
  .hero-notes h3 {
    display: inline;
    margin-right: 8px;
    font-size: 14px;
  }
  .hero-notes p {
    display: inline;
    font-size: 12px;
    line-height: 1.5;
  }
  .cast-section { padding-left: 16px; padding-right: 16px; }
  .cast-form, .result { padding: 26px 20px; }
  .field-row, .manual-grid, .actions { grid-template-columns: 1fr; }
  .hex-layout { grid-template-columns: 1fr 34px 1fr; gap: 10px; }
  .hex-box h3 { font-size: 20px; margin-bottom: 18px; }
  .result::before { font-size: 240px; right: -28px; bottom: -82px; }
  .shensha,
  .najiainfo { padding: 10px; margin-left: -6px; margin-right: -6px; }
  .najiainfo table { font-size: 12px; }
  .najiainfo th, .najiainfo td { padding: 6px 4px; }
  .preview-line { grid-template-columns: 1fr 104px; }
  input, select, .button { font-size: 16px; }
  .auth-dialog { padding: 26px 20px; }
  .auth-code-row { grid-template-columns: 1fr; }
}
