:root {
  color-scheme: light;
  --paper: #f4f3f1;
  --card: #fff;
  --ink: #202632;
  --navy: #1c293e;
  --muted: #565f70;
  --border: #dbdce0;
  --tint: #edf0f5;
  --cinnabar: #a0352a;
  --cinnabar-tint: #f8ece8;
  --serif: "Noto Serif SC", "Songti SC", SimSun, serif;
  --sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 15px/1.55 var(--sans); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { color: inherit; font: inherit; }
button, summary, select { cursor: pointer; }
button:disabled { cursor: default; }
button, input, textarea, select { min-width: 0; }
button, input, select { min-height: 44px; }
button, .button { text-align: center; }
:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 3px; }
h1, h2, p, dl, dd { margin: 0; }
h1 { font: 700 24px/1.35 var(--serif); }
h2 { font-size: 17px; }
small { font-size: 12px; }
svg { flex: none; vertical-align: middle; }

.page { width: min(100%, 560px); margin-inline: auto; padding: max(22px, env(safe-area-inset-top)) 16px 28px; }
.page-with-nav { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
.page-heading { margin: 6px 0 17px; }
.page-heading p { color: var(--muted); font-size: 14px; margin-top: 7px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; }
.form-stack { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.form-stack :is(label, legend) { font-size: 14px; font-weight: 600; }
.form-stack > label:not(:first-child), .label-actions { margin-top: 6px; }
.form-stack > button.primary { margin-top: 8px; }
.form-stack label small { color: var(--muted); font-weight: 400; margin-left: 4px; }
.label-actions { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label-actions button { align-self: center; min-height: 34px; }
.label-actions svg { width: 15px; height: 15px; margin-right: 4px; }
.input-frame, input:not([type=hidden],[type=radio]), select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #fafafa;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}
.input-frame > input:not([type=hidden],[type=radio]) { background: none; border: 0; padding: 0; }
input::placeholder, textarea::placeholder, .placeholder { color: var(--muted); opacity: 1; }
input[type=datetime-local] { display: block; min-width: 0; appearance: none; }
textarea { min-height: 188px; resize: vertical; }
.hint, .text-action { color: var(--muted); font-size: 13px; }
.bare { background: none; border: 0; padding: 0; }
.text-action { font-weight: 600; }
.accent, .accent-text { color: var(--cinnabar); }
.accent { font-size: 14px; font-weight: 650; white-space: nowrap; }
.primary, .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  border-radius: 11px;
  padding: 9px 15px;
  font-weight: 650;
}
.primary { background: var(--navy); color: white; border: 1px solid var(--navy); }
.secondary { background: var(--card); color: var(--navy); border: 1px solid var(--border); }
.primary:hover { background: #283b57; }
.full { width: 100%; }
.form-error { margin-bottom: 8px; border-radius: 9px; padding: 9px 12px; color: var(--cinnabar); background: var(--cinnabar-tint); }

.login-page { width: min(100%, 420px); padding-top: max(46px, env(safe-area-inset-top)); }
.login-page .form-stack { padding: 18px; }
.phone-input, .code-input, .search-bar { display: flex; align-items: center; gap: 10px; padding-block: 0; }
.phone-input > span { color: var(--muted); border-right: 1px solid var(--border); padding-right: 10px; }
.sms-status:empty { display: none; }

.tab-bar { position: fixed; inset: auto 0 0; background: var(--card); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.tab-inner { display: grid; grid-template-columns: repeat(3, 1fr); width: min(100%, 560px); margin-inline: auto; }
.tab-bar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 60px; color: var(--muted); font-size: 12px; }
.tab-bar a[aria-current] { color: var(--navy); font-weight: 750; }
.tab-bar a[aria-current] svg { color: var(--cinnabar); }
.top-bar { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin: -5px 0 10px; }
.back-link, .inline-action { display: inline-flex; align-items: center; gap: 4px; min-height: 42px; color: var(--navy); font-size: 14px; font-weight: 600; }
.inline-action svg { width: 16px; }
.back-link svg { width: 16px; margin-left: -3px; }

.choice, .section-header, .line-value { display: flex; align-items: center; }
.choice, .section-header { justify-content: space-between; gap: 8px; }
.choice > svg { color: var(--muted); width: 16px; height: 16px; }
.line-card { margin-top: 12px; padding: 7px 14px 14px; }
.section-header { margin-bottom: 2px; }
.input-line { display: grid; grid-template-columns: 37px minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 6px; }
.position { font-weight: 650; font-size: 13px; }
.line-value { gap: 9px; font-size: 14px; }
.back-count { color: var(--navy); font-weight: 750; }
.yao-glyph { display: inline-flex; width: 30px; flex: 0 0 30px; gap: 5px; color: var(--navy); }
.yao-glyph i { height: 3px; background: currentColor; flex: 1; border-radius: 1px; }
.yao-glyph.yang { gap: 0; }
.yao-glyph.yang i { border-radius: 1px 0 0 1px; }
.yao-glyph.yang i + i { border-radius: 0 1px 1px 0; }
.cast-group { margin: 7px 0; padding: 0 3px; font-size: 13px; }
.cast-group summary { display: flex; gap: 6px; align-items: center; min-height: 37px; }
.cast-group summary span { color: var(--muted); margin-left: auto; }
.cast-group summary svg { width: 14px; }
.cast-group select { margin-bottom: 4px; }
summary::-webkit-details-marker { display: none; }
summary { list-style: none; }
details[open] > summary > svg:last-child { transform: rotate(180deg); }

.sheet {
  position: fixed;
  inset: auto 0 0;
  width: min(100%, 560px);
  max-width: 100%;
  max-height: 90dvh;
  margin: 0 auto;
  border: 0;
  border-radius: 18px 18px 0 0;
  padding: 10px 16px max(18px, env(safe-area-inset-bottom));
  background: var(--card);
  color: var(--ink);
}
.sheet::backdrop { background-color: rgb(24 32 47 / 48%); }
body:has(dialog[open]) { overflow: hidden; }
.sheet-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 1px; }
.sheet-position { font-size: 15px; font-weight: 700; }
.icon-button { display: grid; place-items: center; width: 44px; border: 0; border-radius: 8px; background: none; color: var(--muted); }
.sheet-hint { margin-bottom: 8px; }
.sheet-choice {
  display: grid;
  grid-template-columns: 40px 30px auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 53px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: white;
  text-align: left;
}
.sheet-choice:last-child { border-bottom: 0; }
.sheet-choice[aria-pressed=true], .sheet-choice:not(:disabled):hover { background: var(--tint); }
.sheet-choice small { color: var(--muted); text-align: right; }
.method-choice { grid-template-columns: 1fr auto; }
.method-choice:disabled { color: var(--muted); }

.search-bar { background: var(--card); margin-bottom: 12px; }
.search-bar svg { color: var(--muted); }
.search-bar .text-action { white-space: nowrap; }
.archive-group { margin-bottom: 8px; padding-inline: 14px; }
.archive-group summary { display: flex; align-items: center; gap: 8px; min-height: 50px; font-weight: 650; }
.archive-group summary svg { width: 16px; color: var(--muted); }
.count { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 500; }
.group-empty { padding: 0 0 11px; }
.archive-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 3px 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.archive-title { font-weight: 650; overflow-wrap: anywhere; }
.archive-meta { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; color: var(--navy); background: var(--tint); font-size: 12px; line-height: 1.65; white-space: nowrap; }
.status-fulfilled { background: var(--cinnabar-tint); color: var(--cinnabar); }
.status-pending { color: var(--muted); background: var(--paper); }
.empty-note { padding: 20px 0; text-align: center; color: var(--muted); }
.empty-note a { margin-top: 11px; }

.reading-card { padding: 14px; margin-bottom: 12px; }
.reading-heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.reading-heading h1 { font-size: 21px; overflow-wrap: anywhere; }
.reading-heading .badge { margin-top: 3px; }
.reading-method { color: var(--muted); font-size: 13px; margin-top: 6px; }
.chart-meta { display: grid; gap: 5px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13px; }
.chart-meta > div { display: flex; gap: 10px; align-items: baseline; }
.chart-meta dt, .chart-meta small { color: var(--muted); }
.chart-meta dt { flex: 0 0 58px; }
.pillars { display: flex; gap: 9px; flex-wrap: wrap; }
.emphasis { color: var(--cinnabar); font-weight: 700; }
.chart-card { overflow: hidden; }
.chart-table { table-layout: fixed; border-collapse: collapse; width: 100%; }
.chart-table th, .chart-table td { text-align: left; padding: 7px 5px; border-bottom: 1px solid var(--border); }
.chart-table thead { background: var(--tint); color: var(--muted); font-size: 11px; }
.chart-table thead th { vertical-align: top; }
.chart-table thead strong { display: block; font: 700 17px/1.45 var(--serif); color: var(--navy); }
.chart-table thead small { display: block; font-size: 11px; font-weight: 400; }
.chart-table .spirit-column { width: 43px; font-size: 12px; font-weight: 500; padding-left: 7px; }
.spirit-column small { display: block; color: var(--muted); font-size: 10px; }
.changed-column { border-left: 1px solid var(--border); }
.chart-table tbody tr:last-child > * { border-bottom: 0; }
.chart-table tbody th { vertical-align: top; }
.yao-content { display: flex; align-items: center; gap: 4px; min-height: 32px; font-size: 12px; color: var(--navy); white-space: nowrap; }
.yao-content .yao-glyph { width: 24px; flex-basis: 24px; }
.yao-mark { display: flex; gap: 2px; align-items: center; color: var(--navy); font-weight: 750; }
.motion, .hidden-spirit { color: var(--cinnabar); }
.hidden-spirit { display: block; font-size: 11px; padding-bottom: 2px; }
.moving-row { background: #fcf6f3; }
.static-note { padding: 6px 12px 9px; }
.static-chart .yao-content { gap: 10px; }
.record-section { margin-top: 17px; }
.record-section h2 { margin: 0 0 7px 2px; }
.notes-card { padding-inline: 12px; }
.note-item { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 11px 0; }
.note-item + .note-item { border-top: 1px solid var(--border); }
.note-item strong { font-size: 14px; }
.note-item p { margin-top: 2px; font-size: 13px; overflow-wrap: anywhere; white-space: pre-wrap; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.note-action { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.note-action svg { width: 16px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.radio-row { display: flex; gap: 8px; margin-top: 6px; }
.radio-row label { display: flex; min-height: 44px; align-items: center; gap: 6px; padding: 0 9px; border: 1px solid var(--border); border-radius: 8px; flex: 1; cursor: pointer; }
.radio-row input { min-height: 0; margin: 0; accent-color: var(--navy); }
.radio-row label:has(:checked) { background: var(--tint); border-color: var(--navy); }

.account-card, .account-link { display: flex; align-items: center; padding: 12px; gap: 10px; margin-bottom: 11px; }
.account-card h2 { font-size: 14px; }
.account-card p { font-size: 15px; color: var(--muted); }
.account-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; color: var(--navy); background: var(--tint); }
.account-link svg:last-child { margin-left: auto; color: var(--muted); }

@media (min-width: 420px) {
  .page { padding-inline: 22px; }
  .chart-table th, .chart-table td { padding-inline: 9px; }
  .chart-table .spirit-column { width: 52px; padding-left: 11px; }
  .yao-content { gap: 5px; font-size: 13px; }
  .yao-content .yao-glyph { width: 28px; flex-basis: 28px; }
}
@media (max-width: 350px) {
  .page { padding-inline: 12px; }
  .chart-table th, .chart-table td { padding-inline: 4px; }
  .chart-table .spirit-column { width: 36px; padding-left: 4px; }
  .yao-content { gap: 3px; font-size: 11px; }
  .yao-content .yao-glyph { width: 18px; flex-basis: 18px; }
}
