﻿* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f5f0;
  --panel: #ffffff;
  --ink: #2b2b2b;
  --ink-soft: #6b6f66;
  --accent: #2f6b4f;
  --accent-soft: #e4efe9;
  --border: #e2e4dc;
  --danger: #b4432f;
  --radius: 14px;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

/* 顶栏 */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 32px; }
.brand h1 { font-size: 22px; letter-spacing: 2px; }
.tagline { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* 布局 */
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  padding: 20px 28px;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.input-panel { align-self: start; position: sticky; top: 88px; }
@media (max-width: 900px) { .input-panel { position: static; } }
.input-panel h2 { font-size: 16px; margin-bottom: 14px; }

/* 上传区 */
.drop-zone {
  border: 2px dashed #b9c4b3;
  border-radius: var(--radius);
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: #fafbf8;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.drop-main { font-size: 15px; font-weight: 600; }
.drop-sub { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.file-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 6px 10px;
}
.file-item .thumb {
  width: 34px; height: 34px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--border); flex-shrink: 0;
}
.file-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .remove { cursor: pointer; color: var(--danger); border: none; background: none; font-size: 14px; }

.divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 10px; color: var(--ink-soft); font-size: 12px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

textarea, input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  background: #fafbf8;
}
textarea:focus, input[type="text"]:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.hints-row { display: flex; gap: 8px; margin-top: 10px; }

.primary-btn {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}
.primary-btn:hover { background: #275a42; }
.primary-btn:disabled { background: #9db5a8; cursor: not-allowed; }

.ghost-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-size: 14px; color: var(--ink);
}
.ghost-btn:hover { background: var(--accent-soft); }

.status {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  font-size: 13px; line-height: 1.5;
  background: var(--accent-soft); color: var(--accent);
}
.status.error { background: #f7e6e2; color: var(--danger); }
.hidden { display: none !important; }

.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--accent); border-top-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: -2px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 结果区 */
.result-panel { min-height: 500px; }
.empty-state { text-align: center; padding: 70px 20px; color: var(--ink-soft); line-height: 1.8; }
.empty-icon { font-size: 44px; margin-bottom: 12px; }
.depth-legend {
  list-style: none; text-align: left; display: inline-block;
  margin-top: 20px; font-size: 13px; line-height: 2.1;
}
.depth-legend b { color: var(--accent); }

.result-head {
  padding-bottom: 14px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.result-head .meta { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.badge {
  display: inline-block; font-size: 12px; padding: 2px 10px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  margin-right: 6px;
}

/* 题目卡片 */
.q-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.q-head {
  padding: 14px 16px;
  background: #f7f8f4;
  border-bottom: 1px solid var(--border);
}
.q-num { font-weight: 700; color: var(--accent); margin-right: 8px; }
.q-text { margin-top: 6px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; }

/* 四层手风琴 */
.layer { border-top: 1px solid var(--border); }
.layer:first-of-type { border-top: none; }
.layer-head {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 11px 16px;
  background: none; border: none;
  font-size: 14px; font-weight: 600; color: var(--ink);
  cursor: pointer; text-align: left;
  font-family: inherit;
}
.layer-head:hover { background: #fafbf8; }
.layer-head .chip {
  font-size: 11px; padding: 1px 8px; border-radius: 999px;
  color: #fff; flex-shrink: 0;
}
.chip.d1 { background: #2f6b4f; }
.chip.d2 { background: #3a7ca5; }
.chip.d3 { background: #b0802b; }
.chip.d4 { background: #7a4988; }
.layer-head .arrow { margin-left: auto; color: var(--ink-soft); transition: transform .15s; font-size: 12px; }
.layer.open .arrow { transform: rotate(90deg); }

.layer-body {
  display: none;
  padding: 4px 16px 16px 16px;
  font-size: 14px; line-height: 1.8;
  white-space: pre-wrap;
}
.layer.open .layer-body { display: block; }

.answer-highlight {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  font-weight: 600;
}

.kp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.kp-tag {
  font-size: 12px; padding: 3px 10px; border-radius: 999px;
  background: #fdf3e0; color: #8a6420; border: 1px solid #eeddb8;
}
.kp-label { font-weight: 600; color: var(--ink); display: block; margin-top: 8px; }

/* 历史抽屉 */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 360px; max-width: 90vw;
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 30;
  display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(0,0,0,.08);
}
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.drawer-head h2 { font-size: 16px; }
.history-list { overflow-y: auto; padding: 12px; }
.history-item {
  padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 8px; cursor: pointer;
  transition: background .15s;
}
.history-item:hover { background: var(--accent-soft); }
.history-item .h-summary { font-size: 14px; font-weight: 600; }
.history-item .h-meta { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.drawer-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 20;
}
.history-empty { text-align: center; color: var(--ink-soft); font-size: 13px; padding: 30px 0; }

/* ---------- 后端徽章与设置弹窗 ---------- */
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.backend-badge {
  font-size: 12px; padding: 4px 10px; border-radius: 999px;
  background: var(--bg); color: var(--ink-soft);
  border: 1px solid var(--border);
}
.backend-badge.ok { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }
.backend-badge.warn { background: #fdf3e0; color: #9a6b1f; border-color: #f0e2c4; }

.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(43, 43, 43, 0.45);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  width: min(460px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
}
.modal h2 { font-size: 17px; margin-bottom: 6px; }
.modal-label { display: block; font-size: 13px; color: var(--ink-soft); margin-top: 12px; }
.modal-label input {
  width: 100%; margin-top: 5px; padding: 9px 11px;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px;
}
.modal-label input:focus { outline: none; border-color: var(--accent); background: #fff; }
.modal-hint { font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; margin: 10px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.primary-btn.slim { width: auto; padding: 9px 22px; margin: 0; }
.modal-check {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; margin-top: 12px; cursor: pointer;
}
.modal-check input { margin-top: 3px; accent-color: var(--accent); }
