.qPageHead{display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:12px}

/* Inline editor inside quiz */
#inlineEditor{ margin-top: 14px; }
#inlineEditor .qItem{ background: rgba(10,16,32,.18); }
.qPageHead h1{margin:0}
.qTools{display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end}

.qList{display:flex; flex-direction:column; gap:12px; margin-top:12px}
.qItem{border:1px solid var(--line); border-radius:16px; padding:14px; background: rgba(10,16,32,.25)}
.qTop{display:flex; gap:10px; align-items:flex-start; justify-content:space-between}
.qInlineActions{display:flex;align-items:center;justify-content:flex-end;min-width:max-content}
.qEditInline{
  border:0;
  background:transparent;
  color:var(--primary2);
  font:inherit;
  font-size:12px;
  font-weight:800;
  cursor:pointer;
  padding:4px 2px;
  text-decoration:underline;
  text-underline-offset:3px;
}
.qEditInline:hover{color:var(--primary)}
.qEditFocus{
  outline:2px solid var(--primary2);
  box-shadow:0 0 0 4px color-mix(in srgb, var(--primary2) 18%, transparent);
}
.qNum{color:var(--muted); font-weight:800; font-size:12px; padding-top:3px}
.qText{flex:1; font-weight:800; line-height:1.3}

.qOpts{margin-top:10px; display:flex; flex-direction:column; gap:8px}
.qOpt{display:flex; gap:10px; align-items:flex-start}
.qOpt input[type="checkbox"]{width:18px; height:18px; margin-top:2px}
.qOptText{flex:1; color:var(--text)}

.qMatchingHeader,
.qMatchingReadonlyRow{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
}
.qMatchingHeader{
  padding:4px 0;
  color:var(--muted);
  font-size:12px;
  font-weight:800;
}
.qMatchingReadonlyCell{
  border:1px solid var(--line);
  border-radius:10px;
  padding:8px 10px;
  background:var(--card);
  min-height:36px;
}
.qMatchingReadonlyCell p:last-child{margin-bottom:0}

.qOptBtns{display:flex; gap:6px; align-items:center}
.qOptBtn{padding:6px 8px; min-width:40px; font-weight:900}
.qDrag{cursor:grab; user-select:none; opacity:.85}
.qDrag:active{cursor:grabbing}
.qOpt.dragOver{outline: 2px solid rgba(34,211,238,.55); border-radius: 14px}

.qQBtns{display:flex; gap:8px; margin-top:12px; justify-content:flex-end; flex-wrap:wrap}

.qBottomBar{margin-top:16px; padding-top:14px; border-top:1px solid rgba(34,48,88,.7)}

.qEdit .qText, .qEdit .qOptText{outline:1px dashed rgba(124,92,255,.45); border-radius:10px; padding:8px 10px; background: rgba(10,16,32,.35)}
.qEdit .qOptText{min-height:38px}

/* Markdown-friendly textareas (preserve \n) */
.qTextarea{
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 80px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(7,11,18,.35);
  color: inherit;
  font: inherit;
  font-weight: 700;
  line-height: 1.35;
}

.qOptTextarea{
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(7,11,18,.35);
  color: inherit;
  font: inherit;
  line-height: 1.35;
}

.qTextarea:focus,
.qOptTextarea:focus{
  outline: none;
  border-color: rgba(160, 190, 255, .55);
  box-shadow: 0 0 0 2px rgba(90, 140, 255, .22);
}

.qEditActions{margin-top:12px; flex-wrap:wrap}
.qEditActions .qAddBtn{margin-top:0}


/* Empty state for exams with no questions */
.qEmpty{
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  line-height: 1.7;
}
.qEmpty p{margin: 0 0 8px}
.qEmpty strong{color: var(--text)}

/* Scroll floating arrows */
.btnScrollNav{
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  z-index: 5000;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.32);
  background: rgba(16,24,48,.96);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .22s, transform .22s, background .18s;
  pointer-events: none;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 26px rgba(0,0,0,.45);
}
.btnScrollTop{ bottom: calc(84px + env(safe-area-inset-bottom)); }
.btnScrollBottom{ bottom: calc(28px + env(safe-area-inset-bottom)); }
.btnScrollNav.visible{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.btnScrollNav:hover{
  background: rgba(40,56,100,.98);
  border-color: rgba(255,255,255,.5);
}
@media (max-width: 640px){
  .btnScrollNav{
    right: max(12px, env(safe-area-inset-right));
    width: 42px;
    height: 42px;
  }
  .btnScrollTop{ bottom: calc(76px + env(safe-area-inset-bottom)); }
  .btnScrollBottom{ bottom: calc(24px + env(safe-area-inset-bottom)); }
}


/* --- AI Ask Button & Response Panel --- */
.aiLoading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  color: #cbd5e1;
}
.aiSpinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(125, 211, 252, 0.2);
  border-top-color: #7dd3fc;
  border-radius: 50%;
  animation: aiSpin 0.8s linear infinite;
}
@keyframes aiSpin {
  to { transform: rotate(360deg); }
}
.aiFunny {
  font-size: 0.9rem;
  text-align: center;
  max-width: 280px;
  line-height: 1.4;
}
.aiResponse {
  max-height: 320px;
  overflow-y: auto;
  padding: 12px;
  margin: 8px 0;
  background: #0f172a;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #e2e8f0;
}
.aiResponse h1, .aiResponse h2, .aiResponse h3 {
  font-size: 1rem;
  margin: 8px 0 4px;
  color: #7dd3fc;
}
.aiResponse p { margin: 0 0 6px; }
.aiResponse ul, .aiResponse ol { margin: 0 0 6px; padding-left: 20px; }
.aiResponse li { margin-bottom: 2px; }
.btnAiClose {
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #1e293b;
  color: #cbd5e1;
  cursor: pointer;
  margin-top: 8px;
}
.btnAiClose:hover { background: #334155; }
.btnAskAI {
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid #7dd3fc;
  background: transparent;
  color: #7dd3fc;
  cursor: pointer;
  font-weight: 600;
  margin-left: 8px;
  transition: all 0.2s;
}
.btnAskAI:hover:not(:disabled) {
  background: rgba(125, 211, 252, 0.12);
}
.btnAskAI:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #64748b;
  color: #64748b;
}

.btnAiCancel {
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #64748b;
  background: #1e293b;
  color: #94a3b8;
  cursor: pointer;
  margin-top: 4px;
}
.btnAiCancel:hover { background: #334155; color: #cbd5e1; }
