/* Basic layout */
.qmn-reading{font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif}
.qmn-topbar{margin-bottom:10px}
.qmn-part-tabs{display:flex;gap:8px;flex-wrap:wrap;margin:6px 0 10px}
.qmn-part-tabs .qmn-pt{border:1px solid #e5e7eb;background:#f3f4f6;border-radius:999px;padding:6px 12px;cursor:pointer}
.qmn-part-tabs .qmn-pt.active{background:#35509a;color:#fff;border-color:#35509a}

.qmn-body{display:grid;grid-template-columns:1.1fr 1.2fr 0.8fr;gap:16px}
.qmn-col{background:#fff;border:1px solid #eee;border-radius:10px;padding:12px;min-height:200px}
.qmn-col h4{margin:0 0 8px 0}

#qmn-opts .qopt{display:block;margin:8px 0}
#qmn-opts .qopt input{margin-right:8px}

#qmn-nav{display:flex;flex-wrap:wrap;gap:6px}
#qmn-nav .qmn-jump{width:34px;height:34px;border-radius:8px;border:1px solid #e5e7eb;background:#f9fafb;cursor:pointer}
#qmn-nav .qmn-jump.active{background:#35509a;color:#fff;border-color:#35509a}

/* answered state for right nav */
.qmn-col.q-right .qnum.answered{background:#10b981;color:#fff;border-color:#10b981}

/* flagged state for right nav */
.qmn-col.q-right .qnum.flagged{ position:relative; box-shadow:0 0 0 2px rgba(234,179,8,0.35) inset; border-color:#f59e0b; }
.qmn-col.q-right .qnum.flagged::after{
  content:'⚑';
  position:absolute;
  top:-6px; right:-6px;
  font-size:12px; line-height:1;
  background:#fff; border:1px solid #f59e0b; border-radius:6px; padding:1px 3px;
  color:#b45309;
}

/* === v5 UI polish === */

/* Sticky quiz header: compact layout */
#qmn-sticky-top{
  position: sticky; top: 0; z-index: 9999;
  background: #f9fafb; border-bottom:1px solid #e5e7eb;
  padding: 4px 8px; display:flex; align-items:center; gap:12px;
}

/* Compact tabs */
.qmn-tabs{ display:flex; flex-wrap:wrap; gap:4px; align-items:center; }
.qmn-tabs a, .qmn-tabs button[data-part]{
  display:inline-block; font-size:13px; line-height:1; padding:6px 10px; margin:0;
  border-radius:6px; background:#f3f4f6; color:#374151; text-decoration:none; border:0;
}
.qmn-tabs a.active, .qmn-tabs button[data-part].active{ background:#35509a; color:#fff; }
.qmn-tabs a:hover, .qmn-tabs button[data-part]:hover{ filter:brightness(0.97); }

/* Slim audio bar */
#qmn-audio-bar{
  flex:1; max-height:44px; padding:4px 8px; background:#fff;
  border:1px solid #e5e7eb; border-radius:8px; display:flex; align-items:center; gap:8px;
}
#qmn-audio-bar audio{ width:100%; height:28px; }
#qmn-audio-bar .btn, #qmn-audio-bar button{
  height:28px; min-width:28px; padding:0 8px; border-radius:6px; border:1px solid #e5e7eb; background:#f9fafb;
}

/* Action buttons aligned */
.qmn-actions{ display:flex; gap:12px; justify-content:center; margin:16px 0; flex-wrap:wrap; }
.qmn-actions .button, #qmn-submit, #qmn-reset{
  padding:10px 18px; border-radius:8px; font-size:14px; font-weight:600; border:none; cursor:pointer; transition:background .2s ease;
}
#qmn-submit{ background:#35509a; color:#fff; }
#qmn-submit:hover{ background:#2c4485; }
#qmn-reset{ background:#f3f4f6; color:#374151; }
#qmn-reset:hover{ background:#e5e7eb; }

/* Ensure anchor jumps leave room for sticky header */
[id^="q-"], .q-item, .qmn-question, [data-q-anchor]{
  scroll-margin-top: calc(var(--qmn-offset, 0px) + 10px);
}

/* === v5.1: Sticky tabs reinforce + balanced buttons === */

/* Keep sticky header always on top with subtle background */
#qmn-sticky-top{
  position: sticky; top: 0; z-index: 10000;
  background: rgba(249,250,251,0.97);
  backdrop-filter: blur(3px);
  border-bottom: 1px solid #e5e7eb;
}

/* Ensure tabs block doesn't collapse and stays visible */
#qmn-sticky-top .qmn-tabs{ flex:0 0 auto; }
.qmn-tabs.sticky, .qmn-tabs.is-sticky, .qmn-tabs.qmn-tabs-sticky{
  position: sticky; top: 0; z-index: 9998;
  background: rgba(249,250,251,0.97);
  padding: 4px 8px;
  border-bottom: 1px solid #e5e7eb;
}

/* Balance action buttons exactly the same height */
.qmn-actions .button, #qmn-submit, #qmn-reset{
  -webkit-appearance:none; appearance:none;
  display:inline-flex; align-items:center; justify-content:center;
  height: 40px !important; line-height: 1 !important;
  padding: 0 18px !important; min-width: 128px;
  border-radius: 8px; font-size: 14px; font-weight: 600;
  border: 1px solid transparent;
  box-sizing: border-box;
}
#qmn-submit{ background:#35509a; color:#fff; border-color:#2c4485; }
#qmn-submit:hover{ background:#2c4485; }
#qmn-reset{ background:#f3f4f6; color:#374151; border-color:#d1d5db; }
#qmn-reset:hover{ background:#e5e7eb; }

/* === v5.2: Circular nav numbers (light blue) === */
.qmn-col.q-right .qnum,
.q-right .qnum{
  display:inline-flex; align-items:center; justify-content:center;
  width:34px; height:34px;
  border-radius:50%;
  background:#60a5fa; /* light blue */
  color:#fff !important;
  border:1px solid #3b82f6;
  text-decoration:none;
  font-weight:600;
  line-height:1;
  box-sizing:border-box;
}
.q-right .qnum:hover{ filter:brightness(0.96); }
.q-right .qnum:focus{ outline:2px solid rgba(59,130,246,0.4); outline-offset:2px; }

/* Active/current nav (optional darker brand tone) */
.q-right .qnum.active{ background:#35509a; border-color:#35509a; color:#fff; }

/* Already answered state keeps white text */
.q-right .qnum.answered{ background:#10b981; border-color:#10b981; color:#fff; }

/* Small screens: slightly smaller dots */
@media (max-width: 480px){
  .q-right .qnum{ width:30px; height:30px; font-size:13px; }
}

/* === v5.3: Left question number as circular badge === */
.q-item .qno{
  display:flex; align-items:center; gap:8px;
  font-weight:600; color:#111827;
  margin-bottom:6px;
}
.q-item .qno-badge{
  display:inline-flex; align-items:center; justify-content:center;
  width:32px; height:32px; border-radius:50%;
  background:#60a5fa; color:#fff; font-weight:700;
  border:1px solid #3b82f6; line-height:1; box-sizing:border-box;
}
/* For segments (part 6-7) right column list */
.q-list .q-item .qno{ margin-bottom:6px; }

/* === v5.3.1: qno badge brand color === */
.q-item .qno-badge{
  background:#35509a !important;
  border-color:#35509a !important;
  color:#fff !important;
}

/* v5.3.2 ensure qno badge brand color even if injected by JS */
.q-item .qno-badge{
  background:#35509a !important;
  border:1px solid #35509a !important;
  color:#fff !important;
  display:inline-flex; align-items:center; justify-content:center;
  width:32px; height:32px; border-radius:50%; font-weight:700; line-height:1;
  box-sizing:border-box;
}
.q-item .qno{ display:flex; align-items:center; gap:8px; margin-bottom:6px; font-weight:600; }

/* === v5.3.3: Restore right nav style - white pills === */
.q-right .qnum{
  display:inline-flex; align-items:center; justify-content:center;
  height:34px; min-width:34px; padding:0 10px;
  background:#fff !important; color:#111827 !important;
  border:1px solid #e5e7eb !important;
  border-radius:18px !important;
  font-weight:600; line-height:1; box-sizing:border-box;
  text-decoration:none;
}
.q-right .qnum:hover{ background:#f9fafb !important; }
.q-right .qnum.active{ border-color:#35509a !important; box-shadow:0 0 0 2px rgba(53,80,154,0.15) inset; }

/* === v5.3.4: Force black text for right nav numbers in all states === */
.q-right .qnum,
.q-right .qnum:link,
.q-right .qnum:visited,
.q-right .qnum.active,
.q-right .qnum.answered,
.q-right .qnum.flagged{
  color:#111827 !important;
}
/* keep answered indicator subtle with border only (text remains black) */
.q-right .qnum.answered{
  background:#fff !important;
  border-color:#10b981 !important;
  box-shadow:0 0 0 2px rgba(16,185,129,0.25) inset;
}
/* flagged keeps black text too */
.q-right .qnum.flagged{ border-color:#f59e0b !important; box-shadow:0 0 0 2px rgba(245,158,11,0.3) inset; }

/* === v5.4: Audio bar compact sizing === */
#qmn-audio-bar{
  max-height: 38px; padding: 2px 8px;
  display:flex; align-items:center; gap:8px; overflow:hidden;
}
#qmn-audio-bar audio{ height:24px !important; }
#qmn-audio-bar .mejs-container,
#qmn-audio-bar .mejs-controls,
#qmn-audio-bar .mejs-embed{ height:24px !important; min-height:24px !important; }
#qmn-audio-bar .mejs-time-rail{ height:4px !important; }
#qmn-audio-bar .btn, #qmn-audio-bar button{ height:28px; min-width:28px; padding:0 8px; }

/* Compact when scrolling */
#qmn-sticky-top.qmn-compact{ padding: 2px 6px !important; }
#qmn-sticky-top.qmn-compact #qmn-audio-bar{ max-height:32px; }
#qmn-sticky-top.qmn-compact #qmn-audio-bar audio{ height:22px !important; }
#qmn-sticky-top{ transition: padding .15s ease; }
#qmn-audio-bar{ transition: max-height .15s ease; }

/* Mobile baseline even smaller */
@media (max-width: 768px){
  #qmn-audio-bar{ max-height:34px; }
  #qmn-audio-bar audio{ height:22px !important; }
}

/* === v5.5: Compact timer/actions & sticky tabs === */

/* Timer compact */
.qmn-topbar .qmn-timer{ font-size:15px; line-height:1; padding:0 6px; display:flex; gap:6px; align-items:center; }
.qmn-topbar .qmn-timer .qmn-timer-label{ font-size:15px; opacity:.8; }

/* Actions compact, unified sizing */
.qmn-actions .btn,
#qmn-submit, #qmn-reset{
  font-size:15px !important;
  height:34px !important;
  padding:0 12px !important;
  border-radius:8px !important;
  line-height:1 !important;
  display:inline-flex; align-items:center; justify-content:center;
}

/* Tabs sticky just below sticky offset */
.qmn-tabs{
  position: sticky;
  top: calc(var(--qmn-offset, 0px));
  z-index: 999;
  background: #fff;
  padding: 6px 0;
  border-bottom: 1px solid #e5e7eb;
}
.qmn-tabs a{ font-size:13px; padding:6px 12px; border-radius:12px; }
