/* ============================
   全局重置 & CSS变量
   ============================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #1c2333;
  --border:    #30363d;
  --text:      #c9d1d9;
  --text2:     #8b949e;
  --accent:    #388bfd;
  --green:     #3fb950;
  --red:       #f85149;
  --amber:     #d29922;
  --purple:    #8b5cf6;

  --A: #3fb950;
  --T: #f85149;
  --C: #388bfd;
  --G: #d29922;
}

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
               'Microsoft YaHei', sans-serif;
  font-size: 13px;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ============================
   Header
   ============================ */
#header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  flex-shrink: 0;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}
.header-logo { font-size: 30px; }
#header h1 { font-size: 17px; font-weight: 700; color: var(--text); }
.subtitle { font-size: 11px; color: var(--text2); margin-top: 2px; }
.header-badge {
  margin-left: auto;
  background: rgba(56,139,253,0.18);
  color: var(--accent);
  border: 1px solid rgba(56,139,253,0.4);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.doc-link {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  margin-left: 8px;
}
.doc-link:hover {
  background: var(--border);
  color: var(--text);
  border-color: var(--text2);
}
.lang-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
  margin-left: 4px;
}
.lang-btn:hover {
  background: var(--border);
  color: var(--text);
  border-color: var(--text2);
}

/* ============================
   Step Navigation Bar
   ============================ */
#step-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  flex-shrink: 0;
  overflow-x: auto;
}
#step-bar-inner {
  display: flex;
  align-items: center;
  min-width: max-content;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  color: var(--text2);
  user-select: none;
}
.step-item:hover { background: var(--bg3); color: var(--text); }
.step-item.active { background: rgba(56,139,253,0.15); color: var(--accent); }
.step-item.done  { color: var(--green); }
.step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid currentColor;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.step-item.active .step-num { background: var(--accent); border-color: var(--accent); color: #fff; }
.step-item.done  .step-num  { background: var(--green);  border-color: var(--green);  color: #fff; }
.step-name { font-size: 12px; font-weight: 500; white-space: nowrap; }
.step-connector { width: 16px; height: 2px; background: var(--border); flex-shrink: 0; }

/* ============================
   Config Panel
   ============================ */
#cfg-bar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 7px 20px;
  flex-shrink: 0;
}
.cfg-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.cfg-field {
  display: flex;
  align-items: center;
  gap: 7px;
}
.cfg-lbl {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
}
.cfg-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.cfg-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: background 0.15s;
}
.cfg-slider::-webkit-slider-thumb:hover { background: #58a6ff; }
.cfg-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}
.cfg-val {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  min-width: 38px;
}
.cfg-gen-btn {
  margin-left: auto;
  background: rgba(63,185,80,0.15);
  border: 1px solid rgba(63,185,80,0.4);
  color: var(--green);
  padding: 4px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}
.cfg-gen-btn:hover {
  background: rgba(63,185,80,0.28);
  border-color: var(--green);
}

/* ============================
   Main Content
   ============================ */
#content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Visualization Panel */
#vis-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
  min-width: 0;
}
#vis-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#step-title { font-size: 15px; font-weight: 600; color: var(--text); }
#step-desc  { font-size: 12px; color: var(--text2); margin-top: 3px; line-height: 1.5; }

#vis-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: var(--bg);
  overflow: hidden;
}
#main-svg {
  width: 100%;
  height: 100%;
  max-width: 820px;
  max-height: 390px;
}

/* Substep progress bar */
#substep-bar {
  padding: 7px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg2);
}
#substep-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}
.sdot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.sdot:hover { border-color: var(--text2); }
.sdot.active { background: var(--accent); transform: scale(1.25); }
.sdot.done   { background: var(--green); }
#substep-label { font-size: 12px; color: var(--text2); flex: 1; }

/* Theory Panel */
#theory-panel {
  width: 300px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--bg2);
  display: flex;
  flex-direction: column;
}
#theory-panel::-webkit-scrollbar { width: 5px; }
#theory-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.theory-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 1;
}
.theory-icon { font-size: 16px; }
.theory-hdr h3 { font-size: 13px; font-weight: 600; }

#theory-content {
  padding: 14px;
  line-height: 1.75;
  color: var(--text);
}
.tsec { margin-bottom: 14px; }
.tsec h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.tsec p { font-size: 12px; color: #c9d1d9; margin-bottom: 6px; }
.tsec ul { margin-left: 16px; font-size: 12px; line-height: 2; }

.hbox {
  background: rgba(56,139,253,0.10);
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  border-radius: 0 4px 4px 0;
  margin: 8px 0;
  font-size: 12px;
  line-height: 1.6;
}
.hbox-g {
  background: rgba(63,185,80,0.10);
  border-left: 3px solid var(--green);
  padding: 8px 10px;
  border-radius: 0 4px 4px 0;
  margin: 8px 0;
  font-size: 12px;
  line-height: 1.6;
}
.code-box {
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--green);
  margin: 6px 0;
  white-space: pre;
  overflow-x: auto;
}
.btag {
  display: inline-block;
  width: 17px; height: 17px;
  border-radius: 3px;
  text-align: center;
  line-height: 17px;
  font-size: 10px;
  font-weight: bold;
  color: white;
  margin: 0 2px;
  vertical-align: middle;
}
.bA { background: var(--A); }
.bT { background: var(--T); }
.bC { background: var(--C); }
.bG { background: var(--G); }

/* ============================
   Controls
   ============================ */
#controls-bar {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 9px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ctrl-group { display: flex; gap: 7px; align-items: center; }
.ctrl-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.ctrl-btn:hover:not(:disabled) { background: var(--border); border-color: var(--text2); }
.ctrl-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.ctrl-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  min-width: 88px;
}
.ctrl-btn.primary:hover:not(:disabled) { background: #58a6ff; }
.ctrl-btn.primary.playing {
  background: var(--purple);
  border-color: var(--purple);
}
