/* ============================================================
 * 仿真页：头部、标签栏、舞台、控制面板、原理面板
 * ============================================================ */

/* ---------------- 头部 ---------------- */
.sim-head {
  padding: 26px 0 20px;
}

.back-link {
  display: inline-block;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  transition: color .15s;
}

.back-link:hover {
  color: var(--brand);
}

.sim-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 0 10px;
  flex-wrap: wrap;
}

.sim-title {
  font-size: clamp(24px, 2.8vw, 32px);
  letter-spacing: -.02em;
}

.sim-cat {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--grad-soft);
  border: 1px solid rgba(79, 70, 229, .14);
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 600;
}

.sim-sum {
  max-width: 860px;
  color: var(--muted);
  font-size: 14.5px;
}

.sim-head .card-tags {
  margin-top: 12px;
}

/* ---------------- 主体布局 ---------------- */
.sim-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 22px;
  align-items: start;
}

.stage-col {
  min-width: 0;
}

/* ---------------- 标签栏 ---------------- */
.tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 13px;
  margin-bottom: 14px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.tab {
  padding: 8px 18px;
  border: none;
  background: transparent;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .16s;
}

.tab:hover {
  color: var(--ink);
}

.tab.is-on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--sh-1);
}

/* ---------------- 图表工具条 ---------------- */
.stage-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--sh-1);
  flex-wrap: wrap;
}

.tools-label {
  font-size: 12px;
  color: var(--muted-2);
  font-weight: 500;
}

.stage-tools .tools-label:not(:first-child) {
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.stage-tools .mini {
  flex: 0 0 auto;
  padding: 5px 12px;
  font-size: 12.5px;
}

.stage-tools .mini.is-on {
  background: var(--brand-soft);
  border-color: rgba(79, 70, 229, .32);
  color: var(--brand);
  font-weight: 600;
}

/* ---------------- 舞台 ---------------- */
.stage {
  position: relative;
  width: 100%;
  height: clamp(420px, 60vh, 660px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  overflow: hidden;
}

.sim-canvas,
.graph-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.sim-canvas {
  cursor: grab;
}

.sim-canvas.is-grabbing {
  cursor: grabbing;
}

/* ---------------- 控制面板 ---------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  padding: 6px 18px 18px;
  position: sticky;
  top: calc(var(--header-h) + 16px);
  max-height: calc(100vh - var(--header-h) - 34px);
  overflow-y: auto;
}

.panel-sec {
  padding: 16px 0 4px;
  border-bottom: 1px solid var(--line);
}

.panel-sec:last-of-type {
  border-bottom: none;
}

.panel-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 13px;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.btn-row .btn {
  flex: 1 1 auto;
  min-width: 74px;
  text-align: center;
}

/* --- 字段 --- */
.field {
  margin-bottom: 15px;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.field-label {
  font-size: 13.5px;
  color: var(--ink-2);
  font-weight: 500;
}

.field-value {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--brand);
  font-weight: 600;
  white-space: nowrap;
}

.field-hint {
  font-size: 12px;
  color: var(--muted-2);
  line-height: 1.55;
  margin-top: 6px;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 4px;
  background: var(--bg-soft);
  outline: none;
  margin: 4px 0 0;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--grad);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, .45);
  cursor: pointer;
  transition: transform .12s;
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4f46e5;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, .45);
  cursor: pointer;
}

.num {
  width: 100%;
  margin-top: 7px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12.5px;
  outline: none;
  transition: border .15s;
}

.num:focus {
  border-color: rgba(79, 70, 229, .5);
  background: #fff;
}

.select {
  width: 100%;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  font-size: 13.5px;
  outline: none;
  cursor: pointer;
  transition: border .15s;
}

.select:focus {
  border-color: rgba(79, 70, 229, .5);
}

.rate-hints {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.mini {
  flex: 1;
  padding: 4px 0;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}

.mini:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

/* --- 复选 --- */
.flag-box {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-bottom: 6px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  line-height: 1.5;
}

.check input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 17px;
  height: 17px;
  margin-top: 2px;
  border-radius: 5px;
  border: 1.5px solid var(--line-2);
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: all .15s;
}

.check input:checked {
  background: var(--grad);
  border-color: transparent;
}

.check input:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 4.5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}

.check:hover input {
  border-color: #b9c2d6;
}

.panel-note {
  margin-top: 16px;
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--bg-soft);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------------- 原理面板 ---------------- */
.about-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  padding: 30px 34px 32px;
}

.principle p {
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.85;
  margin-bottom: 13px;
}

.principle p:last-child {
  margin-bottom: 0;
}

.principle strong {
  color: var(--ink);
  font-weight: 650;
}

.principle p.formula {
  margin: 16px 0;
  padding: 13px 18px;
  border-radius: 10px;
  background: linear-gradient(100deg, rgba(79, 70, 229, .055), rgba(8, 145, 178, .055));
  border-left: 3px solid var(--brand);
  font-size: 15px;
  overflow-x: auto;
}

.eq {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.06em;
  letter-spacing: .01em;
  white-space: nowrap;
}

.principle p.formula .eq {
  font-size: 1.16em;
}

.tryit {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px dashed var(--line-2);
}

.tryit .note-title {
  margin-bottom: 14px;
  font-size: 15px;
}

.tryit .note-list {
  counter-reset: ti;
}

.tryit .note-list li {
  counter-increment: ti;
  padding-left: 30px;
  margin-bottom: 11px;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.7;
  position: relative;
}

.tryit .note-list li::before {
  content: counter(ti);
  position: absolute;
  left: 0;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 700;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .sim-body {
    grid-template-columns: 1fr;
  }

  .panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .sim-head {
    padding: 18px 0 14px;
  }

  .stage {
    height: clamp(300px, 48vh, 420px);
  }

  .about-panel {
    padding: 22px 20px 24px;
  }

  .principle p.formula {
    padding: 11px 14px;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    padding: 8px 13px;
    font-size: 13px;
  }
}
