:root {
  --ink: #172033;
  --muted: #667085;
  --blue: #24469a;
  --blue-2: #4d6cc2;
  --blue-soft: #eaf0ff;
  --mint: #eaf7f4;
  --mint-ink: #167a65;
  --line: #dfe4ee;
  --paper: #ffffff;
  --canvas: #f3f5f9;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    radial-gradient(circle at 90% 0%, rgba(77, 108, 194, .13), transparent 27rem),
    var(--canvas);
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: .55; }
[hidden] { display: none !important; }

.workspace-shell, .admin-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}
.topbar, .admin-topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--blue);
  color: white;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -.5px;
  box-shadow: 0 8px 20px rgba(36, 70, 154, .22);
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; letter-spacing: -.8px; }
h2 { font-size: clamp(24px, 4vw, 38px); letter-spacing: -1.6px; }
h3 { font-size: 20px; }
.eyebrow, .step-label {
  color: var(--blue-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.25px;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.readonly-badge {
  margin-left: auto;
  border: 1px solid #a7d7ca;
  color: var(--mint-ink);
  background: var(--mint);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.hero {
  background: var(--blue);
  color: white;
  padding: clamp(24px, 5vw, 48px);
  border-radius: 26px;
  box-shadow: 0 22px 50px rgba(36, 70, 154, .18);
}
.hero .step-label { color: #bfcdfa; }
.hero > p:not(.step-label) { color: #dce4fb; margin-top: 10px; }
.filter-grid {
  display: grid;
  grid-template-columns: .65fr 1fr .65fr 1.45fr;
  gap: 14px;
  margin-top: 34px;
}
label { display: grid; gap: 7px; }
label > span, .filter-control > label { font-size: 12px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 12px;
  padding: 13px 14px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
input:focus, select:focus, textarea:focus {
  border-color: #6f8be0;
  box-shadow: 0 0 0 4px rgba(111, 139, 224, .16);
}
.hero input, .hero select { border-color: rgba(255, 255, 255, .22); }
.filter-control { display: grid; gap: 7px; min-width: 0; position: relative; }
.filter-control > label { color: inherit; }
.combobox-input-wrap { position: relative; }
.combobox-input-wrap input { padding-right: 43px; }
.combobox-clear, .combobox-search-icon {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
}
.combobox-clear {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.combobox-clear:hover { background: #eef2f9; color: var(--blue); }
.combobox-search-icon { color: #7c879d; font-size: 22px; pointer-events: none; }
.combobox-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid #d5dbe8;
  border-radius: 12px;
  background: white;
  box-shadow: 0 16px 36px rgba(15, 31, 68, .22);
}
.combobox-menu button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}
.combobox-menu button:hover, .combobox-menu button.highlighted {
  background: var(--blue-soft);
  color: var(--blue);
}
.combobox-menu button[aria-selected="true"] { font-weight: 800; }
.combobox-empty { color: var(--muted); padding: 13px 12px; font-size: 13px; text-align: center; }

.results-layout {
  display: grid;
  grid-template-columns: .9fr 1.4fr;
  gap: 20px;
  margin-top: 20px;
  align-items: stretch;
}
.question-panel, .answer-panel, .editor-card, .library-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 12px 30px rgba(25, 39, 71, .06);
}
.question-panel, .answer-panel { padding: 24px; min-height: 480px; }
.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}
.section-heading > strong {
  width: 42px;
  min-height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--blue-soft);
  color: var(--blue);
}
.question-list { display: grid; gap: 8px; max-height: 395px; overflow: auto; padding-right: 4px; }
.question-item {
  text-align: left;
  border: 1px solid transparent;
  background: #f7f8fb;
  border-radius: 13px;
  padding: 13px;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.45;
}
.question-item span {
  display: block;
  color: var(--blue-2);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 5px;
}
.question-item:hover { border-color: #becaf0; }
.question-item.active {
  background: var(--blue-soft);
  border-color: #9eb1e9;
  box-shadow: inset 3px 0 var(--blue);
}
.copy-button, .primary-button {
  border: 0;
  background: var(--blue);
  color: white;
  border-radius: 11px;
  padding: 11px 16px;
  font-weight: 700;
  cursor: pointer;
}
.copy-button:hover, .primary-button:hover { background: #1b3679; }
.answer-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.answer-context span {
  background: var(--blue-soft);
  color: var(--blue);
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
}
.answer-context span.issue-type-after {
  background: #fff0e2;
  color: #a34b00;
}
.answer-context span.issue-type-before {
  background: var(--mint);
  color: var(--mint-ink);
}
.answer-context p { width: 100%; margin-top: 7px; font-weight: 700; }
.answer-copy {
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.9;
  padding: 28px 4px;
  white-space: pre-wrap;
}
.usage-note {
  color: var(--mint-ink);
  background: var(--mint);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 12px;
}
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }
.answer-empty { margin-top: 80px; }

.admin-login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(420px, 100%);
  background: white;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(25, 39, 71, .12);
  display: grid;
  gap: 15px;
}
.login-card .brand-mark { margin-bottom: 6px; }
.login-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.login-card a { color: var(--blue); text-align: center; font-size: 13px; text-decoration: none; }
.form-error { color: #b42318 !important; font-size: 13px; }
.admin-topbar { justify-content: space-between; }
.admin-actions { display: flex; align-items: center; gap: 10px; }
.admin-actions a, .admin-actions button, .text-button, .row-actions button {
  border: 1px solid var(--line);
  background: white;
  color: var(--blue);
  border-radius: 9px;
  padding: 8px 11px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
}
.editor-card, .library-card { padding: 24px; margin-top: 18px; }
.editor-card h2, .library-card h2 { font-size: clamp(21px, 3vw, 30px); }
.editor-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.editor-form .wide, .form-footer { grid-column: 1 / -1; }
.form-footer { display: flex; justify-content: flex-end; align-items: center; gap: 18px; }
.form-footer p { color: var(--mint-ink); margin-right: auto; font-size: 13px; }
.text-button { border: 0; }
.library-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 18px; }
.library-toolbar input { max-width: 360px; }
.admin-table-wrap, .import-preview { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 920px; }
th {
  text-align: left;
  color: var(--muted);
  background: #f7f8fb;
  font-size: 11px;
  letter-spacing: .4px;
  padding: 12px;
  position: sticky;
  top: 0;
}
td { padding: 14px 12px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; line-height: 1.55; }
.answer-cell { max-width: 390px; color: #414b5f; white-space: pre-wrap; }
.row-actions { display: flex; gap: 6px; }
.row-actions .danger { color: #b42318; }
.import-panel { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; align-items: stretch; }
.file-drop {
  position: relative;
  min-height: 120px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 1.5px dashed #aebbe1;
  border-radius: 16px;
  background: #f8faff;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  padding: 20px;
}
.file-drop:hover { border-color: var(--blue-2); background: var(--blue-soft); }
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop strong { color: var(--blue); }
.import-summary {
  border-radius: 16px;
  background: #f7f8fb;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.import-summary p { color: var(--muted); line-height: 1.65; font-size: 13px; }
.import-preview { margin-top: 18px; border: 1px solid var(--line); border-radius: 14px; max-height: 290px; }
.status-error { color: #b42318 !important; }
.table-empty td { color: var(--muted); text-align: center; padding: 36px 16px; }

@media (max-width: 780px) {
  .workspace-shell, .admin-shell { width: min(100% - 20px, 1180px); padding-top: 16px; }
  .filter-grid, .results-layout, .editor-form, .import-panel { grid-template-columns: 1fr; }
  .search-field, .editor-form .wide, .form-footer { grid-column: auto; }
  .hero { border-radius: 20px; }
  .question-panel, .answer-panel { min-height: auto; }
  .question-list { max-height: 330px; }
  .library-toolbar { align-items: stretch; flex-direction: column; }
  .library-toolbar input { max-width: none; }
  .admin-topbar { align-items: flex-start; }
  .admin-actions { flex-wrap: wrap; justify-content: flex-end; }
  .topbar { align-items: flex-start; }
  .readonly-badge { margin-top: 7px; }
}
