/* MCQ Paper Generator (BD) — ToolNest mobile-first styles.
   System font stack only (no webfont downloads, PRD 8).
   Print: A4, 14mm margins, one print stylesheet (PRD 7.6). */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", "Nirmala UI", sans-serif;
  background: #f4f7f5;
  color: #17211d;
  line-height: 1.5;
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 14px 32px;
}

header.site {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 0 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
}

.brand .tool { font-weight: 600; color: #0b6b57; }

.spacer { flex: 1; }

.lang-toggle {
  display: flex;
  border: 1px solid #b9ccc4;
  border-radius: 8px;
  overflow: hidden;
}

.lang-toggle button {
  border: 0;
  background: #fff;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
  font: inherit;
}

.lang-toggle button[aria-pressed="true"] {
  background: #0b6b57;
  color: #fff;
}

h1 { font-size: 1.45rem; line-height: 1.3; margin: 14px 0 8px; }
h2 { font-size: 1.2rem; margin: 4px 0 6px; }
h3 { font-size: 1.05rem; margin: 16px 0 6px; }
h4 { font-size: 1rem; margin: 12px 0 4px; }

.hint { color: #3c4a44; font-size: 0.92rem; margin: 4px 0 8px; }
.counts { color: #3c4a44; font-size: 0.92rem; margin: 6px 0 2px; min-height: 1.2em; }

.banner {
  padding: 10px 12px;
  border-radius: 8px;
  margin: 10px 0;
}

.banner.warn { background: #fdf3e3; border: 1px solid #e8c98a; }
.banner.info { background: #eef4f1; border: 1px solid #b9ccc4; }
.banner.error { background: #fbe9e9; border: 1px solid #d99a9a; }

.confirm-bar {
  background: #fdf3e3;
  border: 1px solid #e8c98a;
  border-radius: 8px;
  padding: 12px;
  margin: 10px 0;
}

.card {
  background: #fff;
  border: 1px solid #d8e2dd;
  border-radius: 12px;
  padding: 16px;
  margin: 14px 0;
}

label { display: block; font-weight: 600; margin: 6px 0 4px; }

input[type="text"], textarea, select {
  width: 100%;
  padding: 11px 12px;
  min-height: 44px;
  border: 1px solid #b9ccc4;
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: inherit;
}

textarea { resize: vertical; overflow-wrap: anywhere; white-space: pre-wrap; }

textarea[readonly] { background: #f4f7f5; }

select { width: auto; min-width: 64px; }

input:focus-visible, textarea:focus-visible, button:focus-visible,
a:focus-visible, summary:focus-visible, select:focus-visible,
.file-btn:focus-visible {
  outline: 3px solid #f2a93b;
  outline-offset: 1px;
}

fieldset.group {
  border: 1px solid #d8e2dd;
  border-radius: 10px;
  padding: 10px 12px 14px;
  margin: 10px 0 4px;
}

fieldset.group legend { font-weight: 700; padding: 0 6px; }

.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin: 6px 14px 6px 0;
  min-height: 44px;
  cursor: pointer;
}

.choice input[type="checkbox"], .choice input[type="radio"] { width: 20px; height: 20px; }

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid #0b6b57;
  border-radius: 8px;
  background: #fff;
  color: #0b6b57;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn.primary { background: #0b6b57; color: #fff; }
.btn.small-btn { min-height: 44px; padding: 7px 12px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.file-btn { cursor: pointer; margin: 0; }

.plain-list { margin: 6px 0 10px; padding-left: 20px; }
.plain-list li { margin: 4px 0; overflow-wrap: anywhere; }

.no-changes {
  background: #eef4f1;
  border-left: 4px solid #0b6b57;
  padding: 10px 12px;
  border-radius: 6px;
  margin: 10px 0;
}

details {
  border: 1px solid #d8e2dd;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
}

summary { font-weight: 600; cursor: pointer; min-height: 44px; display: flex; align-items: center; }

footer { color: #3c4a44; font-size: 0.92rem; margin-top: 18px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Bank list and editor ---------- */

.bank-item {
  border: 1px solid #d8e2dd;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
  background: #f8faf9;
}

.bank-item .bank-stem { font-weight: 600; overflow-wrap: anywhere; }
.bank-item .bank-meta { color: #3c4a44; font-size: 0.9rem; margin: 2px 0 6px; }
.bank-item .bank-state-error { color: #a12626; font-weight: 600; }
.bank-item .bank-state-warning { color: #8a5a00; font-weight: 600; }

.option-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 8px 0;
  border: 1px solid #d8e2dd;
  border-radius: 8px;
  padding: 8px;
}

.option-row .option-text { flex: 1 1 160px; width: auto; }
.option-row .option-tag { font-weight: 700; min-width: 2em; }

.grammar-example {
  background: #f4f7f5;
  border: 1px solid #d8e2dd;
  border-radius: 8px;
  padding: 10px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
  margin: 6px 0;
}

.reject-item {
  border-left: 4px solid #d98a00;
  background: #fdf8ec;
  padding: 8px 10px;
  margin: 8px 0;
  border-radius: 6px;
}

.reject-item pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
  margin: 4px 0 0;
}

/* ---------- Paper preview / print DOM ---------- */

.print-page {
  background: #fff;
  border: 1px solid #c9d4ce;
  box-shadow: 0 2px 10px rgba(23, 33, 29, 0.12);
  padding: 20px 18px;
  margin: 14px auto;
  max-width: 210mm;
  color: #000;
}

.paper-normal { font-size: 11pt; }
.paper-compact { font-size: 9.5pt; }

.paper-head { border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
.paper-head-row { display: flex; align-items: flex-start; gap: 10px; }
.paper-institution { flex: 1; text-align: center; font-weight: 700; font-size: 1.15em; overflow-wrap: anywhere; }
.paper-set-code { border: 2px solid #000; padding: 2px 10px; font-weight: 700; white-space: nowrap; }
.paper-title { text-align: center; font-weight: 700; margin-top: 4px; overflow-wrap: anywhere; }
.paper-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 6px; }
.paper-student { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 8px; }
.blank-line { display: inline-block; min-width: 120px; border-bottom: 1px solid #000; }
.paper-instructions { margin-top: 6px; overflow-wrap: anywhere; }

.q-block { margin: 10px 0; }
.q-head { display: flex; gap: 10px; }
.q-stem { flex: 1; min-width: 0; }
.q-marks { white-space: nowrap; }
.user-text { white-space: pre-wrap; overflow-wrap: anywhere; }

.opts { margin: 4px 0 0 1.6em; }
.opts-stacked .opt { display: block; margin: 2px 0; }
.opts-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 14px; }
.opts-inline { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.opt { overflow-wrap: anywhere; }
.opt-label { font-weight: 600; margin-right: 4px; }

.key-table { border-collapse: collapse; margin: 8px 0 16px; }
.key-table th, .key-table td { border: 1px solid #000; padding: 3px 10px; text-align: center; }
.key-detailed-set { margin: 10px 0 16px; }
.key-entry { margin: 3px 0; overflow-wrap: anywhere; }
.key-footer { border-top: 1px solid #000; margin-top: 14px; padding-top: 8px; }

.sheet-head { border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
.sheet-cols { display: flex; gap: 20px; }
.sheet-col { flex: 1; min-width: 0; }
.sheet-row { display: flex; align-items: center; gap: 4px; margin: 3px 0; }
.sheet-num { min-width: 2.4em; text-align: right; font-weight: 600; }
.bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1.5px solid #000;
  border-radius: 50%;
  font-size: 0.85em;
  flex: none;
}

@media (max-width: 480px) {
  h1 { font-size: 1.25rem; }
  .card { padding: 13px; }
  .print-page { padding: 14px 10px; }
  .sheet-cols { gap: 10px; }
  .bubble { width: 23px; height: 23px; }
}

/* ---------- Print (PRD 7.6) ---------- */

@page {
  size: A4;
  margin: 14mm;
}

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .wrap { max-width: none; padding: 0; margin: 0; }
  #preview-section { border: 0; padding: 0; margin: 0; background: #fff; }
  .print-page {
    border: 0;
    box-shadow: none;
    margin: 0;
    padding: 0;
    max-width: none;
    break-before: page;
  }
  .print-page.first-page { break-before: auto; }
  body[data-print-mode="papers"] #print-key,
  body[data-print-mode="papers"] #print-sheets,
  body[data-print-mode="key"] #print-papers,
  body[data-print-mode="key"] #print-sheets,
  body[data-print-mode="sheets"] #print-papers,
  body[data-print-mode="sheets"] #print-key {
    display: none;
  }
  .q-block { break-inside: avoid; }
  .sheet-row { break-inside: avoid; }
  .key-table tr { break-inside: avoid; }
}
