:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --ink: #1b2432;
  --ink-2: #46566f;
  --muted: #7a879b;
  --line: #dde4ee;
  --accent: #2f6fd0;
  --accent-soft: #eaf1fc;
  --ok: #2f8f5b;
  --warn: #c04a2f;
}

* { box-sizing: border-box; }

/* 作者样式里的 display 会盖掉 [hidden] 的 UA 样式，必须显式压回去 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(140deg, #3f7ede, #2b5fb4);
  color: #fff;
  font-size: 19px;
  box-shadow: 0 4px 12px -4px rgba(47, 111, 208, 0.65);
}

.brand-txt h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.brand-txt p {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.tools {
  display: flex;
  gap: 8px;
}

button.ghost {
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 14px;
  cursor: pointer;
  transition: 0.15s;
}

a.ghost.navlink {
  display: inline-flex;
  align-items: center;
  font-size: 12.5px;
  color: var(--ink-2);
  background: #eef3fd;
  border: 1px solid #d3e0f7;
  border-radius: 9px;
  padding: 7px 14px;
  text-decoration: none;
  transition: 0.15s;
}

a.ghost.navlink:hover {
  background: var(--accent-soft);
  border-color: #c2d5ee;
  color: var(--accent);
}

button.ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: #c2d5ee;
  color: var(--accent);
}

button.ghost:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

button.ghost:active:not(:disabled) {
  transform: translateY(1px);
}

/* ---------- 主体 ---------- */
main {
  max-width: 1420px;
  margin: 0 auto;
  padding: 26px 26px 60px;
}

/* ---------- 上传区 ---------- */
.stage {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 220px);
}

.drop {
  width: min(680px, 100%);
  padding: 54px 36px;
  border: 2px dashed #c6d3e4;
  border-radius: 20px;
  background: var(--card);
  text-align: center;
  cursor: pointer;
  transition: 0.2s;
}

.drop:hover,
.drop.over {
  border-color: var(--accent);
  background: #fbfdff;
  box-shadow: 0 14px 40px -26px rgba(47, 111, 208, 0.55);
}

.drop.over {
  transform: scale(1.008);
}

.drop-icon {
  color: #9fb4d0;
  margin-bottom: 14px;
  transition: 0.2s;
}

.drop:hover .drop-icon {
  color: var(--accent);
}

.drop h2 {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 700;
}

.drop p {
  margin: 6px 0;
  font-size: 13px;
  color: var(--muted);
}

.drop p b {
  color: var(--accent);
  font-weight: 600;
}

.drop-note {
  font-size: 11.5px !important;
  color: #9aa7b9 !important;
  margin-top: 16px !important;
}

/* ---------- 加载 ---------- */
.loading {
  display: grid;
  place-items: center;
  gap: 16px;
  padding: 90px 20px;
  text-align: center;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #d9e3f0;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading p {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}

.raw {
  max-width: 760px;
  max-height: 180px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 12px 14px;
  font-size: 11px;
  line-height: 1.6;
  color: #6b7a90;
  background: #f6f8fb;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- 结果 ---------- */
.result {
  display: grid;
  gap: 18px;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 20px;
}

.result-title h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.result-title p {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

.result-title p.part-meta {
  margin-top: 3px;
  font-size: 11.5px;
  color: #8d99ab;
  letter-spacing: 0.1px;
}

.result-title p.part-meta:empty {
  display: none;
}

.result-meta {
  position: relative;
  flex: 0 0 auto;
}

.result-meta img {
  display: block;
  width: 236px;
  height: 164px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 5px;
  cursor: zoom-in;
  /* 题目图缩到这个尺寸线条会糊掉，压一压对比度让它还认得出是三视图 */
  filter: contrast(1.45) brightness(0.96);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  transform-origin: top right;
}

.result-meta img:hover {
  transform: scale(2.2);
  filter: contrast(1) brightness(1);
  box-shadow: 0 14px 36px rgba(18, 28, 46, 0.2);
  z-index: 40;
}

.result-meta:hover {
  z-index: 40;
}

.result-meta::after {
  content: '⤢';
  position: absolute;
  right: 9px;
  bottom: 9px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(27, 36, 50, 0.62);
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.result-meta:hover::after {
  opacity: 0;
}

/* 原图放大查看 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(12, 18, 28, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  cursor: zoom-out;
  backdrop-filter: blur(3px);
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.panels {
  display: grid;
  grid-template-columns: 1.42fr 1fr;
  gap: 18px;
  align-items: start;
}

@media (max-width: 1080px) {
  .panels { grid-template-columns: 1fr; }
  .result-head { flex-direction: column; align-items: flex-start; }
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px 16px;
  box-shadow: 0 1px 2px rgba(24, 40, 68, 0.04), 0 10px 26px -20px rgba(24, 40, 68, 0.3);
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 10px;
}

.panel-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: #33415a;
}

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px 7px;
  margin-left: 6px;
  vertical-align: 1px;
}

.hint {
  font-size: 11px;
  color: #97a4b7;
  letter-spacing: 0.2px;
}

#gl {
  display: block;
  width: 100%;
  height: 420px;
  border-radius: 12px;
  background: #fbfcfe;
  cursor: grab;
  touch-action: none;
}

#gl:active {
  cursor: grabbing;
}

.views-wrap {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 6px;
}

.views-wrap svg {
  width: 100%;
  height: auto;
  max-height: 420px;
}

/* ---------- 参数面板 ---------- */
.params {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px 18px;
}

.params-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.params-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: #33415a;
}

.param-list {
  display: grid;
  gap: 8px;
}

.param-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfe;
}

.param-row.sub-item {
  background: #fdfaf8;
  border-color: #f0e2da;
}

.tag {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.sub-item .tag {
  background: #fbeee8;
  color: var(--warn);
}

.field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--muted);
}

.field input {
  width: 58px;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink);
  padding: 4px 6px;
  border: 1px solid #dbe3ee;
  border-radius: 6px;
  background: #fff;
  text-align: right;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 208, 0.12);
}

.del {
  margin-left: auto;
  font-size: 11px;
  color: #b0bccd;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-family: inherit;
}

.del:hover {
  color: var(--warn);
  background: #fdf1ed;
}

/* ---------- 错误 ---------- */
.error-box {
  max-width: 620px;
  margin: 60px auto;
  padding: 26px 28px;
  background: var(--card);
  border: 1px solid #f0ddd6;
  border-radius: 16px;
  text-align: center;
}

.error-box h3 {
  margin: 0 0 10px;
  font-size: 15.5px;
  color: var(--warn);
}

.error-box p {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink-2);
}

/* ---------- 框选识别区域 ---------- */
.cropper {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 18px 44px;
  text-align: center;
}

.cropper-head { margin-bottom: 14px; }
.cropper-head h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
}
.cropper-head p {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.7;
}

.crop-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #0e1116;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  box-shadow: 0 10px 34px -18px rgba(18, 28, 46, 0.5);
}

.crop-stage img {
  display: block;
  max-width: 100%;
  height: auto;
  pointer-events: none;
}

.crop-box {
  position: absolute;
  border: 1.5px solid #2f6df6;
  box-shadow: 0 0 0 9999px rgba(8, 12, 20, 0.55);
  cursor: move;
}

.crop-box .h {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 1.5px solid #2f6df6;
  border-radius: 3px;
}
.crop-box .h.tl { left: -7px; top: -7px; cursor: nwse-resize; }
.crop-box .h.tr { right: -7px; top: -7px; cursor: nesw-resize; }
.crop-box .h.bl { left: -7px; bottom: -7px; cursor: nesw-resize; }
.crop-box .h.br { right: -7px; bottom: -7px; cursor: nwse-resize; }

.crop-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

button.primary {
  font-family: inherit;
  font-size: 13px;
  color: #fff;
  background: #2f6df6;
  border: 1px solid #2f6df6;
  border-radius: 9px;
  padding: 8px 20px;
  cursor: pointer;
  transition: 0.15s;
}
button.primary:hover { background: #2457d0; border-color: #2457d0; }

/* ---------- 与原图叠加核对 ---------- */
button.mini {
  font-family: inherit;
  font-size: 11px;
  color: var(--accent);
  background: #eaf1ff;
  border: 1px solid #ccdcfb;
  border-radius: 7px;
  padding: 2px 8px;
  margin-left: 8px;
  cursor: pointer;
}
button.mini:hover:not(:disabled) { background: #dde9ff; }
button.mini:disabled {
  color: #a9b3c2;
  background: #f4f6fa;
  border-color: var(--line);
  cursor: not-allowed;
}

.overlay-wrap {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(12, 18, 28, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
}

.overlay-card {
  background: #fff;
  border-radius: 16px;
  padding: 18px 20px 16px;
  max-width: 1100px;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px -20px rgba(10, 18, 30, 0.5);
}

.overlay-head { margin-bottom: 10px; }
.overlay-head h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
}
.overlay-head p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.6;
}

.cmp {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
  overflow: auto;
}

.cmp-pane {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fff;
}

.cmp-pane img,
.cmp-gen svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 58vh;
  object-fit: contain;
}

.cmp-gen {
  display: grid;
  place-items: center;
  min-height: 120px;
}

.cmp-pane figcaption {
  font-size: 11.5px;
  color: var(--ink-2);
  text-align: center;
}
.cmp-pane figcaption.gen { color: var(--accent); }

.overlay-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

/* ---------- 缺线检查 ---------- */
.miss-wrap {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  text-align: center;
  max-height: 52vh;
  overflow: auto;
}

.miss-wrap img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 6px auto;
}

.miss-wrap .hint { font-size: 11.5px; }

.verdict {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
}
.verdict.good { color: #1f8b4c; }
.verdict.warn { color: #b8761b; }
.verdict.bad { color: #c22e2e; }

/* ---------- 设置面板 ---------- */
.field-label {
  display: block;
  font-size: 12px;
  color: #6b7789;
  margin: 12px 0 5px;
}
.field-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid #e2e8f1;
  border-radius: 8px;
  font: 13px ui-monospace, "Cascadia Mono", Consolas, monospace;
  outline: none;
  background: #fbfcfe;
}
select.field-input { font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; }
.field-input:focus { border-color: #c3d6fb; background: #fff; }
