/* Version: 1.0.0 | Cross-grade Math Interactive Platform Styles */
:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #f59e0b;
  --ok: #16a34a;
  --err: #dc2626;
  --border: #e2e8f0;
  --radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

.topbar {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.16);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  display: grid; place-items: center;
  font-size: 24px; font-weight: 800; color: #fff;
}
.brand h1 { margin: 0; font-size: 1.25rem; display: flex; align-items: center; gap: 8px; }
.badge {
  font-size: 0.72rem; background: #f59e0b; color: #111827;
  padding: 2px 8px; border-radius: 999px; font-weight: 700;
}
.subtitle { margin: 2px 0 0; font-size: 0.84rem; color: #cbd5e1; }

.mode-tabs { display: flex; gap: 8px; }
.tab-btn {
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.1);
  color: #fff; padding: 8px 14px; border-radius: 10px;
  cursor: pointer; font-weight: 600; font-size: 0.92rem;
}
.tab-btn.active { background: #fff; color: #0f172a; border-color: #fff; }

.container { max-width: 1120px; margin: 20px auto; padding: 0 16px 40px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}
.hidden { display: none !important; }

.grade-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.grade-label { font-weight: 700; font-size: 0.95rem; }
.grade-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: #f8fafc; color: var(--muted); font-size: 0.86rem; font-weight: 600; cursor: pointer;
}
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pill.disabled { opacity: 0.58; cursor: not-allowed; }

.student-fields { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.student-fields label { display: flex; flex-direction: column; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.student-fields input {
  margin-top: 4px; padding: 8px 10px; border: 1px solid #cbd5e1;
  border-radius: 8px; font-size: 0.95rem; width: 130px;
}
.student-status { margin-top: 10px; font-size: 0.88rem; color: var(--primary-dark); font-weight: 600; }

.btn {
  padding: 9px 15px; border-radius: 9px; border: none;
  font-weight: 700; cursor: pointer; font-size: 0.9rem;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: #e2e8f0; color: #0f172a; }
.btn.hint-btn { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }

.unit-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.unit-card {
  background: #fff; border: 2px solid var(--border); border-radius: 12px;
  padding: 14px; cursor: pointer; transition: 0.15s ease; text-align: left;
}
.unit-card:hover { border-color: #93c5fd; transform: translateY(-1px); }
.unit-card.active { border-color: var(--primary); background: #eff6ff; }
.unit-card h3 { margin: 0 0 6px; font-size: 1rem; color: var(--ink); }
.unit-card p { margin: 0; font-size: 0.83rem; color: var(--muted); }

.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 1.15rem; }
.chip { font-size: 0.82rem; background: #eff6ff; color: var(--primary-dark); padding: 4px 10px; border-radius: 999px; font-weight: 700; }

.lab-body { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(260px, 1.1fr); gap: 18px; align-items: center; }
@media (max-width: 760px) { .lab-body { grid-template-columns: 1fr; } }
.lab-svg-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 10px; display: flex; justify-content: center; }
.lab-controls label { display: block; margin-bottom: 10px; font-weight: 700; font-size: 0.92rem; }
.lab-controls input[type="range"] { width: 100%; accent-color: var(--primary); }
.lab-formula {
  background: #0f172a; color: #f8fafc; padding: 10px 14px; border-radius: 10px;
  font-family: Consolas, monospace; font-size: 1rem; margin-bottom: 12px;
}

.question-list { display: flex; flex-direction: column; gap: 16px; }
.q-item { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: #fcfdff; }
.q-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.q-diff { font-size: 0.78rem; padding: 2px 8px; border-radius: 6px; background: #e0f2fe; color: #0369a1; font-weight: 700; }
.q-prompt { font-size: 1.03rem; font-weight: 600; margin: 0 0 12px; }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; margin-bottom: 12px; }
.opt-btn {
  text-align: left; padding: 10px 12px; border: 1.5px solid #cbd5e1;
  border-radius: 9px; background: #fff; cursor: pointer; font-size: 0.94rem; font-weight: 600;
}
.opt-btn.selected { border-color: var(--primary); background: #dbeafe; color: #1e3a8a; }
.num-input {
  padding: 10px 12px; border: 1.5px solid #cbd5e1; border-radius: 9px;
  font-size: 1rem; width: 220px; margin-bottom: 12px;
}
.q-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.feedback { margin-top: 10px; padding: 10px 12px; border-radius: 9px; font-size: 0.92rem; white-space: pre-line; }
.feedback.ok { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.feedback.err { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.feedback.hint { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.kpi .val { font-size: 1.7rem; font-weight: 800; color: var(--primary-dark); }
.kpi .lbl { font-size: 0.85rem; color: var(--muted); }
.unit-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 18px; }
.sub-heading { margin: 16px 0 8px; font-size: 1rem; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th, .data-table td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.data-table th { background: #f1f5f9; }
.tag-ok { color: var(--ok); font-weight: 700; }
.tag-err { color: var(--err); font-weight: 700; }

.footer { text-align: center; color: var(--muted); font-size: 0.84rem; padding: 18px; }
