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

.paper-page {
  --tmg-navy: #0f172a;
  --tmg-blue: #2563eb;
  --tmg-muted: #64748b;
  --tmg-line: #e2e8f0;
  --tmg-paper: #f8fafc;
  width: min(100%, 880px);
  min-height: 1120px;
  margin: 0 auto;
  padding: 38px 50px 44px;
  background: #ffffff;
  color: var(--tmg-navy);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 15px;
  line-height: 1.45;
}

.paper-page.empty-state {
  display: grid;
  min-height: 520px;
  place-items: center;
  color: #667085;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
}

.mock-head {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--tmg-navy);
}

.mock-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.mock-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid #bfdbfe;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, #dbeafe 64%, #f8fafc 100%);
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 800;
  color: var(--tmg-blue);
  box-shadow: inset 0 0 8px rgba(37, 99, 235, 0.16);
}

.mock-head h1,
.mock-head h2,
.mock-head p,
.paper-meta p,
.question-card p {
  margin: 0;
}

.mock-brand p,
.mock-brand strong,
.mock-title span {
  font-family: Arial, Helvetica, sans-serif;
}

.mock-brand p {
  color: var(--tmg-navy);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.mock-brand strong {
  display: block;
  margin-top: 5px;
  color: var(--tmg-blue);
  font-size: 14px;
  letter-spacing: 0;
}

.mock-title {
  text-align: right;
}

.mock-head h1 {
  color: #0f172a;
  font-size: 24px;
  line-height: 1.1;
}

.mock-head h2 {
  margin-top: 5px;
  color: #344054;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 700;
}

.mock-title span {
  display: inline-block;
  margin-top: 6px;
  color: var(--tmg-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.paper-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0 12px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  font-weight: 700;
}

.paper-field {
  display: inline-block;
  width: calc(100% - 58px);
  min-height: 22px;
  border-bottom: 1px solid #111827;
}

.instruction-box {
  margin-bottom: 20px;
  padding: 9px 12px;
  border-left: 4px solid var(--tmg-blue);
  background: var(--tmg-paper);
  color: #344054;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
}

.question-card {
  break-inside: avoid;
  position: relative;
  display: grid;
  grid-template-columns: 34px 1fr;
  column-gap: 16px;
  min-height: calc(var(--working-height, 240px) + 120px);
  margin: 0 0 20px;
  padding: 14px 0 16px;
  border-top: 1px solid var(--tmg-line);
  background-image: var(--question-watermark, none);
  background-size: 440px 96px;
  background-position: 0 0;
}

.question-number {
  grid-column: 1;
  align-self: start;
  color: var(--tmg-navy);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  font-weight: 800;
  line-height: 22px;
}

.question-marks {
  float: right;
  margin: 0 0 6px 16px;
  color: #475467;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 22px;
}

.question-body {
  grid-column: 2;
  min-height: 0;
  padding: 0;
  font-size: 15px;
}

.question-body p + p {
  margin-top: 6px;
}

.question-body .pattern-table {
  width: auto;
  min-width: 320px;
  margin: 10px 0 12px;
  border-collapse: collapse;
  font-size: 13px;
}

.question-body .pattern-table th,
.question-body .pattern-table td {
  min-width: 64px;
  padding: 7px 10px;
  border: 1px solid #8793a5;
  text-align: center;
}

.question-body .pattern-table th {
  background: #edf3f8;
  font-weight: 800;
}

.geometry-diagram {
  margin: 10px 0 12px;
}

.geometry-diagram svg {
  display: block;
  max-width: 360px;
  height: auto;
}

.stacked-fraction {
  display: inline-block;
  min-width: 0.85em;
  margin: 0 0.04em;
  vertical-align: -0.28em;
  text-align: center;
  line-height: 0.95;
  font-size: 0.86em;
}

.stacked-fraction span {
  display: block;
}

.stacked-fraction span:first-child {
  padding: 0 0.1em 0.04em;
  border-bottom: 1px solid currentColor;
}

.stacked-fraction span:last-child {
  padding: 0.04em 0.1em 0;
}

.question-figure {
  float: right;
  display: grid;
  width: min(44%, 240px);
  margin: 0 0 12px 18px;
  place-items: center;
}

.question-figure svg {
  width: 100%;
  height: auto;
  max-height: 190px;
}

.question-figure svg text {
  font-family: Arial, Helvetica, sans-serif;
}

.working-space {
  clear: both;
  position: relative;
  min-height: var(--working-height, 240px);
  margin-top: 10px;
}

.question-foot {
  clear: both;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 10px;
}

.question-brand {
  flex-shrink: 0;
  padding: 3px 10px;
  border: 1px solid #dbeafe;
  border-radius: 999px;
  background: #f5f9ff;
  color: #3b82f6;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 8px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.answer-line {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  max-width: 470px;
  margin: 0 0 0 auto;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
}

.answer-line em {
  font-weight: 700;
}

.answer-line span {
  flex: 1;
  min-height: 18px;
  border-bottom: 1px dashed #111827;
}

.answer-key {
  break-before: page;
  margin-top: 36px;
  padding-top: 22px;
  border-top: 2px solid #111827;
  background-image: var(--question-watermark, none);
  background-size: 440px 96px;
  background-position: 0 0;
}

.answer-key.standalone {
  break-before: auto;
  margin-top: 26px;
  padding-top: 0;
  border-top: 0;
}

.answer-key h2 {
  margin: 0 0 16px;
  text-align: center;
  font-size: 22px;
}

.answer-row {
  display: grid;
  grid-template-columns: 95px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #d1d5db;
}

@media print {
  body {
    margin: 0;
    background: #ffffff;
  }

  .site-header,
  .generator-hero,
  .filters,
  .results-head,
  .question-strip {
    display: none !important;
  }

  .workspace,
  .results-panel,
  .preview-shell {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
    border: 0 !important;
  }

  .paper-page {
    width: auto;
    min-height: 0;
    padding: 0;
    box-shadow: none;
  }
}
