/* NexaMed exam tools: lifelines + scratchpad */
.nxm-exam-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -4px 0 18px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-wrap: wrap;
}

.nxm-exam-tools-label {
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.nxm-exam-tools-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nxm-lifeline-btn,
.nxm-scratchpad-trigger {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: 700 0.76rem/1 'DM Sans', sans-serif;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, opacity 0.16s ease, transform 0.16s ease;
}

.nxm-lifeline-btn:hover:not(:disabled),
.nxm-scratchpad-trigger:hover {
  border-color: rgba(0,201,106,0.45);
  background: rgba(0,201,106,0.06);
  transform: translateY(-1px);
}

.nxm-lifeline-btn:disabled,
.nxm-scratchpad-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.nxm-lifeline-btn .nxm-lifeline-count {
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255,255,255,0.07);
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 800;
}

.nxm-lifeline-btn[data-type="remove1"] .nxm-lifeline-count {
  color: var(--accent);
  background: rgba(0,201,106,0.09);
}

.nxm-lifeline-btn[data-type="remove2"] .nxm-lifeline-count {
  color: var(--gold);
  background: rgba(244,197,66,0.09);
}

.nxm-lifeline-btn.used-on-question {
  border-color: rgba(0,201,106,0.28);
  background: rgba(0,201,106,0.045);
}

.nxm-lifeline-btn.no-target {
  opacity: 0.35;
}

.nxm-scratchpad-trigger {
  border-color: rgba(255,255,255,0.09);
  color: var(--muted);
}

.nxm-scratchpad-trigger span:first-child {
  font-size: 0.9rem;
  line-height: 1;
}

.nxm-eliminated {
  display: none !important;
}

.omr-bub.eliminated {
  opacity: 0.18;
  border-style: dashed;
  pointer-events: none;
}

/* Scratchpad */
.nxm-scratchpad-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000000;
  display: none;
  box-sizing: border-box;
  padding: 0;
  font-family: 'DM Sans', sans-serif;
}

.nxm-scratchpad-overlay.open {
  display: block;
}

.nxm-scratchpad-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay, rgba(0,0,0,0.72));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.nxm-scratchpad-window {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background: var(--navy);
  color: var(--text);
  border: 0;
  overflow: hidden;
}

.nxm-scratchpad-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
}

.nxm-scratchpad-title-wrap {
  min-width: 0;
}

.nxm-scratchpad-eyebrow {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 3px;
}

.nxm-scratchpad-header h2 {
  margin: 0;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.7px;
  line-height: 1;
}

.nxm-scratchpad-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nxm-scratchpad-close,
.nxm-scratchpad-tool-btn,
.nxm-scratchpad-icon-btn,
.nxm-scratchpad-text-btn,
.nxm-scratchpad-download,
.nxm-scratchpad-done {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, opacity 0.16s ease, transform 0.16s ease;
}

.nxm-scratchpad-close {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 1.4rem;
  line-height: 1;
}

.nxm-scratchpad-close:hover,
.nxm-scratchpad-tool-btn:hover,
.nxm-scratchpad-icon-btn:hover:not(:disabled),
.nxm-scratchpad-text-btn:hover,
.nxm-scratchpad-download:hover,
.nxm-scratchpad-done:hover {
  color: var(--text);
  border-color: rgba(0,201,106,0.4);
  background: rgba(0,201,106,0.06);
  transform: translateY(-1px);
}

.nxm-scratchpad-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.018);
  overflow-x: auto;
  scrollbar-width: thin;
}

.nxm-scratchpad-tool-group {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding-right: 12px;
  border-right: 1px solid rgba(255,255,255,0.08);
}

.nxm-scratchpad-tool-group:last-child {
  border-right: 0;
  padding-right: 0;
  margin-left: auto;
}

.nxm-scratchpad-tool-label {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 2px;
  white-space: nowrap;
}

.nxm-scratchpad-tool-btn {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.7rem;
  white-space: nowrap;
}

.nxm-scratchpad-tool-btn.active,
.nxm-scratchpad-size[aria-pressed="true"] {
  color: var(--text);
  border-color: rgba(0,201,106,0.4);
  background: rgba(0,201,106,0.08);
}

.nxm-scratchpad-swatches,
.nxm-scratchpad-sizes {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nxm-scratchpad-swatch {
  width: 25px;
  height: 25px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch-color);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.nxm-scratchpad-swatch:hover {
  transform: scale(1.08);
}

.nxm-scratchpad-swatch[aria-pressed="true"] {
  border-color: var(--text);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.1);
}

.nxm-scratchpad-size {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.nxm-scratchpad-size span {
  display: block;
  border-radius: 50%;
  background: var(--text);
}

.nxm-scratchpad-icon-btn {
  width: 34px;
  height: 32px;
  border-radius: 8px;
  font-size: 1rem;
}

.nxm-scratchpad-text-btn {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.7rem;
}

.nxm-scratchpad-scroll {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #0b1220;
  touch-action: pan-y;
}

.nxm-scratchpad-sheet {
  position: relative;
  width: 100%;
  min-height: 760px;
}

.nxm-scratchpad-canvas {
  display: block;
  width: 100%;
  background: #0b1220;
  cursor: crosshair;
  touch-action: pan-y;
}

.nxm-scratchpad-canvas:active {
  cursor: crosshair;
}

.nxm-scratchpad-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--header-bg);
}

.nxm-scratchpad-footer-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.35;
}

.nxm-scratchpad-footer-copy strong {
  color: var(--text);
  font-size: 0.68rem;
}

.nxm-scratchpad-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.nxm-scratchpad-notice {
  max-width: 190px;
  min-height: 1em;
  color: var(--accent);
  font-size: 0.65rem;
  opacity: 0;
  transition: opacity 0.16s ease;
  white-space: nowrap;
}

.nxm-scratchpad-notice.show {
  opacity: 1;
}

.nxm-scratchpad-download,
.nxm-scratchpad-done {
  min-height: 34px;
  padding: 8px 11px;
  border-radius: 9px;
  font-size: 0.7rem;
  white-space: nowrap;
}

.nxm-scratchpad-download {
  color: var(--text);
  background: rgba(255,255,255,0.025);
}

.nxm-scratchpad-done {
  color: #000;
  background: var(--accent);
  border-color: var(--accent);
}

.nxm-scratchpad-done:hover {
  color: #000;
  background: var(--accent);
  opacity: 0.9;
}

@media (max-width: 820px) {
  .nxm-exam-tools {
    align-items: flex-start;
  }

  .nxm-exam-tools-actions {
    width: 100%;
  }

  .nxm-lifeline-btn,
  .nxm-scratchpad-trigger {
    flex: 1 1 auto;
    min-width: 0;
  }

  .nxm-scratchpad-toolbar {
    gap: 10px;
    flex-wrap: nowrap;
  }

  .nxm-scratchpad-tool-group:last-child {
    margin-left: 0;
  }

  .nxm-scratchpad-footer-copy span {
    display: none;
  }
}

@media (max-width: 560px) {
  .nxm-scratchpad-header {
    padding: 12px 13px;
  }

  .nxm-scratchpad-toolbar {
    padding: 8px 10px;
  }

  .nxm-scratchpad-tool-group {
    padding-right: 8px;
  }

  .nxm-scratchpad-tool-label {
    display: none;
  }

  .nxm-scratchpad-footer {
    padding: 9px 10px;
  }

  .nxm-scratchpad-footer-actions {
    width: 100%;
  }

  .nxm-scratchpad-notice {
    display: none;
  }

  .nxm-scratchpad-download,
  .nxm-scratchpad-done {
    flex: 1 1 0;
  }
}
