:root {
  --bg: #fcfcfb;
  --panel: #ffffff;
  --cell: #ffffff;
  --border: #ebe8e4;
  --border-strong: #ddd8d2;
  --focus-border: var(--brand-line);
  --text: #303030;
  --muted: #50544f;
  --dim: #666b66;
  --brand: #ee8a43;
  --brand-dark: #c86a2b;
  --brand-soft: #fff6ee;
  --brand-line: #f3c9a6;
  --heading-accent: #d97a3b;
  --heading-text: #242424;
  --body-text: #3a3a3a;
  --strong-text: #202020;
  --muted-text: #8a8a8a;
  --action: var(--brand);
  --action-hover: var(--brand-dark);
  --action-text: #ffffff;
  --success: #657968;
  --warning: #9b754f;
  --danger: #a64d45;
  --body-mark: #87989c;
  --trio: #c6b9ad;
  --user: #f5eee8;
  /* Legacy aliases kept while the remaining selectors migrate to brand-* names. */
  --accent: var(--brand);
  --accent-dark: var(--brand-dark);
  --accent-soft: var(--brand-soft);
  --accent-line: var(--brand-line);
  --cinnabar: var(--brand);
  --cinnabar-dark: var(--brand-dark);
  --cinnabar-soft: var(--brand-soft);
  --cinnabar-line: var(--brand-line);
  --amber: var(--warning);
  --amber-dark: #7c5c3e;
  --amber-soft: var(--brand-soft);
  --amber-line: var(--brand-line);
  --sky: var(--body-mark);
  --soul: #d4a27b;
  --assistant: transparent;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --font-xs: 11px;
  --font-sm: 12px;
  --font-label: 13px;
  --font-secondary: 14px;
  --font-body: 16px;
  --font-heading: 18px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-sheet: 16px;
  --radius-pill: 22px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: 0.55; }
:focus-visible { outline: 3px solid var(--action); outline-offset: 2px; }
h1:focus-visible, h2:focus-visible { outline: 0; }
.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; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
}

#app { max-width: 480px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

.view { padding: 12px 16px; flex: 1; }
.view.hidden, .hidden { display: none !important; }
.form-group { border: 0; min-width: 0; }
.form-group + .form-group { margin-top: 12px; }
#birth-form > .form-group:first-child { padding-top: 4px; }

.hero {
  text-align: center;
  padding: 8px 8px 7px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}
.hero h1, .topbar-title, .center-cell .logo { font-family: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif; }
.hero h1 { font-size: 24px; letter-spacing: 5px; color: var(--cinnabar-dark); font-weight: 700; }
.hero p { color: var(--muted); margin-top: 3px; font-size: 11px; letter-spacing: 0.08em; }

.panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 4px 4px;
  box-shadow: none;
}

.field-label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 6px; }
.field-label:first-of-type { margin-top: 2px; }

.cal-toggle { display: flex; gap: 8px; margin: 10px 0; }
.cal-btn {
  flex: 1;
  padding: 9px 0;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--cell);
  color: var(--muted);
}
.cal-btn.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px solid var(--brand-line);
  box-shadow: inset 0 0 0 1px var(--brand-line);
  font-weight: 600;
}
.lunar-panel { margin-top: 10px; }
.lunar-row { display: flex; align-items: center; gap: 6px; }
.lunar-select { flex: 1; min-width: 0; }
.lunar-unit { flex-shrink: 0; font-size: 14px; color: var(--muted); }

.date-field {
  width: 100%;
  min-height: 50px;
  padding: 11px 12px;
  font-size: 17px;
  background: var(--cell);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  color-scheme: light;
}
.date-input-wrap {
  position: relative;
  height: 50px;
  background: var(--cell);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.date-input-wrap .date-field {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  opacity: 0.01;
  cursor: pointer;
}
.date-placeholder {
  position: absolute;
  z-index: 1;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-text);
  font-size: 17px;
  pointer-events: none;
}
.date-placeholder.has-value { color: var(--text); }
.date-icon {
  position: absolute;
  z-index: 1;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--dim);
  font-size: 20px;
  line-height: 1;
  pointer-events: none;
}

.hour-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.hour-btn {
  padding: 9px 2px;
  background: var(--cell);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.15s ease;
}
.hour-btn .range { font-size: 11px; color: var(--muted); }
.hour-btn.selected { border: 1px solid var(--brand-line); box-shadow: inset 0 0 0 1px var(--brand-line); color: var(--brand-dark); background: var(--brand-soft); font-weight: 600; }

.unknown-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.unknown-label input { width: 18px; height: 18px; accent-color: var(--amber); }

.advanced-toggle {
  width: 100%;
  min-height: 44px;
  margin-top: 16px;
  padding: 0 4px;
  font-size: 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  cursor: pointer;
  font-weight: 500;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease;
}
.advanced-toggle:hover, .advanced-toggle:focus-visible { background: var(--brand-soft); border-color: var(--brand-line); }
.advanced-mark { color: var(--brand); font-size: 18px; font-weight: 400; line-height: 1; }
.advanced-label { color: var(--text); }
.advanced-toggle .rec { font-size: 11px; color: var(--dim); margin-left: auto; }
.advanced-arrow { color: var(--brand-dark); font-size: 20px; line-height: 1; margin-left: 2px; transition: transform 0.15s ease; }
.advanced-toggle[aria-expanded="true"] .advanced-arrow { transform: rotate(90deg); }
.advanced-hint { font-size: 12px; color: var(--dim); margin: 6px 4px 12px; text-align: left; }
.advanced-panel { margin-top: 12px; padding: 0 0 2px; border-bottom: 1px solid var(--border); }
.select-field {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  background: var(--cell);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.advanced-tip { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

.gender-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gender-btn {
  padding: 14px 0;
  font-size: 17px;
  background: var(--cell);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.gender-btn.selected { border: 1px solid var(--brand-line); box-shadow: inset 0 0 0 1px var(--brand-line); color: var(--brand-dark); background: var(--brand-soft); font-weight: 600; }

.primary-btn {
  width: 100%;
  margin-top: 12px;
  padding: 15px 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  background: var(--action);
  color: var(--action-text);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(213, 111, 45, 0.12);
}
#view-input { padding-bottom: 16px; }
#btn-submit {
  width: 100%;
  margin: 0;
  margin-top: 12px;
  box-shadow: 0 2px 8px rgba(213, 111, 45, 0.12);
}
.primary-btn.small { width: auto; padding: 9px 22px; font-size: 14px; letter-spacing: 1px; margin-top: 16px; }
.primary-btn:disabled { opacity: 0.5; }
.primary-btn:hover, .cta-btn:hover, .send-btn:hover { background: var(--action-hover); }

.form-tip { margin-top: 10px; font-size: 12px; color: var(--danger); text-align: center; min-height: 16px; }
.session-recovery, .session-tab-notice {
  margin-top: 12px;
  padding: 12px;
  color: var(--text);
  background: var(--cinnabar-soft);
  border: 1px solid var(--cinnabar-line);
  border-radius: 8px;
  line-height: 1.6;
  font-size: 13px;
}
.session-tab-notice { position: sticky; top: 8px; z-index: 20; margin: 8px 12px 0; }
.recovery-actions { display: flex; gap: 8px; margin-top: 8px; }
.secondary-btn, .text-btn {
  padding: 8px 12px;
  color: var(--cinnabar-dark);
  background: var(--panel);
  border: 1px solid var(--cinnabar-line);
  border-radius: 8px;
  font-size: 13px;
}
.small-btn { padding: 4px 10px; font-size: 12px; }
.text-btn { display: block; margin: 8px auto 0; border: 0; background: transparent; }
.disclaimer { text-align: center; color: var(--dim); font-size: 12px; line-height: 1.6; margin-top: 18px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 12px; }
.topbar-title { font-size: 17px; font-weight: 700; letter-spacing: 2px; color: var(--text); }
.topbar-spacer { width: 40px; }
.font-control { display: flex; gap: 6px; }
.tool-menu { position: relative; }
.tool-menu summary { list-style: none; display: grid; place-items: center; cursor: pointer; }
.tool-menu summary::-webkit-details-marker { display: none; }
.tool-menu[open] summary { color: var(--brand-dark); border-color: var(--brand-line); background: var(--brand-soft); }
.tool-popover { position: absolute; top: calc(100% + 6px); right: 0; z-index: 10; display: flex; gap: 6px; padding: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(20, 22, 20, 0.08); }
.more-menu { min-width: 132px; padding: 4px; }
.menu-action { width: 100%; padding: 8px 10px; color: var(--text); background: transparent; border: 0; border-radius: 6px; text-align: left; font-size: 13px; white-space: nowrap; }
.menu-action:hover, .menu-action:focus-visible { background: var(--brand-soft); }
.font-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}
.font-btn:active { opacity: 0.7; }
.icon-btn {
  width: 44px;
  height: 44px;
  font-size: 13px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  line-height: 1;
  display: grid;
  place-items: center;
}
.icon-btn svg { width: 21px; height: 21px; display: block; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.banner {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  margin-bottom: 10px;
}

.birth-info {
  font-size: 15px;
  color: var(--text);
  padding: 4px 0 10px;
  margin-bottom: 8px;
  line-height: 1.5;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.birth-primary, .birth-secondary { display: block; }
.birth-primary { font-weight: 600; }
.birth-secondary { color: var(--muted); font-size: 12px; margin-top: 2px; }
.chart-summary {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--muted);
  border-left: 2px solid var(--accent-line);
  padding: 3px 0 3px 10px;
  margin-bottom: 10px;
}
.summary-label {
  color: var(--accent-dark);
  font-size: 11px;
  letter-spacing: 0.12em;
}
.solar-note {
  font-size: 12px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.chart-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.palace-cell {
  background: var(--cell);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 6px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-height: 108px;
  transition: background 0.15s ease;
  text-align: left;
}
.palace-cell.soul { border-color: #d4a27b; background: #fff9f4; }
.palace-cell.body { border-color: #9fbcc6; background: #f3f8fa; border-style: dashed; }
.palace-cell.pos-r1-c1 { grid-row: 1; grid-column: 1; }
.palace-cell.pos-r1-c2 { grid-row: 1; grid-column: 2; }
.palace-cell.pos-r1-c3 { grid-row: 1; grid-column: 3; }
.palace-cell.pos-r1-c4 { grid-row: 1; grid-column: 4; }
.palace-cell.pos-r2-c1 { grid-row: 2; grid-column: 1; }
.palace-cell.pos-r2-c4 { grid-row: 2; grid-column: 4; }
.palace-cell.pos-r3-c1 { grid-row: 3; grid-column: 1; }
.palace-cell.pos-r3-c4 { grid-row: 3; grid-column: 4; }
.palace-cell.pos-r4-c1 { grid-row: 4; grid-column: 1; }
.palace-cell.pos-r4-c2 { grid-row: 4; grid-column: 2; }
.palace-cell.pos-r4-c3 { grid-row: 4; grid-column: 3; }
.palace-cell.pos-r4-c4 { grid-row: 4; grid-column: 4; }
.p-head { display: flex; justify-content: space-between; align-items: baseline; gap: 2px; font-size: 11px; }
.p-name { color: #343632; font-weight: 600; white-space: nowrap; }
.p-ganzhi { color: var(--dim); white-space: nowrap; }
.p-badge { font-size: 9px; padding: 1px 4px; border-radius: 999px; line-height: 1.4; white-space: nowrap; }
.soul-badge { color: var(--brand-dark); background: var(--brand-soft); border: 1px solid var(--brand-line); font-weight: 700; }
.body-badge { color: #557581; background: #e6f2f5; border: 1px solid #c7dfe6; }
.p-majors { margin-top: 5px; line-height: 1.4; }
.p-major { font-size: 12px; font-weight: 700; color: var(--text); display: inline-block; margin-right: 5px; white-space: nowrap; }
.p-major .bri, .p-major .mut { display: inline-block; margin-left: 3px; }
.p-major .bri { font-size: 8px; color: var(--dim); font-weight: 400; }
.p-major .mut { font-size: 9px; color: var(--accent-dark); }
.p-minors, .p-adjs { overflow-wrap: anywhere; }
.p-minors { margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.p-adjs { margin-top: 2px; color: var(--dim); font-size: 8px; line-height: 1.3; }
.p-dec { margin-top: auto; font-size: 11px; color: var(--muted); padding-top: 5px; }
.palace-cell.trio { border-color: var(--trio); background: #f5f5f2; }

.center-cell {
  grid-row: 2 / 4;
  grid-column: 2 / 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--dim);
  font-size: 12px;
  min-height: 172px;
}
.center-cell .logo { font-size: 17px; color: var(--accent-dark); letter-spacing: 3px; font-weight: 700; }
.center-cell .center-mini { font-size: 10px; color: var(--muted); text-align: center; }
.center-cell .center-sihua { font-size: 10px; color: var(--accent-dark); text-align: center; line-height: 1.4; }

.section-title { font-size: 14px; color: var(--muted); margin: 18px 0 8px; letter-spacing: 2px; }
.decadal-table { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--panel); }
.d-row {
  display: grid;
  grid-template-columns: 52px 1fr 52px 1.6fr;
  gap: 6px;
  padding: 9px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.d-row:last-child { border-bottom: none; }
.d-row.current { background: var(--accent-soft); }
.d-row .d-palace { color: #343632; font-weight: 600; }
.d-row .d-range { color: var(--text); }
.d-row .d-ganzhi { color: var(--muted); }
.d-row .d-stars { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.current-label { color: var(--accent-dark); font-weight: 700; }

.cta-bar {
  position: sticky;
  bottom: calc(10px + env(safe-area-inset-bottom));
  margin-top: 18px;
  padding: 12px 0 8px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.cta-btn {
  width: 100%;
  padding: 15px 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  background: var(--action);
  color: var(--action-text);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(213, 111, 45, 0.12);
}

#view-chat { display: flex; flex-direction: column; padding: 10px 12px 0; max-width: 480px; height: 100vh; height: 100dvh; }
#view-chat .chat-messages { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 0 12px; }
.chat-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); position: sticky; bottom: 0; background: var(--bg); }
.chat-input-wrap { flex: 1; min-width: 0; position: relative; border-radius: var(--radius-pill); transition: box-shadow 0.15s ease; }
.chat-input-wrap:focus-within { box-shadow: none; }
.chat-input {
  width: 100%;
  min-width: 0;
  padding: 12px 64px 12px 14px;
  font-size: 16px; /* ≥16px，避免 iOS 聚焦输入时自动放大页面 */
  line-height: 1.5;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  resize: none;
  overflow-y: auto;
  max-height: 140px;
}
.chat-input:focus, .chat-input:focus-visible { border-color: var(--focus-border); outline: none; box-shadow: none; }
.chat-input-meta { position: absolute; right: 10px; bottom: 7px; min-height: 0; margin: 0; color: var(--dim); font-size: 10px; line-height: 1; text-align: right; pointer-events: none; }
.chat-input-meta.empty { visibility: hidden; }
.chat-input-meta.near-limit { color: var(--warning); }
.chat-input-meta.error { color: var(--danger); }
.send-btn {
  flex-shrink: 0;
  height: 50px;
  padding: 0 18px;
  font-size: 15px;
  background: var(--action);
  color: var(--action-text);
  border: none;
  border-radius: var(--radius-pill);
  font-weight: 700;
  cursor: pointer;
}

.msg { margin-bottom: 12px; display: flex; flex-direction: column; }
.msg.user { align-items: flex-end; }
.msg.assistant { align-items: stretch; padding: 0 0 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.assistant-label { color: var(--accent-dark); font-size: 12px; letter-spacing: 0.08em; margin-bottom: 8px; }
html.chat-font-13 { --chat-font-size: 13px; }
html.chat-font-14 { --chat-font-size: 14px; }
html.chat-font-15 { --chat-font-size: 15px; }
html.chat-font-16 { --chat-font-size: 16px; }
html.chat-font-17 { --chat-font-size: 17px; }
html.chat-font-18 { --chat-font-size: 18px; }
html.chat-font-19 { --chat-font-size: 19px; }

.bubble {
  max-width: 88%;
  min-width: 0;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: var(--chat-font-size, 17px);
  line-height: 1.74;
  white-space: pre-wrap;
  word-break: break-word;
  scroll-margin-top: 64px;
}
.msg.user .bubble { background: var(--user); border-bottom-right-radius: 4px; }
.msg.assistant .bubble { max-width: 100%; padding: 0; background: transparent; border: 0; border-radius: 0; white-space: normal; color: var(--body-text); line-height: 1.82; }
.msg.assistant.streaming { border-bottom-color: var(--border-strong); }
.bubble h3 { font-family: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif; font-size: calc(var(--chat-font-size, 17px) + 1px); color: var(--heading-accent); margin: 32px 0 12px; line-height: 1.5; font-weight: 600; letter-spacing: 0.03em; }
.bubble h3:first-child { margin-top: 0; }
.bubble h4 { margin: 22px 0 8px; font-family: inherit; font-size: var(--chat-font-size, 17px); line-height: 1.5; font-weight: 600; color: var(--heading-text); letter-spacing: 0; }
.bubble h4.age-section-title { margin: 22px 0 8px; color: var(--body-text); font-weight: 400; }
.bubble h4.age-section-title:first-child { margin-top: 0; }
.age-range { color: var(--heading-accent); font-weight: 600; }
.bubble p { margin: 15px 0; }
.bubble ol, .bubble ul { margin: 10px 0 10px 22px; padding: 0; }
.bubble li { margin: 6px 0; line-height: 1.78; }
.bubble strong { color: var(--heading-accent); font-weight: 600; }
.bubble em { color: var(--muted); }
.bubble code { background: var(--amber-soft); border: 1px solid var(--amber-line); border-radius: 5px; padding: 1px 4px; font-size: 12px; }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.reply-ending { color: var(--dim); font-size: var(--font-xs); letter-spacing: 0.12em; text-align: right; margin-top: 14px; }
.quick-prompts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.quick-prompts-label { color: var(--dim); font-size: var(--font-xs); margin-right: 2px; }
.quick-prompt { padding: 7px 10px; color: var(--brand-dark); background: var(--panel); border: 1px solid var(--brand-line); border-radius: var(--radius-md); font-size: var(--font-sm); line-height: 1.4; }
.quick-prompt:hover, .quick-prompt:focus-visible { color: var(--brand-dark); background: var(--brand-soft); border-color: var(--brand-line); }
.typing {
  color: var(--dim);
  font-size: 12px;
  padding: 8px 0 0;
}
.retry-action, .chat-error { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; color: var(--danger); font-size: 12px; }
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 22, 20, 0.28); }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  padding: 24px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 -8px 30px rgba(20, 22, 20, 0.08);
}
.modal-card::before { content: ""; position: absolute; top: 9px; left: 50%; width: 38px; height: 4px; border-radius: 999px; background: var(--border); transform: translateX(-50%); }
.modal-card h3 { color: var(--text); margin-bottom: 12px; font-family: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif; }
.m-position { color: var(--cinnabar-dark); font-size: 12px; margin-bottom: 12px; }
.m-section { display: grid; grid-template-columns: 42px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px; line-height: 1.7; }
.m-label { color: var(--muted); }
.m-value { color: var(--text); }
.m-value .star { color: var(--text); font-weight: 700; margin-right: 5px; }
.m-value .mut { color: var(--cinnabar); margin-right: 5px; }
.m-value .bri { color: var(--dim); }
.m-trio-note { color: var(--dim); font-size: 12px; line-height: 1.6; margin-top: 12px; }

.feedback-row { display: flex; gap: 8px; margin-top: 6px; }
.feedback-label { font-size: 12px; color: var(--muted); align-self: center; }
.fb-btn {
  font-size: 12px;
  padding: 4px 12px;
  background: var(--cell);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
}
.fb-btn.active { color: var(--cinnabar-dark); border-color: var(--cinnabar-line); }


@media (max-width: 479px) {
  #view-input .advanced-hint { display: none; }
  #view-input .disclaimer { margin: 12px 4px 16px; font-size: 11px; line-height: 1.55; }
}

@media (max-width: 360px) {
  .view { padding-left: 10px; padding-right: 10px; }
  .palace-cell { min-height: 105px; padding: 6px 5px; }
  .p-major { font-size: 12px; }
  .d-row { grid-template-columns: 44px 1fr 44px 1.2fr; gap: 4px; padding-left: 7px; padding-right: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

@media (min-width: 480px) {
  .view { padding: 20px; }
  .hero { padding: 18px 8px 16px; margin-bottom: 8px; }
  .hero h1 { font-size: 30px; letter-spacing: 7px; }
  .hero p { margin-top: 6px; font-size: 13px; }
  #view-input { padding-bottom: 20px; }
  #btn-submit { position: static; width: 100%; margin-top: 20px; box-shadow: 0 2px 8px rgba(213, 111, 45, 0.12); }
}
