:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #152033;
  background: #f4f7fb;
}

* { box-sizing: border-box; }
body { margin: 0; background: #f4f7fb; }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.shell { width: min(1180px, calc(100% - 32px)); margin: 24px auto 64px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(26px, 4vw, 38px); }
h2 { font-size: 20px; }
.eyebrow { margin-bottom: 6px; color: #087f5b; font-weight: 800; letter-spacing: .12em; }
.muted { color: #64748b; }
.top-actions, .actions, .section-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-head { justify-content: space-between; }
.section-head h2 { margin-bottom: 0; margin-right: auto; }
.card, dialog { border: 1px solid #dbe4ee; border-radius: 16px; background: #fff; box-shadow: 0 8px 28px rgba(15, 23, 42, .06); }
.card { padding: 22px; margin-bottom: 16px; }
.login-card { max-width: 720px; margin-inline: auto; }
.form-grid { display: grid; gap: 14px; margin: 14px 0; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: #334155; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 10px; padding: 10px 12px; color: #0f172a; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(16, 185, 129, .16); border-color: #059669; }
textarea { resize: vertical; line-height: 1.7; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: auto; }
.align-end { align-self: end; }
.button { border: 1px solid transparent; border-radius: 10px; padding: 9px 15px; cursor: pointer; text-decoration: none; font-weight: 800; }
.button.primary { background: #059669; color: #fff; }
.button.secondary { background: #fff; color: #334155; border-color: #cbd5e1; }
.button.danger { color: #b91c1c; border-color: #fecaca; background: #fff7f7; }
.button:disabled { opacity: .55; cursor: wait; }
.message { min-height: 24px; margin: 12px 0 0; color: #047857; }
.message.error { color: #b91c1c; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 18px; border-radius: 14px; background: linear-gradient(135deg, #ecfdf5, #fff); border: 1px solid #a7f3d0; }
.stat strong { display: block; font-size: 28px; color: #047857; }
.tabs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 16px; }
.tab { white-space: nowrap; border: 0; border-radius: 999px; padding: 10px 16px; background: #e2e8f0; color: #475569; font-weight: 800; cursor: pointer; }
.tab.active { background: #0f766e; color: #fff; }
.data-list { display: grid; gap: 10px; margin-top: 14px; }
.row-card { border: 1px solid #e2e8f0; border-radius: 12px; padding: 14px; background: #fbfdff; }
.row-main { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.row-main p { margin-bottom: 5px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { display: inline-block; border-radius: 999px; padding: 3px 9px; background: #e2e8f0; color: #475569; font-size: 13px; font-weight: 800; }
.badge.good { background: #d1fae5; color: #047857; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad { background: #fee2e2; color: #b91c1c; }
.problem-preview { max-width: 760px; white-space: pre-wrap; line-height: 1.55; }
.mono { font-family: Consolas, monospace; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
dialog { width: min(840px, calc(100% - 28px)); max-height: calc(100vh - 40px); padding: 22px; overflow: auto; }
dialog::backdrop { background: rgba(15, 23, 42, .55); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin-bottom: 0; }
.icon-button { border: 0; background: transparent; font-size: 28px; cursor: pointer; }
.query-detail { padding: 14px; margin: 14px 0; border-radius: 12px; background: #f8fafc; line-height: 1.75; }
.row-main > div, .row-card, .query-detail, .answer-section, .change-pane { min-width: 0; }
#queryDialog { width: min(1080px, calc(100% - 28px)); }
.query-meta { color: #475569; font-size: 14px; }
.answer-section { border-top: 1px solid #dce5ee; padding-top: 16px; margin-top: 18px; }
.answer-section h3 { font-size: 18px; margin: 0 0 12px; }
.answer-section h4 { margin: 8px 0; }
.original-ai-answer { background: white; padding: 18px; border: 1px solid #dbe4ee; border-radius: 12px; }
.readable-prose { line-height: 1.8; overflow-wrap: anywhere; }
.readable-prose p { white-space: pre-wrap; margin: 0 0 10px; }
.readable-prose h1, .readable-prose h2, .readable-prose h3, .readable-prose h4, .readable-prose h5, .readable-prose h6 { margin: 14px 0 8px; font-size: 1.05em; }
.readable-prose pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.readable-prose li { margin-bottom: 8px; }
.saved-math, .note-formula { max-width: 100%; }
.note-formula { display: inline-block; vertical-align: middle; overflow-x: auto; }
.saved-math { overflow-x: auto; padding: 8px 0; }
.katex-display { margin: .5em 0; }
.saved-steps { padding-left: 26px; }
.saved-steps > li { padding: 12px 4px; border-bottom: 1px solid #e2e8f0; }
.saved-diagram { display: block; max-width: 100%; max-height: 520px; margin: 12px auto; }
.readable-fold { margin: 12px 0; border: 1px solid #dbe4ee; border-radius: 10px; background: #fff; }
.readable-fold > summary { cursor: pointer; padding: 12px; font-weight: 700; color: #24516c; }
.fold-body { padding: 4px 14px 14px; }
.change-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.change-pane { border: 1px solid #e2e8f0; border-radius: 10px; padding: 14px; }
.change-pane > h3 { margin-top: 0; }
.change-pane.before > h3 { color: #9a3412; }
.change-pane.after > h3 { color: #047857; }
.change-pane .answer-section { margin-top: 10px; padding-top: 10px; }
.changed-field { border-left: 3px solid #60a5fa; padding-left: 10px; }
.change-summary { font-size: 14px; color: #475569; margin: 10px 0; overflow-wrap: anywhere; }
.audit-heading { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.audit-card > .muted { margin: 8px 0; font-size: 14px; }
.field-list { margin: 0; }
.field-list dt { color: #52667a; font-weight: 700; margin: 8px 0 4px; overflow-wrap: anywhere; }
.field-list dd { margin: 0 0 12px; }
.raw-data { max-height: 500px; overflow: auto; }
.table-scroll { overflow-x: auto; margin: 12px 0; }
.table-scroll table { border-collapse: collapse; min-width: 100%; }
.table-scroll th, .table-scroll td { border: 1px solid #dbe4ee; padding: 8px; text-align: left; }
.table-scroll th { background: #eff6ff; }
.problem-preview { max-height: 180px; overflow: auto; white-space: normal; }
.empty { padding: 30px; text-align: center; color: #64748b; }

@media (max-width: 760px) {
  .topbar, .row-main { align-items: stretch; flex-direction: column; }
  .form-grid.two, .form-grid.three, .stats { grid-template-columns: 1fr; }
  .top-actions .button { flex: 1; text-align: center; }
  .change-grid { grid-template-columns: 1fr; }
  .card, dialog { padding: 14px; }
  .original-ai-answer { padding: 12px; }
}
