* { box-sizing: border-box; }
html, body { height: 100%; }

/* ================= 主题变量：默认暗色 ================= */
:root {
  color-scheme: dark;
  --bg-grad-1: #1b2240;
  --bg-grad-2: #14263a;
  --bg-base: #0c0f1d;
  --panel-bg: rgba(12,15,29,.72);
  --border: rgba(255,255,255,.07);
  --border-strong: rgba(255,255,255,.11);
  --card-bg: rgba(255,255,255,.04);
  --findings-bg: rgba(255,255,255,.03);
  --text: #e8ebf5;
  --text-bright: #dbe1f2;
  --text-soft: #c6cde0;
  --text-sub: #97a0ba;
  --text-dim: #9aa3bd;
  --text-mute: #8d96b2;
  --text-faint: #667089;
  --accent: #3fd6bf;
  --accent-text: #5ee6c8;
  --accent-bg: rgba(53,208,186,.16);
  --accent-bg-hover: rgba(53,208,186,.24);
  --accent-border: rgba(63,214,191,.45);
  --btn-on-border: rgba(63,214,191,.6);
  --glow: rgba(63,214,191,.75);
  --btn-bg: rgba(255,255,255,.06);
  --btn-bg-hover: rgba(255,255,255,.12);
  --ok-bg: rgba(53,208,186,.12);
  --ok-border: rgba(53,208,186,.35);
  --danger-text: #ff8291;
  --danger-bg: rgba(255,107,129,.10);
  --danger-border: rgba(255,107,129,.32);
  --strip-track: rgba(255,255,255,.09);
  --tick: rgba(255,255,255,.28);
  --scrollbar: rgba(255,255,255,.12);
  --dot-oct-bg: rgba(255,181,71,.15);
  --dot-oct-border: rgba(255,181,71,.9);
  --dot-inter-bg: rgba(53,208,186,.3);
  --dot-inter-border: #3fd6bf;
  --dot-sq-bg: rgba(233,236,245,.25);
  --dot-sq-border: rgba(233,236,245,.8);
  --dot-ghost-border: rgba(233,236,245,.4);
  --conclusion-bg: rgba(53,208,186,.09);
  --conclusion-border: rgba(53,208,186,.25);
  --conclusion-text: #8ee9d5;
}

/* ================= 亮色覆盖 ================= */
:root[data-theme="light"] {
  color-scheme: light;
  --bg-grad-1: #dfe6f5;
  --bg-grad-2: #d2e2ee;
  --bg-base: #eef1f8;
  --panel-bg: rgba(248,250,253,.85);
  --border: rgba(25,35,65,.09);
  --border-strong: rgba(25,35,65,.14);
  --card-bg: rgba(255,255,255,.6);
  --findings-bg: rgba(255,255,255,.5);
  --text: #222a40;
  --text-bright: #1c2436;
  --text-soft: #3a4358;
  --text-sub: #5c6780;
  --text-dim: #5a6478;
  --text-mute: #6d7891;
  --text-faint: #8a93a8;
  --accent: #0da58c;
  --accent-text: #0a8d77;
  --accent-bg: rgba(13,165,140,.12);
  --accent-bg-hover: rgba(13,165,140,.2);
  --accent-border: rgba(13,165,140,.45);
  --btn-on-border: rgba(13,165,140,.6);
  --glow: rgba(13,165,140,.5);
  --btn-bg: rgba(25,35,65,.05);
  --btn-bg-hover: rgba(25,35,65,.10);
  --ok-bg: rgba(13,165,140,.10);
  --ok-border: rgba(13,165,140,.35);
  --danger-text: #c8384f;
  --danger-bg: rgba(200,56,79,.08);
  --danger-border: rgba(200,56,79,.32);
  --strip-track: rgba(25,35,65,.10);
  --tick: rgba(25,35,65,.25);
  --scrollbar: rgba(25,35,65,.15);
  --dot-oct-bg: rgba(196,120,16,.15);
  --dot-oct-border: rgba(178,106,8,.9);
  --dot-inter-bg: rgba(13,165,140,.25);
  --dot-inter-border: #0da58c;
  --dot-sq-bg: rgba(35,42,64,.2);
  --dot-sq-border: rgba(35,42,64,.75);
  --dot-ghost-border: rgba(35,42,64,.4);
  --conclusion-bg: rgba(13,165,140,.08);
  --conclusion-border: rgba(13,165,140,.28);
  --conclusion-text: #0a7a66;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 18% -8%, var(--bg-grad-1) 0%, rgba(0,0,0,0) 55%),
    radial-gradient(900px 600px at 108% 112%, var(--bg-grad-2) 0%, rgba(0,0,0,0) 55%),
    var(--bg-base);
  transition: color .25s ease;
}
.app { display: flex; height: 100vh; }

/* ---------- 左侧画布区 ---------- */
.stage { position: relative; flex: 1; min-width: 0; }
#cv { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#cv.dragging { cursor: grabbing; }
.legend {
  position: absolute; top: 18px; left: 22px;
  display: flex; gap: 16px;
  font-size: 12.5px; color: var(--text-dim); user-select: none;
}
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; flex: none; }
.dot-oct { background: var(--dot-oct-bg); border: 1.5px solid var(--dot-oct-border); }
.dot-inter { background: var(--dot-inter-bg); border: 1.5px solid var(--dot-inter-border); }
.dot-sq { background: var(--dot-sq-bg); border: 1.5px solid var(--dot-sq-border); }
.dot-ghost { background: transparent; border: 1.5px dashed var(--dot-ghost-border); }
.hint {
  position: absolute; left: 0; right: 0; bottom: 14px;
  text-align: center; font-size: 12.5px; color: var(--text-faint);
  pointer-events: none; user-select: none;
}

/* ---------- 右侧信息面板 ---------- */
.panel {
  width: 384px; padding: 24px 20px 30px;
  overflow-y: auto;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  transition: background-color .25s ease, border-color .25s ease;
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }
.head-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.head h1 { margin: 0; font-size: 19px; letter-spacing: .5px; }
.head p { margin: 6px 0 18px; font-size: 12.5px; color: var(--text-sub); line-height: 1.6; }

/* 主题切换分段控件 */
.theme-seg {
  display: flex; flex: none;
  border: 1px solid var(--border-strong);
  border-radius: 9px; overflow: hidden;
}
.theme-seg button {
  border: none; border-radius: 0;
  background: transparent;
  padding: 5px 10px; font-size: 12px;
  color: var(--text-sub);
}
.theme-seg button + button { border-left: 1px solid var(--border); }
.theme-seg button:hover { background: var(--btn-bg-hover); }
.theme-seg button.on { background: var(--accent-bg); color: var(--accent-text); }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px 15px;
  margin-bottom: 14px;
  transition: background-color .25s ease, border-color .25s ease;
}
.label { font-size: 12px; color: var(--text-mute); letter-spacing: .4px; margin-bottom: 9px; }

.angle-row { font-size: 46px; font-weight: 600; line-height: 1.05; font-variant-numeric: tabular-nums; }
.angle-row .deg { font-size: 22px; color: var(--text-sub); margin-left: 3px; font-weight: 400; }
.mod-line { margin-top: 7px; font-size: 12.5px; color: var(--text-sub); }
.mod-line b { color: var(--text-bright); font-weight: 600; font-variant-numeric: tabular-nums; }
.strip { margin-top: 13px; }
.strip-track { position: relative; height: 6px; border-radius: 3px; background: var(--strip-track); }
.tick { position: absolute; top: -3px; width: 1px; height: 12px; background: var(--tick); }
#stripMark {
  position: absolute; top: -5px; left: 0%;
  width: 3px; height: 16px; border-radius: 2px;
  background: var(--accent); transform: translateX(-50%);
  box-shadow: 0 0 10px var(--glow);
}
.strip-labels {
  display: flex; justify-content: space-between; margin-top: 8px;
  font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 10px;
  font-size: 16px; font-weight: 600; margin-bottom: 12px;
}
.badge.ok { color: var(--accent-text); background: var(--ok-bg); border: 1px solid var(--ok-border); }
.badge.no { color: var(--danger-text); background: var(--danger-bg); border: 1px solid var(--danger-border); }
.kv { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; color: var(--text-soft); padding: 2px 0; }
.kv b { font-variant-numeric: tabular-nums; }

.side-list { list-style: none; margin: 0; padding: 0; }
.side-list li {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--text-soft); padding: 3.5px 0;
  font-variant-numeric: tabular-nums;
}
.side-list em { font-style: normal; font-size: 11.5px; color: var(--text-mute); margin-left: 4px; }
.side-list .src { font-size: 11.5px; color: var(--text-mute); display: inline-flex; align-items: center; gap: 6px; }
.angle-list { font-size: 13px; color: var(--text-soft); line-height: 1.7; font-variant-numeric: tabular-nums; }

/* ---------- 控件 ---------- */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
button, select {
  background: var(--btn-bg);
  border: 1px solid var(--border-strong);
  color: var(--text-soft);
  padding: 7px 12px; border-radius: 9px;
  font-size: 13px; cursor: pointer; font-family: inherit;
  transition: background .15s, border-color .15s, color .15s;
}
button:hover, select:hover { background: var(--btn-bg-hover); }
button.on { border-color: var(--btn-on-border); color: var(--accent-text); }
button.primary { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent-text); min-width: 96px; }
button.primary:hover { background: var(--accent-bg-hover); }
#slider { width: 100%; accent-color: var(--accent); margin: 2px 0 12px; cursor: pointer; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); margin-top: 9px; cursor: pointer; }
.chk input { accent-color: var(--accent); }

/* ---------- 规律小结 ---------- */
.findings {
  border: 1px solid var(--border);
  background: var(--findings-bg);
  border-radius: 14px;
  padding: 13px 16px;
  transition: background-color .25s ease, border-color .25s ease;
}
.findings summary { cursor: pointer; font-size: 13.5px; color: var(--text-bright); font-weight: 600; letter-spacing: .3px; }
.findings-body { margin-top: 10px; font-size: 12.8px; color: var(--text-dim); line-height: 1.8; }
.findings-body ul { margin: 0; padding-left: 18px; }
.findings-body li { margin-bottom: 6px; }
.findings-body b { color: var(--text-bright); }
.conclusion {
  margin: 10px 0 0; padding: 9px 12px; border-radius: 9px;
  background: var(--conclusion-bg);
  border: 1px solid var(--conclusion-border);
  color: var(--conclusion-text);
}

@media (max-width: 920px) {
  .app { flex-direction: column; height: auto; }
  .stage { height: 58vh; min-height: 380px; }
  .panel { width: auto; border-left: none; border-top: 1px solid var(--border); }
}
