:root {
  color-scheme: light;
  --ink: #2d3139;
  --soft-ink: #464b55;
  --muted: #7e8997;
  --paper: #f5faff;
  --cream: #fffdf6;
  --panel: rgba(255, 255, 255, 0.76);
  --panel-solid: #fffefa;
  --line: rgba(64, 74, 92, 0.11);
  --line-strong: rgba(64, 74, 92, 0.18);
  --accent: #7cc9ff;
  --accent-2: #3198ee;
  --accent-3: #c6ecff;
  --accent-4: #e7b56e;
  --accent-5: #75c7bd;
  --chip: #edf8ff;
  --sticker: #eef3f7;
  --shadow: 0 26px 72px rgba(57, 75, 103, 0.13);
  --shadow-soft: 0 14px 34px rgba(57, 75, 103, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    repeating-linear-gradient(90deg, rgba(45, 49, 57, 0.018) 0 1px, transparent 1px 12px),
    repeating-linear-gradient(0deg, rgba(45, 49, 57, 0.014) 0 1px, transparent 1px 14px),
    linear-gradient(180deg, #fffdf6 0%, #f7fbff 38%, #edf8ff 100%),
    var(--paper);
  color: var(--ink);
  font-family:
    "Avenir Next Rounded",
    "Nunito Sans",
    "Avenir Next",
    "SF Pro Text",
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Display",
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 24px;
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px) saturate(1.08);
}

.controls {
  position: sticky;
  top: 22px;
  align-self: start;
  display: grid;
  gap: 18px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(246, 251, 255, 0.78)),
    var(--panel);
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 2px 2px 10px;
}

.seal {
  display: block;
  width: 64px;
  height: 64px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 21px;
  background: #bfeeff;
  box-shadow: 0 16px 30px rgba(74, 143, 199, 0.2);
  overflow: hidden;
}

.seal img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.42);
  transform-origin: center 56%;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(25px, 3vw, 36px);
  line-height: 1.02;
  letter-spacing: 0;
  font-family:
    "Avenir Next Rounded",
    "Avenir Next",
    "SF Pro Display",
    "PingFang SC",
    sans-serif;
  font-weight: 850;
}

.brand p,
.gua-card p,
.eyebrow,
.field span,
.chart-head,
.pill {
  color: var(--muted);
}

.brand p {
  margin-top: 4px;
  font-size: 13px;
}

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

.field span {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 254, 249, 0.9);
  color: var(--ink);
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
select:focus {
  border-color: rgba(49, 152, 238, 0.52);
  background: #ffffff;
  box-shadow: 0 0 0 5px rgba(124, 201, 255, 0.18);
}

.time-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: 8px;
}

.field small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.mini-button {
  min-height: 48px;
  border-radius: 18px;
  padding: 0 10px;
  font-size: 12px;
}

.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid.two.topic-time-grid {
  grid-template-columns: 1fr;
}

.grid.three {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.advanced-time {
  border: 1px solid rgba(49, 152, 238, 0.14);
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(255, 254, 249, 0.8), rgba(232, 248, 255, 0.62)),
    var(--chip);
  padding: 12px 14px;
}

.advanced-time summary {
  color: #37647f;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
}

.advanced-time p {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.mode-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 23px;
  background: rgba(222, 241, 252, 0.78);
  padding: 6px;
}

.mode {
  min-height: 38px;
  border: 0;
  border-radius: 17px;
  background: transparent;
  color: var(--muted);
  padding: 9px 8px;
  cursor: pointer;
  font-weight: 700;
}

.mode.active {
  background: linear-gradient(145deg, #ffffff, #f0f9ff);
  color: #1f6fa8;
  box-shadow: 0 10px 20px rgba(74, 143, 199, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.method-panel {
  min-height: 312px;
}

.hidden {
  display: none;
}

.line-editor,
.coin-grid {
  display: grid;
  gap: 8px;
}

.coin-shaker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 4px;
  border: 1px solid rgba(49, 152, 238, 0.16);
  border-radius: 22px;
  background:
    linear-gradient(145deg, rgba(232, 248, 255, 0.92), rgba(255, 254, 249, 0.82)),
    var(--chip);
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.coin-shaker span {
  display: block;
  margin-bottom: 5px;
  color: #7b93a6;
  font-size: 12px;
  font-weight: 800;
}

.coin-shaker strong {
  display: block;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.2;
}

.coin-shaker p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.coin-tokens {
  display: flex;
  gap: 6px;
}

.coin-token {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: linear-gradient(145deg, #ffe7aa, #e7b56e 62%, #c99145);
  color: #7a552a;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 8px 16px rgba(151, 109, 52, 0.16);
}

.coin-shaker.shaking .coin-token {
  animation: coin-shake 0.36s infinite ease-in-out;
}

.coin-shaker.shaking .coin-token:nth-child(2) {
  animation-delay: 0.08s;
}

.coin-shaker.shaking .coin-token:nth-child(3) {
  animation-delay: 0.16s;
}

@keyframes coin-shake {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  35% {
    transform: translateY(-6px) rotate(-11deg);
  }

  70% {
    transform: translateY(3px) rotate(9deg);
  }
}

.line-row,
.coin-row {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
}

.coin-row.current input {
  border-color: rgba(49, 152, 238, 0.28);
  background: rgba(232, 248, 255, 0.78);
}

.coin-row.done b {
  color: #7a552a;
  background: linear-gradient(145deg, rgba(255, 246, 223, 0.9), rgba(232, 248, 255, 0.72));
}

.coin-row.pending {
  opacity: 0.68;
}

#castCoins {
  width: 100%;
  margin-top: 10px;
}

.line-row b,
.coin-row b {
  display: grid;
  min-height: 34px;
  place-items: center;
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(231, 246, 255, 0.78)),
    var(--sticker);
  color: #2c7fb9;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.76), 0 7px 14px rgba(61, 90, 120, 0.08);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button {
  min-height: 48px;
  border: 1px solid rgba(38, 123, 187, 0.18);
  border-radius: 18px;
  background: linear-gradient(145deg, #79cdff, #3198ee 72%, #267fc8);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(49, 152, 238, 0.2);
}

button.secondary {
  border-color: var(--line-strong);
  background: linear-gradient(145deg, #fffefa, #edf8ff);
  color: #37647f;
}

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

.summary {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  min-height: 136px;
  border: 1px solid var(--line);
  border-radius: 34px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(232, 248, 255, 0.78)),
    linear-gradient(180deg, rgba(124, 201, 255, 0.16), rgba(255, 253, 246, 0.42)),
    var(--panel-solid);
  box-shadow: var(--shadow);
  padding: 25px 26px;
  overflow: hidden;
}

.summary::after {
  content: "";
  position: absolute;
  right: 28px;
  top: 26px;
  width: 76px;
  height: 76px;
  border: 11px solid rgba(124, 201, 255, 0.18);
  border-radius: 26px;
  transform: rotate(8deg);
}

.eyebrow {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  color: #86a0b6;
}

h2 {
  max-width: 860px;
  font-size: clamp(36px, 5.5vw, 74px);
  line-height: 0.98;
  letter-spacing: 0;
  font-family:
    "Avenir Next Rounded",
    "Avenir Next",
    "SF Pro Display",
    "PingFang SC",
    sans-serif;
  font-weight: 850;
}

.pill {
  z-index: 1;
  flex: none;
  border: 1px solid rgba(49, 152, 238, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  padding: 10px 15px;
  color: #37647f;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 9px 18px rgba(61, 90, 120, 0.08);
}

.summary-side {
  z-index: 1;
  display: grid;
  justify-items: end;
  gap: 8px;
  flex: none;
}

.share-button {
  min-height: 38px;
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 13px;
}

.share-status {
  min-height: 18px;
  color: #6d879b;
  font-size: 12px;
  font-weight: 800;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 18px;
}

.chart,
.gua-card,
.reading,
.followup {
  padding: 20px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

.yao-table {
  display: grid;
  gap: 8px;
}

.yao {
  display: grid;
  grid-template-columns: 42px 74px 70px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 62px;
  border: 1px solid transparent;
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.78), rgba(242, 248, 252, 0.72)),
    var(--sticker);
  padding: 8px 10px;
  font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.yao.moving {
  border-color: rgba(49, 152, 238, 0.24);
  background:
    linear-gradient(145deg, rgba(222, 245, 255, 0.88), rgba(255, 255, 255, 0.72)),
    var(--chip);
}

.mark {
  color: #2788d4;
  font-weight: 900;
}

.subtle {
  color: var(--muted);
  font-size: 12px;
}

.yao-detail {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.yao-detail strong {
  color: var(--soft-ink);
  font-weight: 850;
}

.bars {
  display: grid;
  gap: 5px;
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: #3a3433;
}

.bar.yin {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: transparent;
}

.bar.yin::before,
.bar.yin::after {
  content: "";
  border-radius: 999px;
  background: var(--ink);
}

.moving .bar,
.moving .bar.yin::before,
.moving .bar.yin::after {
  background: #3198ee;
}

.gua-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  min-height: 315px;
}

.gua-wrap > div {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 14px;
  padding: 18px 8px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 254, 249, 0.78), rgba(236, 248, 255, 0.72)),
    var(--sticker);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.gua-wrap h3 {
  font-size: 15px;
}

.hexagram {
  display: grid;
  gap: 10px;
  width: min(150px, 100%);
}

.hexagram .bar {
  height: 14px;
}

.hexagram .bar.yin {
  gap: 20px;
}

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

.reading-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 22px;
  background: rgba(255, 254, 249, 0.74);
  padding: 15px;
  line-height: 1.65;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.reading-item strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 14px;
}

.reading-text {
  white-space: pre-line;
}

.reading-item.final {
  grid-column: 1 / -1;
  border-left-color: var(--accent-2);
  background:
    linear-gradient(145deg, rgba(226, 246, 255, 0.86), rgba(255, 254, 249, 0.84) 58%, rgba(231, 181, 110, 0.1)),
    rgba(255, 255, 255, 0.9);
  font-size: 16px;
}

.followup-log {
  display: grid;
  gap: 10px;
  min-height: 70px;
  margin-bottom: 14px;
  line-height: 1.58;
}

.followup-empty,
.message {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 254, 249, 0.74);
  padding: 12px 13px;
  white-space: pre-line;
}

.followup-empty {
  color: var(--muted);
}

.message.user {
  justify-self: end;
  max-width: min(620px, 88%);
  border-color: rgba(49, 152, 238, 0.28);
  background: linear-gradient(145deg, rgba(221, 245, 255, 0.86), rgba(255, 255, 255, 0.74));
}

.message.answer {
  justify-self: start;
  max-width: min(760px, 94%);
  border-left: 4px solid var(--accent);
}

.message strong {
  display: block;
  margin-bottom: 4px;
}

.followup-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
}

.disclaimer {
  max-width: 900px;
  margin: 0 auto 6px;
  color: #7e8997;
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}

@media (max-width: 980px) {
  .shell,
  .layout,
  .reading-body {
    grid-template-columns: 1fr;
  }

  .reading-item.final {
    grid-column: auto;
  }

  .controls {
    position: static;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 14px;
  }

  .summary {
    display: grid;
    align-items: start;
  }

  .summary-side {
    justify-items: start;
  }

  .grid.two,
  .grid.three,
  .actions,
  .gua-wrap,
  .followup-form {
    grid-template-columns: 1fr;
  }

  .yao {
    grid-template-columns: 34px 56px 54px minmax(0, 1fr);
    gap: 7px;
    font-size: 12px;
  }

  .summary {
    padding: 20px;
  }

  .share-button {
    width: 100%;
  }
}
