*{box-sizing:border-box}

body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:#0b1020;
  color:#e9eef6;
  line-height:1.4;
}

header{
  padding:24px 20px 18px;
  border-bottom:1px solid #26304a;
  background:#0e1530;
}

h1{
  margin:0 0 6px;
  font-size:clamp(28px, 4vw, 42px);
  line-height:1.1;
}

.subtitle{
  margin:0;
  color:#9fb0d1;
  max-width:820px;
  font-size:clamp(1rem, 1.2vw, 1.1rem);
}

.header-actions{
  margin-top:12px;
  display:flex;
  justify-content:flex-start;
}

main{
  max-width:1120px;
  margin:24px auto;
  padding:0 16px;
}

.card{
  background:#121a39;
  border:1px solid #243057;
  border-radius:20px;
  padding:20px;
  margin-bottom:18px;
  box-shadow:0 8px 24px rgba(0,0,0,.28);
}

h2{
  margin:0 0 10px;
  font-size:clamp(1.7rem, 2.4vw, 2.2rem);
  line-height:1.15;
}

.form-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 14px 16px;
  align-items: center;
}

label{
  display:flex;
  gap:8px;
  align-items:center;
  font-size:1rem;
}

input[type='text'],
input[type='number'],
select{
  background:#0b1128;
  color:#e9eef6;
  border:1px solid #32406a;
  border-radius:10px;
  padding:10px 12px;
  font-size:1rem;
  min-height:44px;
}

input[type='text']::placeholder{
  color:#8092bb;
}

button{
  background:#22335f;
  color:#e9eef6;
  border:1px solid #3a4a7a;
  border-radius:12px;
  padding:10px 14px;
  font-size:1rem;
  line-height:1.2;
  cursor:pointer;
  transition:background-color .18s ease,border-color .18s ease,transform .08s ease;
}

button:hover{
  background:#2b417c;
}

button:active{
  transform:translateY(1px);
}

button.primary{
  background:#4b9445;
  border-color:#4b9445;
}

button.primary:hover{
  background:#57a34f;
  border-color:#57a34f;
}

button.danger{
  background:#8f2f3a;
  border-color:#8f2f3a;
}

button.danger:hover{
  background:#a23845;
  border-color:#a23845;
}

.secondary{
  background:#22335f;
  color:#e9eef6;
  border:1px solid #3a4a7a;
  padding:8px 12px;
  font-size:.95rem;
}

.secondary:hover{
  background:#2b417c;
}

.status{
  margin-top:12px;
  color:#9fb0d1;
  font-size:1rem;
}

#questionContainer{
  min-height:220px;
  padding:12px;
  border-radius:14px;
  background:#0b1128;
  border:1px solid #2a3a64;
}

.qnum{
  color:#a7b8da;
  margin-bottom:6px;
  font-size:.95rem;
}

.stem{
  font-size:1.15rem;
  margin:6px 0 14px;
  line-height:1.4;
}

.choice{
  margin:10px 0;
  padding:12px;
  border-radius:12px;
  border:1px solid #2a3a64;
  background:#101a35;
  display:block;
}
.choice {
  transition: background 0.15s ease, border-color 0.15s ease;
}

.choice:hover {
  border-color: #4a6bbf;
  background: #14214a;
}

.choice.correct{
  border-color:#2b8a3e;
  background:#0f2a1a;
}

.choice.incorrect{
  border-color:#7e2330;
  background:#2a0f15;
}

.nav{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  margin-top:14px;
}

.feedback{
  margin-top:12px;
  padding:12px;
  border-radius:12px;
  background:#0f1e3d;
  border:1px solid #2a3a64;
}

.test-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px; /* was 10px */
  color: #9fb0d1;
  font-size: 0.95rem;
}

code{
  background:#182349;
  padding:2px 6px;
  border-radius:6px;
}

/* Tooltip */
.tooltip-wrapper{
  position:relative;
  display:inline-block;
}

.tooltip-wrapper .tooltip-text{
  visibility:hidden;
  width:280px;
  background-color:#22335f;
  color:#e9eef6;
  text-align:left;
  border:1px solid #3a4a7a;
  border-radius:10px;
  padding:10px 12px;
  position:absolute;
  z-index:10;
  bottom:125%;
  left:50%;
  transform:translateX(-50%);
  opacity:0;
  transition:opacity 0.2s ease-in-out;
  font-size:.88rem;
  line-height:1.35;
  box-shadow:0 6px 20px rgba(0,0,0,.25);
}

.tooltip-wrapper:hover .tooltip-text{
  visibility:visible;
  opacity:1;
}

.tooltip-wrapper .tooltip-text::after{
  content:"";
  position:absolute;
  top:100%;
  left:50%;
  transform:translateX(-50%);
  border-width:6px;
  border-style:solid;
  border-color:#22335f transparent transparent transparent;
}

/* Footer */
footer{
  margin-top:40px;
  padding:22px 18px 28px;
  font-size:.87rem;
  color:#9fb0d1;
  text-align:center;
  border-top:1px solid #26304a;
}

footer p{
  margin:6px auto;
  max-width:860px;
}

footer a{
  color:#b8c9ff;
}

/* Modal */
.modal{
  display:none;
  position:fixed;
  z-index:1000;
  inset:0;
  background-color:rgba(0,0,0,0.55);
  padding:20px;
}

.modal-content{
  background:#121a39;
  color:#e9eef6;
  border:1px solid #243057;
  box-shadow:0 10px 25px rgba(0,0,0,.4);
  margin:6vh auto 0;
  padding:22px 20px 18px;
  width:min(100%, 560px);
  border-radius:18px;
  position:relative;
}

.modal-content h2,
.modal-content h3{
  color:#e9eef6;
}

.modal-content h2{
  margin-top:0;
  margin-bottom:10px;
}

.modal-content h3{
  margin-top:18px;
  margin-bottom:8px;
}

.modal-content p,
.modal-content li{
  color:#c7d3ea;
}

.modal-content ul{
  padding-left:20px;
}

.close-btn{
  position:absolute;
  top:10px;
  right:14px;
  font-size:1.6rem;
  cursor:pointer;
  color:#e9eef6;
}

.close-btn:hover{
  color:#9fb0d1;
}

@media (max-width: 700px){
  header{
    padding:22px 18px 16px;
  }

  .header-actions{
    justify-content:center;
  }

  main{
    margin:18px auto;
    padding:0 12px;
  }

  .card{
    padding:16px;
    border-radius:18px;
  }

  .row{
    gap:12px;
  }

  h2{
    margin-bottom:8px;
  }

  .nav{
    justify-content:space-between;
  }

  .tooltip-wrapper .tooltip-text{
    width:240px;
  }

  footer{
    font-size:.82rem;
    padding:18px 14px 24px;
  }
}
.card + .card {
  margin-top: 20px;
}
main {
  max-width: 1200px;
}
button {
  transition: all 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

.source-grid {
  margin-bottom: 6px;
}

.source-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr; /* 🔥 stack everything */
  }

  .form-grid label {
    margin-bottom: 4px;
  }

  .source-buttons {
    justify-content: flex-start;
  }
}
.source-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-start; /* force left alignment */
}
@media (max-width: 600px) {
  input[type="text"],
  input[type="number"],
  select {
    width: 100%;
  }
}
.checkbox-group {
  display: flex;
  flex-direction: column; /* 🔥 stack vertically */
  gap: 8px;
  margin-top: 6px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%; /* prevent overflow */
}
.checkbox-group input[type="checkbox"] {
  width: auto;         /* 🔥 overrides the 100% rule */
  flex: 0 0 auto;      /* prevents stretching */
}
.card {
  overflow-x: hidden;
}
@media (max-width: 600px) {
  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .row button {
    width: 100%;
  }

  .tooltip-wrapper {
    width: 100%;
  }

  .tooltip-wrapper button {
    width: 100%;
  }
}
.row {
  margin-top: 10px;
}
