/* Use the same typography and surface tokens as Study GPS. */
.ai-history-actions { display:flex; gap:10px; align-items:center; flex-shrink:0; }
.ai-delete { display:grid; place-items:center; width:44px; height:44px; background:var(--sv-surface); color:var(--muted); border:1px solid var(--line); border-radius:var(--sv-radius-md); cursor:pointer; }
.ai-delete:hover { color:var(--sv-danger); border-color:var(--sv-danger); background:var(--bg-soft); }
.ai-main [hidden] { display: none !important; }
.ai-form fieldset { min-width: 0; padding: 20px; margin: 0; border: 1px solid var(--line); border-radius: var(--sv-radius-md); }
.ai-form legend { padding: 0 8px; font-size: .85rem; font-weight: 700; color: var(--text); }
.ai-form .ai-source-choice { padding: 0; border: 0; }
.ai-source-choice legend { padding: 0; margin-bottom: 12px; }
.ai-source-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ai-form .ai-source-options label { flex-direction: row; align-items: center; padding: 18px; border: 1px solid var(--line); border-radius: var(--sv-radius-md); cursor: pointer; background: var(--sv-surface); }
.ai-source-options label:has(input:checked) { border-color: var(--primary); background: var(--primary-light); box-shadow: inset 0 0 0 1px var(--primary); }
.ai-source-options label:hover { border-color: var(--primary); }
.ai-form .ai-source-options input { width: 17px; height: 17px; flex-shrink: 0; margin: 0 4px 0 0; padding: 0; }
.ai-source-options strong, .ai-source-options small { display: block; }
.ai-source-options small { margin-top: 5px; font-size: .78rem; }
.ai-source-panel { background: var(--bg-soft); }
.ai-main button, .ai-main input, .ai-main textarea, .ai-main select { font-family: inherit; }
.ai-main h1, .ai-main h2, .ai-main h3, .ai-main h4, .ai-cards strong { font-family: "Poppins", "Inter", Arial, sans-serif; }
.ai-main h2 { font-size: clamp(1.3rem, 2.5vw, 1.75rem); line-height: 1.4; }
.ai-main h3 { font-size: 1.05rem; line-height: 1.5; }
.ai-top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 5%;
  border-bottom: 1px solid var(--line);
  background: var(--sv-surface);
}
.ai-top > a {
  font-weight: 800;
}
.ai-top nav {
  display: flex;
  gap: 20px;
}
.ai-main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 24px 90px;
}
.ai-intro {
  max-width: none;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--sv-radius-lg);
  background: linear-gradient(135deg, var(--primary-light), var(--sv-surface) 65%, var(--accent-light));
  box-shadow: var(--sv-shadow-sm);
  margin-bottom: 30px;
}
.ai-intro h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin: 10px 0;
}
.ai-intro p {
  color: var(--muted);
  line-height: 1.7;
}
.ai-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  color: var(--primary);
  font-weight: 700;
}
.ai-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.ai-cards button {
  position: relative;
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--sv-surface);
  color: var(--text);
  padding: 22px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}
.ai-cards button:hover:not(:disabled) { transform: translateY(-4px); border-color: var(--primary); box-shadow: var(--sv-shadow-md); }
.ai-cards button:active:not(:disabled) { transform: translateY(-1px); }
.ai-cards button::after { content: "↗"; position: absolute; top: 22px; right: 20px; font-size: 1.2rem; color: var(--muted); transition: transform 180ms ease; }
.ai-cards button:hover::after { transform: translate(2px,-2px); color: var(--primary); }
.ai-cards .ai-tool-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: var(--sv-radius-md); background: var(--primary-light); color: var(--primary); margin-bottom: 3px; }
.ai-tool-icon svg { width: 25px; height: 25px; }
.ai-cards button[data-tool="doubt"] .ai-tool-icon { background: var(--accent-light); color: var(--accent-dark); }
.ai-cards button[aria-pressed="true"] { background: linear-gradient(145deg,var(--sv-surface),var(--primary-light)); }
.ai-main .btn { min-height: 46px; border-radius: var(--sv-radius-md); font-weight: 650; gap: 10px; transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease; }
.ai-main .btn-primary { background: linear-gradient(135deg,var(--primary),var(--primary-dark)); box-shadow: 0 5px 12px var(--primary-glow); border: 1px solid transparent; }
.ai-main .btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--sv-shadow-md); }
.ai-main .btn:active:not(:disabled) { transform: translateY(0); }
.ai-main .btn-outline:hover:not(:disabled) { background: var(--primary-light); border-color: var(--primary); }
.ai-form input:focus,.ai-form textarea:focus,.ai-form select:focus,.ai-question textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.ai-checks label { cursor: pointer; transition: border-color 160ms ease, background 160ms ease; }
.ai-checks label:hover { border-color: var(--primary); }
.ai-checks label:has(input:checked) { background: var(--primary-light); border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.ai-main input[type="checkbox"],.ai-main input[type="radio"] { accent-color: var(--primary); }
.ai-form input[type="file"] { border: 1px dashed var(--primary); padding: 16px; background: var(--bg-soft); }
.ai-form input[type="file"]::file-selector-button { padding: 9px 14px; margin-right: 12px; border: 0; border-radius: var(--sv-radius-sm); background: var(--primary); color: white; cursor: pointer; font: inherit; }
.ai-main details { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--sv-radius-md); padding: 14px 18px; }
.ai-main summary { cursor: pointer; color: var(--primary); font-weight: 650; }
.ai-main details[open] { background: var(--bg-soft); }
.ai-main details[open] summary { margin-bottom: 14px; }
#ai-status[data-state="error"] { border-left: 4px solid var(--sv-danger); background: var(--sv-surface); }
#ai-status[data-state="success"] { border-left: 4px solid var(--sv-success); }
#ai-status[data-state="loading"]::before,.ai-main button[data-busy="true"]::before { content: ""; display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; margin-right: 10px; vertical-align: -3px; animation: ai-spin 800ms linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
@media(prefers-reduced-motion:reduce) { .ai-main * { animation: none!important; transition: none!important; scroll-behavior:auto!important; } }
.ai-cards button[aria-pressed="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.ai-cards span {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--primary);
}
.ai-cards strong {
  font-size: 1.1rem;
  line-height: 1.4;
}
.ai-cards small {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.6;
}
.ai-panel,
.ai-question,
.ai-result-card {
  background: var(--sv-surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  margin: 18px 0;
  box-shadow: var(--sv-shadow-sm);
}
.ai-panel-heading { padding-bottom: 20px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.ai-panel-heading h2 { margin: 8px 0; }
.ai-panel-heading p { margin: 0; }
.ai-form-footer { padding-top: 20px; border-top: 1px solid var(--line); }
.ai-form-footer .ai-muted { font-size: .8rem; margin: 14px 0 0; max-width: 680px; }
.ai-answer-stack { display: grid; gap: 16px; }
.ai-answer-card { min-width: 0; padding: 22px; background: var(--sv-surface); border: 1px solid var(--line); border-radius: var(--sv-radius-md); box-shadow: var(--sv-shadow-sm); }
.ai-answer-card h3 { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; }
.ai-step { flex-shrink: 0; display: grid; place-items: center; width: 32px; height: 32px; font: 700 .75rem "Inter", Arial, sans-serif; color: var(--primary); background: var(--primary-light); border-radius: 8px; }
.ai-source-question { padding: 20px; margin: 0 0 24px; border: 1px solid var(--line); border-radius: var(--sv-radius-md); background: var(--bg-soft); }
.ai-source-question .ai-prose { margin-top: 10px; }
.ai-practice-card { padding: 24px; border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--sv-radius-md); background: var(--sv-surface); }
.ai-practice-card h3 { margin: 8px 0 14px; }
.ai-score-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 26px; border: 1px solid var(--line); border-radius: var(--sv-radius-md); background: linear-gradient(120deg,var(--primary-light),var(--sv-surface)); }
.ai-score span { font-size: 1.3rem; color: var(--muted); font-weight: 500; }
.ai-score-summary { display: grid; text-align: right; gap: 4px; color: var(--muted); font-size: .8rem; }
.ai-score-summary strong { font-size: 1.7rem; color: var(--primary); }
.ai-grid > .ai-result-card { margin: 0; border-top: 3px solid var(--primary); }
.ai-grid > .ai-result-card:first-child { border-top-color: var(--accent); }
.ai-result-card h3 { margin: 0 0 12px; }
.ai-review-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.ai-mark-badge { padding: 7px 12px; border-radius: 999px; background: var(--primary-light); color: var(--primary); font-size: .8rem; font-weight: 700; }
.ai-review-answers { margin-top: 22px; }
.ai-question > .ai-answer-card { margin-top: 16px; }
@media screen {
  .ai-sheet-page { border-radius: var(--sv-radius-lg); }
  .ai-sheet-page > section { padding: 18px 20px; margin-top: 16px; border: 1px solid #dfe6ef; border-radius: var(--sv-radius-md); background: #fff; }
  .ai-sheet-page > section h3 { margin-top: 0; }
}
.ai-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.ai-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}
.ai-form input,
.ai-form select,
.ai-form textarea,
.ai-question textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-input);
  color: var(--text);
  font: inherit;
  box-sizing: border-box;
}
.ai-wide {
  grid-column: 1/-1;
}
.ai-form small,
.ai-muted {
  font-weight: 400;
  color: var(--muted);
  line-height: 1.6;
}
.ai-checks {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.ai-checks label {
  flex-direction: row;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.ai-checks input {
  width: auto;
}
.ai-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0;
}
.ai-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 10px 0;
  cursor: pointer;
}
.ai-option:has(input:checked) {
  background: var(--primary-light);
  border-color: var(--primary);
}
.ai-prose {
  white-space: pre-wrap;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.ai-bonus {
  padding: 18px;
  border-left: 3px solid var(--primary);
  background: var(--primary-light);
  margin: 20px 0;
  border-radius: 0 var(--sv-radius-md) var(--sv-radius-md) 0;
}
.ai-bonus > strong { display: block; margin-bottom: 8px; color: var(--primary); }
.ai-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.ai-score {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--primary);
}
#ai-status:not(:empty) {
  padding: 16px;
  border-radius: 10px;
  background: var(--primary-light);
  margin: 18px 0;
  white-space: pre-wrap;
}
#ai-status a {
  font-weight: 700;
  text-decoration: underline;
}
.ai-timer {
  position: sticky;
  top: 10px;
  z-index: 3;
  background: var(--sv-surface);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.ai-sheet-page {
  background: white;
  color: #172033;
  padding: 40px;
  margin: 24px 0;
  box-shadow: var(--sv-shadow-sm);
  border: 1px solid #dfe6ef;
}
.ai-sheet-brand {
  font-size: 0.8rem;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #dfe6ef;
  padding-bottom: 12px;
  margin-bottom: 20px;
}
.ai-sheet-page h2 {
  font-size: 1.6rem;
}
.ai-sheet-page h3 {
  font-size: 1.1rem;
  margin-top: 20px;
}
.ai-sheet-page .ai-prose {
  font-size: 0.93rem;
  line-height: 1.55;
}
.ai-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin: 14px 0;
}
.ai-table th,
.ai-table td {
  border: 1px solid #dfe6ef;
  text-align: left;
  padding: 8px;
  overflow-wrap: anywhere;
  font-size: 0.85rem;
}
.ai-diagram {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  padding: 20px;
  background: var(--bg-soft);
  border-radius: 12px;
}
.ai-diagram span {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.ai-history-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--sv-radius-md);
  margin-top: 12px;
  background: var(--bg-soft);
}
button:disabled {
  opacity: 0.6;
  cursor: wait;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}
@media (max-width: 900px) {
  .ai-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .ai-source-options { grid-template-columns: 1fr; }
  .ai-form fieldset { padding: 16px; }
  .ai-intro { padding: 22px; }
  .ai-answer-card, .ai-source-question, .ai-practice-card { padding: 16px; }
  .ai-score-card { padding: 18px; }
  .ai-history-row { align-items: flex-start; flex-direction: column; }
  .ai-main {
    padding: 28px 16px;
  }
  .ai-cards {
    gap: 9px;
  }
  .ai-cards button {
    padding: 15px;
  }
  .ai-form,
  .ai-grid {
    grid-template-columns: 1fr;
  }
  .ai-panel,
  .ai-question {
    padding: 20px;
  }
  .ai-sheet-page {
    padding: 22px;
  }
  .ai-history-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
@page {
  size: A4;
  margin: 14mm;
}
@media print {
  body {
    background: white !important;
  }
  body > *:not(.ai-main),
  .ai-main > *:not(#ai-output),
  #ai-output > .ai-actions,
  #app-sidebar,
  .app-mobile-header,
  .app-sidebar-backdrop,
  .sidebar-tooltip {
    display: none !important;
  }
  .ai-main {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
  }
  #ai-output {
    display: block !important;
  }
  .ai-sheet-page {
    margin: 0;
    border: 0;
    box-shadow: none;
    padding: 0;
    break-after: page;
  }
  .ai-sheet-page:last-child {
    break-after: auto;
  }
  .ai-sheet-brand {
    color: #64748b !important;
  }
  .ai-sheet-page h3 {
    break-after: avoid;
  }
  .ai-table tr {
    break-inside: avoid;
  }
  .ai-bonus {
    break-inside: avoid;
  }
}
body[data-layout="app"] .ai-top {
  display: none;
}
body[data-layout="app"] .ai-main {
  max-width: none;
}
@media (min-width: 1024px) {
  body[data-layout="app"] .ai-main {
    padding-left: 40px;
    padding-right: 40px;
  }
}
@media (max-width: 1023px) {
  body[data-layout="app"] .ai-main {
    padding-top: 90px;
  }
}
@media print {
  .ai-sheet-page {
    column-count: 2;
    column-gap: 7mm;
  }
  .ai-sheet-brand,
  .ai-sheet-page > h2 {
    column-span: all;
  }
  .ai-sheet-page > h2 {
    font-size: 14pt;
    margin: 4mm 0;
  }
  .ai-sheet-page h3 {
    font-size: 10pt;
    margin: 3mm 0 1.5mm;
  }
  .ai-sheet-page .ai-prose {
    font-size: 9pt;
    line-height: 1.35;
  }
  .ai-sheet-page .ai-table th,
  .ai-sheet-page .ai-table td {
    font-size: 8pt;
    padding: 1.5mm;
  }
  .ai-sheet-page .ai-bonus {
    padding: 2mm;
    margin: 2mm 0;
  }
  .ai-sheet-page .ai-table {
    margin: 2mm 0;
  }
  .ai-sheet-brand {
    font-size: 9pt;
  }
}
.ai-chart {
  display: flex;
  gap: 12px;
  padding: 20px;
  background: var(--bg-soft);
  border-radius: 12px;
  overflow-wrap: anywhere;
}
.ai-bar-cell {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 0.8rem;
}
.ai-bar-plot {
  height: 130px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.ai-bar {
  width: 70%;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
}
.ai-bar-cell small {
  display: block;
  margin-top: 8px;
}

/* Revision canvas: live, selectable document content rather than a raster image. */
.ai-canvas-toolbar { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:16px; padding:20px 24px; background:var(--sv-surface); border:1px solid var(--line); border-radius:16px 16px 0 0; }
.ai-canvas-toolbar p { margin:6px 0 0; font-size:.85rem; color:var(--muted); }
.ai-canvas-toolbar .ai-actions { margin:0; }
.ai-canvas { padding:28px; border:1px solid var(--line); border-top:0; border-radius:0 0 16px 16px; background:var(--bg-soft); }
.ai-canvas .ai-sheet-page { max-width:210mm; box-sizing:border-box; margin:0 auto 28px; border-radius:3px; padding:38px; box-shadow:0 8px 26px rgba(23,32,51,.09); }
.ai-canvas .ai-sheet-page:last-child { margin-bottom:0; }
.ai-sheet-page .ai-sheet-brand { color:#4f6f9f; border-bottom:2px solid #4f6f9f; align-items:center; gap:16px; }
.ai-sheet-page .ai-sheet-brand strong { font-family:"Poppins",sans-serif; font-size:1rem; }
.ai-canvas .ai-sheet-page > h2 { color:#3d5a82; font-size:1.65rem; line-height:1.4; margin:24px 0; }
.ai-canvas .ai-sheet-page > section { border:0; border-top:1px solid #dfe6ef; border-radius:0; padding:20px 0 0; margin-top:20px; }
.ai-sheet-section > h3 { color:#3d5a82; display:flex; gap:10px; align-items:baseline; margin:0 0 12px; }
.ai-sheet-number { font:700 .7rem "Inter",sans-serif; color:#437356; background:#eaf3ed; padding:5px 7px; border-radius:5px; flex-shrink:0; }
.ai-sheet-subsection { padding-left:14px; border-left:2px solid #dce8df; margin:16px 0; }
.ai-sheet-subsection h4 { color:#437356; font-size:.92rem; margin:0 0 6px; }
.ai-sheet-page .ai-prose { color:#263449; }
.ai-sheet-page .ai-table th { background:#e8eef5; color:#3d5a82; font-weight:700; }
.ai-sheet-page .ai-table tbody tr:nth-child(even) { background:#f6f8fb; }
.ai-sheet-footer { display:flex; justify-content:space-between; gap:12px; border-top:1px solid #dfe6ef; margin-top:24px; padding-top:12px; color:#4f6f9f; font-size:.68rem; }
.ai-sheet-footer span { color:#64748b; }
.ai-sheet-visual { background:#f6f8fb; border:1px solid #dfe6ef; border-radius:10px; padding:16px; margin:18px 0; break-inside:avoid; }
.ai-sheet-visual figcaption { color:#3d5a82; font-weight:600; font-size:.8rem; margin-bottom:12px; }
.ai-flow { display:flex; flex-wrap:wrap; gap:18px; padding:0; margin:0; list-style:none; }
.ai-flow li { position:relative; flex:1 1 100px; padding:12px; border:1px solid #bfd0df; background:#e8eef5; border-radius:8px; font-size:.8rem; text-align:center; color:#263449; }
.ai-flow li:nth-child(even) { background:#eaf3ed; border-color:#c3d9c9; }
.ai-flow li:not(:last-child)::after { content:'→'; position:absolute; right:-16px; top:calc(50% - 10px); color:#4f6f9f; }
.ai-sheet-chart { display:grid; gap:12px; }
.ai-chart-row { display:grid; grid-template-columns:minmax(60px,1fr) 2fr minmax(50px,auto); gap:10px; align-items:center; font-size:.75rem; color:#263449; }
.ai-chart-track { height:13px; background:#e2e8f0; border-radius:3px; overflow:hidden; }
.ai-chart-fill { height:100%; background:#4f6f9f; }
.ai-chart-row:nth-child(even) .ai-chart-fill { background:#5b9b74; }
@media(max-width:600px) {
  .ai-canvas { padding:12px; }
  .ai-canvas .ai-sheet-page { padding:20px; }
  .ai-canvas-toolbar { padding:16px; }
  .ai-canvas-toolbar .btn { flex:1; }
  .ai-flow { flex-direction:column; }
  .ai-flow li { flex:auto; }
  .ai-flow li:not(:last-child)::after { content:'↓'; top:auto; bottom:-19px; right:calc(50% - 5px); }
  .ai-sheet-brand, .ai-sheet-footer { flex-wrap:wrap; }
  .ai-chart-row { grid-template-columns:minmax(45px,1fr) 1fr minmax(40px,auto); gap:6px; }
}
@media print {
  .ai-canvas-toolbar { display:none!important; }
  .ai-canvas { padding:0; border:0; background:white; }
  .ai-canvas .ai-sheet-page { max-width:none; padding:0; margin:0; border:0; box-shadow:none; }
  .ai-sheet-footer { column-span:all; }
  .ai-canvas .ai-sheet-page > section { padding:2mm 0 0; margin-top:2mm; }
  .ai-canvas .ai-sheet-page > h2 { font-size:14pt; margin:4mm 0; }
  .ai-sheet-visual { padding:2mm; margin:2mm 0; }
  .ai-sheet-subsection { margin:2mm 0; }
  .ai-flow li { padding:2mm; font-size:8pt; }
  .ai-sheet-page { print-color-adjust:exact; -webkit-print-color-adjust:exact; }
}
.ai-overview-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:20px; margin:28px 0; }
.ai-overview-card { display:flex; flex-direction:column; align-items:flex-start; gap:14px; }
.ai-overview-card h2 { font-size:1.3rem; margin:0; }
.ai-overview-card p { flex:1; color:var(--muted); line-height:1.7; }
.ai-overview-card .btn { white-space:normal; text-align:left; }
.ai-prose p { margin:0 0 .7em; }
.ai-prose p:last-child { margin-bottom:0; }
.ai-prose ul { margin:.4em 0; padding-left:1.3em; }
.ai-prose li { margin:.4em 0; }
.ai-prose li::marker { color:#4f6f9f; }
.ai-about { margin-top:32px; }
@media print { .ai-about { display:none !important; } }
@media(max-width:900px) { .ai-overview-grid { grid-template-columns:1fr; } }

/* Brand-colour study boards. All decoration and maps reuse the saved text. */
.ai-canvas .ai-sheet-page { --sheet-blue:#3d5a82; --sheet-green:#437356; background:radial-gradient(ellipse at top right,#d8e9e0,transparent 48%),linear-gradient(155deg,#edf3fa,#f7faf8); border:1px solid #ccd9e4; border-radius:18px; overflow-wrap:anywhere; }
.ai-sheet-hero { position:relative; background:linear-gradient(115deg,#213956,#3d5a82 68%,#437356); color:#fff; padding:28px; border-radius:14px; margin:20px 0; border-bottom:5px solid #8ec6a4; }
.ai-sheet-hero .ai-sheet-kicker { display:block; color:#d6eedf; font:700 .65rem "Inter",sans-serif; letter-spacing:.15em; }
.ai-sheet-page .ai-sheet-hero h2 { color:#fff; font:700 clamp(1.45rem,3vw,2.1rem)/1.25 "Poppins","Inter",sans-serif; margin:14px 0; }
.ai-sheet-hero p { color:#e2ebf5; margin:0; font-size:.78rem; }
.ai-sheet-hero p span { padding:0 8px; color:#b9e3ca; }
.ai-sheet-grid { display:grid; gap:18px; }
.ai-sheet-grid .ai-sheet-section { background:#fff; border:1px solid #cfdae6; border-left:5px solid #4f6f9f; border-radius:12px; padding:20px; min-width:0; box-shadow:0 3px 0 #dce5ef; }
.ai-sheet-grid .ai-sheet-section:nth-child(even) { border-left-color:#5b9b74; background:#f3f9f5; box-shadow:0 3px 0 #d8e7dd; }
.ai-sheet-grid .ai-sheet-section h3 { margin:0 0 14px; font:700 1.05rem/1.45 "Poppins","Inter",sans-serif; }
.ai-sheet-grid .ai-sheet-section:nth-child(even) h3 { color:#376345; }
.ai-sheet-page .ai-prose { white-space:normal; line-height:1.65; }
.ai-sheet-page .ai-prose strong { color:#284b70; background:#e3edf8; padding:1px 3px; border-radius:3px; font-weight:800; box-decoration-break:clone; -webkit-box-decoration-break:clone; }
.ai-sheet-page .ai-sheet-section:nth-child(even) .ai-prose strong { color:#295339; background:#dceee2; }
.ai-sheet-page .ai-sheet-number { color:#fff; background:#4f6f9f; border-radius:6px; }
.ai-sheet-section:nth-child(even) .ai-sheet-number { background:#437356; }
.ai-sheet-page .ai-table th { background:#3d5a82; color:#fff; padding:11px 9px; }
.ai-sheet-page .ai-table td { background:#fff; color:#24374c; padding:10px 9px; }
.ai-sheet-page .ai-table tbody tr:nth-child(even) td { background:#eaf2ed; }
.ai-sheet-page .ai-sheet-subsection { padding:2px 0 2px 14px; border-left:3px solid #9dc3ac; }
.ai-sheet-page .ai-bonus { background:#eaf3ed; color:#294c36; border:1px solid #bfd9c7; border-left:4px solid #437356; }
.ai-topic-map { margin:0 0 22px; padding:18px; background:#ffffffb8; border:1px solid #c6d8cd; border-radius:12px; break-inside:avoid; }
.ai-topic-map figcaption { color:#437356; font:800 .62rem "Inter",sans-serif; letter-spacing:.14em; margin-bottom:12px; }
.ai-map-root { border-radius:8px; background:#3d5a82; color:#fff; padding:12px 16px; width:fit-content; max-width:100%; margin:auto; text-align:center; font:700 .85rem/1.5 "Poppins","Inter",sans-serif; }
.ai-topic-map ul { list-style:none; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; padding:20px 0 0; margin:0; position:relative; }
.ai-topic-map ul::before { content:''; position:absolute; height:20px; top:0; left:50%; border-left:2px solid #9db7a9; }
.ai-topic-map li { position:relative; border:1px solid #becfe1; border-top:3px solid #4f6f9f; border-radius:7px; background:#eaf0f8; padding:12px; color:#294767; font-size:.78rem; line-height:1.5; }
.ai-topic-map li:nth-child(even) { background:#e8f3ec; color:#315d40; border-color:#bcd6c5; border-top-color:#437356; }
.ai-topic-map li span { display:block; margin-top:5px; font-size:.72rem; }
.ai-practice-only .ai-practice-card { margin-top:18px; border-radius:14px; background:linear-gradient(120deg,var(--sv-surface),var(--primary-light)); }
@media(max-width:600px) {
  .ai-sheet-page .ai-sheet-hero { padding:22px 18px; }
  .ai-sheet-grid .ai-sheet-section { padding:16px; }
  .ai-topic-map ul { grid-template-columns:1fr; }
}
@media print {
  .ai-canvas .ai-sheet-page { column-count:1; padding:6mm; border-radius:0; }
  .ai-sheet-hero { padding:5mm; margin:3mm 0; break-inside:avoid; }
  .ai-sheet-page .ai-sheet-hero h2 { font-size:17pt; }
  .ai-sheet-grid { display:block; columns:2; column-gap:5mm; }
  .ai-sheet-grid .ai-sheet-section { padding:3mm; margin:0 0 4mm; break-inside:avoid; box-shadow:none; }
  .ai-topic-map { padding:3mm; margin-bottom:4mm; }
  .ai-topic-map li { padding:2mm; font-size:8pt; }
  .ai-topic-map li span { font-size:7pt; }
  .ai-sheet-footer { break-inside:avoid; }
}
/* Keep selected question counts clear on narrow screens. */
.quiz-count-row{display:grid;gap:.6rem;padding:.9rem;border:1px solid var(--border,#dcd7ef);border-radius:12px;background:var(--surface,#fff)}
.quiz-count-row input[type=number]{max-width:9rem}
.quiz-section-heading{padding:.7rem 1rem;border-left:4px solid #7952d8;background:#eee8ff;color:#35245e;border-radius:8px;font-size:1.1rem}
