/* Tema Pesona Bedengan: biru + oranye */
:root {
  --biru: #1d6fb8;
  --biru-tua: #14507f;
  --biru-muda: #e8f2fb;
  --oren: #f97316;
  --oren-tua: #ea580c;
  --oren-muda: #fff3e8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: linear-gradient(180deg, #eaf4fd 0%, #f6f8fa 240px);
  color: #1f2937;
}

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 100px;
}

h1 { font-size: 1.3rem; margin: 0 0 8px; color: var(--biru-tua); }
h2 { font-size: 1.15rem; margin: 4px 0 6px; color: var(--biru-tua); }

.muted { color: #6b7280; }
.small { font-size: 0.8rem; }

.logo {
  display: block;
  margin: 0 auto 14px;
  max-width: 220px;
  width: 60%;
  height: auto;
}

.card {
  background: white;
  border-radius: 14px;
  padding: 24px 20px;
  box-shadow: 0 1px 3px rgba(20, 80, 127, 0.12);
  border-top: 4px solid var(--oren);
}
.center-card { margin-top: 16px; }

.test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.test-card {
  background: white;
  border-radius: 14px;
  padding: 22px 18px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(20, 80, 127, 0.12);
  border-top: 4px solid var(--biru);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.test-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(20, 80, 127, 0.18);
  border-top-color: var(--oren);
}
.test-card-icon { font-size: 2.2rem; margin-bottom: 6px; }
.test-card h2 { margin: 4px 0 8px; }
.test-card p { min-height: 40px; }
.test-card .submit-btn { margin-top: 10px; }

.instructions {
  color: #4b5563;
  font-size: 0.95rem;
  margin: 10px 0 18px;
  line-height: 1.55;
}

.welcome-name { font-size: 1.05rem; margin: 4px 0 14px; }

.info-box { display: flex; gap: 10px; margin-bottom: 14px; }
.info-item {
  flex: 1;
  background: var(--biru-muda);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--biru-tua);
}
.info-item b { display: block; font-size: 1.3rem; color: var(--oren-tua); }

.section-list { margin-bottom: 16px; font-size: 0.9rem; color: #4b5563; }
.section-list summary { cursor: pointer; color: var(--biru); font-weight: 600; }
.section-list ol { margin: 10px 0 0; padding-left: 20px; line-height: 1.7; }

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--biru-tua);
  margin-bottom: 5px;
}

.name-input {
  width: 100%;
  padding: 13px;
  font-size: 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  margin-bottom: 14px;
  background: #fbfdff;
}
.name-input:focus { outline: 2px solid var(--biru); border-color: var(--biru); }

/* ---------- Timer bulat melayang kanan atas ---------- */
.timer-float {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 72px;
  height: 72px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 6px rgba(20, 80, 127, 0.35));
}
.timer-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg {
  fill: white;
  stroke: #dbe7f2;
  stroke-width: 5;
}
.ring-fg {
  fill: none;
  stroke: var(--biru);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s linear;
}
.timer-float.urgent .ring-fg { stroke: #dc2626; }
.timer-float.urgent { animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.timer-inner {
  position: relative;
  text-align: center;
  line-height: 1.1;
}
.timer-inner #timerText {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--biru-tua);
  font-variant-numeric: tabular-nums;
  display: block;
}
.timer-float.urgent #timerText { color: #dc2626; }
.save-status {
  font-size: 0.65rem;
  color: #059669;
  display: block;
  min-height: 0.8em;
}

/* ---------- Section ---------- */
.section-head { margin-bottom: 16px; padding-right: 80px; }
.section-progress {
  display: inline-block;
  background: var(--oren);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 8px;
}
.part-label {
  font-size: 0.8rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.question-card {
  background: white;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(20, 80, 127, 0.1);
}

.question-number { font-size: 0.8rem; color: var(--oren-tua); font-weight: 600; margin-bottom: 6px; }

.question-text {
  font-size: 1.02rem;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.45;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-size: 0.95rem;
  line-height: 1.4;
}
.option-label:active { background: #f1f5f9; }
.option-label input { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--biru); }
.option-label.selected { border-color: var(--biru); background: var(--biru-muda); }

.yesno-row { display: flex; gap: 10px; }
.option-label.yesno { flex: 1; justify-content: center; font-weight: 600; }

.nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}
.nav-btn {
  padding: 14px 18px;
  font-size: 1rem;
  border: 1px solid #cbd5e1;
  background: white;
  border-radius: 10px;
  cursor: pointer;
  color: var(--biru-tua);
  font-weight: 600;
}
.nav-next { flex: 1; margin-top: 0; }

.submit-btn {
  width: 100%;
  padding: 15px;
  font-size: 1.05rem;
  font-weight: 600;
  color: white;
  background: var(--biru);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: 12px;
}
.submit-btn:disabled { background: #93b8d8; cursor: not-allowed; }
.start-btn { background: var(--oren); font-size: 1.15rem; padding: 17px; }
.start-btn:disabled { background: #fdba74; }

.error-msg {
  color: #dc2626;
  font-size: 0.9rem;
  margin-top: 10px;
}

.success-screen { text-align: center; padding: 30px 20px 40px; }
.success-screen h2 { color: var(--oren-tua); }
.big-icon { font-size: 3rem; margin-bottom: 8px; }

/* ---------- Banner error jaringan (audit #1.2) ---------- */
.network-error-banner {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 200;
  background: #dc2626;
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  font-size: 0.9rem;
}
.network-error-banner button {
  background: #fff;
  color: #dc2626;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

/* Selagi banner error jaringan tampil: kunci interaksi lain di halaman
   supaya tidak ada aksi kedua yang gagal menimpa retry aksi pertama. */
#app.app-blocked {
  pointer-events: none;
  opacity: 0.6;
  transition: opacity 0.15s;
}

/* ---------- Blok Kraepelin ---------- */
/* Kraepelin Mobile Zero-Scroll & Horizontal Display */
.kraep-wrap {
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  position: fixed;
  inset: 0;
  touch-action: manipulation;
  user-select: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 12px) 16px env(safe-area-inset-bottom, 12px) 16px;
  box-sizing: border-box;
  background: var(--bg, #f8fafc);
}

.kraep-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
  padding-right: 76px;
}

.kraep-col-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--biru-tua);
}

.kraep-mute-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.kraep-mute-btn:active {
  background: #e2e8f0;
}

.kraep-progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
  margin-right: 76px;
}

.kraep-progress-fill {
  height: 100%;
  background: var(--biru);
  width: 100%;
  transition: width 0.1s linear, background 0.2s;
}
.kraep-progress-fill.kraep-progress-urgent {
  background: #dc2626;
}

.kraep-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: auto 0;
}
.kraep-column.kraep-slide {
  animation: kraepSlideIn 0.22s ease;
}
@keyframes kraepSlideIn {
  from { transform: translateX(-14px); opacity: 0.35; }
  to { transform: none; opacity: 1; }
}

.kraep-pair-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #ffffff;
  padding: 24px 16px;
  border-radius: 16px;
  border: 2px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  margin: auto 0;
  box-sizing: border-box;
  max-width: 100%;
}

.kraep-num-box {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
  background: #f1f5f9;
  border-radius: 12px;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  box-sizing: border-box;
  flex-shrink: 0;
}

.kraep-op {
  font-size: 1.8rem;
  font-weight: 700;
  color: #64748b;
  flex-shrink: 0;
}

.kraep-ans-box {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
  background: #eff6ff;
  border-radius: 12px;
  color: #2563eb;
  border: 2px dashed #3b82f6;
  box-sizing: border-box;
  flex-shrink: 0;
}

.kraep-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.kraep-key {
  height: 52px;
  font-size: 1.5rem;
  font-weight: 700;
  border-radius: 10px;
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  touch-action: manipulation;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.kraep-key:active {
  background: #e2e8f0;
  transform: translateY(1px);
}

.kraep-key-zero {
  grid-column: 1 / span 2;
}

.kraep-key-undo {
  background: #f1f5f9;
  color: #475569;
  font-size: 1.25rem;
}
.kraep-key-undo:active {
  background: #cbd5e1;
  color: #1e293b;
}

/* Rekap sesi latihan */
.kraep-practice-ok, .kraep-practice-warn {
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 10px;
  text-align: left;
  font-size: 0.95rem;
  line-height: 1.5;
}
.kraep-practice-ok { background: #dcfce7; color: #14532d; }
.kraep-practice-warn { background: var(--oren-muda); color: var(--oren-tua); }
.kraep-practice-mistakes {
  margin: 0 0 12px;
  padding-left: 20px;
  text-align: left;
  font-size: 0.9rem;
  color: #475569;
}
.kraep-practice-mistakes li { margin-bottom: 3px; }
