:root {
  color-scheme: light;
  --paper: oklch(96% 0.014 83);
  --paper-deep: oklch(91% 0.025 81);
  --ink: oklch(25% 0.023 78);
  --ink-soft: oklch(47% 0.018 76);
  --forest: oklch(33% 0.07 158);
  --forest-deep: oklch(22% 0.055 158);
  --forest-soft: oklch(48% 0.065 151);
  --rice: oklch(92% 0.034 86);
  --cinnabar: oklch(58% 0.12 38);
  --hairline: color-mix(in oklch, var(--ink) 16%, transparent);
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-pill: 999px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html {
  background: #dedbd4;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #dedbd4;
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible,
textarea:focus-visible,
.chart-scroller:focus-visible {
  outline: 2px solid var(--cinnabar);
  outline-offset: 3px;
}

.app-shell {
  position: relative;
  width: min(100%, 430px);
  min-height: 100svh;
  margin: 0 auto;
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
  overflow: hidden;
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--paper) 96%, white) 0%, var(--paper) 56%, oklch(94% 0.021 84) 100%);
  box-shadow: 0 0 48px rgba(39, 35, 26, 0.16);
}

.topbar {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: color-mix(in oklch, white 76%, var(--paper));
  box-shadow: 0 5px 16px rgba(47, 42, 31, 0.08);
  transition: transform 140ms cubic-bezier(0.2, 0, 0, 1), box-shadow 140ms ease;
}

.icon-button:active,
.book-tab:active,
.section-tabs button:active,
.ask-button:active,
.question-composer > button:active,
.year-tooltip button:active {
  transform: scale(0.96);
}

.icon-button svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.title-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: "Songti SC", STSong, serif;
  font-size: 20px;
  letter-spacing: 0.12em;
}

.title-mark {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: var(--rice);
  background: var(--forest);
  font-size: 13px;
  letter-spacing: 0;
}

.book-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 2px;
  box-shadow: inset 0 -1px var(--hairline);
}

.book-tab {
  position: relative;
  min-height: 58px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: "Songti SC", STSong, serif;
  font-size: 18px;
  transition: transform 140ms cubic-bezier(0.2, 0, 0, 1), color 160ms ease;
}

.book-tab.is-active {
  color: var(--ink);
}

.book-tab.is-active::after {
  position: absolute;
  right: 20%;
  bottom: 0;
  left: 20%;
  height: 2px;
  border-radius: var(--r-pill);
  background: var(--forest);
  content: "";
}

.book-tab span {
  font-family: sans-serif;
  font-size: 11px;
}

main {
  padding-top: 12px;
}

.section-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 18px 18px;
}

.section-tabs button {
  position: relative;
  min-height: 45px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 15px;
  transition: transform 140ms cubic-bezier(0.2, 0, 0, 1), color 160ms ease;
}

.section-tabs button.is-active {
  color: var(--ink);
  font-weight: 650;
}

.section-tabs button.is-active::after {
  position: absolute;
  right: 28%;
  bottom: 1px;
  left: 28%;
  height: 2px;
  border-radius: var(--r-pill);
  background: var(--cinnabar);
  content: "";
}

.fortune-panel {
  position: relative;
  margin: 0 14px;
  overflow: hidden;
  border-radius: var(--r-lg);
  color: color-mix(in oklch, var(--rice) 92%, white);
  background:
    radial-gradient(80% 50% at 82% -4%, rgba(222, 199, 143, 0.42), transparent 70%),
    radial-gradient(70% 44% at 15% 28%, rgba(130, 159, 120, 0.32), transparent 75%),
    linear-gradient(166deg, var(--forest-soft) 0%, var(--forest) 42%, var(--forest-deep) 100%);
  box-shadow: 0 18px 42px rgba(25, 61, 45, 0.2);
}

.fortune-panel::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.06'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  content: "";
}

.fortune-heading {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 24px 20px 18px;
}

.eyebrow {
  margin: 0 0 7px;
  color: color-mix(in oklch, var(--rice) 72%, transparent);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.fortune-heading h1 {
  max-width: 250px;
  margin: 0;
  font-family: "Songti SC", STSong, serif;
  font-size: 24px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.mode-badge {
  display: inline-flex;
  min-width: 48px;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  color: var(--forest-deep);
  background: color-mix(in oklch, var(--rice) 88%, transparent);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(15, 41, 30, 0.14);
}

.chart-stage {
  position: relative;
  z-index: 2;
  height: 356px;
  margin-top: 0;
  overflow: hidden;
  isolation: isolate;
}

.chart-scroller {
  position: absolute;
  inset: 0;
  overflow-x: scroll;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  touch-action: pan-y;
  cursor: grab;
}

.chart-scroller:active {
  cursor: grabbing;
}

.chart-scroller::-webkit-scrollbar {
  display: none;
}

#fortuneChart {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  height: 356px;
  overflow: visible;
  transition: opacity 180ms ease, transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

#fortuneChart.is-switching {
  opacity: 0.38;
  transform: scale(0.994);
}

.dayun-hit-layer {
  position: absolute;
  top: 0;
  left: 0;
  height: 356px;
  pointer-events: none;
}

.dayun-hit {
  position: absolute;
  top: 34px;
  height: 275px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  pointer-events: auto;
}

.score-scale {
  position: absolute;
  z-index: 6;
  top: 54px;
  bottom: 52px;
  left: 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: rgba(245, 235, 209, 0.58);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.score-scale::after {
  position: absolute;
  top: -18px;
  bottom: -9px;
  left: -9px;
  z-index: -1;
  width: 34px;
  background: linear-gradient(90deg, rgba(21, 58, 43, 0.76), rgba(21, 58, 43, 0));
  content: "";
}

.axis-name {
  position: absolute;
  z-index: 7;
  color: rgba(245, 235, 209, 0.72);
  font-size: 9px;
  letter-spacing: 0.05em;
  pointer-events: none;
}

.axis-y {
  top: 12px;
  left: 12px;
}

.axis-x {
  right: 14px;
  bottom: 13px;
}

.year-tooltip {
  position: absolute;
  z-index: 12;
  top: 72px;
  left: 50%;
  display: grid;
  width: 142px;
  gap: 3px;
  padding: 12px;
  border-radius: var(--r-md);
  color: var(--ink);
  background: color-mix(in oklch, var(--rice) 95%, white);
  box-shadow: 0 14px 36px rgba(8, 32, 23, 0.34);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px) scale(0.96);
  transition: opacity 140ms ease, transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.year-tooltip[hidden] {
  display: none;
}

.year-tooltip.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}

.year-tooltip::after {
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 10px;
  height: 10px;
  background: inherit;
  content: "";
  transform: translateX(-50%) rotate(45deg);
}

.year-tooltip p,
.year-tooltip span {
  margin: 0;
  color: var(--ink-soft);
  font-size: 9px;
}

.year-tooltip strong {
  font-family: "Songti SC", STSong, serif;
  font-size: 16px;
}

.year-tooltip button {
  position: relative;
  z-index: 1;
  min-height: 34px;
  margin-top: 6px;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--rice);
  background: var(--forest);
  font-size: 11px;
  font-weight: 650;
  transition: transform 140ms cubic-bezier(0.2, 0, 0, 1);
}

.detail-section {
  margin: 34px 20px 0;
}

.detail-index {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  color: var(--ink-soft);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.detail-index i {
  height: 1px;
  background: var(--hairline);
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.detail-header p {
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-size: 11px;
}

.detail-header h2 {
  margin: 0;
  font-family: "Songti SC", STSong, serif;
  font-size: 30px;
  font-weight: 550;
  letter-spacing: -0.022em;
}

.detail-score {
  display: grid;
  min-width: 62px;
  justify-items: end;
}

.detail-score strong {
  color: var(--cinnabar);
  font-family: "Songti SC", STSong, serif;
  font-size: 32px;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.detail-score span {
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 9px;
}

.detail-summary {
  margin: 18px 0 0;
  color: color-mix(in oklch, var(--ink) 84%, var(--paper));
  font-family: "Songti SC", STSong, serif;
  font-size: 17px;
  line-height: 1.75;
  text-wrap: pretty;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.detail-tags span {
  padding: 7px 10px;
  border-radius: var(--r-pill);
  color: var(--forest);
  background: color-mix(in oklch, var(--forest) 9%, var(--paper));
  font-size: 10px;
}

.ask-button {
  display: flex;
  width: 100%;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding: 13px 14px 13px 18px;
  border: 0;
  border-radius: var(--r-md);
  color: var(--rice);
  background: var(--forest);
  box-shadow: 0 10px 25px rgba(31, 76, 57, 0.2);
  text-align: left;
  transition: transform 140ms cubic-bezier(0.2, 0, 0, 1), box-shadow 140ms ease;
}

.ask-button span {
  display: grid;
  gap: 2px;
}

.ask-button small {
  color: color-mix(in oklch, var(--rice) 64%, transparent);
  font-size: 9px;
}

.ask-button strong {
  font-family: "Songti SC", STSong, serif;
  font-size: 17px;
  font-weight: 500;
}

.ask-button > i {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  color: var(--forest);
  background: var(--rice);
  font-size: 18px;
  font-style: normal;
}

.question-composer {
  display: grid;
  gap: 12px;
  margin: 42px 20px 0;
  padding-top: 26px;
  border-top: 1px solid var(--hairline);
}

.question-composer > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.question-composer p,
.question-composer h2 {
  margin: 0;
}

.question-composer p,
.question-composer label {
  color: var(--ink-soft);
  font-size: 10px;
}

.question-composer h2 {
  font-family: "Songti SC", STSong, serif;
  font-size: 24px;
  font-weight: 500;
}

.question-composer textarea {
  width: 100%;
  resize: none;
  padding: 14px;
  border: 0;
  border-radius: var(--r-md);
  color: var(--ink);
  background: color-mix(in oklch, var(--paper-deep) 70%, white);
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--ink) 10%, transparent);
  font-size: 13px;
  line-height: 1.65;
}

.question-composer > button {
  min-height: 48px;
  border: 0;
  border-radius: var(--r-md);
  color: var(--rice);
  background: var(--cinnabar);
  font-weight: 650;
  transition: transform 140ms cubic-bezier(0.2, 0, 0, 1);
}

.question-composer > button span {
  margin-left: 8px;
}

.toast {
  position: fixed;
  z-index: 40;
  right: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  max-width: calc(min(100vw, 430px) - 40px);
  padding: 11px 16px;
  border-radius: var(--r-pill);
  color: var(--rice);
  background: color-mix(in oklch, var(--ink) 94%, transparent);
  box-shadow: 0 10px 28px rgba(28, 24, 17, 0.24);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 10px) scale(0.96);
  transition: opacity 140ms ease, transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(50%, 0) scale(1);
}

@media (hover: hover) {
  .icon-button:hover {
    box-shadow: 0 7px 20px rgba(47, 42, 31, 0.13);
  }

  .ask-button:hover {
    box-shadow: 0 13px 30px rgba(31, 76, 57, 0.28);
  }
}

@media (max-width: 350px) {
  .fortune-panel {
    margin-inline: 9px;
  }

  .fortune-heading {
    padding-inline: 16px;
  }

  .fortune-heading h1 {
    font-size: 21px;
  }

}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
