:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --border: #dce4ee;
  --border-strong: #c7d2df;
  --text: #162033;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-soft: #eaf1ff;
  --primary-hover: #1d4ed8;
  --success: #0f766e;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --sidebar-width: 330px;
  font-family:
    "Microsoft YaHei UI",
    "Microsoft YaHei",
    "PingFang SC",
    "Noto Sans CJK SC",
    Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  color: var(--text);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

code,
pre {
  font-family: Consolas, "Cascadia Code", "Courier New", monospace;
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app-shell {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  min-height: 76px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  min-width: 320px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  background: var(--primary);
  border-radius: 12px;
  font-weight: 800;
  letter-spacing: -2px;
  box-shadow: 0 7px 18px rgba(37, 99, 235, 0.24);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button {
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  background: var(--panel);
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.button:hover {
  border-color: #9fb0c6;
  background: #f8fafc;
}

.button:active {
  transform: translateY(1px);
}

.button-primary {
  color: white;
  border-color: var(--primary);
  background: var(--primary);
}

.button-primary:hover {
  color: white;
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.button-small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.source-panel {
  padding: 15px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
}

.source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.source-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.badge,
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #1d4ed8;
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 700;
}

.source-description {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.search-wrap {
  position: relative;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.search-wrap input {
  width: 100%;
  min-height: 40px;
  padding: 8px 52px 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  background: white;
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.count-badge {
  position: absolute;
  top: 21px;
  right: 20px;
  min-width: 28px;
}

.file-list {
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.file-item {
  width: 100%;
  margin: 0 0 4px;
  padding: 10px 10px 9px;
  display: block;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  background: transparent;
}

.file-item:hover {
  background: #f5f8fc;
  border-color: #e6edf5;
}

.file-item.active {
  color: #153e9f;
  background: var(--primary-soft);
  border-color: #bfd2ff;
}

.file-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.file-path {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
}

.file-meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.review-check {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  color: white;
  background: #16a34a;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 900;
}

.draft-dot {
  min-height: 20px;
  padding: 2px 7px;
  display: inline-flex;
  align-items: center;
  color: #8a5a00;
  background: #fff7d6;
  border: 1px solid #f3d36c;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.file-item.reviewed {
  border-color: #bbf7d0;
}

.sidebar-empty {
  padding: 32px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.main-panel {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.welcome-view,
.error-view {
  width: min(700px, calc(100% - 40px));
  margin: 10vh auto 0;
  padding: 42px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.welcome-icon {
  width: 74px;
  height: 74px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 20px;
  font-size: 19px;
  font-weight: 900;
}

.welcome-view h2,
.error-view h2 {
  margin: 0;
  font-size: 24px;
}

.welcome-view p,
.error-view p {
  margin: 14px auto 0;
  color: var(--muted);
  line-height: 1.8;
}

.welcome-tip {
  margin-top: 22px;
  padding: 14px 16px;
  color: #334155;
  background: #f8fafc;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.welcome-tip code {
  color: #0f3a91;
}

.error-view {
  border-color: #fecaca;
}

.error-view h2 {
  color: var(--danger);
}

.document-view {
  width: min(1180px, calc(100% - 36px));
  margin: 18px auto 40px;
}

.document-toolbar {
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.document-heading {
  min-width: 0;
}

.question-number {
  display: inline-block;
  margin-bottom: 6px;
  padding: 3px 9px;
  color: #1743a4;
  background: var(--primary-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.document-heading h2 {
  margin: 0;
  font-size: 23px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.current-file-name {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.document-actions {
  margin-left: auto;
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.tabs {
  margin-top: 14px;
  padding: 5px;
  display: inline-flex;
  gap: 4px;
  background: #e9eef5;
  border-radius: 10px;
}

.tab {
  padding: 8px 18px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.tab.active {
  color: var(--text);
  background: white;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.tab-panel {
  margin-top: 12px;
}

.render-target {
  display: grid;
  gap: 14px;
}

.content-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
  overflow: visible;
}

.annotation-box {
  width: 100%;
  padding: 12px 18px 18px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.answer-content .annotation-box {
  padding: 16px 0 0;
}

.annotation-actions {
  width: 100%;
  display: flex;
  justify-content: flex-end;
}

.annotation-button {
  min-height: 30px;
  padding: 5px 12px;
  color: #0f766e;
  background: #ecfdf5;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.annotation-button:hover {
  background: #d1fae5;
  border-color: #5eead4;
}

.annotation-editor {
  width: min(520px, 100%);
  display: grid;
  gap: 7px;
  align-self: stretch;
}

.annotation-editor textarea {
  width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
  color: var(--text);
  background: #fffdf5;
  border: 1px solid #f0d98c;
  border-radius: 8px;
  line-height: 1.7;
  outline: none;
}

.annotation-editor textarea:focus {
  border-color: #d99b18;
  box-shadow: 0 0 0 3px rgba(217, 155, 24, 0.16);
}

.annotation-hint {
  color: var(--muted);
  font-size: 12px;
}

.card-heading {
  margin: 0;
  padding: 13px 18px;
  color: #243047;
  background: var(--panel-soft);
  border-bottom: 1px solid var(--border);
  font-size: 16px;
}

.card-body {
  padding: 18px;
}

.question-text {
  margin: 0;
  color: #111827;
  font-size: 17px;
  line-height: 2;
  overflow-wrap: anywhere;
}

.subsection {
  margin-top: 18px;
}

.subsection:first-child {
  margin-top: 0;
}

.field-title {
  margin: 0 0 9px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

.value-text {
  margin: 0;
  line-height: 1.9;
  overflow-wrap: anywhere;
}

.value-list {
  margin: 0;
  padding-left: 24px;
}

.value-list li {
  margin: 8px 0;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.timeline {
  position: relative;
  display: grid;
  gap: 14px;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 15px;
  bottom: 15px;
  left: 17px;
  width: 2px;
  background: #c9d8f8;
}

.timeline-item {
  position: relative;
  padding: 13px 16px 13px 52px;
  background: #fbfdff;
  border: 1px solid #e3eaf3;
  border-radius: 11px;
}

.timeline-step {
  position: absolute;
  z-index: 1;
  top: 12px;
  left: 6px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--primary);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #a9c1f7;
  font-size: 11px;
  font-weight: 900;
}

.timeline-content {
  margin: 0;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.answer-details {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.answer-details > summary {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #243047;
  background: var(--panel-soft);
  border-bottom: 1px solid transparent;
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
  list-style: none;
}

.answer-details > summary::-webkit-details-marker {
  display: none;
}

.answer-details > summary::before {
  content: "›";
  width: 21px;
  height: 21px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
}

.answer-details[open] > summary {
  border-bottom-color: var(--border);
}

.answer-details[open] > summary::before {
  transform: rotate(90deg);
}

.answer-content {
  padding: 18px;
}

.object-grid {
  display: grid;
  gap: 14px;
}

.object-field {
  min-width: 0;
}

.object-field + .object-field {
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.nested-object {
  padding: 14px;
  background: #fbfcfe;
  border: 1px solid #e5ebf2;
  border-radius: 10px;
}

.array-cards {
  display: grid;
  gap: 10px;
}

.array-card {
  padding: 13px 14px;
  background: #fbfcfe;
  border: 1px solid #e4eaf1;
  border-radius: 10px;
}

.formula-block {
  margin: 10px 0;
  padding: 13px 14px;
  overflow-x: auto;
  background: #f8fbff;
  border-left: 4px solid #90b2ff;
  border-radius: 6px;
  line-height: 1.8;
}

.null-value {
  color: var(--muted);
  font-style: italic;
}

.boolean-value,
.number-value {
  font-weight: 700;
}

.raw-json {
  margin: 0;
  padding: 20px;
  min-height: 300px;
  overflow: auto;
  color: #dbeafe;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: var(--shadow);
}

.statusbar {
  min-height: 30px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 11px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 48px;
  z-index: 100;
  max-width: 360px;
  padding: 11px 15px;
  color: white;
  background: #172033;
  border-radius: 9px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.24);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.review-submit-row {
  margin-top: 16px;
  padding: 0 0 6px;
  width: 100%;
  display: flex;
  justify-content: flex-end;
}

.submit-review-button {
  min-height: 44px;
  padding: 10px 18px;
  color: white;
  background: #16a34a;
  border: 1px solid #15803d;
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(22, 163, 74, 0.24);
  font-weight: 900;
}

.submit-review-button:hover {
  background: #15803d;
}

.submit-review-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

mjx-container[jax="CHTML"][display="true"] {
  margin: 0.8em 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
}

@media (max-width: 900px) {
  :root {
    --sidebar-width: 270px;
  }

  .brand {
    min-width: 0;
  }

  .brand p {
    display: none;
  }

  .document-toolbar {
    flex-direction: column;
  }

  .document-actions {
    margin-left: 0;
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    margin-left: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 320px minmax(0, 1fr);
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .document-view {
    width: calc(100% - 20px);
  }

  .welcome-view,
  .error-view {
    width: calc(100% - 20px);
    margin-top: 20px;
    padding: 28px 20px;
  }

  .statusbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
}
