:root {
  color-scheme: light;
  --paper: #f6f1e7;
  --panel: #fffdf6;
  --quiet: #f1e9da;
  --ink: #251d19;
  --muted: #62594e;
  --line: #dcd0b9;
  --red: #942923;
  --tint: #f4e2db;
  --serif: 'Songti SC', STSong, 'Noto Serif CJK SC', 'Noto Serif SC', SimSun, serif;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
[hidden] { display: none !important; }
a { color: var(--red); text-underline-offset: .2em; }
button, input, select { font: inherit; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
h1, h2, h3, p, dl { margin: 0; }
h1, h2 { font-family: var(--serif); }
.layout { width: min(1260px, 100%); padding: 28px 40px 48px; margin: auto; }
.masthead { border-top: 4px solid var(--red); border-bottom: 1px solid var(--line); padding: 24px 0 25px; margin-bottom: 25px; }
.wordmark { background: var(--red); color: white; font: 700 .9rem var(--serif); padding: .38rem .65rem; text-decoration: none; display: inline-block; }
.masthead h1 { font-size: clamp(2.2rem, 4.8vw, 4.4rem); letter-spacing: .06em; line-height: 1.17; margin: 11px 0 6px; }
.masthead p, .hint { color: var(--muted); }
.hint { font-size: .875rem; }
.workspace { display: grid; grid-template-columns: minmax(235px, 285px) minmax(0, 1fr); gap: 22px; align-items: start; }
.workspace aside { display: grid; gap: 16px; min-width: 0; }
.panel { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); padding: 24px; min-width: 0; }
.panel h2 { font-size: 1.28rem; line-height: 1.35; margin-bottom: .65rem; }
.birth-form { display: grid; gap: 12px; }
.birth-form label { display: block; font-size: .875rem; font-weight: 600; }
.birth-form label span { font-weight: 400; }
input, select { display: block; background: white; color: var(--ink); border: 1px solid #ab9d87; border-radius: 4px; width: 100%; min-width: 0; margin-top: 4px; padding: .49rem .6rem; min-height: 42px; }
#hour-note { display: block; margin-top: 4px; }
.form-actions, .chart-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-actions { margin-top: 3px; }
.form-actions a { font-size: .85rem; }
.primary, .secondary, .danger { display: inline-block; padding: .48rem .75rem; border: 1px solid var(--red); border-radius: 4px; cursor: pointer; font-size: .875rem; font-weight: 650; text-decoration: none; }
.primary, .danger { background: var(--red); color: white; }
.secondary { background: transparent; color: var(--red); }
.primary:hover, .danger:hover { background: #76201b; }
.secondary:hover { background: var(--tint); }
.error { border-left: 3px solid var(--red); background: var(--tint); padding: .5rem .7rem; margin-bottom: .75rem; color: #721e1a; }
.saved ul { padding: 0; margin: 0; list-style: none; }
.saved li + li { border-top: 1px solid var(--line); }
.saved li a { display: grid; gap: .18em; padding: .5em .55em; text-decoration: none; overflow-wrap: anywhere; }
.saved li a:hover, .saved [aria-current] { background: var(--tint); }
.saved li a span { color: var(--muted); font-size: .82rem; }
.empty { min-height: 260px; display: grid; align-content: center; justify-items: start; }
.empty p { margin-bottom: 1rem; color: var(--muted); }
.chart-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.chart-head h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); margin: .15rem 0 .25rem; overflow-wrap: anywhere; }
.chart-head > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.remove { font-size: .875rem; color: var(--red); }
.remove summary { cursor: pointer; padding: .4em; }
.remove form { margin-top: .25em; }
.remove p { margin-bottom: .35em; color: var(--muted); }
.pillars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.pillar { background: var(--quiet); border: 1px solid var(--line); border-radius: 4px; padding: 12px; }
.pillar.day-pillar { background: var(--tint); border-color: #ba7d70; }
.pillar h3 { display: flex; justify-content: space-between; gap: 3px; flex-wrap: wrap; font-size: .9rem; }
.pillar h3 span { font-size: .78rem; color: var(--muted); font-weight: 500; }
.ganzhi { font: 700 clamp(1.9rem, 3.9vw, 3.55rem)/1.1 var(--serif); letter-spacing: .08em; margin: 9px 0 12px; }
.wood { color: #346143; }.fire { color: #942923; }.earth { color: #76541e; }.metal { color: #5c5c61; }.water { color: #305772; }
.pillar dl { font-size: .79rem; }
dl div { display: flex; gap: .55rem; align-items: baseline; }
dl div + div { margin-top: .2rem; }
dt { color: var(--muted); flex: 0 0 auto; }
dd { margin: 0; }
.term-note { font-size: .83rem; color: var(--muted); margin: 10px 0 0; }
.balance, .cycles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.element-row { display: grid; grid-template-columns: 1.1rem minmax(0, 1fr) 5.4rem; align-items: center; gap: .5rem; margin: .27rem 0; }
.element-row > span:first-child { font-weight: 650; }
meter { display: block; width: 100%; height: .72rem; appearance: none; }
meter::-webkit-meter-bar { border: none; background: var(--quiet); }
meter::-webkit-meter-optimum-value { background: currentColor; }
meter::-moz-meter-bar { background: currentColor; }
.value { text-align: right; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.reading { background: var(--quiet); padding: 12px 15px; border-radius: 4px; }
.score { display: flex; gap: .45em; align-items: baseline; flex-wrap: wrap; margin: -.2em 0 .35em; color: var(--muted); font-size: .85rem; }
.score strong { color: var(--red); font: 700 2.5rem/1.1 var(--serif); }
.reading dl { font-size: .86rem; }
.cycles .hint { margin: -.35rem 0 .4rem; }
.cycles table { border-collapse: collapse; width: 100%; text-align: left; font-size: .79rem; }
.cycles th, .cycles td { border-bottom: 1px solid var(--line); padding: .3rem .25rem; }
.cycles thead th { color: var(--muted); font-weight: 600; }
.cycles .current { background: var(--tint); color: #76201b; }
.chart footer { margin-top: 16px; color: var(--muted); font-size: .78rem; }
.offline .layout { max-width: 980px; }
@media (max-width: 960px) {
  .layout { padding-inline: 22px; }
  .workspace { grid-template-columns: minmax(190px, 230px) minmax(0, 1fr); gap: 13px; }
  .panel { padding: 16px; }
  .cycles { grid-template-columns: 1fr; }
}
@media (max-width: 690px) {
  .layout { padding: 16px 14px 28px; }
  .masthead { margin-bottom: 14px; padding: 15px 0; }
  .workspace, .balance { grid-template-columns: 1fr; }
  .workspace aside { gap: 13px; }
  .workspace:has(.chart) .chart { grid-row: 1; }
  .pillars { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ganzhi { font-size: 2.5rem; }
}
@page { size: A4; margin: 11mm; }
@media print {
  body { background: white; print-color-adjust: exact; -webkit-print-color-adjust: exact; font-size: 10pt; }
  .layout { padding: 0; width: 100%; }
  .masthead, .controls, .chart-actions, .empty { display: none; }
  .workspace { display: block; }
  .chart { border: 0; padding: 0; background: white; }
  .chart-head { margin-bottom: 10px; }
  .pillars { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ganzhi { font-size: 28pt; }
  .balance, .cycles { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 12px; padding-top: 10px; }
  .pillar, .balance, .cycles { break-inside: avoid; }
}
