:root {
  color-scheme: light;
  --canvas: oklch(0.968 0.004 160);
  --surface: oklch(0.995 0.002 160);
  --surface-subtle: oklch(0.942 0.008 160);
  --surface-strong: oklch(0.906 0.012 160);
  --ink: oklch(0.235 0.018 160);
  --ink-soft: oklch(0.42 0.018 160);
  --muted: oklch(0.49 0.016 160);
  --border: oklch(0.84 0.012 160);
  --border-strong: oklch(0.68 0.025 160);
  --accent: oklch(0.39 0.086 163);
  --accent-hover: oklch(0.33 0.081 163);
  --accent-soft: oklch(0.93 0.026 163);
  --moving: oklch(0.49 0.14 35);
  --moving-soft: oklch(0.94 0.03 35);
  --error: oklch(0.47 0.17 27);
  --error-soft: oklch(0.95 0.024 27);
  --success: oklch(0.41 0.09 152);
  --focus: oklch(0.62 0.105 165);
  --radius: 6px;
  --header-height: 64px;
  --z-sticky: 20;
  --z-backdrop: 40;
  --z-modal: 50;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
  color: var(--ink);
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.55;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: calc(var(--z-modal) + 1);
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--surface);
  transform: translateY(-150%);
  transition: transform 160ms ease-out;
}

.skip-link:focus {
  transform: translateY(0);
}

.product-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  padding: 0 32px;
  border-bottom: 1px solid color-mix(in oklch, var(--border) 82%, transparent);
  background: color-mix(in oklch, var(--canvas) 94%, transparent);
  backdrop-filter: blur(12px);
}

.product-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-seal {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 4px;
  background: var(--ink);
  color: var(--surface);
  font-family: SimSun, "Songti SC", serif;
  font-size: 1.05rem;
  font-weight: 400;
}

.account-button {
  display: inline-flex;
  min-width: 0;
  max-width: 220px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 160ms ease-out, color 160ms ease-out;
}

.account-button span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-button:hover {
  background: var(--surface-strong);
  color: var(--ink);
}

.account-button:active {
  background: var(--border);
}

.account-button:focus-visible,
.product-brand:focus-visible,
.back-button:focus-visible,
.secondary-link:focus-visible,
.skip-link:focus-visible {
  outline: 3px solid color-mix(in oklch, var(--focus) 62%, transparent);
  outline-offset: 2px;
}

.account-state-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
}

.account-button[data-active="true"] .account-state-dot {
  background: var(--success);
}

.entry-main {
  width: min(100% - 40px, 720px);
  margin: 0 auto;
  padding: 72px 0 88px;
}

.entry-intro {
  margin-bottom: 48px;
}

.entry-index {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.83rem;
  font-weight: 700;
}

.entry-intro h1,
.reading-context h1 {
  max-width: 18ch;
  margin: 0;
  font-size: 2.45rem;
  font-weight: 650;
  line-height: 1.18;
  letter-spacing: 0;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.entry-intro > p:last-child {
  max-width: 52ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.casting-form {
  display: flex;
  flex-direction: column;
}

.form-block {
  position: relative;
  min-width: 0;
  margin: 0;
  padding: 24px 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.form-block legend,
.field-title {
  display: block;
  margin-bottom: 12px;
  padding: 0;
  color: var(--ink-soft);
  font-size: 0.87rem;
  font-weight: 650;
}

.gender-block {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
}

.gender-block legend {
  grid-column: 1;
  margin: 0;
}

.gender-block .field-error {
  grid-column: 2;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 300px);
  padding: 3px;
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.segmented-control label {
  position: relative;
  cursor: pointer;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: grid;
  min-height: 38px;
  place-items: center;
  border-radius: 4px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  transition: background 150ms ease-out, color 150ms ease-out;
}

.segmented-control label:hover span {
  color: var(--ink);
}

.segmented-control input:checked + span {
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  box-shadow: 0 1px 4px color-mix(in oklch, var(--ink) 12%, transparent);
}

.segmented-control input:focus-visible + span {
  outline: 3px solid color-mix(in oklch, var(--focus) 58%, transparent);
  outline-offset: 1px;
}

.segmented-control[aria-invalid="true"] {
  outline: 1px solid var(--error);
}

.question-field textarea,
.followup-form textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: 0;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out, background 150ms ease-out;
}

.question-field textarea {
  min-height: 108px;
  padding: 15px 46px 15px 16px;
  line-height: 1.7;
}

.question-field textarea:hover,
.followup-form textarea:hover,
.dialog-field input:hover,
.date-fields input:hover {
  border-color: var(--ink-soft);
}

.question-field textarea:focus,
.followup-form textarea:focus,
.dialog-field input:focus,
.date-fields input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--focus) 22%, transparent);
}

.question-field textarea[aria-invalid="true"],
.date-fields input[aria-invalid="true"] {
  border-color: var(--error);
  background: var(--error-soft);
}

textarea::placeholder,
input::placeholder {
  color: oklch(0.45 0.012 160);
  opacity: 1;
}

.field-counter {
  position: absolute;
  right: 12px;
  bottom: 39px;
  color: var(--muted);
  font-size: 0.72rem;
}

.field-error,
.form-message,
.followup-message {
  min-height: 20px;
  margin: 5px 0 0;
  color: var(--error);
  font-size: 0.78rem;
}

.block-heading,
.section-heading,
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.block-heading {
  margin-bottom: 18px;
}

.block-heading h2,
.section-heading h2,
.dialog-heading h2 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 680;
  line-height: 1.3;
  letter-spacing: 0;
}

.block-heading p,
.section-heading p,
.dialog-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

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

.date-fields label {
  position: relative;
  min-width: 0;
}

.date-fields label > span {
  position: absolute;
  top: 50%;
  right: 12px;
  z-index: 1;
  color: var(--muted);
  font-size: 0.78rem;
  pointer-events: none;
  transform: translateY(-50%);
}

.date-fields input {
  width: 100%;
  height: 48px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: 0;
  font-variant-numeric: tabular-nums;
}

input[type="number"] {
  appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.primary-action,
.current-time-action,
.primary-button,
.secondary-button {
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 650;
  transition: background 160ms ease-out, border-color 160ms ease-out, color 160ms ease-out, transform 120ms ease-out;
}

.primary-action,
.current-time-action {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
}

.primary-action {
  min-height: 52px;
  margin-top: 10px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
}

.primary-action:hover,
.primary-button:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.primary-action:active,
.current-time-action:active,
.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.primary-action:focus-visible,
.current-time-action:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.icon-button:focus-visible {
  outline: 3px solid color-mix(in oklch, var(--focus) 55%, transparent);
  outline-offset: 2px;
}

.primary-action:disabled,
.current-time-action:disabled,
.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.58;
  transform: none;
}

.primary-action.is-loading > span:first-child::after {
  content: "中";
  margin-left: 4px;
}

.action-arrow {
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 160ms ease-out;
}

.primary-action:hover .action-arrow,
.current-time-action:hover .action-arrow {
  transform: translateX(3px);
}

.method-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.method-divider::before,
.method-divider::after {
  width: 100%;
  height: 1px;
  background: var(--border);
  content: "";
}

.current-time-action {
  min-height: 72px;
  padding: 12px 16px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.current-time-action:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.current-time-action strong,
.current-time-action small {
  display: block;
}

.current-time-action strong {
  font-size: 0.94rem;
}

.current-time-action small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.form-message {
  text-align: center;
}

.product-footer {
  display: flex;
  width: min(100% - 40px, 1120px);
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.74rem;
}

.account-dialog {
  width: min(calc(100% - 32px), 440px);
  margin: auto;
  padding: 24px;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 40px color-mix(in oklch, var(--ink) 28%, transparent);
}

.account-dialog::backdrop {
  z-index: var(--z-backdrop);
  background: color-mix(in oklch, var(--ink) 48%, transparent);
}

.account-dialog[open] {
  animation: dialog-in 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 1.3rem;
}

.icon-button:hover {
  background: var(--surface-strong);
  color: var(--ink);
}

.account-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 24px 0;
  padding: 1px;
  background: var(--border);
}

.account-stats div {
  min-width: 0;
  padding: 14px;
  background: var(--surface-subtle);
}

.account-stats dt,
.account-stats dd {
  margin: 0;
}

.account-stats dt {
  color: var(--muted);
  font-size: 0.72rem;
}

.account-stats dd {
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
  text-overflow: ellipsis;
}

.dialog-field {
  display: block;
}

.dialog-field span {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 650;
}

.dialog-field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: 0;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.secondary-button {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--ink-soft);
}

.secondary-button:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.dialog-message {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.dialog-message[data-state="error"] {
  color: var(--error);
}

.dialog-message[data-state="success"] {
  color: var(--success);
}

/* Result page */
.result-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
}

.result-header .account-button {
  justify-self: end;
}

.back-button {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: 0.83rem;
  text-decoration: none;
  transition: background 160ms ease-out, color 160ms ease-out;
}

.back-button:hover {
  background: var(--surface-strong);
  color: var(--ink);
}

.back-button span:first-child {
  font-size: 1.05rem;
}

.result-main {
  width: min(100% - 48px, 1120px);
  margin: 0 auto;
  padding: 56px 0 96px;
}

.reading-context {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  padding-bottom: 44px;
}

.reading-context h1 {
  max-width: 24ch;
  font-size: 2rem;
}

.reading-meta {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.analysis-status {
  flex: 0 0 auto;
  margin-top: 4px;
  padding: 6px 9px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 0.76rem;
  font-weight: 650;
}

.chart-section,
.interpretation-section,
.followup-section {
  padding: 40px 0;
  border-top: 1px solid var(--border);
}

.section-heading {
  margin-bottom: 22px;
}

.hexagram-comparison {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr);
  align-items: center;
}

.hexagram-panel {
  min-width: 0;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.hexagram-panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.hexagram-panel header span {
  color: var(--muted);
  font-size: 0.73rem;
}

.hexagram-panel h3 {
  margin: 3px 0 0;
  font-size: 1.15rem;
  line-height: 1.3;
  letter-spacing: 0;
}

.hexagram-panel small {
  color: var(--muted);
  font-size: 0.73rem;
  white-space: nowrap;
}

.change-direction {
  color: var(--muted);
  font-size: 1.2rem;
  text-align: center;
}

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

.hexagram-line-row {
  display: grid;
  grid-template-columns: 26px minmax(100px, 1fr) 28px;
  align-items: center;
  gap: 12px;
  min-height: 14px;
}

.hexagram-line-row > span:first-child {
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.yao-symbol {
  display: flex;
  width: 100%;
  min-width: 86px;
  height: 12px;
  align-items: center;
  justify-content: space-between;
  gap: 14%;
}

.yao-symbol i {
  display: block;
  width: 43%;
  height: 8px;
  border-radius: 1px;
  background: var(--ink);
}

.yao-symbol.is-yang {
  gap: 0;
}

.yao-symbol.is-yang i:first-child {
  width: 100%;
}

.yao-symbol.is-yang i:last-child {
  display: none;
}

.yao-symbol.is-moving i {
  background: var(--moving);
}

.moving-marker {
  min-height: 18px;
  color: var(--moving);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}

.chart-meta {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  margin: 24px 0;
  padding: 1px;
  background: var(--border);
}

.chart-meta div {
  min-width: 0;
  padding: 13px 12px;
  background: var(--surface-subtle);
}

.chart-meta dt,
.chart-meta dd {
  margin: 0;
}

.chart-meta dt {
  color: var(--muted);
  font-size: 0.7rem;
}

.chart-meta dd {
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 650;
}

.line-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.line-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: fixed;
}

.line-table caption {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.line-table th,
.line-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.line-table th {
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.line-table td {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.line-table tr:last-child td {
  border-bottom: 0;
}

.line-table th:nth-child(1),
.line-table td:nth-child(1) {
  width: 76px;
}

.line-table th:nth-child(2),
.line-table td:nth-child(2) {
  width: 132px;
}

.line-table th:nth-child(4),
.line-table td:nth-child(4) {
  width: 138px;
}

.line-table th:nth-child(5),
.line-table td:nth-child(5) {
  width: 70px;
  text-align: center;
}

.line-table td strong,
.line-table td small {
  display: block;
}

.line-table td strong {
  color: var(--ink);
  font-size: 0.84rem;
}

.line-table td small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.69rem;
}

.line-table .table-symbol .yao-symbol {
  min-width: 90px;
}

.line-table .table-symbol .yao-symbol i {
  height: 6px;
}

.moving-row {
  background: var(--moving-soft);
}

.hidden-spirit {
  color: var(--accent-hover);
  font-weight: 650;
}

.role-tag {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.72rem;
  font-weight: 700;
}

.hidden-note {
  max-width: 75ch;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.65;
}

.interpretation-section {
  padding-top: 48px;
}

.interpretation-heading {
  margin-bottom: 18px;
}

.answer-text {
  max-width: 75ch;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.88;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.followup-section {
  padding-bottom: 0;
}

.followup-log {
  display: grid;
  max-width: 75ch;
  gap: 16px;
  margin-bottom: 18px;
}

.followup-item {
  padding: 16px 18px;
  border-radius: 8px;
  background: var(--surface-subtle);
}

.followup-item h3,
.followup-item p {
  margin: 0;
}

.followup-item h3 {
  font-size: 0.88rem;
  font-weight: 700;
}

.followup-item p {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.75;
  white-space: pre-wrap;
}

.followup-form {
  display: grid;
  max-width: 75ch;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.followup-form textarea {
  min-height: 58px;
  padding: 12px 14px;
}

.followup-form .primary-button {
  min-width: 78px;
  min-height: 58px;
}

.result-loading,
.result-error {
  min-height: 560px;
  padding-top: 20px;
}

.loading-heading {
  display: grid;
  width: min(100%, 540px);
  gap: 12px;
}

.skeleton {
  display: block;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-strong), var(--surface), var(--surface-strong));
  background-size: 200% 100%;
  animation: skeleton-pulse 1.3s linear infinite;
}

.skeleton-short {
  width: 100px;
  height: 14px;
}

.skeleton-title {
  width: min(100%, 380px);
  height: 38px;
}

.skeleton-meta {
  width: min(100%, 280px);
  height: 16px;
}

.loading-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 40px;
  margin-top: 74px;
}

.skeleton-chart {
  height: 310px;
}

.result-loading > p {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

@keyframes skeleton-pulse {
  to { background-position: -200% 0; }
}

.result-error {
  display: grid;
  align-content: center;
  justify-items: start;
}

.error-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  background: var(--error-soft);
  color: var(--error);
  font-weight: 800;
}

.result-error h1 {
  margin: 18px 0 0;
  font-size: 1.55rem;
  letter-spacing: 0;
}

.result-error p {
  max-width: 56ch;
  margin: 10px 0 0;
  color: var(--muted);
}

.error-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

.secondary-link {
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: 0.86rem;
  text-decoration: none;
}

.secondary-link:hover {
  background: var(--surface-strong);
  color: var(--ink);
}

@media (max-width: 820px) {
  .product-header {
    padding: 0 18px;
  }

  .result-main {
    width: min(100% - 32px, 1120px);
    padding-top: 40px;
  }

  .hexagram-comparison {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .change-direction {
    transform: rotate(90deg);
  }

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

  .loading-grid {
    gap: 20px;
  }
}

@media (max-width: 560px) {
  :root {
    --header-height: 58px;
  }

  .product-header {
    padding: 0 12px;
  }

  .entry-main {
    width: min(100% - 32px, 720px);
    padding: 44px 0 64px;
  }

  .entry-intro {
    margin-bottom: 32px;
  }

  .entry-intro h1,
  .reading-context h1 {
    font-size: 1.72rem;
  }

  .entry-intro > p:last-child {
    font-size: 0.88rem;
  }

  .gender-block {
    grid-template-columns: 76px 1fr;
  }

  .segmented-control {
    width: 100%;
  }

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

  .date-fields label:first-child {
    grid-column: span 2;
  }

  .date-fields label:last-child {
    grid-column: span 2;
  }

  .product-footer {
    width: min(100% - 32px, 1120px);
  }

  .result-header {
    grid-template-columns: 1fr auto 1fr;
  }

  .compact-brand > span:last-child,
  .back-button > span:last-child {
    display: none;
  }

  .back-button {
    width: 36px;
    height: 36px;
    justify-content: center;
    padding: 0;
  }

  .result-header .account-button {
    max-width: 112px;
  }

  .result-main {
    padding: 32px 0 72px;
  }

  .reading-context {
    display: block;
    padding-bottom: 32px;
  }

  .analysis-status {
    display: inline-block;
    margin-top: 18px;
  }

  .chart-section,
  .interpretation-section,
  .followup-section {
    padding: 32px 0;
  }

  .hexagram-panel {
    padding: 18px;
  }

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

  .line-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .line-table {
    min-width: 0;
  }

  .line-table thead {
    display: none;
  }

  .line-table tbody {
    display: grid;
    gap: 10px;
  }

  .line-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
  }

  .line-table tr.moving-row {
    background: var(--moving-soft);
  }

  .line-table td,
  .line-table td:nth-child(1),
  .line-table td:nth-child(2),
  .line-table td:nth-child(4),
  .line-table td:nth-child(5) {
    display: block;
    width: auto;
    min-width: 0;
    min-height: 62px;
    padding: 10px 12px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    text-align: left;
  }

  .line-table td:nth-child(even) {
    border-right: 0;
  }

  .line-table td:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .line-table td::before {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.66rem;
    font-weight: 500;
  }

  .line-table .table-symbol .yao-symbol {
    width: 100%;
    min-width: 0;
    max-width: 116px;
  }

  .line-table .role-tag {
    width: 26px;
    height: 26px;
  }

  .answer-text {
    font-size: 0.9rem;
    line-height: 1.82;
  }

  .followup-form {
    grid-template-columns: 1fr;
  }

  .followup-form .primary-button {
    min-height: 46px;
  }

  .loading-grid {
    grid-template-columns: 1fr;
    margin-top: 54px;
  }

  .loading-grid .skeleton-chart:last-child {
    display: none;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .account-dialog {
    padding: 20px;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .product-header {
    background: var(--canvas);
    backdrop-filter: none;
  }
}

/* Compact professional chart */
.result-page {
  background: var(--canvas);
}

.result-main {
  width: min(100% - 40px, 820px);
  padding: 36px 0 88px;
}

.professional-chart {
  padding: 0 0 34px;
  border-top: 0;
}

.reading-facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin: 0 0 24px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--border-strong);
}

.reading-facts > div {
  display: grid;
  min-width: 0;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 8px;
  padding: 5px 8px 5px 0;
}

.reading-facts .fact-wide {
  grid-column: 1 / -1;
}

.reading-facts dt,
.reading-facts dd {
  min-width: 0;
  margin: 0;
}

.reading-facts dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.reading-facts dd {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.professional-board {
  overflow: hidden;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface);
}

.board-column-head {
  display: grid;
  grid-template-columns: 48px minmax(0, 1.08fr) 24px minmax(0, 0.94fr);
  align-items: end;
  min-height: 68px;
  padding: 11px 12px 10px;
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface-subtle);
}

.board-column-head > span:first-child {
  align-self: center;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
}

.board-column-head > div {
  display: grid;
  min-width: 0;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 8px;
  align-items: baseline;
}

.board-column-head small {
  color: var(--muted);
  font-size: 0.68rem;
}

.board-column-head strong {
  overflow: hidden;
  color: var(--accent);
  font-size: 1rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-column-head div > span {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.67rem;
}

.professional-lines {
  display: flex;
  flex-direction: column;
}

.professional-line {
  display: grid;
  grid-template-columns: 48px minmax(0, 1.08fr) 24px minmax(0, 0.94fr);
  align-items: center;
  min-height: 52px;
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
}

.professional-line:last-child {
  border-bottom: 0;
}

.professional-line.is-moving {
  background: var(--moving-soft);
}

.six-god {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 600;
}

.hex-side {
  display: grid;
  min-width: 0;
  align-items: center;
}

.base-side {
  grid-template-columns: minmax(112px, 1fr) 92px 18px 18px;
  gap: 7px;
}

.changed-side {
  grid-template-columns: 92px minmax(108px, 1fr) 18px;
  gap: 8px;
}

.line-copy {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 6px;
  line-height: 1.28;
}

.line-copy strong {
  min-width: 0;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.hidden-inline {
  flex-basis: 100%;
  color: var(--moving);
  font-size: 0.65rem;
  font-weight: 650;
  white-space: nowrap;
}

.board-yao {
  display: flex;
  width: 100%;
  height: 9px;
  align-items: center;
  justify-content: space-between;
  gap: 14%;
}

.board-yao i {
  display: block;
  width: 43%;
  height: 6px;
  border-radius: 1px;
  background: var(--ink);
}

.board-yao.is-yang {
  gap: 0;
}

.board-yao.is-yang i:first-child {
  width: 100%;
}

.board-yao.is-yang i:last-child {
  display: none;
}

.board-yao.is-moving i {
  background: var(--moving);
}

.moving-glyph,
.change-arrow {
  color: var(--moving);
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
}

.board-role {
  min-height: 18px;
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
}

.interpretation-section,
.followup-section {
  padding: 36px 0;
  border-top-color: var(--border-strong);
}

.interpretation-heading {
  margin-bottom: 20px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.4;
  letter-spacing: 0;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.answer-loading {
  display: grid;
  max-width: 70ch;
  gap: 10px;
}

.answer-loading > span {
  display: block;
  width: 100%;
  height: 12px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--surface-strong), var(--surface), var(--surface-strong));
  background-size: 200% 100%;
  animation: skeleton-pulse 1.3s linear infinite;
}

.answer-loading > span:nth-child(2) { width: 92%; }
.answer-loading > span:nth-child(3) { width: 96%; }
.answer-loading > span:nth-child(4) { width: 68%; }

.answer-loading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.answer-error {
  max-width: 70ch;
  padding: 14px 16px;
  background: var(--error-soft);
}

.answer-error p {
  margin: 0 0 10px;
  color: var(--error);
  font-size: 0.82rem;
}

.answer-text {
  display: grid;
  max-width: 70ch;
  gap: 28px;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.9;
  white-space: normal;
}

.answer-section-block {
  min-width: 0;
}

.answer-section-block h3 {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.96rem;
  line-height: 1.4;
  letter-spacing: 0;
}

.answer-section-block p,
.answer-section-block ul {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.answer-section-block p + p,
.answer-section-block p + ul,
.answer-section-block ul + p {
  margin-top: 12px;
}

.answer-section-block ul {
  padding-left: 1.25em;
}

.answer-结论 {
  padding: 16px 18px;
  background: var(--accent-soft);
}

.followup-item {
  border-radius: var(--radius);
}

@media (max-width: 680px) {
  .result-main {
    width: min(100% - 24px, 820px);
    padding-top: 24px;
  }

  .reading-facts {
    grid-template-columns: 1fr;
    margin-bottom: 18px;
    padding-bottom: 13px;
  }

  .reading-facts .fact-wide {
    grid-column: auto;
  }

  .reading-facts > div {
    grid-template-columns: 40px minmax(0, 1fr);
    padding: 3px 0;
  }

  .reading-facts dt {
    font-size: 0.7rem;
  }

  .reading-facts dd {
    font-size: 0.78rem;
  }

  .board-column-head,
  .professional-line {
    grid-template-columns: 32px minmax(0, 1.08fr) 10px minmax(0, 0.92fr);
  }

  .board-column-head {
    min-height: 58px;
    padding: 8px 6px;
  }

  .board-column-head > span:first-child {
    font-size: 0.65rem;
  }

  .board-column-head > div {
    display: block;
  }

  .board-column-head small,
  .board-column-head div > span {
    display: block;
    font-size: 0.6rem;
  }

  .board-column-head strong {
    display: block;
    font-size: 0.78rem;
  }

  .professional-line {
    min-height: 47px;
    padding: 4px 6px;
  }

  .six-god {
    font-size: 0.66rem;
  }

  .base-side {
    grid-template-columns: minmax(68px, 1fr) 52px 11px 13px;
    gap: 3px;
  }

  .changed-side {
    grid-template-columns: 52px minmax(66px, 1fr) 13px;
    gap: 4px;
  }

  .line-copy {
    column-gap: 2px;
  }

  .line-copy strong {
    font-size: 0.68rem;
  }

  .hidden-inline {
    font-size: 0.57rem;
  }

  .board-yao i {
    height: 5px;
  }

  .moving-glyph,
  .change-arrow,
  .board-role {
    font-size: 0.64rem;
  }

  .professional-chart {
    padding-bottom: 28px;
  }

  .interpretation-section,
  .followup-section {
    padding: 28px 0;
  }

  .answer-text {
    gap: 22px;
    font-size: 0.88rem;
    line-height: 1.82;
  }

  .answer-结论 {
    padding: 14px;
  }
}

@media (max-width: 350px) {
  .base-side {
    grid-template-columns: minmax(56px, 1fr) 42px 9px 10px;
    gap: 2px;
  }

  .changed-side {
    grid-template-columns: 42px minmax(54px, 1fr) 10px;
    gap: 2px;
  }

  .line-copy strong {
    font-size: 0.62rem;
  }

  .hidden-inline {
    font-size: 0.53rem;
  }
}
