/* ── Quant Finance Lab — shared styles ── */

.lab-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.2rem 4rem;
}

.lab-hero {
  padding: 2.2rem 0 1.4rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.8rem;
}

.lab-hero .lab-eyebrow {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
  margin-bottom: 0.4rem;
}

.lab-hero h1 {
  font-size: clamp(1.6rem, 2.4vw + 0.6rem, 2.3rem);
  margin: 0 0 0.6rem;
  line-height: 1.25;
}

.lab-hero p {
  color: var(--muted);
  max-width: 720px;
  margin: 0;
}

/* Stepper */
.lab-stepper {
  display: flex;
  gap: 0.4rem;
  margin: 1.4rem 0 0.2rem;
  flex-wrap: wrap;
}

.lab-step {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  font-size: 0.82rem;
  color: var(--muted);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
}

.lab-step .step-num {
  display: inline-flex;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  align-items: center;
  justify-content: center;
}

.lab-step.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.lab-step.active .step-num {
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.lab-step.done {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
}

.lab-step.done .step-num {
  background: var(--success);
  color: #fff;
}

/* Section card */
.lab-section {
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 1.6rem 1.8rem;
  margin-bottom: 1.4rem;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.lab-section h2 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.lab-section h2 .sec-badge {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  letter-spacing: 0.04em;
}

.lab-section .sec-hint {
  color: var(--muted);
  margin: 0 0 1.2rem;
  font-size: 0.95rem;
}

/* Asset picker grid */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.7rem;
  margin-top: 0.6rem;
}

.asset-card {
  position: relative;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.18s var(--transition);
  user-select: none;
}

.asset-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.1);
}

.asset-card.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(37, 99, 235, 0.02));
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.15);
}

.asset-card .ac-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.asset-card .ac-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
}

.asset-card .ac-tag {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--muted);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
}

.asset-card .ac-desc {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.25rem;
  line-height: 1.4;
  min-height: 2.3em;
}

.asset-card .ac-metrics {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: 'Space Grotesk', sans-serif;
}

.asset-card .ac-metrics span b {
  color: var(--ink);
  font-weight: 600;
  margin-left: 0.2rem;
}

.asset-card .ac-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.18s var(--transition);
}

.asset-card.selected .ac-check {
  opacity: 1;
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

/* Filter chips */
.filter-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.filter-chip {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid transparent;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--muted);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  transition: all 0.15s;
}

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

.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Method chips (multi-select) */
.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
}

.method-chip {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.18s;
  position: relative;
}

.method-chip:hover {
  border-color: var(--primary-light);
}

.method-chip.selected {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(37, 99, 235, 0.01));
}

.method-chip .mc-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.method-chip .mc-sub {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.3rem;
  line-height: 1.4;
}

.method-chip .mc-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Settings controls */
.settings-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.9rem;
  margin-top: 0.4rem;
}

.setting-block {
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
}

.setting-block label {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.setting-block input[type="number"],
.setting-block input[type="date"],
.setting-block select {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
}

.setting-block input:focus,
.setting-block select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.setting-block .hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.3rem;
}

/* Buttons */
.btn-lab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  border: none;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-lab:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.25);
}

.btn-lab:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-lab.ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-lab.ghost:hover {
  background: var(--primary);
  color: #fff;
}

.btn-lab.small {
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
}

/* Result cards */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.1rem 1.1rem;
  transition: all 0.2s;
}

.result-card:hover {
  border-color: var(--primary-light);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.08);
}

.result-card h4 {
  margin: 0 0 0.5rem;
  font-size: 0.96rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.result-card h4 .rc-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.88rem;
}

.metric-row:last-child {
  border-bottom: none;
}

.metric-row .mk {
  color: var(--muted);
}

.metric-row .mv {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  color: var(--ink);
}

.metric-row .mv.pos {
  color: var(--success);
}

.metric-row .mv.neg {
  color: var(--danger);
}

/* Weights bar */
.weights-bar {
  margin: 0.6rem 0 0.1rem;
  display: flex;
  height: 24px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.weights-bar .wseg {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.72rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.weights-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.weights-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.weights-legend .wdot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* Chart containers */
.chart-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.2rem 1.2rem;
  margin-top: 0.8rem;
}

.chart-box h3 {
  margin: 0 0 0.6rem;
  font-size: 1.02rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.chart-box h3 .chart-hint {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--muted);
}

.chart-wrap {
  position: relative;
  width: 100%;
  min-height: 340px;
}

/* Methodology note */
.method-note {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(245, 158, 11, 0.02));
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.86rem;
  color: var(--ink);
  margin-top: 0.8rem;
  line-height: 1.55;
}

.method-note b {
  color: var(--accent);
}

/* Reflection questions */
.reflection-block {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.05), transparent);
  border: 1px solid rgba(37, 99, 235, 0.12);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin-top: 0.6rem;
}

.reflection-block h4 {
  margin: 0 0 0.5rem;
  color: var(--primary);
  font-size: 0.98rem;
}

.reflection-block .r-q {
  margin: 0.7rem 0 0.35rem;
  font-size: 0.92rem;
  color: var(--ink);
  font-weight: 600;
}

.reflection-block textarea {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: 'Noto Serif TC', serif;
  font-size: 0.92rem;
  line-height: 1.55;
}

.reflection-block textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Export area */
.export-bar {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.export-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1.3rem;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s var(--transition);
  z-index: 9999;
}

.export-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Empty state */
.empty-state {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 2px dashed var(--line);
  border-radius: 14px;
}

.empty-state .es-icon {
  font-size: 1.8rem;
  margin-bottom: 0.4rem;
}

/* Selected summary */
.selection-summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.9rem;
  background: rgba(37, 99, 235, 0.06);
  border-radius: 10px;
  margin-top: 0.9rem;
  font-size: 0.9rem;
  color: var(--primary);
}

.selection-summary b {
  font-family: 'Space Grotesk', sans-serif;
}

/* Lab index page cards */
.lab-roadmap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}

.lab-roadmap-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.3rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: all 0.2s;
  position: relative;
}

.lab-roadmap-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.1);
  border-color: var(--primary-light);
}

.lab-roadmap-card.coming-soon {
  opacity: 0.72;
}

.lab-roadmap-card .lab-num {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.lab-roadmap-card h3 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.35;
}

.lab-roadmap-card p {
  color: var(--muted);
  margin: 0.2rem 0 0.6rem;
  font-size: 0.92rem;
  line-height: 1.55;
  flex-grow: 1;
}

.lab-roadmap-card .cs-tag {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--bg-2);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
}

/* ── Learning objectives ── */
.objectives .objective-list {
  margin: 0.4rem 0 0 1.2rem;
  padding: 0;
  line-height: 1.9;
}

.objectives .objective-list li {
  margin-bottom: 0.15rem;
}

/* ── Lab 1 v2：課綱對照徽章 ── */
.syllabus-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.badge-ch {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent, #6366f1);
  border: 1px solid rgba(99, 102, 241, 0.35);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* ── Lab 1 v2：資產選擇器（chip style） ── */
.asset-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.55rem;
  margin-top: 0.5rem;
}
.asset-chip {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  transition: all 0.15s;
  text-align: left;
}
.asset-chip b { font-size: 0.95rem; }
.asset-chip span { font-size: 0.78rem; color: var(--muted); }
.asset-chip:hover { border-color: var(--accent, #6366f1); }
.asset-chip.on {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--accent, #6366f1);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

/* 頻率切換列 */
.freq-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 0.8rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-2, #f7f7f9);
  border-radius: 10px;
}
.freq-row .freq-label { font-weight: 600; }

/* 公式盒 */
.formula-box {
  background: var(--bg-2, #f7f7f9);
  border-left: 4px solid var(--accent, #6366f1);
  padding: 0.85rem 1rem;
  border-radius: 8px;
}
.formula-box h4 { margin: 0 0 0.4rem; font-size: 1rem; }

/* 期間標示 */
.lab-note {
  display: inline-block;
  background: rgba(0,0,0,0.04);
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
}

/* 統計表（Step 2） */
.table-scroll { overflow-x: auto; }
.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.6rem;
  font-size: 0.93rem;
}
.stats-table th,
.stats-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
}
.stats-table th {
  background: var(--bg-2, #f7f7f9);
  font-weight: 600;
  text-align: center;
}
.stats-table td:first-child,
.stats-table th:first-child { text-align: left; }
.stats-table .mono { font-family: 'SF Mono', Menlo, monospace; }
.stats-table small { color: var(--muted); }
.stats-table .tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.72rem;
  margin-top: 0.15rem;
}
.tag-right { background: rgba(239,68,68,0.12); color: #dc2626; }
.tag-left  { background: rgba(16,185,129,0.12); color: #047857; }

/* 觀察摘要 */
.interpret-box {
  background: rgba(99,102,241,0.06);
  border-left: 4px solid rgba(99,102,241,0.5);
  padding: 0.85rem 1rem;
  border-radius: 8px;
}
.interpret-box h4 { margin: 0 0 0.4rem; font-size: 1rem; }
.interpret-box ul { margin: 0; padding-left: 1.2rem; line-height: 1.75; }
.interpret-box code {
  background: rgba(0,0,0,0.06);
  padding: 0.05em 0.35em;
  border-radius: 4px;
  font-size: 0.88em;
}

/* Code block (details/pre) */
.code-block {
  margin-top: 0.8rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.code-block > summary {
  padding: 0.55rem 0.85rem;
  background: var(--bg-2, #f7f7f9);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
  user-select: none;
}
.code-block > summary:hover { background: rgba(99,102,241,0.07); }
.code-block pre {
  margin: 0;
  padding: 0.85rem 1rem;
  background: #1e1e2e;
  color: #e0e0f0;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.55;
}
.code-block pre code {
  font-family: 'SF Mono', 'Fira Code', Menlo, Consolas, monospace;
  white-space: pre;
}

/* 常態檢驗區 */
.normality-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.4rem 0 1rem;
  font-weight: 600;
}
.normality-picker { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.mini-chip {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  padding: 0.25rem 0.65rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.mini-chip.on { background: var(--accent, #6366f1); color: white; border-color: transparent; }

.norm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.norm-card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}
.norm-card h4 { margin: 0 0 0.35rem; font-size: 1rem; }
.card-hint { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.7rem; line-height: 1.55; }
@media (max-width: 900px) { .norm-grid { grid-template-columns: 1fr; } }

/* k-sigma table */
.ksigma-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.3rem;
  font-size: 0.9rem;
}
.ksigma-table th,
.ksigma-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.ksigma-table th { background: var(--bg-2, #f7f7f9); font-weight: 600; }
.ksigma-table td:first-child { text-align: left; font-weight: 600; }

/* K² card */
.k2-card { margin-top: 0.3rem; }
.k2-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}
.k2-stat {
  background: var(--bg-2, #f7f7f9);
  padding: 0.55rem 0.4rem;
  border-radius: 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.k2-label { font-size: 0.75rem; color: var(--muted); }
.k2-val { font-weight: 700; font-size: 1rem; font-family: 'SF Mono', Menlo, monospace; }
.k2-verdict {
  margin-top: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.k2-verdict.reject { background: rgba(239,68,68,0.08); border-left: 4px solid #dc2626; }
.k2-verdict.accept { background: rgba(16,185,129,0.08); border-left: 4px solid #047857; }
.k2-verdict u { text-decoration: underline dotted; }
@media (max-width: 700px) { .k2-grid { grid-template-columns: repeat(2, 1fr); } }

/* Chart row for Histogram + QQ */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }

/* 前言三欄：操作／觀念／方法 */
.intro-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 0.6rem;
}
.intro-card {
  background: var(--bg-2, #f7f7f9);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.05rem;
}
.intro-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.intro-card ol,
.intro-card ul {
  margin: 0;
  padding-left: 1.1rem;
  line-height: 1.7;
}
.intro-card li {
  margin-bottom: 0.3rem;
  font-size: 0.93rem;
}
.intro-card li:last-child {
  margin-bottom: 0;
}
.intro-card li code {
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.05);
  padding: 0.05em 0.35em;
  border-radius: 4px;
}
@media (max-width: 960px) {
  .intro-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Concept cards (collapsible) ── */
.concept-prelude {
  margin-bottom: 0.8rem;
}

.concept-card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  margin-bottom: 0.55rem;
  overflow: hidden;
  transition: border-color 0.15s;
}

.concept-card[open] {
  border-color: var(--primary-light);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.06);
}

.concept-card summary {
  padding: 0.85rem 1rem;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  list-style: none;
  user-select: none;
  transition: background 0.12s;
}

.concept-card summary::-webkit-details-marker { display: none; }

.concept-card summary:hover {
  background: var(--bg-2);
}

.concept-card summary::after {
  content: "＋";
  margin-left: auto;
  color: var(--muted);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem;
  transition: transform 0.15s;
}

.concept-card[open] summary::after {
  content: "−";
  color: var(--primary);
}

.concept-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

.concept-tag {
  margin-left: auto;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  background: var(--bg-2);
  color: var(--muted);
  border-radius: 6px;
  font-weight: 600;
  margin-right: 0.5rem;
}

.concept-body {
  padding: 0 1.15rem 1.15rem;
  border-top: 1px dashed var(--line);
  margin-top: 0.2rem;
  padding-top: 0.8rem;
}

.concept-formula {
  background: var(--bg-2);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  margin: 0.4rem 0 0.8rem;
  text-align: center;
  overflow-x: auto;
}

.concept-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
  font-size: 0.92rem;
  line-height: 1.65;
}

.concept-grid .concept-pros {
  color: var(--success);
}

.concept-grid .concept-cons {
  color: var(--danger);
}

@media (min-width: 720px) {
  .concept-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1.5rem;
  }
}

/* ── Practice problems ── */
.practice-problem {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 0.8rem;
  transition: border-color 0.15s;
}

.practice-problem.solved {
  border-color: var(--success);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.04), transparent);
}

.practice-problem h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.practice-problem h3 .pp-num {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.72rem;
  background: var(--primary);
  color: #fff;
  padding: 0.18rem 0.55rem;
  border-radius: 6px;
  letter-spacing: 0.03em;
}

.practice-problem.solved h3 .pp-num {
  background: var(--success);
}

.practice-problem .pp-prompt {
  margin: 0 0 0.7rem;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.7;
}

.practice-problem .pp-prompt code {
  background: var(--bg-2);
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  font-family: 'Space Grotesk', monospace;
  font-size: 0.88rem;
}

.practice-problem .pp-prompt b {
  color: var(--primary-dark);
}

.practice-problem .pp-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.55rem;
  margin-top: 0.6rem;
}

.pp-input-block {
  padding: 0.55rem 0.7rem;
  border-radius: 9px;
  background: var(--bg-2);
  border: 1px solid var(--line);
}

.pp-input-block label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
}

.pp-input-block input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
}

.pp-input-block input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.pp-input-block.correct input {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.06);
}

.pp-input-block.wrong input {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.05);
}

.pp-input-block .pp-check {
  font-size: 0.75rem;
  margin-top: 0.2rem;
  min-height: 1.1em;
}

.pp-input-block.correct .pp-check {
  color: var(--success);
}

.pp-input-block.wrong .pp-check {
  color: var(--danger);
}

.practice-problem .pp-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
  flex-wrap: wrap;
  align-items: center;
}

.practice-problem .pp-hint {
  margin-top: 0.7rem;
  padding: 0.7rem 0.9rem;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.09), transparent);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1.6;
}

.practice-problem .pp-hint b {
  color: var(--accent);
}

.practice-summary {
  margin-top: 1rem;
  padding: 0.9rem 1.15rem;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), transparent);
  border: 1px solid rgba(37, 99, 235, 0.18);
  font-size: 0.92rem;
}

.practice-summary b {
  color: var(--primary);
}

/* ── Interactive practice widgets ── */
.pp-intro {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 0.9rem 0;
  line-height: 1.65;
}
.pp-intro b { color: var(--text); }

.pp-slider-row {
  display: grid;
  grid-template-columns: 110px 1fr 82px;
  align-items: center;
  gap: 0.6rem;
  margin: 0.45rem 0;
  font-size: 0.9rem;
}
.pp-slider-row > label {
  font-weight: 600;
  font-family: var(--font-mono, "Space Grotesk", monospace);
  color: var(--text);
}
.pp-slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  height: 6px;
}
.pp-slider-row .pp-val {
  text-align: right;
  font-family: var(--font-mono, "Space Grotesk", monospace);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--primary);
}

.pp-stat-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  margin: 0.9rem 0 0.6rem;
}
.pp-stat-board .stat {
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid rgba(37, 99, 235, 0.14);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}
.pp-stat-board .stat .label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.15rem;
}
.pp-stat-board .stat .value {
  display: block;
  font-family: var(--font-mono, "Space Grotesk", monospace);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.pp-stat-board .stat.highlight {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.32);
}
.pp-stat-board .stat.highlight .value { color: #059669; }
.pp-stat-board .stat.danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.22);
}
.pp-stat-board .stat.danger .value { color: #dc2626; }

.pp-canvas-wrap {
  background: #fafbff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  padding: 0.6rem;
  margin: 0.6rem 0;
}
.pp-canvas-wrap canvas { width: 100% !important; height: 260px !important; }

.pp-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
  margin: 0.6rem 0;
}
.pp-choice {
  background: #fff;
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  font-family: var(--font-mono, "Space Grotesk", monospace);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.15s ease;
  text-align: center;
  color: var(--text);
}
.pp-choice:hover:not(.disabled) {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.pp-choice.selected {
  background: rgba(37, 99, 235, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}
.pp-choice.correct {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #059669;
}
.pp-choice.wrong {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
  color: #dc2626;
}
.pp-choice.disabled { cursor: default; }

.pp-timer {
  display: inline-block;
  background: #fff;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  border-radius: 999px;
  padding: 0.25rem 0.85rem;
  font-family: var(--font-mono, "Space Grotesk", monospace);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-left: 0.5rem;
}
.pp-timer.warn { background: rgba(245, 158, 11, 0.15); border-color: #f59e0b; color: #b45309; }
.pp-timer.danger { background: rgba(239, 68, 68, 0.15); border-color: #ef4444; color: #b91c1c; }

.pp-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 64px;
  align-items: center;
  gap: 0.5rem;
  margin: 0.3rem 0;
  font-size: 0.88rem;
}
.pp-bar-row .bar-label {
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono, "Space Grotesk", monospace);
}
.pp-bar-track {
  height: 16px;
  background: rgba(148, 163, 184, 0.18);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.pp-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.25s ease;
}
.pp-bar-row .bar-val {
  text-align: right;
  font-family: var(--font-mono, "Space Grotesk", monospace);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.pp-bar-group {
  background: #fafbff;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  margin: 0.5rem 0;
}
.pp-bar-group h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.92rem;
  color: var(--text);
}

.pp-trophy {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  border: 1px solid #f59e0b;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #92400e;
  margin-left: 0.5rem;
}

.pp-feedback {
  margin: 0.6rem 0;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.55;
  border-left: 3px solid transparent;
}
.pp-feedback.info {
  background: rgba(37, 99, 235, 0.06);
  border-left-color: var(--primary);
  color: #1e40af;
}
.pp-feedback.success {
  background: rgba(16, 185, 129, 0.08);
  border-left-color: #10b981;
  color: #065f46;
}
.pp-feedback.warn {
  background: rgba(245, 158, 11, 0.08);
  border-left-color: #f59e0b;
  color: #92400e;
}

.pp-progress {
  display: flex;
  gap: 0.4rem;
  margin: 0.3rem 0 1rem;
}
.pp-progress .dot {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.3);
  border: 2px solid transparent;
  transition: all 0.2s ease;
}
.pp-progress .dot.active {
  background: var(--primary);
  border-color: rgba(37, 99, 235, 0.25);
}
.pp-progress .dot.solved {
  background: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.pp-scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
  margin: 0.6rem 0;
}
.pp-scenario {
  background: #fff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
}
.pp-scenario h5 {
  margin: 0 0 0.25rem 0;
  font-size: 0.88rem;
  color: var(--primary);
}
.pp-scenario .big-num {
  font-family: var(--font-mono, "Space Grotesk", monospace);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pp-scenario .sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

@media (max-width: 720px) {
  .pp-slider-row { grid-template-columns: 80px 1fr 64px; font-size: 0.85rem; }
}

/* ───── Lab 1 / 2 共用元件 ───── */

.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.section-head h2 {
  margin: 0;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.section-head .step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}

.section-head .section-hint {
  flex: 1;
  color: #64748b;
  font-size: 0.9rem;
  min-width: 260px;
}

/* Preset 按鈕列 */
.preset-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.preset-btn {
  text-align: left;
  padding: 0.9rem 1rem;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  cursor: pointer;
  transition: 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-family: inherit;
}

.preset-btn b {
  font-size: 1rem;
  color: #0f172a;
}

.preset-btn span {
  font-size: 0.82rem;
  color: #64748b;
}

.preset-btn:hover {
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.preset-btn.active {
  background: linear-gradient(135deg, #dbeafe, #ede9fe);
  border-color: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}

/* 日期設定列 */
.dates-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.1rem;
  align-items: center;
  padding: 0.9rem 1rem;
  background: #f8fafc;
  border-radius: 12px;
  margin-bottom: 1rem;
}

.dates-row label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: #334155;
}

.dates-row input[type="date"] {
  padding: 0.35rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-family: inherit;
}

.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-left: auto;
}

.date-presets .chip {
  padding: 0.3rem 0.7rem;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.82rem;
  color: #334155;
  font-family: inherit;
  transition: 0.15s;
}

.date-presets .chip:hover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
}

/* Portfolio summary */
.portfolio-summary {
  padding: 1rem 1.1rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
}

.ps-title {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.7rem;
}

.ps-rows {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ps-row {
  display: grid;
  grid-template-columns: 60px 1fr 52px;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.9rem;
}

.ps-row .sym {
  font-weight: 600;
  color: #0f172a;
}

.ps-row .bar {
  height: 9px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.ps-row .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  border-radius: 999px;
}

.ps-row .pct {
  text-align: right;
  color: #334155;
  font-variant-numeric: tabular-nums;
}

.ps-meta {
  margin-top: 0.7rem;
  font-size: 0.82rem;
  color: #64748b;
}

/* 算法設定比較卡 */
.calc-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 1rem;
}

.calc-card {
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 2px solid #e2e8f0;
  background: #ffffff;
}

.calc-card.baseline {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.calc-card.custom {
  border-color: #2563eb;
  background: linear-gradient(135deg, #f0f9ff, #eff6ff);
}

.calc-card h3 {
  margin: 0 0 0.8rem;
  font-size: 1.05rem;
  color: #0f172a;
}

.calc-dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.8rem;
  margin: 0;
  font-size: 0.92rem;
}

.calc-dl dt {
  color: #64748b;
}

.calc-dl dd {
  margin: 0;
  color: #0f172a;
  font-weight: 600;
}

.calc-note {
  margin: 0.7rem 0 0;
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.45;
}

.calc-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.calc-row > label {
  font-size: 0.85rem;
  color: #475569;
  font-weight: 500;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.radio-group .radio {
  padding: 0.35rem 0.75rem;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #334155;
  font-family: inherit;
  transition: 0.12s;
}

.radio-group .radio:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.radio-group .radio.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  font-weight: 600;
}

/* KPI 比較表 */
.kpi-compare {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
  margin-bottom: 1rem;
}

.kpi-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  align-items: center;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.95rem;
}

.kpi-row:last-child {
  border-bottom: none;
}

.kpi-row.header {
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.kpi-row .kpi-label {
  color: #0f172a;
  font-weight: 500;
}

.kpi-row .kpi-val {
  font-variant-numeric: tabular-nums;
  color: #334155;
}

.kpi-row .kpi-val.base {
  color: #64748b;
}

.kpi-row .kpi-val.cust {
  color: #2563eb;
  font-weight: 600;
}

.kpi-row .kpi-diff {
  font-variant-numeric: tabular-nums;
  color: #94a3b8;
  font-size: 0.88rem;
}

.kpi-row.big-diff {
  background: #fef2f2;
}

.kpi-row.big-diff .kpi-diff {
  color: #dc2626;
  font-weight: 600;
}

.kpi-legend {
  padding: 0.55rem 1rem;
  background: #f8fafc;
  font-size: 0.82rem;
  color: #64748b;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  border-top: 1px solid #f1f5f9;
}

.kpi-legend .chip-legend {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

/* Chart 容器 */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.chart-card {
  padding: 1rem 1.1rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
}

.chart-card h3 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
  color: #0f172a;
}

.chart-card .chart-box {
  height: 240px;
}

/* Reflections / Export */
.reflections-grid {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}

.reflections-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.95rem;
  color: #0f172a;
  font-weight: 500;
}

.reflections-grid textarea {
  padding: 0.7rem 0.9rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.92rem;
  resize: vertical;
  min-height: 70px;
}

.reflections-grid textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.export-row {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

/* ───── Lab 2 · VaR 三法並排 ───── */

.var-compare {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.9rem;
}

.var-card {
  position: relative;
  padding: 1rem 1.1rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.var-card .var-dot {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.var-title {
  font-weight: 700;
  color: #0f172a;
  font-size: 1.05rem;
}

.var-info {
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.4;
  min-height: 2.4em;
}

.var-metrics {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem 0.7rem;
  margin: 0.5rem 0 0;
  font-size: 0.92rem;
}

.var-metrics dt {
  color: #64748b;
}

.var-metrics dd {
  margin: 0;
  color: #0f172a;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.chart-note {
  margin: 0.6rem 0 0;
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.45;
}

.chart-note b {
  color: #0f172a;
}

/* Extreme 5 天表 */
.extreme-cards {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fffbeb;
}

.extreme-title {
  margin: 0 0 0.8rem;
  font-size: 1rem;
  color: #0f172a;
}

.extreme-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.extreme-row {
  display: grid;
  grid-template-columns: 110px 140px 1fr 1fr 1fr;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  background: #ffffff;
  border: 1px solid #fef3c7;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}

.extreme-row .ex-date {
  font-weight: 600;
  color: #0f172a;
}

.extreme-row .ex-actual {
  color: #dc2626;
  font-weight: 600;
}

.extreme-row .miss {
  display: inline-block;
  padding: 1px 6px;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 999px;
  font-size: 0.75rem;
  margin-left: 3px;
  font-weight: 600;
}

.extreme-row .hit {
  display: inline-block;
  padding: 1px 6px;
  background: #f0fdf4;
  color: #15803d;
  border-radius: 999px;
  font-size: 0.75rem;
  margin-left: 3px;
  font-weight: 600;
}

/* ───── Lab 5 · Capstone ───── */

.progress-labs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.55rem;
  margin-top: 0.5rem;
}

.progress-lab {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
  text-decoration: none;
  color: #0f172a;
  transition: 0.15s;
}

.progress-lab:hover {
  border-color: #2563eb;
  transform: translateY(-1px);
}

.progress-lab.done {
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  border-color: #10b981;
}

.progress-lab .pl-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  font-weight: 700;
}

.progress-lab.done .pl-check {
  background: #10b981;
  color: #ffffff;
}

.progress-lab .pl-name {
  flex: 1;
  font-weight: 600;
}

.progress-lab .pl-status {
  font-size: 0.78rem;
  color: #64748b;
}

.progress-lab.done .pl-status {
  color: #10b981;
  font-weight: 600;
}

.persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.8rem;
}

.persona-card {
  padding: 1.1rem 1.1rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
  cursor: pointer;
  transition: 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.persona-card:hover {
  transform: translateY(-2px);
  border-color: #94a3b8;
}

.persona-card.selected {
  border-color: #2563eb;
  background: linear-gradient(135deg, #eff6ff, #ede9fe);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.15);
}

.persona-card .persona-icon {
  font-size: 2rem;
}

.persona-card h3 {
  margin: 0;
  font-size: 1.08rem;
  color: #0f172a;
}

.persona-card p {
  margin: 0;
  font-size: 0.88rem;
  color: #475569;
  line-height: 1.5;
}

.persona-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.persona-tags .tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #4338ca;
  font-weight: 600;
}

.persona-detail {
  margin-top: 1rem;
}

.persona-detail-card {
  padding: 0.9rem 1.1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.pd-head {
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.4rem;
}

.pd-target {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.target-chip {
  font-size: 0.85rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-weight: 600;
}

.target-chip.danger {
  background: #fee2e2;
  color: #991b1b;
}

/* Weight sliders */
.weight-sliders {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.wslider-row {
  display: grid;
  grid-template-columns: 170px 1fr 52px;
  gap: 0.8rem;
  align-items: center;
  padding: 0.55rem 0.8rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #ffffff;
}

.wslider-row .ws-sym {
  font-weight: 700;
  color: #0f172a;
}

.wslider-row .ws-desc {
  font-size: 0.78rem;
  color: #64748b;
}

.wslider-row .ws-range {
  width: 100%;
  accent-color: #2563eb;
}

.wslider-row .ws-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #2563eb;
}

.weight-summary {
  margin-top: 0.9rem;
  padding: 0.9rem 1.1rem;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.ws-total {
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #0f172a;
}

.ws-total .ws-note {
  font-weight: 400;
  color: #64748b;
  font-size: 0.82rem;
}

.ws-bar-row {
  display: grid;
  grid-template-columns: 70px 1fr 60px;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  margin-bottom: 0.25rem;
}

.ws-bar-sym {
  font-weight: 600;
  color: #0f172a;
}

.ws-bar-row .pct {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #334155;
}

/* Verdict card */
.verdict-card {
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 2px solid #e2e8f0;
  background: #ffffff;
}

.verdict-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  margin-bottom: 0.8rem;
  font-weight: 700;
}

.verdict-head.pass {
  background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
  color: #15803d;
}

.verdict-head.fail {
  background: #fef3c7;
  color: #92400e;
}

.verdict-icon {
  font-size: 1.4rem;
}

.verdict-checks {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.vcheck {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.45rem 0.7rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
}

.vcheck.pass {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.vcheck.fail {
  background: #fef2f2;
  border-color: #fecaca;
}

.vcheck .vc-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-weight: 700;
  color: #ffffff;
}

.vcheck.pass .vc-mark { background: #10b981; }
.vcheck.fail .vc-mark { background: #ef4444; }

.vcheck .vc-label {
  color: #0f172a;
  font-weight: 500;
}

.vcheck .vc-actual {
  font-variant-numeric: tabular-nums;
  color: #475569;
  font-size: 0.85rem;
}

.reflections-grid input[type="text"] {
  padding: 0.65rem 0.9rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
}
.reflections-grid input[type="text"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* mobile */
@media (max-width: 720px) {
  .lab-section {
    padding: 1.1rem 1.05rem;
  }
  .asset-card .ac-desc {
    min-height: 0;
  }
  .lab-hero h1 {
    font-size: 1.45rem;
  }
  .calc-compare-grid,
  .chart-row,
  .var-compare {
    grid-template-columns: 1fr;
  }
  .kpi-row {
    grid-template-columns: 1.3fr 1fr 1fr;
    font-size: 0.85rem;
  }
  .kpi-row .kpi-diff {
    display: none;
  }
  .date-presets {
    margin-left: 0;
    width: 100%;
  }
  .extreme-row {
    grid-template-columns: 1fr 1fr;
    font-size: 0.8rem;
  }
}

/* ============================================================
 * Lab 2 · Tail Risk & √T Rule
 * ============================================================ */
.tail-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.tail-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.tail-card h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.table-scroll {
  overflow-x: auto;
}

.sqrt-table thead th {
  background: #eef2ff;
  color: #1e3a8a;
  text-align: center;
  border-bottom: 1px solid #c7d2fe;
}
.sqrt-table td {
  text-align: center;
  padding: 0.45rem 0.55rem;
  font-size: 0.92rem;
}
.sqrt-table .ty {
  color: #475569;
  font-size: 0.82rem;
  font-weight: 600;
}
.sqrt-table .mono {
  font-family: "Space Grotesk", monospace;
  color: #1e40af;
}
.sqrt-table tr.sqrt-head td {
  border-top: 1.5px solid #c7d2fe;
}
.sqrt-table tr.err-row td.err {
  color: #b91c1c;
  font-weight: 600;
}
.sqrt-table .err-bad {
  display: inline-block;
  margin-left: 0.2rem;
}

@media (max-width: 820px) {
  .tail-tables {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
 * Lab 3 · Mean-Variance Efficient Frontier
 * ============================================================ */
.mv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}
.mv-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.mv-card h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.mv-card table.stats-table td,
.mv-card table.stats-table th {
  padding: 0.35rem 0.5rem;
  font-size: 0.88rem;
  text-align: center;
}
.mv-card table.stats-table td:first-child,
.mv-card table.stats-table th:first-child {
  text-align: left;
}

.gmv-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.gmv-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.8rem;
}
.stat-pill {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.92rem;
}
.stat-pill span { color: #475569; }
.stat-pill b { color: #1e40af; font-family: "Space Grotesk", monospace; }

.gmv-right h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.abcd-box {
  margin-top: 1rem;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.abcd-box h4 {
  margin: 0 0 0.6rem;
  font-size: 0.98rem;
  color: #c2410c;
}
.abcd-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}
.abcd-cell {
  background: #ffffff;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.abcd-cell span {
  font-size: 0.82rem;
  color: #9a3412;
}
.abcd-cell b {
  font-family: "Space Grotesk", monospace;
  color: #1f2937;
  font-size: 1.1rem;
}

@media (max-width: 960px) {
  .mv-grid { grid-template-columns: 1fr; }
  .gmv-grid { grid-template-columns: 1fr; }
  .abcd-grid { grid-template-columns: 1fr 1fr; }
}

