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

body {
  background: #0b1120;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #f1f5f9;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.container {
  max-width: 800px;
  width: 100%;
  background: #1e293b;
  border-radius: 2rem;
  padding: 1.8rem 2rem 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  border: 1px solid #334155;
}

header h1 {
  font-weight: 500;
  font-size: 1.6rem;
  letter-spacing: -0.5px;
  color: #e2e8f0;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

header h1::before {
  content: "🎓";
  font-size: 1.8rem;
}

/* ── camera container (portrait) ── */
.camera-container {
  position: relative;
  background: #0f172a;
  border-radius: 1.5rem;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  aspect-ratio: 3 / 4;
  /* portrait ratio */
  width: 100%;
  max-width: 480px;
  margin: 0 auto 1.2rem;
  border: 1px solid #334155;
}

#video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Mirror will be applied dynamically via JS */
  background: #0b1120;
}

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  /* Mirror will be applied dynamically via JS */
}

/* face guide – centered oval for portrait */
.face-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 62%;
  height: 50%;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  border: 3px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3), 0 0 0 6px rgba(255, 255, 255, 0.03);
  transition: border-color 0.2s, box-shadow 0.2s;
  pointer-events: none;
  animation: pulse 2.5s infinite;
}

.face-guide.active {
  border-color: #22c55e;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
  animation: none;
}

.face-guide.warning {
  border-color: #f59e0b;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.2);
  animation: pulse-warn 1.8s infinite;
}

.face-guide.error {
  border-color: #ef4444;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.25);
  animation: pulse-error 1.4s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1);
  }

  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.02);
  }
}

@keyframes pulse-warn {

  0%,
  100% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(1);
  }

  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.04);
  }
}

@keyframes pulse-error {

  0%,
  100% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1);
  }

  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.97);
  }
}

.status {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
  padding: 0.45rem 1.2rem;
  border-radius: 40px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: border-color 0.2s, background 0.2s;
}

/* preview */
.preview-section {
  margin-top: 0.2rem;
  display: flex;
  justify-content: center;
}

#preview {
  display: none;
  max-width: 140px;
  max-height: 140px;
  border-radius: 1rem;
  border: 2px solid #334155;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  object-fit: cover;
  aspect-ratio: 3/4;
}

/* form */
.student-form {
  margin: 0.8rem 0 1rem;
}

.form-group {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #94a3b8;
  letter-spacing: 0.3px;
}

.form-group input {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 30px;
  padding: 0.45rem 1rem;
  color: #f1f5f9;
  font-size: 0.9rem;
  flex: 1;
  min-width: 140px;
  outline: none;
  transition: border 0.2s;
}

.form-group input:focus {
  border-color: #60a5fa;
}

/* controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0 0.8rem;
  justify-content: center;
}

.controls button {
  background: #2d3b52;
  border: none;
  border-radius: 60px;
  padding: 0.5rem 1.2rem;
  font-weight: 600;
  font-size: 0.8rem;
  color: #e2e8f0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  flex: 1 0 auto;
  justify-content: center;
  min-width: 90px;
}

.controls button:hover:not(:disabled) {
  background: #3b4b66;
  border-color: #60a5fa40;
  transform: scale(1.02);
}

.controls button:disabled {
  opacity: 0.4;
  filter: grayscale(0.6);
  transform: none;
  cursor: not-allowed;
}

.controls button#captureBtn {
  background: #2563eb;
  color: white;
  flex: 1.8;
}

.controls button#captureBtn:hover:not(:disabled) {
  background: #3b82f6;
}

.controls button#saveBtn {
  background: #16a34a;
  color: white;
}

.controls button#saveBtn:hover:not(:disabled) {
  background: #22c55e;
}

.controls button#retakeBtn {
  background: #9333ea;
  color: white;
}

.controls button#retakeBtn:hover:not(:disabled) {
  background: #a855f7;
}

.controls button#switchCamera {
  background: #475569;
}

.controls button#switchCamera:hover:not(:disabled) {
  background: #64748b;
}

/* info panel */
.info-panel {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  background: #0f172a80;
  padding: 0.6rem 0.8rem;
  border-radius: 2rem;
  margin-top: 0.5rem;
  border: 1px solid #2d3b52;
  font-size: 0.7rem;
  font-weight: 500;
  color: #94a3b8;
  text-align: center;
  backdrop-filter: blur(2px);
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-item span {
  font-weight: 600;
  font-size: 0.8rem;
  color: #e2e8f0;
}

.status-good {
  color: #4ade80 !important;
}

.status-warning {
  color: #facc15 !important;
}

.status-bad {
  color: #f87171 !important;
}

@media (max-width: 560px) {
  .container {
    padding: 1rem;
  }

  .controls button {
    min-width: 70px;
    font-size: 0.7rem;
    padding: 0.4rem 0.8rem;
  }

  .info-panel {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.3rem;
    padding: 0.5rem;
  }

  .camera-container {
    max-width: 100%;
  }

  .form-group {
    flex-direction: column;
    align-items: stretch;
  }
}