:root {
  color-scheme: light;
  --bg-a: #fff8fb;
  --bg-b: #f7f1ff;
  --bg-c: #eefbf7;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-solid: #fffefd;
  --soft: rgba(255, 255, 255, 0.68);
  --text: #3b2948;
  --muted: rgba(59, 41, 72, 0.62);
  --faint: rgba(59, 41, 72, 0.42);
  --line: rgba(176, 106, 179, 0.14);
  --line-strong: rgba(176, 106, 179, 0.24);
  --pink: #f0a7c6;
  --violet: #b79df2;
  --mint: #9edfc7;
  --gold: #d9b67e;
  --danger: #b54862;
  --shadow: 0 24px 70px rgba(126, 87, 194, 0.12);
  --shadow-soft: 0 12px 30px rgba(126, 87, 194, 0.075);
  --wood: #2f9a68;
  --fire: #c45748;
  --earth: #ad7a32;
  --metal: #72798a;
  --water: #2e79ad;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 6%, rgba(255, 214, 231, .72), transparent 30%),
    radial-gradient(circle at 86% 4%, rgba(220, 214, 255, .7), transparent 31%),
    radial-gradient(circle at 56% 100%, rgba(204, 245, 232, .62), transparent 34%),
    linear-gradient(145deg, var(--bg-a) 0%, var(--bg-b) 48%, var(--bg-c) 100%);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; padding: 18px; }
.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.78), rgba(255,255,255,.58));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 2px 12px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 46px; height: 46px; border-radius: 18px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--pink), var(--violet)); font-weight: 900; box-shadow: 0 14px 28px rgba(176,106,179,.22); }
.brand h1, .brand p, h2, h3, h4, p { margin: 0; }
.brand h1 { font-size: 18px; letter-spacing: -.03em; }
.brand p { color: var(--muted); font-size: 13px; margin-top: 2px; }

.search-box input, label input, label select, textarea, .picker-cell select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px 13px;
  background: rgba(255,255,255,.72);
  color: var(--text);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.search-box input:focus, label input:focus, label select:focus, textarea:focus, .picker-cell select:focus { border-color: var(--line-strong); box-shadow: 0 0 0 4px rgba(176,106,179,.1); background: #fff; }
textarea { margin-top: 12px; resize: vertical; min-height: 96px; line-height: 1.65; }
select option { background: white; color: var(--text); }

.sidebar-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sidebar-stats div { min-width: 0; border: 1px solid rgba(176,106,179,.12); border-radius: 18px; padding: 10px 11px; background: rgba(255,255,255,.58); box-shadow: 0 8px 18px rgba(126,87,194,.045); }
.sidebar-stats div.wide { grid-column: 1 / -1; }
.sidebar-stats strong { display: block; color: #7e578f; font-size: 18px; line-height: 1.18; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-stats span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 800; }

.customer-list { display: flex; flex-direction: column; gap: 9px; overflow: auto; padding-right: 2px; }
.customer-item { text-align: left; padding: 13px; border-radius: 20px; background: rgba(255,255,255,.58); border: 1px solid rgba(176,106,179,.1); color: var(--text); box-shadow: 0 8px 18px rgba(126,87,194,.045); transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease; }
.customer-item:hover { background: rgba(255,255,255,.82); transform: translateY(-1px); box-shadow: 0 12px 24px rgba(126,87,194,.07); }
.customer-item.active { border-color: rgba(176,106,179,.32); background: linear-gradient(135deg, rgba(255,248,251,.92), rgba(244,232,255,.72)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.62), 0 12px 26px rgba(126,87,194,.08); }
.customer-item strong { display: block; margin-bottom: 5px; font-size: 15px; letter-spacing: -.01em; }
.customer-item span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.customer-item small { display: inline-flex; margin-top: 8px; color: #8d5a95; background: rgba(176,106,179,.1); border-radius: 999px; padding: 5px 8px; font-size: 12px; font-weight: 850; }
.birthday-dot { float: right; font-style: normal; font-size: 11px; color: #fff; background: linear-gradient(135deg, var(--pink), var(--violet)); border-radius: 999px; padding: 3px 8px; }

.main-panel { min-width: 0; overflow: auto; }
.empty-state, .detail-view { max-width: 1400px; margin: 0 auto; }
.empty-state { min-height: calc(100vh - 36px); display: grid; place-items: center; text-align: center; }
.empty-state > div { max-width: 590px; border: 1px solid var(--line); border-radius: 32px; padding: 38px; background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.empty-state h2 { font-size: clamp(30px, 5vw, 48px); letter-spacing: -.05em; margin-bottom: 10px; }
.hidden { display: none !important; }
.muted, .section-title span { color: var(--muted); }

.detail-header, .tool-section, .result-panel { border: 1px solid var(--line); border-radius: 28px; background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.detail-header { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 16px; padding: 22px 24px; }
.detail-header h2 { font-size: clamp(28px, 4vw, 44px); letter-spacing: -.05em; margin-bottom: 6px; }
.eyebrow { color: rgba(176, 106, 179, .78); font-size: 11px; font-weight: 900; letter-spacing: .2em; text-transform: uppercase; margin-bottom: 6px; }
.birthday-badge { min-width: 168px; border: 1px solid rgba(176,106,179,.13); border-radius: 20px; padding: 12px 14px; background: linear-gradient(135deg, rgba(255,214,231,.58), rgba(220,214,255,.5)); }
.birthday-badge strong { display: block; font-size: 17px; letter-spacing: -.02em; }
.birthday-badge span { color: var(--muted); font-size: 12px; }
.header-actions, .action-row, .modal-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }

.workspace-grid { display: grid; grid-template-columns: minmax(560px, 1.12fr) minmax(420px, .88fr); gap: 18px; align-items: start; }
.left-stack, .right-stack { min-width: 0; }
.tool-section, .result-panel { padding: 18px; margin-top: 16px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title h3 { font-size: 18px; letter-spacing: -.03em; }

.system-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(126px, 1fr)); gap: 10px; }
.preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mingli-options { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.compact-title { margin-bottom: 10px; }
.compact-title h3 { font-size: 15px; }
.check-card { display: flex; align-items: center; gap: 9px; min-height: 48px; border: 1px solid rgba(176,106,179,.12); background: rgba(255,255,255,.58); border-radius: 16px; padding: 10px 12px; color: var(--text); line-height: 1.25; transition: background .16s ease, border-color .16s ease, transform .16s ease; }
.check-card:hover { transform: translateY(-1px); background: rgba(255,255,255,.82); }
.check-card:has(input:checked) { border-color: rgba(176,106,179,.28); background: rgba(244,232,255,.68); font-weight: 800; }
.check-card input { width: 17px; height: 17px; accent-color: #b06ab3; }
.preset-button { min-height: 52px; border-radius: 17px; background: rgba(255,255,255,.58); border: 1px solid rgba(176,106,179,.12); color: var(--text); padding: 10px 13px; text-align: left; line-height: 1.35; transition: transform .16s ease, background .16s ease, border-color .16s ease; }
.preset-button:hover { background: rgba(255,255,255,.84); transform: translateY(-1px); }
.preset-button.active { border-color: transparent; background: linear-gradient(135deg, rgba(240,167,198,.88), rgba(183,157,242,.88)); color: #fff; font-weight: 850; box-shadow: 0 14px 28px rgba(176,106,179,.18); }

.primary-button, .secondary-button, .danger-button, .ghost-button { min-height: 42px; padding: 0 16px; border-radius: 999px; font-weight: 850; transition: transform .16s ease, box-shadow .16s ease, background .16s ease; }
.primary-button:hover, .secondary-button:hover, .danger-button:hover, .ghost-button:hover { transform: translateY(-1px); }
.primary-button { color: #4e3922; background: linear-gradient(135deg, #ecd595, #f5e8bf, #d9b67e); box-shadow: 0 18px 35px rgba(210,179,118,.28); }
.secondary-button { color: #5a3c67; background: rgba(255,255,255,.64); border: 1px solid rgba(176,106,179,.14); }
.danger-button { color: var(--danger); background: rgba(255,228,230,.72); border: 1px solid rgba(181,72,98,.12); }
.ghost-button { background: transparent; color: var(--muted); }
.sidebar .primary-button { width: 100%; color: #fff; background: linear-gradient(135deg, var(--pink), var(--violet)); box-shadow: 0 16px 30px rgba(176,106,179,.2); }

.result-content, .answer-content { line-height: 1.72; }
.result-content { white-space: normal; }
.answer-content { white-space: pre-wrap; }
.answer-panel { min-height: 430px; }
.answer-content { min-height: 340px; border: 1px solid rgba(176,106,179,.12); border-radius: 22px; padding: 14px; background: rgba(255,255,255,.56); }
.answer-empty { min-height: 312px; display: grid; align-content: center; gap: 10px; white-space: normal; }
.answer-empty strong { color: var(--text); font-size: 18px; letter-spacing: -.02em; }
.answer-empty span { color: var(--muted); line-height: 1.7; }
.answer-content.streaming::after { content: ''; display: inline-block; width: 7px; height: 1.1em; margin-left: 3px; background: #b06ab3; vertical-align: -2px; animation: blink .9s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.ai-answer-card { border: 1px solid rgba(176,106,179,.1); border-radius: 20px; padding: 12px 13px; margin: 0 0 10px; background: rgba(255,255,255,.66); box-shadow: 0 8px 18px rgba(126,87,194,.05); white-space: pre-wrap; }
.ai-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.ai-answer-card strong { display: block; color: #b06ab3; font-size: 14px; }
.copy-line-button { min-height: 28px; border-radius: 999px; padding: 0 10px; color: #3f7f59; background: rgba(236,249,240,.9); border: 1px solid rgba(83,150,111,.18); font-size: 12px; font-weight: 850; }
.ai-answer-card.talk { background: rgba(236,249,240,.72); border-color: rgba(83,150,111,.16); }
.ai-answer-card.talk strong { color: #3f7f59; }
.ai-answer-card.notice { background: rgba(255,247,223,.74); border-color: rgba(217,182,126,.22); }
.ai-answer-card.notice strong { color: #9b6b2b; }

.chart-empty { display: grid; gap: 10px; align-content: center; min-height: 172px; border: 1px dashed rgba(176,106,179,.2); border-radius: 22px; padding: 18px; color: var(--muted); background: rgba(255,255,255,.42); }
.chart-empty strong { color: var(--text); font-size: 18px; letter-spacing: -.02em; }
.chart-empty span { line-height: 1.6; }
.chart-card { border: 1px solid rgba(176,106,179,.1); border-radius: 18px; padding: 12px 13px; margin-bottom: 10px; background: rgba(255,255,255,.62); box-shadow: 0 8px 18px rgba(126,87,194,.04); }
.chart-card strong { display: block; margin-bottom: 6px; color: #7e578f; }
.notice-area { margin-top: 14px; }
.notice { padding: 10px 12px; border-radius: 18px; background: rgba(255,247,223,.82); border: 1px solid rgba(217,182,126,.24); color: #715126; margin-bottom: 8px; line-height: 1.5; }
.history-list { display: grid; gap: 10px; }
.history-item { padding: 12px; border: 1px solid rgba(176,106,179,.1); border-radius: 20px; background: rgba(255,255,255,.6); }
.history-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.history-head strong { color: var(--text); }
.history-head span { flex: none; color: var(--faint); font-size: 12px; }
.history-item pre { white-space: pre-wrap; margin: 8px 0 0; color: var(--muted); max-height: 210px; overflow: auto; }

.bazi-chart { white-space: normal; background: linear-gradient(180deg, rgba(255,255,255,.82), rgba(255,255,255,.66)); border: 1px solid rgba(176,106,179,.12); border-radius: 24px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow-soft); }
.bazi-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.bazi-head h4 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.bazi-day-master { border: 1px solid rgba(176,106,179,.12); background: rgba(244,232,255,.72); color: #7e578f; border-radius: 999px; padding: 7px 11px; font-weight: 850; }
.bazi-brief { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.bazi-board-wrap { overflow-x: auto; padding-bottom: 4px; }
.bazi-board { min-width: 520px; display: grid; grid-template-columns: 64px repeat(var(--cols), minmax(92px, 1fr)); border: 1px solid rgba(176,106,179,.12); border-radius: 20px; overflow: hidden; background: #fff; }
.bazi-row-labels, .bazi-col { display: grid; grid-template-rows: 32px 34px 58px 32px 58px 32px 66px; }
.bazi-row-labels span, .bazi-col > div, .bazi-col > span { display: grid; place-items: center; border-bottom: 1px solid rgba(176,106,179,.1); background: rgba(255,255,255,.84); padding: 4px; text-align: center; }
.bazi-row-labels span { background: rgba(244,232,255,.56); color: var(--muted); font-size: 12px; font-weight: 850; }
.bazi-col > * { border-left: 1px solid rgba(176,106,179,.1); }
.bazi-col > :last-child, .bazi-row-labels > :last-child { border-bottom: 0; }
.bazi-label { font-weight: 900; background: rgba(255,248,251,.76) !important; }
.bazi-god { color: var(--muted); font-size: 13px; }
.bazi-char { font-size: 34px; font-weight: 900; line-height: 1; }
.bazi-char.branch { font-size: 32px; }
.bazi-element { font-size: 12px; font-weight: 900; border-radius: 999px; padding: 4px 8px !important; justify-self: center; align-self: center; min-height: auto !important; border-bottom: 0 !important; }
.bazi-hidden { display: flex !important; flex-direction: column; gap: 3px; font-size: 12px; line-height: 1.2; }
.bazi-hidden span { display: flex; justify-content: center; gap: 5px; }
.bazi-hidden b { font-size: 14px; }
.bazi-hidden em { color: var(--muted); font-style: normal; }
.bazi-col.day-master .bazi-label { background: rgba(236,249,240,.78) !important; color: #3f7f59; }
.wood { color: var(--wood); background: rgba(47,154,104,.1) !important; }
.fire { color: var(--fire); background: rgba(196,87,72,.1) !important; }
.earth { color: var(--earth); background: rgba(173,122,50,.1) !important; }
.metal { color: var(--metal); background: rgba(114,121,138,.1) !important; }
.water { color: var(--water); background: rgba(46,121,173,.1) !important; }
.neutral { color: var(--muted); background: rgba(244,232,255,.44) !important; }
.bazi-luck-block { margin-top: 12px; border: 1px solid rgba(176,106,179,.1); border-radius: 20px; padding: 11px; background: rgba(255,255,255,.48); }
.bazi-luck-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 9px; }
.bazi-luck-title strong { color: #7e578f; font-size: 15px; }
.bazi-luck-title span { color: var(--muted); font-size: 12px; }
.bazi-luck-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 7px; margin-top: 0; }
.bazi-luck-item { min-height: 88px; display: grid; align-content: space-between; border: 1px solid rgba(176,106,179,.1); border-radius: 16px; background: rgba(255,255,255,.66); padding: 8px; }
.bazi-luck-item.current { border-color: rgba(176,106,179,.3); background: rgba(244,232,255,.66); box-shadow: inset 0 0 0 1px rgba(255,255,255,.5); }
.bazi-luck-item span { color: var(--muted); font-size: 11px; display: block; }
.bazi-luck-item strong { display: flex; gap: 4px; font-size: 22px; line-height: 1; }
.bazi-luck-item em { color: var(--faint); font-size: 11px; font-style: normal; line-height: 1.2; }
.bazi-note { color: var(--muted); font-size: 13px; margin-top: 10px; line-height: 1.5; }

.modal { border: 0; border-radius: 28px; padding: 0; width: min(600px, calc(100vw - 28px)); box-shadow: 0 30px 80px rgba(60,30,80,.32); background: transparent; }
.modal::backdrop { background: rgba(40,24,52,.46); backdrop-filter: blur(4px); }
.modal form { padding: 22px; display: grid; gap: 12px; border: 1px solid var(--line); border-radius: 28px; background: rgba(255,255,255,.92); }
.modal label { display: grid; gap: 6px; color: var(--muted); }
.field-block { display: grid; gap: 7px; color: var(--muted); }
.field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.field-label small { color: var(--faint); }
.picker-row { display: grid; gap: 8px; }
.picker-date { grid-template-columns: 1fr .8fr .8fr; }
.picker-time { grid-template-columns: 1fr 1fr; }
.picker-cell { position: relative; display: block; }
.picker-cell select { padding-right: 34px; }
.picker-unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-style: normal; pointer-events: none; }
.form-hint { margin: -2px 0 0; border: 1px solid rgba(83,150,111,.18); background: rgba(236,249,240,.72); color: #3f7f59; border-radius: 18px; padding: 9px 11px; font-size: 13px; line-height: 1.5; }
.inline-check { display: flex !important; grid-template-columns: none; align-items: center; flex-direction: row; gap: 9px; color: var(--text) !important; }
.inline-check input { width: 18px; height: 18px; accent-color: #b06ab3; }
.small-modal p { line-height: 1.6; color: var(--muted); }
.stacked { flex-direction: column; align-items: stretch; }

@media (max-width: 1180px) { .workspace-grid { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; padding: 12px; }
  .sidebar { position: static; height: auto; max-height: 52vh; }
  .detail-header { grid-template-columns: 1fr; }
  .main-panel { overflow: visible; }
  .preset-grid { grid-template-columns: 1fr; }
  .picker-date { grid-template-columns: 1fr; }
}
