:root {
  color-scheme: dark;
  --bg: #0b0b0b;
  --panel: #171717;
  --text: #f5f5f7;
  --muted: #ababaf;
  --line: #383839;
  --error: #ffaaa6;
  font: 16px/1.6 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #fafaf8;
    --panel: #fff;
    --text: #202020;
    --muted: #646461;
    --line: #d3d3ce;
    --error: #a12c30;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
#intake { width: min(100% - 40px, 760px); margin: 0 auto; padding-bottom: 64px; }
h1, h2, h3, p, dl, dd, fieldset, legend { margin: 0; }
.intro {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 26px 0 36px;
  border-bottom: 1px solid var(--line);
}
.wordmark { font-size: 18px; font-weight: 650; letter-spacing: -.045em; }
h1 { margin: 44px 0 10px; font-size: clamp(32px, 5.2vw, 48px); line-height: 1.18; font-weight: 550; letter-spacing: -.045em; }
.intro p { max-width: 34em; color: var(--muted); font-size: 15px; }
.dial {
  position: absolute;
  z-index: -1;
  top: -90px;
  right: -40px;
  width: 260px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 50%;
  transform: rotate(-25deg);
}
.dial i, .dial b, .dial::before, .dial::after { position: absolute; border: 1px solid var(--line); border-radius: 50%; }
.dial i { inset: 10%; }
.dial b { inset: 17%; }
.dial::before, .dial::after { content: ''; inset: 41% 2%; }
.dial::after { transform: rotate(90deg); }
form { padding-top: 30px; }
fieldset { min-width: 0; padding: 0; border: 0; }
legend, h2 { padding: 0; font-size: 22px; font-weight: 560; letter-spacing: -.03em; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 24px; margin-top: 20px; }
label { display: block; margin-bottom: 7px; font-weight: 550; font-size: 14px; }
small { margin-left: 4px; color: var(--muted); font-size: 12px; font-weight: 400; }
input, select, button { font: inherit; }
input, select {
  display: block;
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}
input::placeholder, select:invalid { color: var(--muted); opacity: 1; }
input::-webkit-date-and-time-value { text-align: left; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.city-picker { position: relative; }
#city-list {
  position: absolute;
  z-index: 1;
  width: 100%;
  max-height: 215px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 4px 0 0;
  padding: 4px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  list-style: none;
}
#city-list li { padding: 10px; min-height: 44px; line-height: 1.5; border-radius: 3px; cursor: pointer; }
#city-list li:hover, #city-list [aria-selected=true] { background: var(--text); color: var(--bg); }
.hint, .privacy, #form-status { color: var(--muted); font-size: 13px; }
.hint:not(:empty) { margin-top: 6px; }
.intake-notice, .ai-option, .report-privacy { font-size: 14px; }
.intake-notice { margin-top: 10px; color: var(--muted); }
.intake-notice a, .report-privacy { color: inherit; text-underline-offset: 3px; }
.ai-option { display: flex; align-items: center; gap: 9px; margin: 24px 0 0; }
.ai-option input { width: 18px; height: 18px; flex: none; accent-color: var(--text); }
.report-privacy { display: inline-block; margin-top: 20px; }
.privacy { margin: 6px 0 16px; line-height: 1.75; }
#generate { min-height: 46px; padding: 8px 24px; border: 0; border-radius: 6px; background: var(--text); color: var(--bg); font-weight: 580; cursor: pointer; }
button:disabled, fieldset:disabled button { cursor: wait; opacity: .65; }
#form-status:not(:empty) { margin-top: 12px; }
#form-status.error { color: var(--error); }
@media (max-width: 540px) {
  .intro { padding-bottom: 24px; }
  .intro p { max-width: 22em; }
  .dial { top: -98px; right: -62px; width: 200px; }
  h1 { margin-top: 30px; }
  .fields { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  #generate { width: 100%; }
}

/* Match the overseas workspace's profile rail, answer column and chart pane. */
.workspace {
  --canvas: #000;
  --rail: #090909;
  --chart-bg: #101010;
  --divider: #29292b;
  --product-secondary: #b8b8bd;
  --product-tertiary: #93939a;
  display: grid;
  grid-template-columns: clamp(176px, 16.6vw, 226px) minmax(0,1fr) clamp(350px, 32vw, 500px);
  height: 100vh;
  height: 100dvh;
  background: var(--canvas);
}
.workspace[hidden], .workspace [hidden] { display: none; }
.workspace > * { min-width: 0; overflow: auto; }
.sidebar { padding: 14px 10px; border-right: 1px solid var(--divider); background: var(--rail); }
.brand { display: flex; align-items: center; gap: 7px; min-height: 40px; margin: 0 6px; }
.brand img { object-fit: contain; }
.brand .wordmark { font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.brand-system { padding-left: 7px; border-left: 1px solid var(--divider); color: var(--product-tertiary); font-size: 9px; line-height: 1.3; }
.profile { margin-top: 18px; }
.profile h2 { padding: 5px 8px; font-size: 11px; color: var(--product-tertiary); font-weight: 450; }
.profile-card { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 8px; }
.profile-copy { min-width: 0; overflow-wrap: anywhere; }
.profile-copy strong, .profile-copy small { display: block; margin: 0; }
.profile-copy strong { font-weight: 550; font-size: 12px; }
.profile-copy small { margin-top: 3px; color: var(--product-tertiary); font-size: 11px; }
.edit-profile { min-height: 40px; padding: 4px 9px; border: 0; border-radius: 8px; background: transparent; color: var(--product-secondary); font-size: 12px; cursor: pointer; }
.edit-profile:hover { background: var(--panel); color: var(--text); }
.analysis-panel { padding: 30px clamp(24px, 3vw, 52px); }
#report-title { margin: 0; font-size: 23px; font-weight: 560; letter-spacing: -.04em; line-height: 1.4; }
.answer { max-width: 700px; margin: 36px auto 0; }
.answer h2, .chart-head h2 { font-size: 14px; font-weight: 600; }
.answer h2 { color: var(--product-secondary); }
#summary { margin: 12px 0 0; line-height: 1.9; white-space: pre-line; overflow-wrap: anywhere; }
.chart-panel { background: var(--rail); border-left: 1px solid var(--divider); }
.chart-head { padding: 20px 18px 14px; border-bottom: 1px solid var(--divider); }
.chart-tabs { margin-top: 12px; display: flex; gap: 4px; }
.chart-tabs button {
  display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px;
  color: var(--product-secondary); background: transparent; border: 0; border-radius: 9px;
  font-size: 13px; font-weight: 520; cursor: pointer;
}
.chart-tabs button[aria-selected=true], .chart-tabs button:hover { background: var(--panel); color: var(--text); }
.chart-scroll { padding: 24px clamp(12px, 1.4vw, 24px); }
.chart-scroll [role=tabpanel] { min-width: 0; }
.chart-svg { display: block; width: 100%; max-width: 530px; margin: auto; height: auto; fill: var(--text); }
.chart-svg rect { fill: var(--chart-bg); stroke: var(--line); }
.chart-title { font-size: 18px; font-weight: 700; }
.chart-svg .pillar-label { font-size: 13px; }
.chart-svg :is(.stem, .branch) { font-size: 28px; }
.chart-svg :is(.hidden, .ten-god, .meta, .tiny, .house-number) { font-size: 12px; fill: var(--product-tertiary); }
.chart-svg .pillar-label { fill: var(--product-secondary); }
.chart-svg .rasi { font-size: 14px; font-weight: 700; }
.chart-svg .graha { font-size: 12px; fill: #ddd2bd; }
.chart-svg .lagna { font-size: 12px; font-weight: 700; }
.bazi-svg .element-metal { fill: #e9c46a; }
.bazi-svg .element-wood { fill: #66c487; }
.bazi-svg .element-water { fill: #69a7ff; }
.bazi-svg .element-fire { fill: #ff6b6b; }
.bazi-svg .element-earth { fill: #c58a5a; }
#fact-details { margin: 20px 0 0; border-top: 1px solid var(--divider); }
#fact-details > summary { padding: 11px 2px; color: var(--product-secondary); font-size: 13px; cursor: pointer; }
#facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
#facts div { padding: 4px 0; }
#facts dt, #partial-pillars dt { color: var(--product-tertiary); font-size: 12px; }
#facts dd { margin-top: 2px; font-size: 14px; }
#partial-bazi h3 { margin: 0 0 10px; font-size: 15px; font-weight: 550; }
#partial-pillars { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 5px; }
#partial-pillars div { padding: 12px 4px; text-align: center; background: var(--chart-bg); border: 1px solid var(--divider); border-radius: 6px; }
#partial-pillars dd { margin-top: 6px; font-size: 18px; overflow-wrap: anywhere; }
.chart-notice { margin: 12px 0; color: var(--product-secondary); font-size: 13px; line-height: 1.8; }
html[data-theme="light"] .workspace { --canvas: #fafaf8; --rail: #f1f1ee; --chart-bg: #fff; --divider: #d7d7d1; --product-secondary: #646461; --product-tertiary: #656560; }
html[data-theme="light"] .chart-svg .graha { fill: var(--text); }
html[data-theme="light"] .bazi-pillar-card { background: var(--chart-bg); border-color: var(--line); }
html[data-theme="light"] .bazi-presentation { --bazi-line: var(--line); --bazi-ink: var(--text); --bazi-wash: var(--bg); }
html[data-theme="light"] .bazi-svg .element-metal { fill: #806000; }
html[data-theme="light"] .bazi-svg .element-wood { fill: #216e40; }
html[data-theme="light"] .bazi-svg .element-water { fill: #245da6; }
html[data-theme="light"] .bazi-svg .element-fire { fill: #b43838; }
html[data-theme="light"] .bazi-svg .element-earth { fill: #80512c; }
@media (min-width: 761px) and (max-width: 970px) {
  .workspace { grid-template-columns: 155px minmax(0,1fr) minmax(320px,40%); }
  .analysis-panel { padding-inline: 16px; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: minmax(0,1fr); grid-template-rows: auto auto 1fr; height: auto; min-height: 100dvh; }
  .workspace > * { overflow: visible; }
  .sidebar { border: 0; padding: 8px 16px; border-bottom: 1px solid var(--divider); }
  .brand { margin: 0; min-height: 28px; }
  .profile { display: flex; align-items: center; justify-content: space-between; gap: 5px; margin-top: 5px; }
  .profile h2 { display: none; }
  .profile-card { padding: 4px 0; }
  .edit-profile { flex: none; min-height: 44px; padding-inline: 4px; }
  .analysis-panel { padding: 18px 16px; }
  #report-title { font-size: 18px; }
  .answer { margin-top: 10px; }
  .answer h2 { font-size: 12px; }
  #summary { margin-top: 4px; font-size: 14px; line-height: 1.75; }
  .chart-panel { border-left: 0; border-top: 1px solid var(--divider); }
  .chart-head { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 4px; padding: 6px 12px 6px 16px; }
  .chart-tabs { margin: 0; }
  .chart-tabs button { min-height: 44px; }
  .chart-scroll { padding: 16px 10px 24px; }
}
#varga-pager { display: grid; grid-template-columns: 44px minmax(0, 190px) 44px; justify-content: center; align-items: center; gap: 8px; margin-top: 18px; }
#varga-pager[hidden] { display: none; }
#varga-pager button { width: 38px; height: 38px; justify-self: center; padding: 0; border: 0; border-radius: 50%; color: var(--text); background: var(--panel); font-size: 22px; cursor: pointer; }
#varga-pager button:disabled { opacity: .3; cursor: default; }
#varga-select { height: 40px; padding: 0 8px; font: inherit; font-size: 13px; }
@media (max-width: 760px) {
  #varga-pager button { width: 44px; height: 44px; }
  #varga-select { height: 44px; font-size: 16px; }
}
