:root {
  --bg-1: #050816;
  --bg-2: #0a1024;
  --accent: #00e5ff;
  --accent-soft: rgba(0, 229, 255, 0.15);
  --accent-2: #7c4dff;
  --text: #e6edf3;
  --text-dim: #9aa6b2;
  --card: rgba(13, 22, 49, 0.78);
  --card-border: rgba(0, 229, 255, 0.2);
  --success: #19d27a;
  --warn: #f5a524;
  --error: #ff5470;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-1);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

#three-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.4);
}

.lang-switch {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 4px;
}

.lang-switch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
}

.lang-switch button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04142a;
  font-weight: 700;
}

.container {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 4vw, 28px);
  line-height: 1.25;
}

h2 {
  font-size: clamp(18px, 3.4vw, 22px);
  margin: 0 0 14px;
  line-height: 1.3;
}

p {
  line-height: 1.55;
  color: var(--text-dim);
}

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
}

.section-tag {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width 0.4s ease;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.option:hover {
  border-color: rgba(0, 229, 255, 0.45);
  background: rgba(0, 229, 255, 0.05);
}

.option.selected {
  border-color: var(--accent);
  background: rgba(0, 229, 255, 0.12);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.option-key {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.option.selected .option-key {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04142a;
}

.option-text {
  flex: 1;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

.input-field label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.input-field input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

.input-field input:focus {
  border-color: var(--accent);
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
  flex-wrap: wrap;
}

button.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 10px;
  letter-spacing: 0.03em;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

button.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04142a;
  box-shadow: 0 6px 18px rgba(0, 229, 255, 0.25);
}

.btn-primary:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(0, 229, 255, 0.35); }

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-ghost:not(:disabled):hover { background: rgba(255, 255, 255, 0.09); }

.knowledge-note {
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(124, 77, 255, 0.08);
  border: 1px solid rgba(124, 77, 255, 0.25);
  border-left: 3px solid var(--accent-2);
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-dim);
  display: none;
}

.knowledge-note.show { display: block; }

.knowledge-note strong { color: var(--text); }

.error-msg {
  margin-top: 10px;
  color: var(--error);
  font-size: 13px;
  min-height: 18px;
}

/* report */
.score-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), rgba(255, 255, 255, 0.06) 0);
  display: grid;
  place-items: center;
  margin: 18px auto 8px;
  position: relative;
}

.score-circle::after {
  content: '';
  position: absolute;
  inset: 12px;
  background: var(--bg-2);
  border-radius: 50%;
}

.score-circle-inner {
  position: relative;
  text-align: center;
  z-index: 1;
}

.score-value { font-size: 30px; font-weight: 700; color: var(--text); }
.score-label { font-size: 12px; color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase; }

.report-level {
  text-align: center;
  margin-bottom: 18px;
  font-size: 16px;
  color: var(--text);
}

.report-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.report-item {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  border-left: 3px solid var(--text-dim);
  font-size: 13.5px;
  line-height: 1.45;
}

.report-item.correct { border-left-color: var(--success); }
.report-item.incorrect { border-left-color: var(--error); }
.report-item.demo { border-left-color: var(--accent-2); }

.report-item .qtext { color: var(--text); font-weight: 600; margin-bottom: 6px; }
.report-item .qmeta { color: var(--text-dim); font-size: 12px; margin-top: 6px; }
.report-item .qmeta strong { color: var(--text); font-weight: 600; }

/* admin */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin: 16px 0 22px;
}

.stat {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 14px 18px;
}

.stat-value { font-size: 22px; font-weight: 700; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 4px; }

.admin-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.responses {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.responses th, table.responses td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

table.responses th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

table.responses tr:hover td { background: rgba(255, 255, 255, 0.03); }

.row-actions { display: flex; gap: 6px; }

.row-actions button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
}
.row-actions button:hover { background: rgba(0, 229, 255, 0.12); border-color: var(--accent); }
.row-actions button.danger:hover { background: rgba(255, 84, 112, 0.12); border-color: var(--error); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.show { display: flex; }

.modal {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal h3 { margin: 0; }

.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 14px;
  font-size: 13.5px;
}

.detail-grid dt { color: var(--text-dim); }
.detail-grid dd { margin: 0; color: var(--text); }

.empty {
  text-align: center;
  padding: 30px;
  color: var(--text-dim);
}

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .container { padding: 8px 14px 32px; }
  .card { padding: 20px 16px; }
  .option { padding: 12px 14px; }
  .option-text { font-size: 14px; }
  .actions button.btn { flex: 1; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid dt { font-weight: 600; margin-top: 6px; }
}
