/* Shared tokens. Layer order: canvas 0, content 1, navigation 40, overlays 100. */
:root {
    color-scheme: dark;
    --surface: #111827; --surface-raised: #1b2536; --surface-input: #141d2d;
    --text-primary: #e8edf5; --text-secondary: #adb9cd; --line: #39475c;
    --action: #7550c9; --action-hover: #6440b4; --focus: #c4b5fd;
    --error: #fda4af; --accent: #bea6f4; --shadow: 0 18px 50px rgb(5 11 22 / .16);
    --bg-deep: var(--surface); --black-deep: #0e1624; --bg-card-solid: var(--surface-raised);
    --bg-card: var(--surface-raised); --text-main: var(--text-primary); --text-dim: var(--text-secondary);
    --accent-purple: var(--accent); --accent-gold: #e9bc69;
    --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

html { scroll-padding-top: 80px; }
body { background: var(--surface); color: var(--text-primary); font-family: var(--font-ui); }
button, input, select, textarea { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--focus) !important; outline-offset: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent) !important; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: 8px; left: 16px; transform: translateY(-150%); z-index: 200; padding: 12px 20px; background: var(--surface-raised); color: var(--text-primary); border-radius: 8px; }
.skip-link:focus { transform: none; }
.glass-card { background: var(--surface-raised); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: none; }
#hero { min-height: 100dvh; padding: 110px 40px 48px; background: var(--surface); }
#hero header { height: 80px; padding: 0 40px; }
#hero header > a { font-size: 20px; letter-spacing: .14em; }
#hero-canvas { opacity: .76; pointer-events: none; }
.hero-layout { width: min(1160px, 100%); margin: auto; display: grid; grid-template-columns: minmax(0,1fr) minmax(390px,480px); align-items: center; gap: clamp(40px,6vw,96px); text-align: left; }
.hero-copy { min-width: 0; }
.hero-copy h1 { font-size: clamp(32px,3.2vw,46px); line-height: 1.28; letter-spacing: -.025em; margin: 0 0 18px; text-wrap: balance; }
.hero-copy > p { font-family: var(--font-ui); font-size: 16px; line-height: 1.75; max-width: 38ch; margin: 0 0 24px; color: var(--text-secondary); }
.hero-chart-preview { width: min(340px,100%); margin: 0; }
.hero-chart-preview img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 16px; }
.hero-chart-preview figcaption { margin-top: 8px; color: var(--text-secondary); font-size: 12px; }
.birth-card { width: 100%; padding: 28px; border-radius: 16px; }
.birth-card-heading { padding-bottom: 20px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.birth-card-heading h2 { font-family: var(--font-ui); font-size: 21px; font-weight: 650; margin: 0 0 6px; }
.birth-card-heading p { color: var(--text-secondary); font-size: 13px; line-height: 1.7; margin: 0; }
#birth-form { text-align: left; }
#birth-form > :not([hidden]) ~ :not([hidden]) { margin-top: 18px; }
#birth-form label, #birth-form legend { color: var(--text-primary); font-size: 13px; font-weight: 500; }
#birth-form .form-input { min-width: 0; min-height: 48px; border: 1px solid var(--line); background: var(--surface-input); color: var(--text-primary); border-radius: 10px; font-size: 15px; }
#birth-form .form-input::placeholder { color: var(--text-secondary); opacity: 1; }
#birth-form .form-input[aria-invalid="true"] { border-color: var(--error); }
.gender-field { padding: 0; border: 0; display: flex; align-items: center; }
.gender-field legend { float: left; margin: 12px 28px 0 0; }
.gender-toggle { border: 1px solid var(--line); background: var(--surface-input); }
.gender-label { min-height: 40px; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.gender-option input:checked ~ .gender-label { background: var(--action); color: #fafaff; }
.gender-option input:focus-visible ~ .gender-label { outline: 2px solid var(--focus); outline-offset: 3px; }
.field-help { color: var(--text-secondary); font-size: 12px; line-height: 1.65; margin-top: 7px; }
.field-error, .form-error { color: var(--error); font-size: 13px; line-height: 1.6; margin-top: 6px; }
.form-error { padding: 12px; border: 1px solid currentColor; border-radius: 10px; }
.place-feedback { display: flex; gap: 12px; align-items: baseline; }
#place-status { color: var(--text-secondary); font-size: 12px; line-height: 1.7; }
#place-status:empty { display: none; }
.text-action { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; min-height: 44px; font-size: 13px; cursor: pointer; }
#place-suggestions { background: var(--surface-raised); color: var(--text-primary); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; z-index: 30; }
.place-suggestion { padding: 12px 14px; min-height: 44px; font-size: 13px; line-height: 1.65; cursor: pointer; }
.place-suggestion:hover, .place-suggestion[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 15%, var(--surface-raised)); }
#timezone-status { color: var(--text-secondary); border-color: var(--line); background: var(--surface-input); line-height: 1.7; overflow-wrap: anywhere; }
#cta-button { display: flex; width: 100%; min-height: 52px; align-items: center; justify-content: center; border: 0; border-radius: 10px; background: var(--action); color: #fafaff; font-size: 16px; font-weight: 650; white-space: nowrap; cursor: pointer; box-shadow: none; transition: background .16s, transform .16s; }
#cta-button:hover { background: var(--action-hover); transform: none; box-shadow: none; }
#cta-button:active { transform: scale(.985); }
#cta-button:disabled { cursor: wait; opacity: .75; }
.lang-btn { min-width: 32px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
.lang-btn.active { background: var(--action); color: #fafaff; }
.seo-eyebrow, .palace-title-eyebrow, .full-report-start-eyebrow { letter-spacing: .06em; }
.seo-explainer .seo-eyebrow, .seo-trust .seo-eyebrow { display: none; }
#why, #reverse-trace, #reports, .seo-explainer, .seo-trust, .seo-faq { background: var(--surface); }
.seo-explainer-card { background: transparent; border: 0; box-shadow: none; padding-left: 0; padding-right: 0; }
.faq-item { background: var(--surface-raised); border-color: var(--line); box-shadow: none; }
.faq-item summary { color: var(--text-primary); font-family: var(--font-ui); font-size: 15px; }
#footer { background: var(--surface); border-top: 1px solid var(--line); }
/* Chart reading: keep palace geometry, strengthen hierarchy and quiet decoration. */
#global-header { background: var(--surface); border-color: var(--line); }
#dashboard { height: 100dvh; }
#center-stage { background: var(--black-deep); }
.tech-grid { opacity: .2; }
.reactor-ring, #stage-canvas { display: none; }
.palace-card { background: var(--surface-raised); border-color: var(--line); border-radius: 10px; }
.palace-card:hover { border-color: var(--accent); }
.palace-card.selected, .palace-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.palace-title { font-family: var(--font-ui); font-weight: 650; }
.palace-detail-card, .full-report-container, .mobile-timeline-sheet { background: var(--surface-raised); color: var(--text-primary); }
.palace-detail-header, .full-report-header { background: var(--surface-raised); border-color: var(--line); }
#palace-detail-close, #full-report-close, .mobile-sheet-close { min-width: 44px; min-height: 44px; display: inline-flex; justify-content: center; align-items: center; }
.prose-container { font-family: var(--font-ui); font-size: 16px; line-height: 1.85; }
.prose-container p, .prose-container li { line-height: 1.85; }
.prose-container h2, .prose-container h3 { font-family: var(--font-ui); line-height: 1.5; }
.report-part-shell { scroll-margin-top: 110px; }
.full-report-start, .full-report-entry-card { background: var(--surface-input); border-color: var(--line); box-shadow: none; }
.full-report-toc { background: var(--surface-raised); }
.full-report-toc-item.is-active { color: var(--accent); }
.report-export-btn, .report-part-retry { min-height: 40px; }
#palace-detail-content { overscroll-behavior: contain; font-size: 15px; }
@media(min-width:1280px) {
    .palace-detail-overlay { justify-content: flex-end; padding: 16px; background: rgb(5 11 22 / .25); }
    .palace-detail-card { height: calc(100dvh - 32px); max-height: none; max-width: 460px; margin: 0; }
}
@media(max-width:1023px) {
    #hero { padding: 104px 24px 48px; }
    .hero-layout { grid-template-columns: minmax(0,1fr) minmax(330px,1fr); gap: 32px; }
    #hero header { padding: 0 24px; }
    .birth-card { padding: 22px; }
    .hero-copy h1 { font-size: 34px; }
}
@media(max-width:767px) {
    #hero { display: block; min-height: 100dvh; padding: 94px 16px 40px; }
    #hero header { height: 104px; padding: 16px; gap: 12px; flex-wrap: wrap; align-content: center; }
    #hero header > a { font-size: 17px; letter-spacing: .12em; }
    #hero header .lang-switcher { padding: 2px; }
    .lang-btn { padding: 6px 8px; font-size: 11px; }
    .hero-layout { display: flex; flex-direction: column; gap: 24px; width: 100%; }
    .hero-copy { width: 100%; }
    .hero-copy h1 { font-size: clamp(25px,6.6vw,34px); line-height: 1.4; max-width: 24ch; margin-bottom: 10px; }
    .hero-copy > p { font-size: 14px; line-height: 1.7; max-width: 38ch; margin-bottom: 0; }
    .hero-chart-preview { display: none; }
    .birth-card { padding: 22px 18px; }
    .birth-card-heading { margin-bottom: 18px; padding-bottom: 16px; }
    #birth-form .birth-datetime-grid { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 12px; }
    #birth-form input[type="date"], #birth-form input[type="time"] { padding: 10px 8px; font-size: 14px; }
    #birth-form input[type="text"] { font-size: 16px; }
    #global-header > div { padding-left: 12px; padding-right: 12px; }
    #global-header .mobile-chart-title { position: static; transform: none; max-width: 38%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
    .palace-detail-card { height: min(86dvh,820px); max-height: 86dvh; margin: 0; border-radius: 20px 20px 0 0; }
    .palace-detail-overlay { align-items: flex-end; padding: 0; }
    .full-report-header { flex-wrap: wrap; gap: 8px; }
    #full-report-body { padding: 20px 16px; }
    .prose-container { font-size: 16px; }
}
@media(prefers-reduced-motion:reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Guides share the same type and surface vocabulary as the calculator. */
body:has(.guide-header) { --guide-bg: var(--surface); --guide-text: var(--text-primary); --guide-muted: var(--text-secondary); --guide-line: var(--line); --guide-gold: var(--accent); --guide-violet: var(--accent); background: var(--surface); }
.guide-header, .guide-footer { border-color: var(--line); }
.guide-header { min-height: 76px; }
.guide-brand { color: var(--text-primary); }
.guide-index > header > span { display: none; }
.guide-index h1, .article-hero h1 { color: var(--text-primary); }
.guide-index h2, .guide-article h2 { color: var(--text-primary); font-family: var(--font-ui); }
.guide-index > header p, .article-hero p, .article-body p { color: var(--text-secondary); }
.guide-card, .related-card { background: var(--surface-raised); box-shadow: none; }
.guide-card h2 { font-size: 19px; line-height: 1.5; }
.guide-card-featured { grid-column: 1 / -1; border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface-raised)); padding: 28px; }
.guide-card-featured h2 { font-size: 25px; }
.guide-card-featured p { max-width: 65ch; }
.guide-card small { display: block; color: var(--text-secondary); }
.guide-languages a { min-width: 30px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
.chart-cta { background: var(--surface-raised); border-color: var(--accent); box-shadow: none; }
.chart-cta::before { display: none; }
.chart-cta strong { color: var(--text-primary); }
.chart-cta small { color: var(--text-secondary); }
.chart-cta-eyebrow { display: none; }
.chart-cta-action { background: var(--action); color: #fafaff; box-shadow: none; white-space: nowrap; }
.mobile-toc { background: var(--surface-raised); }
.article-body section { scroll-margin-top: 32px; }
@media(max-width:767px) {
    .guide-header { flex-wrap: wrap; gap: 10px; padding: 16px 0; }
    .guide-card-featured { padding: 22px; }
    .guide-card-featured h2 { font-size: 21px; }
    .guide-layout, .guide-index { padding-top: 32px; }
}
.palace-card::before, .palace-card::after { display: none; }
.palace-card:hover { transform: none; background: color-mix(in srgb,var(--accent) 8%,var(--surface-raised)); box-shadow: none; z-index: 2; }
.palace-card.selected { background: color-mix(in srgb,var(--accent) 12%,var(--surface-raised)); }
.palace-card.related { background: color-mix(in srgb,var(--accent) 7%,var(--surface-raised)); border-color: var(--accent); }
.center-info-box { background: none; }
#current-time-display { color: var(--text-secondary); font-family: var(--font-ui); font-size: 13px; line-height: 1.4; letter-spacing: 0; margin-bottom: 8px; }
#palace-focus-label { color: var(--text-primary); font-family: var(--font-ui); font-size: 24px; font-weight: 650; line-height: 1.25; letter-spacing: 0; text-align: center; margin-bottom: 12px; }
.center-info-box.is-palace-preview #palace-focus-label { color: var(--accent-purple); letter-spacing: 0; }
.palace-actions { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.palace-actions button { min-height: 40px; border-radius: 8px; padding: 7px 16px; font-size: 13px; cursor: pointer; }
#read-selected-palace { color: #fafaff; background: var(--action); }
#read-selected-palace:disabled { display: none; }
.legend-container { border: 0; background: transparent; box-shadow: none; padding: 6px 8px; }
.legend-item > span { box-shadow: none; }
.vector-line { filter: none; animation: none !important; }
.palace-star .star-major { font-family: var(--font-ui); text-shadow: none; }
.palace-name, .palace-stem { color: var(--text-secondary); font-size: 11px; }
@media(min-width:1280px) {
    .palace-grid { width: min(100%,calc(100dvh - 200px),720px); max-width: 720px; grid-template-columns: repeat(4,minmax(0,1fr)); grid-template-rows: repeat(4,minmax(0,1fr)); aspect-ratio: 1; gap: 6px; }
    .palace-title { font-size: 14px; }
    .palace-star { font-size: 17px; }
    .palace-star .star-minor { font-size: 12px; line-height: 1.4; }
}
@media(max-width:767px) {
    #current-time-display { font-size: 11px; margin-bottom: 4px; }
    #palace-focus-label { font-size: 18px; margin-bottom: 8px; }
    .palace-actions button { min-height: 36px; font-size: 11px; padding: 5px 9px; }
    .palace-actions { gap: 0; }
    .center-info-box { padding: 6px; }
    .legend-container { gap: 4px 10px; padding: 0; margin-top: 3px; }
    .palace-name, .palace-stem { font-size: 10px; }
}
.full-report-container { background: var(--surface-raised) !important; }
.full-report-start-button, .full-report-entry-button { background: var(--action); color: #fafaff; border-color: var(--action); box-shadow: none; }
.full-report-start-button:hover, .full-report-entry-button:hover { background: var(--action-hover); color: #fafaff; box-shadow: none; }
.full-report-start-chapter-number { color: var(--text-secondary); }
.full-report-start-title { color: var(--text-primary); }
.full-report-start-description, .full-report-start-note { color: var(--text-secondary); }
.report-export-btn { color: var(--text-primary); background: var(--surface-input); border-color: var(--line); }
.report-export-btn:disabled { color: var(--text-secondary); opacity: .65; }
.sidebar { background-image: none; }
.natal-card.active { background: color-mix(in srgb,var(--accent) 8%,var(--surface-raised)); }
.natal-card-symbol, .chart-header-brand-mark, .full-report-nav-icon { color: var(--accent); background: transparent; border-color: var(--line); }
.chart-header-solar { color: var(--text-secondary); }
.full-report-btn { background: var(--surface-raised); border-color: var(--line); color: var(--text-primary); box-shadow: none; }
.full-report-btn:hover { background: var(--surface-input); border-color: var(--accent); box-shadow: none; }
.palace-detail-header { border-bottom: 1px solid var(--line); }
.analysis-error { background: var(--surface-input); padding: 16px; border: 1px solid var(--line); border-radius: 12px; color: var(--text-primary); font-size: 14px; line-height: 1.75; margin-bottom: 20px; }
.analysis-error button { color: var(--accent); min-height: 44px; display: block; text-decoration: underline; text-underline-offset: 3px; }
:root { --color-surface: 17 24 39; --color-raised: 27 37 54; --color-text: 232 237 245; --color-muted: 173 185 205; --color-deep: 14 22 36; --color-line: 57 71 92; --color-accent: 190 166 244; --color-gold: 233 188 105; }
/* Stable solid fills for action controls; accent foreground tokens are not button fills. */
button.bg-purple-accent, .bg-purple-accent.text-white { background: var(--action); color: #fafaff; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { filter: none; opacity: .8; }
@media(max-width:767px) {
    #hero header { position: absolute; inset: 0 0 auto; width: 100%; display: flex; flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: nowrap; height: 70px; padding: 12px 16px; gap: 12px; }
    #hero header > a { flex: none; margin: 0; font-size: 16px; letter-spacing: .06em; white-space: nowrap; }
    #hero .lang-switcher { flex: none; margin: 0; transform: none; }
    #hero .hero-copy { text-align: left; }
}
.insight-terminal { background: var(--surface-raised); border-color: var(--line); box-shadow: none; backdrop-filter: none; }
.example-report-header { padding: 20px 28px; border-bottom: 1px solid var(--line); color: var(--text-secondary); font-size: 13px; }
.insight-terminal .terminal-body { padding: 28px; }
.example-tag { color: var(--accent); font-size: 14px; }
.insight-terminal .suggestion-box { background: var(--surface-input); border-color: var(--accent); }
.insight-tab { border-color: transparent; background: transparent; }
.insight-tab.active { background: var(--surface-raised); border-color: var(--accent) !important; box-shadow: none; }
.insight-tab:hover { transform: none; }
@media (min-width: 768px) and (max-width: 1023px) {
    .insight-navigation { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; overflow: visible; padding-bottom: 0; }
    .insight-tab { width: 100%; min-width: 0; min-height: 64px; padding: 12px; }
    .insight-tab > .flex { margin-bottom: 0; }
}

.ui-icon { display:inline-block; width:1.15em; height:1.15em; background:currentColor; mask:var(--icon) center / contain no-repeat; -webkit-mask:var(--icon) center / contain no-repeat; vertical-align:-.18em; flex-shrink:0; }
.icon-wallet { --icon: url("/assets/icons/wallet.svg"); }
.palace-wallet-icon { display: block; width: 1.15em; height: 1.15em; color: var(--accent-gold); }
.icon-briefcase { --icon: url("/assets/icons/briefcase.svg"); }
.icon-heart { --icon: url("/assets/icons/heart.svg"); }
.icon-shield-check { --icon: url("/assets/icons/shield-check.svg"); }
.icon-pulse { --icon: url("/assets/icons/pulse.svg"); }
.icon-fingerprint { --icon: url("/assets/icons/fingerprint.svg"); }
.icon-sparkle { --icon: url("/assets/icons/sparkle.svg"); }
/* Keep mobile chart controls on the same semantic surfaces as desktop. */
.center-info-box .legend-container { background: transparent; }
.mobile-tab-bar { background: var(--surface-raised); border-color: var(--line); box-shadow: 0 -6px 20px rgb(0 0 0 / .08); }
.structured-stream-status { background: var(--surface-input); color: var(--accent); border-color: var(--line); }
.palace-stream-status { background: none; color: var(--accent); border: 0; box-shadow: none; padding: 0; }

.mobile-timeline-container { background: var(--surface-raised); color: var(--text-primary); border-color: var(--line); }

/* Full report: chapter headings must lead the reading hierarchy. */
.full-report-reader .report-part-header h2 {
    margin: .35rem 0 0;
    color: var(--accent);
    font-size: clamp(1.8rem, 2.6vw, 2rem);
    font-weight: 700;
    line-height: 1.3;
}
.full-report-reader .report-part-content h2 {
    margin: 2.1rem 0 .7rem;
    padding-left: .75rem;
    border-left: 2px solid var(--accent);
    color: var(--text-primary);
    font-size: 1.16rem;
    font-weight: 650;
    line-height: 1.45;
}
.full-report-reader .report-part-content h3 {
    margin: 1.55rem 0 .6rem;
    color: var(--text-secondary);
    font-size: 1.03rem;
    font-weight: 650;
    line-height: 1.5;
}
@media (max-width: 768px) {
    .full-report-reader .report-part-header h2 { font-size: 1.65rem; }
    .full-report-reader .report-part-content h2 { font-size: 1.08rem; }
}
