:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1f2633;
  --muted: #667085;
  --border: #d9dee8;
  --primary: #3b5bdb;
  --success: #2f9e44;
  --danger: #e03131;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 0.7rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { padding: 0.4rem 0.8rem; font-size: 0.9rem; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger  { background: var(--danger);  border-color: var(--danger);  color: #fff; }

/* ---------- Login / profile ---------- */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 8px 24px rgba(31, 38, 51, 0.08);
}
.auth-card h1 { margin-top: 0; text-align: center; }
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.auth-form { display: flex; flex-direction: column; gap: 0.9rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }
.auth-form input {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
}
.msg { padding: 0.6rem 0.8rem; border-radius: 8px; font-size: 0.9rem; }
.msg.error { background: #fff0f0; color: var(--danger); }
.msg.notice { background: #ebfbee; color: var(--success); }

[hidden] { display: none !important; }

/* ---------- Task page ---------- */
.app-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 200px;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas:
    "top     top     top"
    "types   params  actions"
    "types   task    actions"
    "counter counter counter";
}
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 1rem; }

/* ---------- Language switch (EN / HU) ---------- */
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-link {
  padding: 0.3rem 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}
.lang-link + .lang-link { border-left: 1px solid var(--border); }
.lang-link:hover { background: var(--bg); }
.lang-link.active { background: var(--primary); color: #fff; }
.auth-card .lang-switch { float: right; }
.profile-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
}
.type-frame {
  grid-area: types;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 2rem 1rem;
  border-right: 1px solid var(--border);
}
.type-frame h2 {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
/* Same shape as the task buttons (.btn); the chosen type gets a deeper colour. */
.type-btn { background: #dbe4ff; border-color: #bac8ff; color: var(--primary); }
.type-btn:hover { background: #c8d5ff; }
.type-btn.active {
  background: #263fa8;
  border-color: #263fa8;
  color: #fff;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
}

.params { grid-area: params; padding: 1rem 1rem 0; }
.params-pane {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.param { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--muted); }
.param select {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  color: var(--text);
}

.task-area { grid-area: task; padding: 2rem 1rem; min-width: 0; }
.task-pane { display: flex; overflow-x: auto; }
.task-pane > * { margin: 0 auto; }
.actions {
  grid-area: actions;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 2rem 1rem;
  border-left: 1px solid var(--border);
}
.counter {
  grid-area: counter;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
  padding: 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.exercises {
  margin: 0;
  padding: 1.5rem 2rem 1.5rem 3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.4rem;
  align-self: flex-start;
}
.exercise { padding: 0.5rem 0; }
.exercise > * { vertical-align: middle; }
/* An equation is five cells (number, operator, number, '=', number), one of them the text box,
   so every equation has the same width wherever its text box is. */
.equation { display: inline-grid; grid-template-columns: 3.2em 1.4em 3.2em 1.4em 3.2em; align-items: center; text-align: center; }
.answer {
  width: 100%;
  padding: 0.3rem 0.2rem;
  border: 1px solid #000;
  border-radius: 6px;
  background: var(--surface);
  font: inherit;
  color: var(--text);
  text-align: center;
}
.answer:focus { outline: none; box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.45); }
.answer[readonly] { background: var(--bg); }
.correct-result { display: inline-block; min-width: 2.5em; margin-left: 1rem; text-align: right; color: var(--muted); }
.mark { display: inline-block; width: 22px; height: 22px; margin-left: 0.6rem; border-radius: 50%; }
.mark.good { background: var(--success); }
.mark.bad  { background: var(--danger); }

.extra-actions { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.extra-actions:empty { display: none; }
.extra-actions .btn[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }

/* ---------- Error message (js/main.js showError) ---------- */
.message {
  position: fixed;
  top: 1rem;
  left: 50%;
  z-index: 10;
  transform: translateX(-50%);
  max-width: min(560px, calc(100% - 2rem));
  padding: 0.75rem 1rem;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: #fff0f0;
  color: var(--danger);
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(31, 38, 51, 0.18);
  cursor: pointer;
}
@media print { .message { display: none !important; } }

/* ---------- Secrets of the Numbers ---------- */
.secrets-box {
  padding: 1.25rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-self: flex-start;
}
.secrets-title { margin: 0 0 0.5rem; text-align: center; font-size: 1.3rem; }
.secrets-heading { margin: 1rem 0 0.25rem; color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.secrets-box .exercises { padding: 0 0 0 2.5rem; border: none; background: none; }

/* ---------- Saved tasks ---------- */
.saved-dialog {
  width: min(680px, calc(100% - 2rem));
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(31, 38, 51, 0.18);
}
.saved-dialog::backdrop { background: rgba(31, 38, 51, 0.35); }
.saved-dialog h2 { margin: 0 0 1rem; font-size: 1.15rem; }
.saved-empty { color: var(--muted); }
.saved-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.saved-table th, .saved-table td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; }
.saved-table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.saved-table td:last-child { white-space: nowrap; text-align: right; }
.saved-table .btn + .btn { margin-left: 0.4rem; }
.saved-close { margin: 1rem 0 0; text-align: right; }

/* ---------- E-mail newsletter (since v00_08): profile section, dialog, thank-you / privacy pages ---------- */
.newsletter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }
.newsletter-state { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 600; }
.newsletter-state input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--success); }
.newsletter .msg { margin: 0 0 0.9rem; }
.newsletter .section-hint { margin: 0.75rem 0 0; }
.newsletter-dialog { width: min(460px, calc(100% - 2rem)); }
.newsletter-form { display: flex; flex-direction: column; gap: 1rem; }
.newsletter-form h2 { margin: 0; }
.newsletter-form .field { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; color: var(--muted); }
.newsletter-form .field input { padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; color: var(--text); }
.newsletter-form .check { display: flex; align-items: flex-start; gap: 0.55rem; font-size: 0.95rem; cursor: pointer; }
.newsletter-form .check input { flex: none; width: 1.1rem; height: 1.1rem; margin: 0.15rem 0 0; }
.newsletter-form .form-actions { justify-content: flex-end; }
.info-card { max-width: 560px; }
.info-card .thanks { font-size: 1.15rem; text-align: center; }
.info-card .policy { min-height: 6rem; }
.card-actions { margin: 1.5rem 0 0; text-align: center; }

/* ---------- Profile page: top bar and left frame as on the task page ---------- */
.profile-page {
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "top   top"
    "types content";
}
.profile-content { grid-area: content; width: 100%; max-width: 980px; padding: 2rem 1.5rem; min-width: 0; }
.profile-content h1 { margin: 0 0 1.25rem; font-size: 1.5rem; }
.profile-content h2 { margin: 1.75rem 0 0.6rem; font-size: 1.1rem; }
.profile-content h1 + h2 { margin-top: 0; }
.panel {
  margin: 0 0 1rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel.empty { color: var(--muted); }
.section-hint { margin: 0 0 1rem; color: var(--muted); }
.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.75rem 1.5rem; margin: 0; font-size: 1.05rem; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; }
.danger-zone { border-color: #ffc9c9; }
.danger-zone h2 { margin: 0 0 0.4rem; color: var(--danger); }
.danger-zone p { margin: 0 0 1rem; color: var(--muted); }
.table-wrap { padding: 0.5rem 1rem; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.data-table th, .data-table td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--border); text-align: left; }
.data-table thead th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tfoot th { border-top: 2px solid var(--border); border-bottom: none; }
.data-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table .nowrap { white-space: nowrap; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; margin-left: 0.4rem; }

/* ---------- Tasks / Blog dropdown, visitors (since v00_06) ---------- */
.section-select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-weight: 600;
  color: var(--text);
}
.guest-note a { color: var(--primary); }
.guest-links { margin: 1.25rem 0 0; text-align: center; font-size: 0.9rem; color: var(--muted); }
.guest-links a { color: var(--primary); font-weight: 600; text-decoration: none; }
.profile-content > .msg { margin: 0 0 1rem; }

/* ---------- User List ---------- */
.role-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  vertical-align: middle;
}
.role-badge.role-admin { background: #ffe3e3; color: var(--danger); }
.role-badge.role-author { background: #dbe4ff; color: var(--primary); }
.user-detail h2 { margin: 0 0 1rem; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; padding: 0.75rem 0; border-top: 1px solid var(--border); }
.inline-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }
.inline-form input, .inline-form select, .post-form input, .post-form select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  color: var(--text);
}
.data-table tr.selected td { background: #edf2ff; }

/* ---------- Blog ---------- */
/* Post titles on the left, the post in the middle, the post types on the right. */
.blog-page {
  grid-template-columns: 240px minmax(0, 1fr) 220px;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "top   top     top"
    "posts content topics";
}
.post-list { grid-area: posts; padding: 2rem 1rem; border-right: 1px solid var(--border); }
.post-list h2, .topic-frame h2 {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.post-list ul { margin: 0; padding: 0; list-style: none; }
.post-list li + li { margin-top: 0.25rem; }
.post-list a { display: block; padding: 0.45rem 0.6rem; border-radius: 8px; color: var(--text); text-decoration: none; line-height: 1.35; }
.post-list a:hover { background: #dbe4ff; }
.post-list a.active { background: #263fa8; color: #fff; font-weight: 600; }
.post-list a.active .badge.private { background: #fff; }
.post-list-empty { color: var(--muted); }
.topic-frame { grid-area: topics; border-right: none; border-left: 1px solid var(--border); }
.blog-page .profile-content { max-width: none; }
.post-form .version { margin: 0; padding: 1rem 1.25rem 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; gap: 0.75rem; }
.post-form .version legend { padding: 0 0.4rem; font-weight: 700; color: var(--text); }
.type-btn .count { float: right; font-weight: 400; opacity: 0.75; }
.frame-extra { margin-top: 1rem; }
.post-meta { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.9rem; }
.badge.private { padding: 0.05rem 0.45rem; border-radius: 999px; background: #fff3bf; color: #8f6400; font-size: 0.8rem; font-weight: 700; }
.post-title { margin: 0 0 0.25rem; }
/* Quill's .ql-editor gives lists, alignment and code blocks their look; here it is not scrolled or padded. */
.post-content.ql-editor { height: auto; padding: 0; overflow: visible; font-size: 1.05rem; line-height: 1.6; }
/* Pictures in the editor and in posts: width attribute in % of the line, text wrap by class. */
.ql-editor img { max-width: 100%; height: auto; }
.ql-editor img.ql-img-left { float: left; margin: 0.25em 1.25em 0.75em 0; }
.ql-editor img.ql-img-right { float: right; margin: 0.25em 0 0.75em 1.25em; }
.ql-editor img.ql-img-center { display: block; margin: 0.75em auto; }
.post-content { display: flow-root; } /* the post ends below its last floating picture */
/* Picture tools of the editor (js/blog_edit.js): frame with resize handle and a button bar. */
.img-tools { position: absolute; z-index: 5; pointer-events: none; }
.img-frame { position: absolute; inset: 0; border: 2px dashed var(--primary); }
.img-handle {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 4px;
  background: var(--primary);
  cursor: nwse-resize;
  pointer-events: auto;
  touch-action: none;
}
.img-tools-bar {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(31, 38, 51, 0.18);
  pointer-events: auto;
}
.img-tool {
  min-width: 2rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.img-tool:hover { background: var(--bg); }
.img-tool[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); }
.post-actions { margin: 1.5rem 0 0; }
.post-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; }
.post-form .wide { grid-column: 1 / -1; }
.post-form .field { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; color: var(--muted); }
.post-form .field .section-hint { margin: 0; font-weight: 400; font-size: 0.85rem; }
.editor { min-height: 380px; background: var(--surface); color: var(--text); font-size: 1.05rem; font-weight: 400; }
.editor .ql-editor { min-height: 380px; }
.post-form .ql-toolbar { background: var(--bg); border-radius: 8px 8px 0 0; }
.form-actions { display: flex; gap: 0.75rem; }

/* ---------- Number pyramid ---------- */
.pyramid-box {
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pyramid-hint { margin: 0 0 1rem; color: var(--muted); text-align: center; }
.pyramid-score { margin: 1rem 0 0; text-align: center; font-weight: 700; }
.pyramid-score:empty { display: none; }
/* Rows are in the DOM bottom-up (level 1 first); centring them gives the staged look. */
.pyramid { display: flex; flex-direction: column-reverse; align-items: center; gap: 4px; }
.pyramid-row { display: flex; gap: 4px; }
.cell {
  width: 3.4rem;
  height: 3.4rem;
  padding: 0 0.2rem;
  border: 1px solid #000;
  border-radius: 4px;
  background: var(--surface);
  font: inherit;
  font-size: 1.1rem;
  color: var(--text);
  text-align: center;
}
/* Borders stay thin and black; focus and results are shown by a ring and the fill colour. */
.cell:focus { outline: none; box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.45); }
.cell:disabled { background: var(--bg); cursor: not-allowed; }
.cell.given { display: grid; place-items: center; background: #e7ecfb; font-weight: 700; }
.cell.base:not([readonly]) { border-style: dashed; }
.cell.good { background: #d3f9d8; color: var(--success); font-weight: 700; }
.cell.bad  { background: #ffe3e3; color: var(--danger);  font-weight: 700; }

/* ---------- Arithmetic Practice III: workbook grid (SVG sheet + one <input> per square) ---------- */
.ag-box {
  --ag-size: 2.2rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ag-hint { margin: 0 0 0.5rem; color: var(--muted); text-align: center; }
.ag-problems { display: flex; flex-wrap: wrap; justify-content: center; gap: 1.5rem 2.5rem; margin-top: 1rem; }
.ag-problem { break-inside: avoid; }
.ag-title { margin: 0 0 0.4rem; font-size: 0.95rem; color: var(--muted); }
.ag-score { margin: 1rem 0 0; text-align: center; font-weight: 700; }
.ag-score:empty { display: none; }
.ag-grid {
  position: relative;
  width: calc(var(--cols) * var(--ag-size));
  height: calc(var(--rows) * var(--ag-size));
}
/* The sheet lies over the inputs (lines stay visible on coloured squares); clicks go through it. */
.ag-sheet { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ag-lines line { stroke: #a5c8f0; stroke-width: 1; vector-effect: non-scaling-stroke; }
.ag-rule { stroke: #000; stroke-width: 2.5; vector-effect: non-scaling-stroke; stroke-linecap: square; }
.ag-given { font-size: 68px; font-weight: 700; fill: var(--text); text-anchor: middle; dominant-baseline: central; }
.ag-cell {
  position: absolute;
  top: calc(var(--r) * var(--ag-size));
  left: calc(var(--c) * var(--ag-size));
  width: var(--ag-size);
  height: var(--ag-size);
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 1.15rem;
  color: #1c3fa8;
  text-align: center;
  caret-color: transparent;
}
.ag-cell.answer { background: rgba(255, 212, 59, 0.28); }
.ag-cell:focus { outline: 2px solid rgba(59, 91, 219, 0.7); outline-offset: -2px; }
.ag-cell.good { background: #b2f2bb; color: var(--success); font-weight: 700; }
.ag-cell.bad  { background: #ffc9c9; color: var(--danger);  font-weight: 700; }

/* ---------- Geometry: shapes ---------- */
.shape-list { display: flex; flex-direction: column; gap: 1rem; width: 100%; max-width: 860px; }
.shape-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 1.25rem;
  align-items: start;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  break-inside: avoid;
}
.shape-title { margin: 0 0 0.25rem; font-size: 1.05rem; }
.shape-questions { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.shape-hint { margin: 0 0 0.2rem; font-size: 0.85rem; color: var(--muted); }
.shape-statement {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}
.shape-check { flex: none; width: 1.1rem; height: 1.1rem; margin: 0.1rem 0 0; cursor: pointer; }
.shape-text { flex: 1; min-width: 0; }
.shape-statement.good { border-color: var(--success); background: #d3f9d8; }
.shape-statement.bad  { border-color: var(--danger);  background: #ffe3e3; }
.shape-verdict { flex: none; font-size: 0.8rem; font-weight: 700; }
.shape-verdict:empty { display: none; }
.shape-statement.good .shape-verdict { color: var(--success); }
.shape-statement.bad  .shape-verdict { color: var(--danger); }
.shape-score { margin: 0.25rem 0 0; font-weight: 700; }
.shape-score:empty, .shapes-total:empty { display: none; }
.shapes-total { margin: 0; text-align: center; font-weight: 700; font-size: 1.1rem; }
.shape-figure { margin: 0; }
.shape-picture { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; }

@media (max-width: 640px) {
  .app-page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "top" "types" "params" "actions" "task" "counter";
  }
  .profile-page { grid-template-rows: auto auto 1fr; grid-template-areas: "top" "types" "content"; }
  .topbar { flex-wrap: wrap; gap: 0.5rem; }
  .brand { display: none; }
  .profile-content { padding: 1.25rem 1rem; }
  .post-form { grid-template-columns: minmax(0, 1fr); }
  /* No room for text beside a picture on a phone: wrapped pictures stand alone, centred. */
  .post-content img.ql-img-left, .post-content img.ql-img-right { float: none; display: block; margin: 0.75em auto; }
  .blog-page { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "top" "topics" "posts" "content"; }
  .post-list { padding: 1rem; border-right: none; border-bottom: 1px solid var(--border); }
  .topic-frame { border-left: none; }
  .topbar-right { gap: 0.5rem; }
  .type-frame { flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--border); padding: 1rem; }
  .type-frame h2 { width: 100%; }
  .type-btn { flex: 1; padding: 0.6rem 0.4rem; }
  .actions { flex-direction: row; flex-wrap: wrap; border-left: none; padding: 1rem; }
  .actions .btn { flex: 1; padding: 0.6rem 0.4rem; }
  #extra-actions { flex-basis: 100%; }
  .extra-actions { flex-direction: row; margin-top: 0; }
  .cell { width: 2.6rem; height: 2.6rem; font-size: 0.95rem; }
  .ag-box { --ag-size: 1.75rem; padding: 1rem 0.75rem; }
  .ag-cell { font-size: 1rem; }
  .shape-card { grid-template-columns: minmax(0, 1fr); }
  .shape-figure { order: -1; max-width: 300px; }
  .exercises { padding: 1rem 1rem 1rem 2.5rem; font-size: 1.2rem; }
  .counter { gap: 1rem; }
}

/* ---------- Printing: parameters, the task and the score ---------- */
@media print {
  .topbar, .type-frame, .actions, .lang-switch { display: none !important; }
  body, .app-page { display: block; min-height: 0; background: #fff; }
  .params { padding: 0 0 1rem; }
  .params-pane { border: none; padding: 0; }
  /* Print the chosen parameter values as plain text, not as dropdowns. */
  .param select { appearance: none; -webkit-appearance: none; border: none; padding: 0; color: var(--text); font-weight: 700; }
  .task-area { padding: 0; }
  .counter { margin-top: 1.5rem; background: none; border-top: 1px solid #000; }
  .task-pane { overflow: visible; }
  .exercises, .pyramid-box, .secrets-box, .ag-box { border: none; }
  .ag-cell, .ag-sheet { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .ag-cell:focus { outline: none; }
  .secrets-section { break-inside: avoid; }
  /* Keep the green/red results and the shaded first level on paper. */
  .answer:focus { box-shadow: none; }
  .cell, .mark, .shape-statement { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cell:focus { box-shadow: none; }
}
