/* Chart and reading surfaces share the type, spacing and controls of the main shell. */
.report-shortcut { display: none; }
.report-shortcut svg { width: 15px; height: 15px; transform: rotate(90deg); }
#main-report h2:focus { outline: none; }
#main-report .question-interpretation .lead:focus { outline: none; }
@media screen and (max-width: 1023px) {
  .reading-overview .report-shortcut { display: inline-flex; padding-inline: 0 8px; }
}
@media screen and (min-width: 1024px) and (max-width: 1199px) {
  .bazi-reading .report-shortcut { display: inline-flex; grid-column: 1 / -1; justify-self: start; padding-inline: 0 8px; }
}

.reading-overview,
.reading-body .report {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--panel-shadow);
}

.reading-overview {
  margin-block-end: 20px;
  padding: clamp(16px, 3vw, 24px);
}

.reading-overview > h1,
.reading-overview > .question {
  margin: 8px 0 18px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: 600 clamp(22px, 2.2vw, 30px) / 1.55 var(--serif);
}

.reading-overview > .question {
  font-size: clamp(18px, 1.7vw, 23px);
}

.reading-overview > .fine {
  margin: -4px 0 16px;
}

.bagua-wheel,
.bazi-wheel {
  position: relative;
  container-type: inline-size;
  isolation: isolate;
  width: 100%;
  max-width: 336px;
  aspect-ratio: 1;
  margin: 20px auto;
  color: var(--primary);
}

.wheel-orbit {
  position: absolute;
  inset: 9%;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: radial-gradient(circle, var(--surface-subtle) 32%, var(--surface) 72%);
  pointer-events: none;
}

.wheel-orbit::before,
.wheel-orbit::after {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px dashed var(--border);
  border-radius: 50%;
}

.wheel-orbit::after {
  inset: 24%;
  border-style: solid;
}

.trigram {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: max-content;
  min-width: 28px;
  padding: 2px 3px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-size: clamp(12px, 4.4cqi, 15px);
  line-height: 1.2;
}

.trigram-0 { left: 50%; top: 10%; }
.trigram-1 { left: 78%; top: 22%; }
.trigram-2 { left: 90%; top: 50%; }
.trigram-3 { left: 78%; top: 78%; }
.trigram-4 { left: 50%; top: 90%; }
.trigram-5 { left: 22%; top: 78%; }
.trigram-6 { left: 10%; top: 50%; }
.trigram-7 { left: 22%; top: 22%; }

.trigram.is-active {
  color: var(--primary);
  font-weight: 650;
}

.trigram small {
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 10px / 1.3 var(--sans);
}

.wheel-bars {
  display: grid;
  width: 48px;
  width: clamp(38px, 18cqi, 62px);
  gap: 3px;
  gap: clamp(2px, 1.3cqi, 4.5px);
}

.wheel-yao {
  position: relative;
  display: flex;
  gap: 16%;
  height: 4px;
  height: clamp(3px, 1.35cqi, 5px);
}

.wheel-yao i {
  flex: 1;
  border-radius: 1px;
  background: currentColor;
}

.trigram .wheel-bars {
  width: 22px;
  width: clamp(18px, 8.2cqi, 27px);
  gap: 2px;
}

.trigram .wheel-yao {
  height: 2.5px;
}

.wheel-yao.is-moving {
  color: var(--accent);
}

.wheel-yao b {
  position: absolute;
  top: 50%;
  left: calc(100% + 4px);
  width: 5px;
  height: 5px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: currentColor;
  font-size: 0;
}

.wheel-yao.is-picked b {
  outline: 1px solid currentColor;
  outline-offset: 2px;
}

.wheel-core,
.day-master,
.wheel-pillar {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  font-family: var(--sans);
  cursor: pointer;
}

.wheel-core,
.day-master {
  top: 50%;
  left: 50%;
  aspect-ratio: 1;
  border-radius: 50%;
}

.wheel-core {
  width: clamp(84px, 46%, 144px);
  gap: 4px;
  gap: clamp(3px, 1.4cqi, 5px);
  box-shadow: 0 2px 9px rgb(32 60 46 / 7%);
}

.wheel-core strong,
.day-master strong,
.wheel-pillar strong {
  font: 600 23px / 1.12 var(--serif);
  font-size: clamp(20px, 8.2cqi, 29px);
}

.wheel-core small,
.day-master small,
.day-master > span,
.wheel-pillar small,
.wheel-pillar > span {
  color: var(--secondary);
  font-size: 12px;
  font-size: clamp(11px, 3.7cqi, 12px);
  line-height: 1.4;
}

.day-master {
  width: clamp(64px, 30%, 92px);
  gap: 2px;
  background: var(--primary-soft);
  border-color: var(--control-border);
}

.wheel-pillar {
  width: clamp(54px, 24%, 76px);
  min-height: 44px;
  gap: 3px;
  padding: 7px 4px;
  border-radius: var(--radius);
}

.wheel-pillar.position-0 { left: 50%; top: 16%; }
.wheel-pillar.position-1 { left: 84%; top: 50%; }
.wheel-pillar.position-2 { left: 50%; top: 84%; }
.wheel-pillar.position-3 { left: 16%; top: 50%; }

.wheel-pillar strong {
  font-size: clamp(20px, 7.5cqi, 25px);
}

.wheel-pillar[aria-pressed="true"],
.luck-cycle[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.wheel-core[aria-pressed="true"],
.day-master[aria-pressed="true"] {
  border-color: var(--primary);
}

.wheel-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-block: 10px 2px;
}

.wheel-tabs button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  min-width: 44px;
  min-height: 44px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--secondary);
  font: 550 13px / 1.45 var(--sans);
}

.wheel-tabs button[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.moving-dot { color: var(--accent); }
.wheel-tabs button[aria-pressed="true"] .moving-dot { color: inherit; }

.wheel-systems {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 16px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-subtle);
}

.wheel-systems button {
  min-width: 64px;
  border-color: transparent;
  background: transparent;
}

.wheel-systems button[aria-pressed="true"] {
  border-color: var(--border);
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgb(32 60 46 / 9%);
}

.candidate-label {
  display: block;
  margin: 0 0 18px;
  color: var(--secondary);
}

.candidate-label select { margin-top: 6px; }

.pillar-detail,
.luck-selected {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-subtle);
}

.pillar-detail h3,
.luck-selected h3,
.luck-segment h3 {
  margin: 0 0 5px;
  color: var(--primary);
  font: 600 17px / 1.6 var(--serif);
}

.pillar-detail p,
.luck-selected p,
.luck-scope p,
.luck-method p {
  margin: 5px 0;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.8;
}

.pillar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-block: 20px;
}

.pillar {
  padding: 10px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.pillar strong {
  display: block;
  margin-block: 5px;
  color: var(--primary);
  font: 600 25px / 1.45 var(--serif);
}

.pillar small { font-size: 12px; }

.luck-panel,
.luck-scope {
  min-width: 0;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.luck-panel {
  position: relative;
  container-type: inline-size;
}

.luck-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.luck-heading h2,
.luck-panel > h2,
.luck-scope h2 {
  margin: 0;
  color: var(--text);
  font: 600 22px / 1.5 var(--serif);
}

.luck-heading > span {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--secondary);
  font-size: 12px;
}

.luck-start {
  margin: 7px 0 0;
  color: var(--secondary);
  font-size: 13px;
  line-height: 1.75;
  font-variant-numeric: tabular-nums;
}

.luck-method,
.source-list details {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.luck-method summary,
.source-list summary {
  width: fit-content;
  max-width: 100%;
  min-height: 44px;
  padding-block: 9px;
  color: var(--primary);
  font-size: 13px;
}

.luck-timeline {
  position: relative;
  display: flex;
  gap: 8px;
  margin-inline: -3px;
  padding: 4px 3px 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--control-border) transparent;
}

.luck-cycle {
  display: flex;
  flex: 0 0 108px;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-height: 116px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.luck-cycle strong {
  color: var(--primary);
  font: 600 25px / 1.25 var(--serif);
}

.luck-cycle small,
.luck-cycle span {
  color: var(--secondary);
  font-size: 11px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.luck-cycle small:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
}

.luck-cycle b {
  padding-inline: 3px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 650;
}

.luck-selected { margin-top: 4px; }
.luck-selected .btn { margin-block: 9px 0; }
.luck-panel .btn { min-height: 44px; }
.luck-panel > .fine { margin-block-end: 0; }

.luck-year-row {
  display: grid;
  grid-template-columns: minmax(72px, .8fr) minmax(0, 1.2fr);
  align-items: stretch;
  gap: 8px;
}

.luck-year-row input,
.luck-year-row .btn {
  min-width: 0;
  width: 100%;
  margin: 0;
}

.luck-year-row .btn { padding-inline: 8px; flex-wrap: wrap; gap: 2px 6px; }
.luck-year-row .credit-tag { margin-inline-start: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }

.luck-segment {
  margin: 12px 0 0;
  padding: 1px 0 1px 12px;
  border-inline-start: 2px solid var(--primary);
}

@container (min-width: 32rem) {
  .luck-selected {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0 16px;
  }

  .luck-selected .btn {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
  }
}

.reading-body .report {
  padding: clamp(16px, 3vw, 36px);
  margin-block: 0 18px;
}

.report > * {
  max-width: 43rem;
  margin-inline: auto;
}

.reading-body .report > h2 {
  margin-block: 0 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font: 600 clamp(24px, 2.3vw, 34px) / 1.48 var(--serif);
  letter-spacing: .015em;
}

.opening-quote,
.quote {
  margin-block: 12px;
  padding: 15px clamp(13px, 2.5vw, 22px);
  border-inline-start: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: #f2e6cb;
}

.opening-quote blockquote,
.quote {
  color: var(--text);
  font: 500 clamp(18px, 1.5vw, 22px) / 1.8 var(--serif);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.opening-quote blockquote { margin: 0; }

.opening-quote figcaption {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 9px;
  color: var(--secondary);
  font-size: 12px;
  line-height: 1.65;
}

.opening-quote figcaption::before {
  content: "";
  flex: 0 0 16px;
  align-self: center;
  border-top: 1px solid var(--accent);
}

.reading-part { margin-block: 24px 0; }

.reading-part:has(> .reading-label:only-child) { display: none; }

.reading-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 11px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.6;
  letter-spacing: .07em;
}

.reading-label::before {
  content: "";
  width: 3px;
  height: 1em;
  border-radius: 2px;
  background: var(--accent);
}

.answer-part {
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.reading-section + .reading-section,
.luck-report-period + .luck-report-period {
  margin-top: 18px;
}

.report h3 {
  margin-block: 16px 6px;
  color: var(--text);
  font: 650 17px / 1.65 var(--sans);
}

.report p,
.report ul {
  margin-block: 6px 10px;
  color: var(--secondary);
  font-size: 16px;
  line-height: 1.9;
}

.report .fine { color: var(--muted); font-size: 13px; }

.reading-section > p { white-space: pre-line; }

.report .lead,
.report .conclusion-summary {
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.75;
}

.report .question-interpretation > p {
  margin: 0 0 .85em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.report .question-interpretation > .lead {
  font: 600 clamp(20px, 1.8vw, 25px) / 1.65 var(--serif);
}

.question-interpretation > p:last-child { margin-bottom: 0; }
.reading-evidence { margin-block-start: 20px; }
.reading-evidence > summary { font-weight: 600; }
.passage-reading + .passage-reading { margin-top: 22px; }
.opening-quote figcaption a { color: inherit; text-underline-offset: 3px; }

.report ul { padding-inline-start: 1.3em; }
.report li + li { margin-top: 5px; }
.report li::marker { color: var(--primary); }

.bazi-portrait > .bazi-scope { margin-block: 0 8px; }
.bazi-portrait > details { padding-block: 0; }
.bazi-evidence > details { margin: 0 0 0 .7rem; padding-block: 0; }
.bazi-evidence > details[open] { padding-bottom: 12px; }
.bazi-judgments > .reading-section + .reading-section { border-top: 1px solid var(--border); }

.citations {
  display: flex;
  flex-wrap: wrap;
  gap: 0 14px;
}

.citations a,
.source-link {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: var(--control-border);
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.citations a {
  display: inline-flex;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 5px 1px;
  font-size: 12px;
  line-height: 1.6;
}

.source-link,
.source-meta,
.details-grid {
  font-size: 12px;
  line-height: 1.8;
}

.source-meta,
.details-grid { color: var(--secondary); }

.details-grid p { margin-block: 5px; }

.reading-body > details,
#followup-form {
  margin-block: 12px;
  padding: 0 clamp(14px, 2vw, 20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.reading-body > details > summary {
  min-height: 46px;
  padding-block: 11px;
  color: var(--primary);
  font-weight: 550;
}

.reading-body > details[open] { padding-bottom: 14px; }

.reading-body > details > summary svg {
  display: inline-block;
  vertical-align: -.2em;
}

#followup-form { padding-block: 16px; }
#followup-form label { margin-top: 0; }
#followup-form .btn { margin-bottom: 0; }

.source-list {
  margin: 4px 0 0;
  padding-inline-start: 1.9em;
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.75;
}

.source-list li {
  margin-block: 3px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  scroll-margin-block: 22px;
  overflow-wrap: anywhere;
}

.source-list li::marker { color: var(--primary); }

.source-list li:focus,
.source-list li:target {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  background: var(--primary-soft);
  color: var(--text);
}

.source-list h3 { margin: 4px 0; font-size: 14px; }
.source-list p { margin: 4px 0 12px; font-size: 14px; }

:is(.wheel-core, .day-master, .wheel-pillar, .wheel-tabs button, .luck-cycle, .citations a):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (hover: hover) {
  :is(.wheel-core, .day-master, .wheel-pillar, .wheel-tabs button, .luck-cycle):hover {
    border-color: var(--primary);
  }

  .wheel-tabs button:not([aria-pressed="true"]):hover,
  .wheel-pillar:not([aria-pressed="true"]):hover,
  .luck-cycle:not([aria-pressed="true"]):hover {
    background: var(--surface-subtle);
  }

  .citations a:hover { text-decoration-color: currentColor; }
}

@media screen and (min-width: 1024px) {
  .reading-overview { margin-bottom: 0; }
}

@media (max-width: 360px) {
  .reading-overview,
  .reading-body .report { padding: 14px; }

  .wheel-tabs button { padding-inline: 8px; }
}

@media print {
  .reading-overview,
  .reading-body .report,
  .reading-body > details {
    margin-block: 0 12pt;
    padding: 0;
    border: 0;
    background: white;
    color: black;
    box-shadow: none;
  }

  .reading-overview {
    position: static;
    max-height: none;
    overflow: visible;
    break-inside: avoid;
  }

  .luck-panel,
  .wheel-tabs,
  .candidate-label,
  #followup-form { display: none; }

  .bagua-wheel { max-width: 180pt; }
  .report > * { max-width: none; }
  .report h2, .report h3, .reading-label { break-after: avoid; }
  .opening-quote, .luck-segment { break-inside: avoid; }
  .report p, .report ul { orphans: 2; widows: 2; }

  .wheel-yao i,
  .wheel-yao b {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .citations a { min-height: 0; padding: 0; }
}
