/* ============================================================
   Quantum Explorer - 量子计算学习平台样式
   深色量子科技风格
   ============================================================ */

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #1a2236;
  --bg-card-hover: #1f2b45;
  --border: #2a3550;
  --text-primary: #e8ecf4;
  --text-secondary: #9aa5b8;
  --accent: #4f8cff;
  --accent-bright: #6ea8ff;
  --accent-purple: #9b6dff;
  --accent-cyan: #22d3ee;
  --accent-green: #34d399;
  --accent-orange: #fbbf24;
  --accent-red: #f87171;
  --gradient-main: linear-gradient(135deg, #4f8cff 0%, #9b6dff 100%);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --radius: 12px;
}

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

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ============ 星空背景 ============ */
.bg-stars {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(79, 140, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(155, 109, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(34, 211, 238, 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: -1;
}

.bg-stars::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20px 30px, #ffffff33, transparent),
    radial-gradient(1px 1px at 130px 80px, #ffffff44, transparent),
    radial-gradient(1.5px 1.5px at 230px 120px, #ffffff22, transparent),
    radial-gradient(1px 1px at 340px 60px, #ffffff33, transparent),
    radial-gradient(1px 1px at 420px 150px, #ffffff55, transparent),
    radial-gradient(1.5px 1.5px at 520px 90px, #ffffff22, transparent);
  background-size: 550px 200px;
  animation: twinkle 8s ease-in-out infinite alternate;
}

@keyframes twinkle {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* ============ 顶部导航 ============ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px rgba(79, 140, 255, 0.5));
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-name em {
  font-style: normal;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.navbar-tabs {
  display: flex;
  gap: 6px;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.25s;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(79, 140, 255, 0.1);
}

.tab-btn.active {
  background: var(--gradient-main);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(79, 140, 255, 0.35);
}

/* ============ 主容器 ============ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ 学习中心 Hero ============ */
.hero {
  text-align: center;
  padding: 40px 20px 36px;
  background: linear-gradient(180deg, rgba(79, 140, 255, 0.08), transparent);
  border-radius: 16px;
  margin-bottom: 32px;
}

.hero h1 {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 14px;
  background: linear-gradient(90deg, #ffffff, var(--accent-bright));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  color: var(--text-secondary);
  font-size: 16px;
}

/* ============ 概念卡片 ============ */
.concepts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.concept-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.concept-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-main);
  opacity: 0;
  transition: opacity 0.3s;
}

.concept-card:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.concept-card:hover::before {
  opacity: 1;
}

.concept-icon {
  font-size: 40px;
  margin-bottom: 12px;
  display: block;
}

.concept-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.concept-card .concept-summary {
  color: var(--text-secondary);
  font-size: 14px;
}

.concept-card .concept-tag {
  display: inline-block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--accent-bright);
  background: rgba(79, 140, 255, 0.12);
  padding: 4px 10px;
  border-radius: 12px;
}

/* ============ 概念详情 ============ */
.concept-detail {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  margin-top: 20px;
}

.btn-back {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 20px;
  transition: all 0.25s;
}

.btn-back:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
}

.concept-detail h2 {
  font-size: 26px;
  margin-bottom: 16px;
}

.concept-detail .concept-full {
  font-size: 16px;
  color: var(--text-primary);
  line-height: 1.8;
  margin-bottom: 20px;
  white-space: pre-line;
}

.demo-launch {
  background: rgba(79, 140, 255, 0.08);
  border: 1px dashed var(--accent);
  border-radius: 12px;
  padding: 16px 20px;
  margin-top: 16px;
}

.demo-launch p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 12px;
}

/* ============ 通用按钮 ============ */
.btn-primary {
  background: var(--gradient-main);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.25s;
  width: 100%;
}

.btn-primary:hover {
  filter: brightness(1.15);
  box-shadow: 0 4px 16px rgba(79, 140, 255, 0.4);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.25s;
  width: 100%;
  margin-top: 10px;
}

.btn-ghost {
  padding: 10px 22px;
  border-radius: 10px;
  border: 1px solid rgba(140, 200, 255, 0.45);
  background: transparent;
  color: #a8d4ff;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.25s;
}
.btn-ghost:hover {
  border-color: #5db2ff;
  color: #ffffff;
  background: rgba(40, 110, 190, 0.18);
}

.btn-secondary:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.hidden {
  display: none !important;
}

/* ============ 线路实验室 ============ */
.lab-header {
  margin-bottom: 24px;
}

.lab-header h2 {
  font-size: 26px;
  margin-bottom: 8px;
}

.lab-header p {
  color: var(--text-secondary);
}

.lab-layout {
  display: grid;
  grid-template-columns: 220px 1fr 300px;
  gap: 20px;
  align-items: start;
}

/* 门面板 */
.gate-panel, .circuit-panel, .result-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.gate-panel h3, .result-panel h3 {
  font-size: 16px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.gate-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.gate-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 6px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.gate-btn:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
  background: rgba(79, 140, 255, 0.1);
}

.gate-btn.selected {
  background: var(--gradient-main);
  color: #fff;
  border-color: transparent;
}

.gate-btn .gate-hint {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 2px;
}

.gate-btn.selected .gate-hint {
  color: rgba(255, 255, 255, 0.8);
}

.angle-control {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}

.angle-control label {
  font-size: 13px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 8px;
}

.angle-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.angle-control #angle-value {
  display: block;
  text-align: center;
  font-size: 13px;
  color: var(--accent-cyan);
  margin-top: 6px;
  font-family: "Consolas", monospace;
}

/* 电路面板 */
.circuit-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.circuit-controls label {
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.circuit-controls select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 14px;
}

.btn-run {
  background: linear-gradient(135deg, #34d399, #10b981);
  color: #fff;
  border: none;
  padding: 8px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  margin-left: auto;
}

.btn-run:hover {
  filter: brightness(1.15);
  box-shadow: 0 4px 16px rgba(52, 211, 153, 0.4);
}

.circuit-canvas {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 200px;
  overflow-x: auto;
  padding: 16px;
}

.empty-hint {
  color: var(--text-secondary);
  font-size: 14px;
  text-align: center;
  padding: 30px 10px;
}

/* 线路网格 */
.circuit-grid {
  position: relative;
  min-width: 400px;
}

.circuit-wire {
  display: flex;
  align-items: center;
  height: 52px;
  border-bottom: 1px solid rgba(42, 53, 80, 0.5);
  position: relative;
}

.circuit-wire:last-child {
  border-bottom: none;
}

.wire-label {
  width: 42px;
  text-align: center;
  font-size: 13px;
  color: var(--accent-cyan);
  font-family: "Consolas", monospace;
  flex-shrink: 0;
}

.wire-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  position: relative;
}

.gate-box {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--accent-bright);
  width: 42px;
  height: 34px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  z-index: 2;
  transition: all 0.2s;
  user-select: none;
}

.gate-box:hover {
  background: rgba(79, 140, 255, 0.2);
  transform: translate(-50%, -50%) scale(1.1);
}

.gate-box.control-dot {
  background: var(--accent);
  border-color: var(--accent);
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.gate-box.connector {
  background: var(--accent);
  border: none;
  width: 2px;
  height: 52px;
  border-radius: 0;
}

/* 结果面板 */
.result-content {
  font-size: 14px;
}

.result-stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(42, 53, 80, 0.4);
  color: var(--text-secondary);
}

.result-stat strong {
  color: var(--text-primary);
}

.state-vector {
  margin: 12px 0;
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 12px;
  font-family: "Consolas", monospace;
  font-size: 12px;
  line-height: 1.8;
  color: var(--accent-cyan);
  max-height: 220px;
  overflow-y: auto;
}

.chart-container {
  margin-top: 14px;
}

.chart-container h4 {
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.bar-label {
  width: 40px;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: "Consolas", monospace;
  text-align: right;
  flex-shrink: 0;
}

.bar-track {
  flex: 1;
  height: 20px;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--gradient-main);
  border-radius: 4px;
  transition: width 0.6s ease;
  min-width: 2px;
}

.bar-value {
  width: 56px;
  font-size: 12px;
  color: var(--accent-bright);
  font-family: "Consolas", monospace;
  flex-shrink: 0;
}

.loading {
  text-align: center;
  padding: 20px;
  color: var(--accent-cyan);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.error-msg {
  color: var(--accent-red);
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
  padding: 12px;
  border-radius: 8px;
  margin: 10px 0;
  font-size: 14px;
}

/* ============ 算法演示 ============ */
.demos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.demo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  cursor: pointer;
  transition: all 0.3s;
}

.demo-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent-purple);
  box-shadow: var(--shadow);
}

.demo-card h3 {
  font-size: 18px;
  margin-bottom: 10px;
  color: var(--accent-bright);
}

.demo-card p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 14px;
}

.demo-card .demo-tag {
  display: inline-block;
  font-size: 12px;
  color: var(--accent-purple);
  background: rgba(155, 109, 255, 0.15);
  padding: 4px 10px;
  border-radius: 12px;
}

.demo-result {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  margin-top: 20px;
}

.demo-result h2 {
  font-size: 24px;
  margin-bottom: 10px;
}

.demo-desc {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.7;
}

.learn-box {
  background: rgba(155, 109, 255, 0.08);
  border: 1px solid rgba(155, 109, 255, 0.3);
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-primary);
}

.learn-box strong {
  color: var(--accent-purple);
}

/* ============ 关于页 ============ */
.about-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 800px;
  margin: 0 auto;
  overflow: hidden;
}

.about-header {
  text-align: center;
  padding: 40px 24px;
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.15), rgba(155, 109, 255, 0.15));
  border-bottom: 1px solid var(--border);
}

.about-logo {
  font-size: 56px;
  display: block;
  margin-bottom: 12px;
}

.about-header h2 {
  font-size: 30px;
  margin-bottom: 6px;
}

.about-sub {
  color: var(--text-secondary);
  font-size: 14px;
}

.about-body {
  padding: 28px 32px;
}

.about-body h3 {
  font-size: 17px;
  margin: 20px 0 10px;
  color: var(--accent-bright);
}

.about-body p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.8;
}

.about-body ul {
  margin: 10px 0 10px 20px;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 2;
}

.about-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ============ 页脚 ============ */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 13px;
  border-top: 1px solid var(--border);
  background: rgba(10, 14, 26, 0.6);
}
.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
}
.footer-links a {
  color: #7fd4ff;
  text-decoration: none;
  transition: color 0.2s;
}
.footer-links a:hover {
  color: #ffffff;
}
.footer-sep {
  color: rgba(140, 190, 235, 0.4);
}
.footer-share {
  background: transparent;
  border: none;
  color: #7fd4ff;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}
.footer-share:hover {
  color: #ffffff;
}

.hidden-canvas {
  display: none;
}

/* ============ 真机运行按钮 ============ */
.btn-real {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  border: none;
  padding: 8px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
}

.btn-real:hover {
  filter: brightness(1.15);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
}

/* ============ 真机运行模态框 ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 18px;
  color: var(--accent-orange);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--accent-red);
}

.modal-body {
  padding: 20px 24px;
}

.modal-note {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 12px;
}

.originir-code {
  background: #0d1220;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--accent-cyan);
  overflow-x: auto;
  max-height: 260px;
  overflow-y: auto;
  white-space: pre;
}

.device-selector {
  margin-top: 18px;
}

.device-selector h4 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.device-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-option {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.device-option:hover {
  border-color: var(--accent-orange);
}

.device-option.selected {
  border-color: var(--accent-orange);
  background: rgba(245, 158, 11, 0.1);
}

.device-option input[type="radio"] {
  accent-color: var(--accent-orange);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.device-option .device-info {
  flex: 1;
}

.device-option .device-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.device-option .device-detail {
  font-size: 12px;
  color: var(--text-secondary);
}

.device-option .device-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent-green);
  flex-shrink: 0;
}

.modal-tip {
  margin-top: 18px;
  background: rgba(79, 140, 255, 0.06);
  border: 1px dashed rgba(79, 140, 255, 0.4);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.modal-tip strong {
  color: var(--accent-bright);
}

.modal-tip ol {
  margin: 6px 0 0 18px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.modal-footer .btn-primary,
.modal-footer .btn-secondary {
  width: auto;
  margin-top: 0;
}

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
  .lab-layout {
    grid-template-columns: 1fr;
  }
  .navbar {
    flex-direction: column;
    gap: 12px;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 16px;
  }
  .hero h1 {
    font-size: 26px;
  }
  .brand-sub {
    display: none;
  }
  .navbar-tabs {
    flex-wrap: wrap;
    justify-content: center;
  }
  .concepts-grid, .demos-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   语言切换按钮
   ============================================================ */
.lang-switcher {
  margin-left: 16px;
  display: flex;
  align-items: center;
}

.btn-lang {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(99, 102, 241, 0.5);
  color: #c4b5fd;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  letter-spacing: 1px;
}

.btn-lang:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.4), rgba(139, 92, 246, 0.4));
  border-color: #818cf8;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

@media (max-width: 900px) {
  .lang-switcher {
    margin-left: 8px;
  }
  .btn-lang {
    padding: 4px 12px;
    font-size: 12px;
  }
}

/* ============================================================
   Quantum Explorer 2.0 新增组件样式
   ============================================================ */

/* --- 量子门酉矩阵参考 --- */
.gate-matrix {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}

.gate-matrix h4 {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.gate-matrix h4 #gate-matrix-name {
  color: var(--accent-cyan);
  font-family: "Consolas", monospace;
  margin-left: 4px;
}

#gate-matrix-content {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.matrix-cell {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid rgba(79, 140, 255, 0.25);
  border-radius: 6px;
  font-family: "Consolas", monospace;
  font-size: 12px;
  color: var(--accent-bright);
}

.matrix-cell.dim {
  opacity: 0.45;
}

/* --- 线路统计信息栏 --- */
.circuit-stats {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.stat-chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stat-chip strong {
  color: var(--accent-bright);
  font-family: "Consolas", monospace;
  font-size: 13px;
}

.stat-chip .stat-cnot {
  color: var(--accent-orange);
}

.stat-chip .stat-depth {
  color: var(--accent-green);
}

/* --- 布洛赫球面板 --- */
.bloch-panel {
  margin-top: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.bloch-panel h4 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bloch-focus {
  color: var(--accent-cyan);
  font-family: "Consolas", monospace;
  font-size: 12px;
  background: rgba(34, 211, 238, 0.12);
  padding: 2px 10px;
  border-radius: 12px;
}

.bloch-wrap {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

#bloch-canvas {
  border-radius: 8px;
  background: radial-gradient(circle at 50% 40%, #141c30 0%, #0a0e1a 100%);
  cursor: grab;
  flex-shrink: 0;
}

#bloch-canvas:active {
  cursor: grabbing;
}

.bloch-side {
  flex: 1;
  min-width: 0;
}

.bloch-qubit-select {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.bloch-qubit-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.bloch-qubit-btn:hover {
  border-color: var(--accent);
  color: var(--accent-bright);
}

.bloch-qubit-btn.active {
  background: var(--gradient-main);
  color: #fff;
  border-color: transparent;
}

.bloch-coords {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: "Consolas", monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.bloch-coords .coord-xy {
  color: var(--accent-cyan);
}

.bloch-coords .coord-z {
  color: var(--accent-orange);
}

.bloch-coords .coord-th {
  color: var(--accent-green);
}

/* ============ 知识测验 ============ */
.quiz-setup {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.quiz-setup select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
}

.quiz-setup select:focus {
  border-color: var(--accent);
}

.quiz-progress {
  font-size: 14px;
  color: var(--accent-bright);
  margin-bottom: 16px;
  font-weight: 600;
}

.quiz-questions {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.quiz-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: border-color 0.2s;
}

.quiz-card:hover {
  border-color: var(--accent);
}

.quiz-q-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.quiz-q-num {
  background: var(--gradient-main);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  border-radius: 6px;
  padding: 3px 10px;
}

.quiz-cat {
  background: rgba(79, 140, 255, 0.15);
  color: var(--accent-bright);
  font-size: 12px;
  border-radius: 20px;
  padding: 2px 12px;
}

.quiz-q-text {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.quiz-option:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.quiz-option.selected {
  border-color: var(--accent);
  background: rgba(79, 140, 255, 0.12);
}

.quiz-opt-letter {
  width: 26px;
  height: 26px;
  min-width: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.quiz-option.selected .quiz-opt-letter {
  background: var(--gradient-main);
  border-color: transparent;
  color: #fff;
}

.quiz-actions {
  margin-top: 22px;
  text-align: center;
}

.quiz-result-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.score-banner {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--gradient-main);
  border-radius: var(--radius);
  padding: 20px 26px;
  margin-bottom: 24px;
  color: #fff;
}

.score-emoji {
  font-size: 44px;
}

.score-main h3 {
  font-size: 22px;
}

.quiz-feedback {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
}

.feedback-card {
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 14px 18px;
  background: var(--bg-primary);
}

.feedback-card.ok {
  border-left-color: var(--accent-green);
}

.feedback-card.no {
  border-left-color: var(--accent-red);
}

.feedback-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.fb-mark {
  font-size: 18px;
}

.fb-q {
  font-weight: 600;
  flex: 1;
}

.fb-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 20px;
}

.feedback-card.ok .fb-badge {
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent-green);
}

.feedback-card.no .fb-badge {
  background: rgba(248, 113, 113, 0.15);
  color: var(--accent-red);
}

.fb-line {
  font-size: 14px;
  margin: 4px 0;
}

.fb-line.ok-line {
  color: var(--accent-green);
}

.fb-explain {
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(155, 109, 255, 0.08);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
}

/* ============ Python 课程 ============ */
.python-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  align-items: start;
}

.python-lessons {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: sticky;
  top: 20px;
}

.python-lessons h3 {
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--accent-bright);
}

.lesson-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lesson-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lesson-item:hover {
  border-color: var(--accent);
}

.lesson-item.active {
  border-color: var(--accent);
  background: rgba(79, 140, 255, 0.12);
}

.lesson-title {
  font-size: 14px;
  font-weight: 600;
}

.lesson-summary {
  font-size: 12px;
  color: var(--text-secondary);
}

.python-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.lesson-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
}

.lesson-content h3 {
  font-size: 20px;
  margin-bottom: 12px;
}

.lesson-body p {
  margin-bottom: 12px;
  font-size: 14.5px;
}

.lesson-body pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 10px 0 14px;
  overflow-x: auto;
}

.lesson-body code {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 13px;
  color: var(--accent-cyan);
}

.lesson-body pre code {
  color: var(--text-primary);
  line-height: 1.6;
}

.lesson-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
}

.python-editor-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.python-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}

.python-editor-box textarea {
  width: 100%;
  min-height: 170px;
  background: var(--bg-primary);
  border: none;
  color: var(--text-primary);
  font-family: "Consolas", "Courier New", monospace;
  font-size: 13.5px;
  line-height: 1.7;
  padding: 16px 18px;
  resize: vertical;
  outline: none;
  tab-size: 4;
}

.python-output {
  background: #0d1117;
  border-top: 1px solid var(--border);
  color: var(--accent-green);
  font-family: "Consolas", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.7;
  padding: 14px 18px;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 48px;
  margin: 0;
}

.python-output.has-error {
  color: var(--accent-red);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}

/* ============ 通信协议演示（传态/超密编码） ============ */
.custom-demo-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin: 16px 0;
}

.custom-demo-box h3 {
  font-size: 17px;
  margin-bottom: 12px;
  color: var(--accent-bright);
}

.teleport-orig {
  font-size: 14px;
  margin-bottom: 14px;
  color: var(--text-secondary);
}

.proto-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin-bottom: 14px;
}

.proto-table th {
  text-align: left;
  color: var(--accent-bright);
  font-size: 12.5px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
}

.proto-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(42, 53, 80, 0.5);
}

.proto-table tr:hover td {
  background: rgba(79, 140, 255, 0.06);
}

.proto-table .mono {
  font-family: "Consolas", monospace;
}

.proto-table .ok-cell {
  color: var(--accent-green);
}

.demo-verdict {
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  padding: 12px 16px;
}

.demo-verdict.ok {
  background: rgba(52, 211, 153, 0.12);
  color: var(--accent-green);
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.demo-verdict.no {
  background: rgba(248, 113, 113, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.demo-hint {
  font-size: 13px;
  color: var(--text-muted, #94a3b8);
  margin-top: 10px;
  padding: 8px 12px;
  background: rgba(148, 163, 184, 0.08);
  border-radius: 8px;
}

@media (max-width: 860px) {
  .python-layout {
    grid-template-columns: 1fr;
  }

  .python-lessons {
    position: static;
  }
}

/* ============================================================
 * 试用版欢迎遮罩（PWA 首访引导）
 * ============================================================ */
.trial-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at center, rgba(6, 18, 44, 0.92) 0%, rgba(2, 6, 18, 0.97) 100%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}
.trial-overlay.show {
  opacity: 1;
  visibility: visible;
}
.trial-card {
  width: min(560px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  padding: 38px 40px 30px;
  border-radius: 20px;
  border: 1px solid rgba(120, 190, 255, 0.35);
  background: linear-gradient(160deg, rgba(16, 40, 84, 0.95), rgba(8, 16, 40, 0.98));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 40px rgba(60, 150, 255, 0.12);
  text-align: center;
  transform: translateY(14px) scale(0.98);
  transition: transform 0.35s ease;
}
.trial-overlay.show .trial-card {
  transform: translateY(0) scale(1);
}
.trial-badge {
  display: inline-block;
  padding: 5px 14px;
  margin-bottom: 16px;
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: #7fd4ff;
  background: rgba(40, 130, 220, 0.16);
  border: 1px solid rgba(90, 180, 255, 0.4);
}
.trial-title {
  font-size: 2.1rem;
  margin: 0 0 8px;
  color: #f0f7ff;
}
.trial-title em {
  color: #6fc3ff;
  font-style: normal;
}
.trial-tagline {
  color: #9db8d8;
  margin: 0 0 22px;
  font-size: 0.95rem;
}
.trial-features {
  list-style: none;
  margin: 0 0 26px;
  padding: 0;
  text-align: left;
}
.trial-features li {
  padding: 9px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: rgba(20, 50, 100, 0.35);
  border-left: 3px solid rgba(90, 180, 255, 0.6);
  color: #cfe3f8;
  font-size: 0.93rem;
}
.trial-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.trial-note {
  margin: 0;
  font-size: 0.8rem;
  color: #6f8cac;
}

/* ============ UI 细节打磨 ============ */
/* 下拉框：统一深色外观 + 自定义箭头 */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239aa5b8' d='M1.4 0l4.6 4.6L10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

select:hover {
  border-color: var(--accent);
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}

select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* 滚动条：匹配深色主题 */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #2c3a5c;
  border-radius: 6px;
  border: 2px solid var(--bg-primary);
}
::-webkit-scrollbar-thumb:hover {
  background: #3a4c78;
}
* {
  scrollbar-width: thin;
  scrollbar-color: #2c3a5c var(--bg-primary);
}

/* 文本选区：量子渐变 */
::selection {
  background: rgba(79, 140, 255, 0.35);
  color: #ffffff;
}

/* 键盘可达性焦点环 */
:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

/* 按钮按下反馈 */
.btn-primary:active,
.btn-secondary:active,
.btn-ghost:active,
.btn-run:active,
.btn-real:active {
  transform: translateY(1px) scale(0.98);
}

