/* =====================================================================
   PEF QAT Test Studio — Teacher Dashboard v1.6 (visual layer)
   Loads after qat-design.css. Only the signed-in teacher app is styled
   here; the sign-in page and the A4 paper/print output are untouched.
   ===================================================================== */
.qat-app {
  --v2-green: #0B5D3F;
  --v2-green-dk: #08452F;
  --v2-green-soft: #E3F2EA;
  --v2-green-tint: #F4FAF7;
  --v2-accent: #2DBE7B;
  --v2-bg: #F3F7F5;
  --v2-line: #DCE8E1;
  --v2-line-2: #EEF3F0;
  --v2-ink: #10241B;
  --v2-ink-2: #33463D;
  --v2-muted: #5A6B63;
  background: var(--v2-bg);
  color: var(--v2-ink);
}
.qat-app .qat-btn-primary,
.qat-app .qat-btn-primary:hover:not(:disabled) {
  background: var(--v2-green);
  box-shadow: none;
}
.qat-app .qat-btn-primary:hover:not(:disabled) { background: var(--v2-green-dk); }
.qat-app .qat-btn { min-height: 44px; border-radius: 10px; }
.qat-app .qat-text-btn { color: var(--v2-green); font-weight: 600; }
.qat-app :focus-visible { outline: 3px solid rgba(45, 190, 123, 0.55); outline-offset: 2px; }

/* ---------- Sidebar: white, calm ---------- */
.qat-app .qat-sidebar {
  background: #fff;
  color: var(--v2-ink);
  border-right: 1px solid var(--v2-line);
  padding: 22px 14px 18px;
}
.qat-app .qat-side-brand { text-align: left; display: grid; grid-template-columns: 40px 1fr; column-gap: 10px; align-items: center; padding: 0 6px 22px; }
.qat-app .qat-side-mark { grid-row: span 2; width: 40px; height: 40px; margin: 0; border-radius: 11px; background: var(--v2-green); }
.qat-app .qat-side-mark svg { width: 22px; height: 22px; }
.qat-app .qat-side-name { font-size: 15px; color: var(--v2-ink); }
.qat-app .qat-side-brand small { margin: 0; color: var(--v2-muted); letter-spacing: 0; }
.qat-app .qat-side-link { color: var(--v2-ink-2); font-weight: 500; font-size: 14px; }
.qat-app .qat-side-link:hover { background: var(--v2-line-2); color: var(--v2-ink); }
.qat-app .qat-side-link.is-active { background: var(--v2-green-soft); color: var(--v2-green); font-weight: 700; box-shadow: none; }
.qat-app .qat-side-link .qat-nav-count { background: var(--v2-line-2); color: var(--v2-ink-2); }
.qat-app .qat-side-link.is-active .qat-nav-count { background: #fff; color: var(--v2-green); }
.qat-app .qat-side-foot { border-top-color: var(--v2-line); }

/* ---------- Top bar ---------- */
.qat-app .qat-appbar { border-color: var(--v2-line); box-shadow: none; border-radius: 14px; }
.qat-app .qat-welcome strong { font-size: 17px; font-weight: 800; color: var(--v2-ink); }
.qat-app .qat-welcome span { color: var(--v2-muted); }
.qat-app .qat-avatar { background: #FBE7B5; color: #6B4B00; box-shadow: none; }
.qat-app .qat-quota-text { background: var(--v2-green-soft); color: var(--v2-green); }

/* ---------- Shared bits ---------- */
.qat-v2-card {
  background: #fff;
  border: 1px solid var(--v2-line);
  border-radius: 16px;
  padding: 20px;
}
.qat-v2-h2 { margin: 0; font-size: 17px; font-weight: 700; color: var(--v2-ink); display: flex; align-items: center; gap: 8px; }
.qat-v2-count { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--v2-line-2); color: var(--v2-ink-2); }
.qat-v2-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; }
.qat-v2-num {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 99px;
  background: var(--v2-green); color: #fff; font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.qat-v2-note { margin: 6px 0 0; font-size: 12.5px; color: var(--v2-muted); line-height: 1.5; }

/* ---------- HOME ---------- */
.qat-v2-home { display: flex; flex-direction: column; gap: 22px; }
.qat-v2-hero {
  background: var(--v2-green);
  color: #fff;
  border-radius: 18px;
  padding: 28px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 22px;
}
.qat-v2-hero-copy { max-width: 540px; }
.qat-v2-hero-copy h1 { margin: 0 0 8px; color: #fff; font-size: clamp(22px, 2.4vw, 28px); font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; }
.qat-v2-hero-copy p { margin: 0; color: #D6EFE2; font-size: 15px; line-height: 1.55; }
.qat-v2-hero-side { display: flex; flex-direction: column; gap: 14px; min-width: 240px; }
.qat-v2-quota-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: #D6EFE2; margin-bottom: 6px; }
.qat-v2-quota-row strong { color: #fff; }
.qat-v2-bar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.22); overflow: hidden; }
.qat-v2-bar span { display: block; height: 100%; background: #fff; border-radius: 99px; }
.qat-v2-hero-btn {
  min-height: 52px; padding: 0 22px; border: 0; border-radius: 12px;
  background: #fff; color: var(--v2-green); font: inherit; font-size: 16px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; cursor: pointer;
}
.qat-v2-hero-btn:hover { background: var(--v2-green-soft); }

.qat-v2-block { display: flex; flex-direction: column; gap: 12px; }
.qat-v2-quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.qat-v2-quick {
  text-align: left; font: inherit; cursor: pointer;
  background: #fff; border: 1px solid var(--v2-line); border-radius: 14px; padding: 18px;
  display: flex; flex-direction: column; gap: 6px; color: var(--v2-ink);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.qat-v2-quick:hover { border-color: var(--v2-green); transform: translateY(-1px); }
.qat-v2-quick strong { font-size: 16px; }
.qat-v2-quick > span:last-child { font-size: 13px; color: var(--v2-muted); line-height: 1.4; }
.qat-v2-tag { align-self: flex-start; font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 99px; }
.qat-v2-tag.is-green { color: var(--v2-green); background: var(--v2-green-soft); }
.qat-v2-tag.is-amber { color: #7A4E00; background: #FBEFD2; }
.qat-v2-tag.is-blue { color: #1F4E8C; background: #E2ECF8; }

.qat-v2-recent-body { display: flex; flex-direction: column; }
.qat-v2-rp-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--v2-line-2); }
.qat-v2-rp-ico {
  flex: 0 0 42px; width: 42px; height: 42px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; background: var(--v2-green-soft); color: var(--v2-green);
}
.qat-v2-rp-row:nth-child(3n+2) .qat-v2-rp-ico { background: #FBEFD2; color: #7A4E00; }
.qat-v2-rp-row:nth-child(3n) .qat-v2-rp-ico { background: #E2ECF8; color: #1F4E8C; }
.qat-v2-rp-main { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.qat-v2-rp-main strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qat-v2-rp-main span { font-size: 13px; color: var(--v2-muted); }
.qat-v2-rp-btn {
  min-height: 42px; padding: 0 16px; border-radius: 9px; border: 0;
  background: var(--v2-green); color: #fff; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.qat-v2-rp-btn:hover { background: var(--v2-green-dk); }
.qat-v2-empty { padding: 26px 10px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--v2-muted); font-size: 14px; }
.qat-v2-empty strong { color: var(--v2-ink); font-size: 15px; }

/* ---------- CREATE PAPER ---------- */
.qat-v2-studio { display: flex; flex-direction: column; gap: 18px; }
.qat-v2-studio-head { display: flex; align-items: center; gap: 14px; }
.qat-v2-studio-head h1 { margin: 0; font-size: 24px; font-weight: 800; color: var(--v2-ink); }
.qat-v2-studio-head p { margin: 2px 0 0; font-size: 13px; color: var(--v2-muted); }
.qat-v2-back {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 12px; cursor: pointer;
  background: #fff; border: 1px solid var(--v2-line); color: var(--v2-ink);
  display: inline-flex; align-items: center; justify-content: center;
}
.qat-v2-studio-grid { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.qat-app .qat-v2-studio-main.qat-builder-panel {
  flex: 999 1 560px; min-width: 0;
  background: transparent; border: 0; border-radius: 0; box-shadow: none; padding: 0;
  display: flex; flex-direction: column; gap: 16px;
}
.qat-v2-format { display: flex; flex-direction: column; gap: 16px; }
.qat-v2-step { display: flex; flex-direction: column; gap: 14px; }
.qat-v2-step-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--v2-ink); display: flex; align-items: center; gap: 10px; }
.qat-v2-row-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; font-size: 13px; color: var(--v2-muted); }
.qat-v2-row-head .qat-inline-actions { display: inline-flex; align-items: center; gap: 14px; }
.qat-app .qat-v2-row-head #qat-units-heading { font-size: 13px; font-weight: 600; color: var(--v2-ink-2); }

/* Class buttons (built by JS) */
.qat-app .qat-v2-grades { display: flex; flex-wrap: wrap; gap: 8px; }
.qat-app .qat-v2-grades .qat-grade-btn {
  min-height: 44px; padding: 6px 16px; margin: 0; border-radius: 10px;
  border: 1px solid var(--v2-line); background: #fff; color: var(--v2-ink-2);
  display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 1px;
  font: inherit; font-size: 14px; font-weight: 600; box-shadow: none; cursor: pointer;
}
.qat-app .qat-v2-grades .qat-grade-btn .qat-grade-tag { font-size: 11px; font-weight: 500; color: var(--v2-muted); background: none; padding: 0; }
.qat-app .qat-v2-grades .qat-grade-btn:hover { border-color: var(--v2-green); }
.qat-app .qat-v2-grades .qat-grade-btn.is-active { border: 2px solid var(--v2-green); background: var(--v2-green-soft); color: var(--v2-green); }
.qat-app .qat-v2-grades .qat-grade-btn.is-active .qat-grade-tag { color: var(--v2-green); background: none; }

/* Subject cards (built by JS) */
.qat-app .qat-v2-books { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.qat-app .qat-v2-books .qat-book-chip {
  margin: 0; width: 100%; min-height: 64px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--v2-line); background: #fff; box-shadow: none;
  display: flex; flex-direction: row-reverse; align-items: flex-start; justify-content: space-between; gap: 10px;
  text-align: left; font: inherit; cursor: pointer;
}
.qat-app .qat-v2-books .qat-book-chip:hover { border-color: var(--v2-green); }
.qat-app .qat-v2-books .qat-book-chip.is-active { border: 2px solid var(--v2-green); background: var(--v2-green-tint); }
.qat-app .qat-v2-books .qat-chip-check {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 6px; font-size: 13px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--v2-line); background: #fff; color: var(--v2-muted);
}
.qat-app .qat-v2-books .qat-book-chip.is-active .qat-chip-check { background: var(--v2-green); border-color: var(--v2-green); color: #fff; }
.qat-app .qat-v2-books .qat-chip-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.qat-app .qat-v2-books .qat-chip-main strong { font-size: 15px; color: var(--v2-ink); }
.qat-app .qat-v2-books .qat-chip-main small { font-size: 12px; color: var(--v2-muted); line-height: 1.35; }

/* Pattern cards */
.qat-v2-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.qat-app .qat-v2-mode {
  text-align: left; font: inherit; cursor: pointer; margin: 0;
  padding: 14px; border-radius: 12px; border: 1px solid var(--v2-line); background: #fff; box-shadow: none;
  display: flex; flex-direction: column; gap: 4px; color: var(--v2-ink);
}
.qat-app .qat-v2-mode strong { font-size: 14px; }
.qat-app .qat-v2-mode small { font-size: 12px; color: var(--v2-muted); }
.qat-app .qat-v2-mode:hover { border-color: var(--v2-green); }
.qat-app .qat-v2-mode.is-active { border: 2px solid var(--v2-green); background: var(--v2-green-tint); color: var(--v2-ink); }
.qat-v2-blueprint { border: 1px solid var(--v2-line-2); border-radius: 12px; overflow: hidden; }
.qat-v2-bp-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; font-size: 13px; border-top: 1px solid var(--v2-line-2); color: var(--v2-ink-2); }
.qat-v2-bp-row:first-child { border-top: 0; }
.qat-v2-bp-row.is-total { background: #F6F9F7; color: var(--v2-ink); font-weight: 700; }
.qat-v2-blueprint .qat-v2-note { padding: 0 14px 12px; }
.qat-v2-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.qat-app .qat-v2-filters select,
.qat-app .qat-v2-header-grid input { min-height: 44px; border-radius: 10px; border: 1px solid var(--v2-line); font-size: 14px; }

/* Subject tabs (built by JS) */
.qat-app .qat-v2-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--v2-line-2); }
.qat-app .qat-v2-tabs .qat-book-tab {
  flex: 1 1 auto; min-height: 40px; margin: 0; padding: 0 14px; border-radius: 9px; border: 0;
  background: transparent; color: var(--v2-ink-2); font: inherit; font-size: 13px; font-weight: 600; box-shadow: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
}
.qat-app .qat-v2-tabs .qat-book-tab.is-active { background: #fff; color: var(--v2-green); font-weight: 700; box-shadow: 0 1px 2px rgba(16, 36, 27, 0.1); }
.qat-app .qat-v2-tabs .qat-tab-badge { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: rgba(11, 93, 63, 0.08); color: inherit; }

/* Chapter list (built by JS) — compact grid so 5 books never make a long page */
.qat-app .qat-v2-units {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px;
  max-height: none; overflow: visible; padding: 0; border: 0; background: none;
}
.qat-app .qat-v2-units .qat-unit-item {
  margin: 0; min-height: 48px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--v2-line); background: #fff;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
}
.qat-app .qat-v2-units .qat-unit-item:has(input:checked) { border-color: var(--v2-green); background: var(--v2-green-tint); }
.qat-app .qat-v2-units .qat-unit-item input { flex: 0 0 18px; width: 18px; height: 18px; margin: 0; accent-color: var(--v2-green); }
.qat-app .qat-v2-units .qat-unit-title { display: block; font-size: 13px; font-weight: 600; color: var(--v2-ink); line-height: 1.3; }
.qat-app .qat-v2-units .qat-unit-meta { display: block; font-size: 11.5px; color: var(--v2-muted); margin-top: 1px; }
.qat-v2-custom { margin-top: 6px; }

/* Header box (details/summary) */
.qat-v2-header-box { padding: 0; }
.qat-v2-header-box > summary {
  list-style: none; cursor: pointer; padding: 16px 20px;
  display: flex; align-items: center; gap: 12px;
}
.qat-v2-header-box > summary::-webkit-details-marker { display: none; }
.qat-v2-header-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.qat-v2-header-copy strong { font-size: 16px; color: var(--v2-ink); }
.qat-v2-header-copy span { font-size: 13px; color: var(--v2-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qat-v2-edit-pill { flex: 0 0 auto; min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--v2-line); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; color: var(--v2-ink); }
.qat-v2-header-box[open] .qat-v2-edit-pill { background: var(--v2-green-soft); border-color: var(--v2-green); color: var(--v2-green); }
.qat-v2-header-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; padding: 4px 20px 0; }
.qat-v2-header-actions { padding: 14px 20px 18px; }

/* Summary card */
.qat-v2-summary {
  flex: 1 1 300px; max-width: 360px; box-sizing: border-box;
  position: sticky; top: 16px;
  background: #fff; border: 1px solid var(--v2-line); border-radius: 16px; padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.qat-v2-sum-main { display: flex; flex-direction: column; gap: 10px; padding: 0; background: none; border: 0; font-family: inherit; }
.qat-v2-sum-marks { display: flex; align-items: baseline; gap: 8px; }
.qat-v2-sum-marks strong { font-size: 42px; font-weight: 800; color: var(--v2-green); line-height: 1; }
.qat-v2-sum-marks span { font-size: 14px; color: var(--v2-muted); }
.qat-v2-sum-lines { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 10px; background: #F6F9F7; font-size: 13px; color: var(--v2-ink-2); }
.qat-v2-sum-opts { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--v2-line-2); padding-top: 14px; }
.qat-v2-sum-opts label { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--v2-ink); cursor: pointer; }
.qat-v2-sum-opts input { width: 18px; height: 18px; margin: 0; accent-color: var(--v2-green); }
.qat-v2-cta { display: flex; flex-direction: column; gap: 8px; }
.qat-v2-cta-info { display: none; }
.qat-app .qat-v2-generate { width: 100%; min-height: 52px; font-size: 16px; font-weight: 700; border-radius: 12px; }
.qat-v2-sum-note { margin: 0; font-size: 12px; color: var(--v2-muted); text-align: center; }

/* Preview pane */
.qat-app .qat-v2-preview { margin-top: 4px; border: 1px solid var(--v2-line); }

/* ---------- Tablet / mobile ---------- */
@media (max-width: 1100px) {
  .qat-v2-summary { max-width: none; position: static; }
}
@media (max-width: 860px) {
  .qat-v2-hero { padding: 20px; border-radius: 16px; }
  .qat-v2-hero-side { min-width: 0; width: 100%; }
  .qat-v2-hero-btn { width: 100%; }
  .qat-v2-quick-grid { grid-auto-flow: column; grid-auto-columns: 72%; grid-template-columns: none; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
  .qat-v2-quick { scroll-snap-align: start; }
  .qat-v2-rp-row { flex-wrap: nowrap; }
  .qat-v2-rp-main { flex: 1 1 auto; }
  .qat-v2-card { padding: 16px; border-radius: 14px; }
  .qat-v2-studio-head h1 { font-size: 20px; }
  .qat-v2-studio-head p { display: none; }
  .qat-app .qat-v2-units { grid-template-columns: 1fr; }
  .qat-app .qat-v2-books { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qat-v2-header-box > summary { padding: 14px 16px; }
  .qat-v2-header-grid { padding: 4px 16px 0; }
  .qat-v2-header-actions { padding: 12px 16px 16px; }

  /* Summary becomes a card at the end + a sticky bar above the bottom menu */
  .qat-v2-summary { padding: 16px; padding-bottom: 8px; }
  .qat-v2-studio .qat-v2-summary .qat-v2-sum-main { display: none; }
  .qat-v2-cta {
    position: fixed; left: 0; right: 0; z-index: 9985;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    flex-direction: row; align-items: center; gap: 12px;
    padding: 10px 14px; background: #fff; border-top: 1px solid var(--v2-line);
    box-shadow: 0 -10px 24px -20px rgba(16, 36, 27, 0.6);
  }
  .qat-v2-cta-info { display: flex; flex-direction: column; gap: 1px; }
  .qat-v2-cta-info strong { font-size: 18px; color: var(--v2-green); white-space: nowrap; }
  .qat-v2-cta-info span { font-size: 12px; color: var(--v2-muted); white-space: nowrap; }
  .qat-app .qat-v2-generate { flex: 1; min-height: 48px; }
  .qat-app.qat-v2-cta-off .qat-v2-cta { display: none; }
  .qat-v2-studio { padding-bottom: 76px; }
  .qat-app .qat-preview-btns { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
}
@media (max-width: 420px) {
  .qat-app .qat-v2-books { grid-template-columns: 1fr; }
}
.qat-app .qat-v2-books .qat-chip-main strong,
.qat-app .qat-v2-books .qat-chip-main small { white-space: normal; overflow: visible; text-overflow: clip; }
.qat-v2-rp-btn { white-space: nowrap; flex: 0 0 auto; }
@media (max-width: 860px) {
  .qat-app .qat-v2-grades { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qat-app .qat-v2-grades .qat-grade-btn { width: 100%; }
  .qat-v2-rp-btn { padding: 0 14px; }
}

/* ---------- v1.7 additions ---------- */
.qat-v2-bp-row.is-head { background: #F6F9F7; font-weight: 600; color: var(--v2-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.qat-v2-persubject { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; padding: 12px 14px 0; border-top: 1px solid var(--v2-line-2); }
.qat-v2-persubject label {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; min-height: 44px; box-sizing: border-box;
  border: 1px solid var(--v2-line); border-radius: 10px; cursor: pointer; background: #fff;
}
.qat-v2-persubject label:has(input:checked) { border: 2px solid var(--v2-green); background: var(--v2-green-tint); }
.qat-v2-persubject input { margin: 2px 0 0; width: 18px; height: 18px; accent-color: var(--v2-green); }
.qat-v2-persubject span { display: flex; flex-direction: column; gap: 2px; }
.qat-v2-persubject strong { font-size: 13.5px; color: var(--v2-ink); }
.qat-v2-persubject small { font-size: 12px; color: var(--v2-muted); }
.qat-v2-blueprint .qat-v2-note { padding-top: 10px; }
.qat-v2-rp-actions { display: inline-flex; gap: 8px; flex: 0 0 auto; }
.qat-v2-rp-btn.is-ghost { background: #fff; color: var(--v2-ink); border: 1px solid var(--v2-line); }
.qat-v2-rp-btn.is-ghost:hover { background: var(--v2-line-2); }
.qat-app .qat-dup-btn { margin: 0; }
@media (max-width: 860px) {
  .qat-v2-rp-row { flex-wrap: wrap; }
  .qat-v2-rp-main { flex: 1 1 calc(100% - 60px); }
  .qat-v2-rp-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
}

/* v1.8: Urdu print font — Jameel Noori Nastaleeq (bundled; a copy installed on the
   computer is used first). Numbers and English inside Urdu text use the paper font. */
@font-face {
  font-family: 'Jameel Noori Nastaleeq';
  src: local('Jameel Noori Nastaleeq'), local('JameelNooriNastaleeq'),
       url('../fonts/jameel-noori-nastaleeq.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: block;
}
.qat-a4-ur,
.qat-opt-ur {
  font-family: 'Jameel Noori Nastaleeq', 'Urdu Typesetting', 'Noto Nastaliq Urdu', serif;
  font-weight: normal;
  direction: rtl;
  unicode-bidi: isolate;
}
.qat-a4-ur {
  display: block;
  margin-top: 1px;
  font-size: 1.18em;
  line-height: 1.75;
  text-align: right;
}
.qat-opt-ur { font-size: 1.12em; line-height: 1.5; margin-left: 4px; }
.qat-a4-ur .qat-ltr,
.qat-opt-ur .qat-ltr {
  font-family: 'Source Serif 4', 'Times New Roman', Georgia, serif;
  font-size: 0.82em;
  font-weight: 600;
  margin: 0 0.22em;
  unicode-bidi: isolate;
}
.qat-a4-ur-note { font-size: 1.15em; color: #111; margin: 0 0 4px; }

/* v1.8: PEF QAT model-paper sections (Section I / II / III) */
.qat-a4-qat-sec { margin: 14px 0 6px; break-inside: avoid; page-break-inside: avoid; }
.qat-a4-qat-sec-title {
  text-align: center; font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800;
  font-size: 13px; letter-spacing: .08em; margin-bottom: 6px;
}
.qat-a4-qat-instr {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  font-family: 'Plus Jakarta Sans', sans-serif; font-size: 12.5px; font-weight: 600;
  border-bottom: 1px solid #222; padding-bottom: 3px;
}
.qat-a4-qat-instr > span:last-child { white-space: nowrap; }

/* v1.8: Custom mode — rows grouped by chapter */
.qat-app .qat-cat-unit-head {
  grid-column: 1 / -1; margin: 10px 0 2px; padding: 6px 10px; border-radius: 8px;
  background: var(--v2-line-2, #eef2ef); color: var(--v2-ink, #0f172a);
  font-weight: 700; font-size: 13px;
}
.qat-app .qat-cat-unit-head:first-child { margin-top: 0; }
.qat-app .qat-type-badge {
  display: inline-block; padding: 0 6px; border-radius: 5px; font-weight: 700; font-size: 10.5px;
  background: #e7f0ec; color: #0B5D3F;
}
.qat-app .qat-type-badge.qat-type-short { background: #fff4e0; color: #8a5a00; }
.qat-app .qat-type-badge.qat-type-long { background: #ffe9ec; color: #a1123a; }
.qat-a4-q-head > span:first-child:has(.qat-a4-ur) { flex: 1 1 auto; min-width: 0; }

/* v1.9: Urdu-medium questions (Urdu book) — right-to-left, Jameel Noori Nastaleeq */
.qat-ur-text {
  font-family: 'Jameel Noori Nastaleeq', 'Urdu Typesetting', 'Noto Nastaliq Urdu', serif;
  font-weight: normal;
  font-size: 1.22em;
  line-height: 1.9;
  direction: rtl;
  unicode-bidi: isolate;
}
.qat-ur-text .qat-ltr {
  font-family: 'Source Serif 4', 'Times New Roman', Georgia, serif;
  font-size: 0.8em; font-weight: 600; margin: 0 0.2em; unicode-bidi: isolate;
}
.qat-rtl { direction: rtl; text-align: right; }
.qat-rtl .qat-a4-q-head > span:first-child { flex: 1 1 auto; min-width: 0; }
.qat-rtl .qat-a4-q-head strong { font-family: 'Jameel Noori Nastaleeq', serif; font-weight: normal; font-size: 1.2em; }
.qat-rtl .qat-a4-opts > div.qat-ur-text { font-size: 1.15em; line-height: 1.7; }
.qat-rtl .qat-q-actions { direction: ltr; }
.qat-a4-passage-box.qat-rtl .qat-ur-passage { font-size: 1.15em; line-height: 2; text-align: justify; }
.qat-a4-qat-sec.qat-rtl .qat-a4-qat-sec-title.qat-ur-text { text-align: center; font-size: 1.45em; letter-spacing: 0; }
.qat-a4-qat-sec.qat-rtl .qat-a4-qat-instr.qat-ur-text { font-size: 1.2em; font-weight: normal; }
.qat-bubble.qat-bubble-ur { font-family: 'Jameel Noori Nastaleeq', serif; font-size: 0.95em; line-height: 1; }
.qat-rtl .qat-ur-label { margin-left: 0.35em; }
@media print {
  .qat-ur-text { font-size: 1.4em !important; line-height: 1.85 !important; }
  .qat-rtl .qat-a4-opts > div.qat-ur-text { font-size: 1.3em !important; }
  .qat-a4-passage-box.qat-rtl .qat-ur-passage { font-size: 1.3em !important; }
  .qat-a4-ur { font-size: 1.3em !important; }
  .qat-opt-ur { font-size: 1.2em !important; }
}

/* v1.11 — PEF QAT English Section II */
.qat-eng-sub { margin-top: 8px; }
.qat-eng-line { margin: 4px 0 6px 14px; }
.qat-eng-prompt { font-weight: 500; }
.qat-eng-word .qat-eng-prompt { font-weight: 700; }
.qat-eng-write { border-bottom: 1px solid #555; height: 22px; margin: 2px 0 4px 28px; }
@media print { .qat-eng-write { height: 26px; } }

/* v1.11.2: Urdu category names (Urdu books) in the custom panel */
.qat-cat-name.qat-cat-name-ur {
  display: block;
  font-family: 'Jameel Noori Nastaleeq', 'Urdu Typesetting', 'Noto Nastaliq Urdu', serif;
  font-weight: normal;
  font-size: 17px;
  line-height: 1.7;
  direction: rtl;
  text-align: right;
}
.qat-a4-group-title.qat-ur-text { direction: rtl; text-align: right; }
.qat-cat-avail.qat-cat-avail-ur { direction: rtl; text-align: right; font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif; font-size: 14px; }

/* v1.13: PEF QAT English Class 3 */
.qat-e3-grid { display: flex; flex-wrap: wrap; gap: 6px 26px; margin: 4px 0 8px 14px; }
.qat-e3-cell { display: inline-flex; align-items: baseline; gap: 4px; min-width: 150px; }
.qat-e3-word { font-size: 1.05em; letter-spacing: .5px; }
.qat-e3-blank { display: inline-block; min-width: 90px; border-bottom: 1px solid #555; height: 1em; margin-left: 4px; }
.qat-e3-line .qat-a4-q-head { align-items: baseline; }
.qat-e3-choice { display: inline-block; margin: 0 14px 0 4px; padding: 0 6px; }
.qat-e3-match { border-collapse: collapse; margin: 4px 0 8px 14px; width: calc(100% - 14px); max-width: 520px; }
.qat-e3-match th, .qat-e3-match td { border: 1px solid #777; padding: 4px 10px; text-align: left; }
.qat-e3-match th { background: #f1f1f1; }
.qat-e3-cell .qat-q-actions button, .qat-e3-match .qat-q-actions button { padding: 0 5px; font-size: 11px; }
.qat-e3-match .qat-q-actions { display: inline-flex; gap: 3px; margin-left: 6px; }
.qat-e3-write { margin-left: 14px; }

/* v1.14: PEF QAT Urdu Class 3 */
.qat-u3-instr { margin-top: 8px; }
.qat-u3-instr strong { font-family: 'Jameel Noori Nastaleeq', serif; font-weight: bold; }
.qat-u3-q { margin: 4px 14px 6px 0; }
.qat-u3-line { border-bottom: 1px dashed #555; height: 26px; margin: 2px 22px 2px 0; }
.qat-u3-table { border-collapse: collapse; margin: 6px auto 10px; width: 92%; font-size: 1.15em; }
.qat-u3-table th, .qat-u3-table td { border: 1px solid #666; padding: 3px 10px; text-align: right; line-height: 1.9; }
.qat-u3-table th { background: #eee; font-weight: normal; text-align: center; }
.qat-u3-table td.qat-u3-letters { text-align: center; letter-spacing: 1px; white-space: nowrap; }
.qat-u3-table td.qat-u3-blank { min-width: 120px; }
.qat-u3-table .qat-q-actions { display: inline-flex; gap: 3px; direction: ltr; float: left; }
.qat-u3-table .qat-q-actions button, .qat-u3-instr .qat-q-actions button, .qat-u3-q .qat-q-actions button { padding: 0 5px; font-size: 11px; }
.qat-u3-instr .qat-q-actions { display: inline-flex; gap: 3px; direction: ltr; }
@media print { .qat-u3-line { height: 30px; } }

/* v1.15: PEF QAT General Knowledge Class 3 */
.qat-gk3-bank { text-align: center; font-size: 1.2em; margin: 4px 0 8px; font-weight: bold; }

/* v1.16: PEF QAT Mathematics Class 3 */
.qat-m3-qhead { margin-top: 10px; }
.qat-m3-ur { font-size: 1.15em; margin: 0 0 6px; }
.qat-m3-ur-sub { font-size: 1.05em; color: #333; }
.qat-m3-act { display: inline-flex; gap: 3px; }
.qat-m3-act button { padding: 0 5px; font-size: 11px; }
.qat-m3-frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; line-height: 1.1; margin: 0 2px; }
.qat-m3-frac > span:first-child { border-bottom: 1.5px solid #222; padding: 0 3px; }
.qat-m3-roman { border: 2px solid #333; border-radius: 22px; padding: 8px 14px; margin: 6px auto 10px; max-width: 360px; }
.qat-m3-rrow { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.qat-m3-rnum { display: inline-flex; width: 30px; height: 30px; border: 1.5px solid #333; border-radius: 50%; align-items: center; justify-content: center; font-weight: bold; }
.qat-m3-rline { flex: 1; border-bottom: 1.5px solid #333; }
.qat-m3-rbox { width: 22px; height: 22px; border: 1.5px solid #333; transform: rotate(45deg); }
.qat-m3-tbl { border-collapse: collapse; margin: 6px auto 10px; width: 80%; }
.qat-m3-tbl th, .qat-m3-tbl td { border: 1px solid #555; padding: 6px 10px; text-align: center; height: 26px; }
.qat-m3-tbl .qat-m3-wide { width: 60%; text-align: left; }
.qat-m3-times th, .qat-m3-times td { min-width: 44px; }
.qat-m3-times .qat-m3-actcell { border: none; }
.qat-m3-cmp td { width: 25%; }
.qat-m3-fx { font-size: 1.1em; }
.qat-m3-vgrid { display: flex; flex-wrap: wrap; border: 1px solid #555; margin: 6px 0 10px; }
.qat-m3-vbox { flex: 1 1 45%; border: 1px solid #555; padding: 6px 10px 10px; min-height: 110px; }
.qat-m3-vlab { display: flex; justify-content: space-between; }
.qat-m3-vert { margin: 6px auto 0; border-collapse: collapse; font-size: 1.2em; letter-spacing: 2px; }
.qat-m3-vert td { width: 22px; text-align: center; padding: 1px 2px; }
.qat-m3-vline td { border-top: 1.5px solid #222; border-bottom: 1.5px solid #222; height: 24px; }
.qat-m3-item { margin: 4px 0 6px 10px; }

/* v1.17: testing mode note on sign-in page */
.qat-beta-note { margin-top: 22px; background: rgba(255,255,255,0.08); border: 1px solid rgba(212,168,75,0.45); border-radius: 14px; padding: 16px 18px; }
.qat-beta-note strong { display: block; font-size: 1.05rem; margin-bottom: 4px; color: #F2C14E; }
.qat-root .qat-beta-note p { margin: 0 0 6px; line-height: 1.6; color: #E8EEF6; font-size: .95rem; }
.qat-root .qat-beta-note .qat-beta-ur { color: #fff; text-align: right; font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif; font-size: 1.25rem; line-height: 2; margin: 6px 0 0 !important; }

/* ================= v1.18: mobile UX pass ================= */
.qat-mview, .qat-mview-hint, .qat-v2-backpaper { display: none; }
.qat-v2-backpaper { min-height: 48px; align-items: center; justify-content: center; }
.qat-app a.qat-bn-item, .qat-app a.qat-side-link { text-decoration: none !important; }
@media screen and (max-width: 860px) {
  /* Dashboard: quick-start cards stacked, not cut off */
  .qat-v2-quick-grid { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: 1fr; overflow: visible; gap: 10px; }
  .qat-v2-quick { padding: 14px 16px; }

  /* Toast sits above the bottom bars */
  .qat-toast { left: 12px; right: 12px; bottom: calc(150px + env(safe-area-inset-bottom, 0px)); text-align: center; }

  /* Paper mode: when the paper is ready only the paper is shown */
  .qat-app.qat-paper-mode .qat-v2-studio-grid { display: none; }
  .qat-app.qat-paper-mode .qat-v2-studio { padding-bottom: 150px; }
  .qat-app .qat-v2-preview { border: 0; background: transparent; margin-top: 0; }
  /* Editing settings after a paper is ready: Generate bar comes back with "View paper" */
  .qat-app.qat-v2-cta-off:not(.qat-paper-mode) .qat-v2-cta { display: flex; }
  .qat-app:not(.qat-paper-mode) .qat-v2-preview { display: none; }
  .qat-app.qat-has-paper:not(.qat-paper-mode) .qat-v2-backpaper { display: inline-flex; }
  .qat-app.qat-has-paper:not(.qat-paper-mode) .qat-v2-cta-info { display: none; }
  .qat-app.qat-paper-mode .qat-v2-preview .qat-preview-toolbar {
    position: fixed; left: 0; right: 0; z-index: 9986;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    margin: 0; padding: 10px 14px; background: #fff; border-top: 1px solid var(--v2-line);
    box-shadow: 0 -10px 24px -20px rgba(16, 36, 27, 0.6); border-radius: 0;
  }
  .qat-app .qat-v2-preview .qat-preview-meta { display: none; }
  .qat-app .qat-v2-preview .qat-preview-btns { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
  .qat-app .qat-v2-preview .qat-preview-btns .qat-btn { min-height: 48px; font-size: 15px; }

  .qat-mview {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 0 0 6px;
    background: #E8EFEB; border-radius: 12px; position: sticky; top: 8px; z-index: 5;
  }
  .qat-mview button {
    border: 0; background: transparent; border-radius: 9px; min-height: 42px;
    font: inherit; font-size: 14px; font-weight: 700; color: #4B6358; cursor: pointer;
  }
  .qat-mview button.is-on { background: #fff; color: var(--v2-green, #0B6B47); box-shadow: 0 2px 8px -3px rgba(16,36,27,.35); }
  .qat-mview-hint { display: block; margin: 0 2px 8px; font-size: 12.5px; color: #5C7268; text-align: center; }

  .qat-app .qat-paper-stage { padding: 0; overflow: hidden; display: block; }
  /* Full page: real A4 scaled to the phone width (same layout as the print) */
  .qat-app .qat-paper-stage.is-fit .qat-a4-sheet { width: 210mm; min-height: 297mm; margin: 0 auto; box-shadow: 0 6px 20px rgba(15,23,42,.18); }
  /* Swap questions: readable text with big tap targets */
  .qat-app .qat-paper-stage.is-edit .qat-a4-sheet { width: 100%; min-width: 0; min-height: 0; padding: 16px 12px; box-sizing: border-box; font-size: 13.5px; overflow-x: auto; }
  .qat-app .qat-paper-stage.is-edit .qat-swap-btn,
  .qat-app .qat-paper-stage.is-edit .qat-del-btn { min-width: 36px; min-height: 36px; font-size: 16px; }
}

/* v1.18: guest page on phones - sign-in comes right after the title */
@media screen and (max-width: 860px) {
  .qat-root .qat-auth-shell { display: flex; flex-direction: column; gap: 18px; }
  .qat-root .qat-auth-hero { display: contents; }
  .qat-root .qat-auth-hero > .qat-brand-line { order: 1; align-self: flex-start; }
  .qat-root .qat-auth-hero > .qat-auth-title { order: 2; margin: 0; font-size: 26px; line-height: 1.2; }
  .qat-root .qat-auth-hero > .qat-auth-sub { order: 3; margin: 0; font-size: 14.5px; }
  .qat-root .qat-auth-card { order: 4; }
  .qat-root .qat-auth-hero > .qat-beta-note { order: 5; margin-top: 0; }
  .qat-root .qat-auth-hero > .qat-qat-highlights { display: none; }
  .qat-root .qat-auth-hero::after { display: none; }
  .qat-root .qat-feature-grid { grid-template-columns: 1fr; gap: 10px; }
  .qat-root .qat-feature { display: grid; grid-template-columns: 42px 1fr; column-gap: 14px; padding: 14px 16px; border-radius: 14px; }
  .qat-root .qat-feature .qat-ico { grid-row: span 2; width: 42px; height: 42px; margin: 0; }
  .qat-root .qat-feature h3 { margin: 0 0 2px; font-size: 15.5px; }
  .qat-root .qat-feature p { margin: 0; font-size: 13.5px; line-height: 1.5; }
}
@media screen and (max-width: 860px) {
  .qat-root .qat-steps { gap: 10px; }
  .qat-root .qat-steps li { display: grid; grid-template-columns: 40px 1fr; column-gap: 14px; padding: 14px 16px; }
  .qat-root .qat-steps li .qat-step-no { grid-row: span 2; margin: 0; }
  .qat-root .qat-steps li strong { margin: 0; align-self: end; }
  .qat-root .qat-steps li p { margin: 2px 0 0; }
}
