/* Shared answer pad (svarpanel): compact talpanel + Godkend, and a letter layout. */
.answer-pad { display: grid; gap: 8px; width: 100%; min-width: 0; max-width: 30rem; margin-inline: auto; }
.pad-grid[hidden] { display: none !important; }
.pad-digits { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.pad-letters { display: grid; gap: 6px; }
.pad-row { display: flex; justify-content: center; gap: 5px; }
.pad-key { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0; min-height: 56px; padding: 0 4px; border: 1.5px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink); font: inherit; font-size: 1.5rem; font-weight: 700; line-height: 1; touch-action: manipulation; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pad-key .luxi-icon { width: 24px; height: 24px; flex: 0 0 24px; }
.pad-key:active:not(:disabled) { transform: translateY(1px); background: var(--lavender); }
.pad-key:disabled { opacity: .45; cursor: default; }
.pad-key.pad-submit:disabled { opacity: .55; }
.pad-backspace, .pad-switch, .pad-shift { font-size: 1rem; }
.pad-shift[aria-pressed="true"] { background: var(--lavender); border-color: var(--purple); }
/* Godkend is the green button with a check in every theme (user note 03.10:
   "hvad er godkend? Det er den grønne knap"); the ready line names it so
   (answer_instruction) and shows a small copy of it (.godkend-chip). */
:root { --godkend: #16734d; --godkend-strong: #0e5236; }
.pad-submit { background: var(--godkend); border-color: var(--godkend); color: #fff; font-size: 1rem; }
.pad-submit:active:not(:disabled) { background: var(--godkend-strong); }
.button.primary.godkend-button { background: var(--godkend); border-color: var(--godkend); color: #fff; box-shadow: 0 4px 0 var(--godkend-strong); }
.button.primary.godkend-button:hover:not(:disabled) { background: var(--godkend-strong); }
.godkend-chip { display: inline-grid; place-items: center; flex: 0 0 auto; width: 48px; height: 40px; border-radius: 12px; background: var(--godkend); color: #fff; box-shadow: 0 3px 0 var(--godkend-strong); }
.godkend-chip .luxi-icon { width: 26px; height: 26px; stroke-width: 3; }
/* The chosen answer wakes Godkend: one short pulse when it becomes active. */
@media (prefers-reduced-motion: no-preference) {
  .button.primary.godkend-button:not(:disabled) { animation: godkend-ready .9s ease-out 1; }
}
@keyframes godkend-ready { 40% { transform: scale(1.04); box-shadow: 0 4px 0 var(--godkend-strong), 0 0 0 6px #16734d33; } }

/* A sound to listen to sits under the question as a light listen button with a big
   speaker, so it is not mistaken for the green Godkend button. */
.task-stimulus:has(> .stimulus-play) { display: flex; justify-content: center; }
.button.stimulus-play { gap: 12px; min-height: 64px; margin: 6px auto 4px; padding: 10px 22px; border: 2px solid var(--theme-primary, var(--purple)); background: var(--theme-soft, var(--lavender)); color: var(--theme-strong, var(--purple-dark)); box-shadow: 0 3px 0 var(--theme-primary, var(--purple)); font-size: 1.2rem; }
.button.stimulus-play:hover:not(:disabled) { background: var(--theme-soft, var(--lavender)); filter: brightness(.97); color: var(--theme-strong, var(--purple-dark)); }
.button.stimulus-play .luxi-icon { width: 34px; height: 34px; }
.pad-row .pad-key { flex: 1 1 0; max-width: 3.2rem; min-height: 50px; font-size: 1.3rem; }
.pad-row .pad-shift, .pad-row .pad-backspace, .pad-row .pad-switch { flex: 1.5 1 0; max-width: 4.6rem; }
.pad-row .pad-space { flex: 4 1 0; max-width: none; min-width: 0; overflow: hidden; font-size: .95rem; font-weight: 600; }
.pad-row .pad-submit { flex: 2.5 1 0; max-width: 8rem; }
/* Sign keys after the digits (− and comma for decimals, fractions, points): Godkend fills the rest of its row. */
.pad-digits .pad-symbol + .pad-submit { grid-column: span 6; }
.pad-digits .pad-symbol + .pad-symbol + .pad-submit { grid-column: span 5; }
@media (max-width: 430px) {
  .pad-digits { gap: 6px; }
  .pad-key { min-height: 52px; }
  .pad-row { gap: 3px; }
  .pad-row .pad-key { min-height: 46px; padding: 0 2px; font-size: 1.15rem; }
  .pad-submit span { font-size: .9rem; }
}
.answer-pad { container-type: inline-size; }
@container (max-width: 520px) {
  .pad-digits .pad-submit span { display: none; }
  .pad-digits .pad-submit .luxi-icon { width: 30px; height: 30px; flex-basis: 30px; }
}

/* Number answers: the answer box sits above the pad, as in the kladde prototype. */
.uses-answer-pad .response-fields { gap: 12px; }
.uses-answer-pad .response-hint { text-align: center; color: var(--muted); }
.mode-numeric .response-slots { align-items: center; gap: 12px; }
.response-answer-label { font-weight: 700; }
.mode-numeric .response-slot[aria-pressed] { outline: 0; border-color: var(--purple); border-width: 2px; }
.mode-numeric .response-slot { min-width: 9rem; min-height: 58px; font-size: 1.9rem; letter-spacing: .06em; }
.response-keyboard { display: grid; }
.response-keyboard[hidden] { display: none; }
.with-answer-pad .task-actions:not(:has(button:not([hidden]), form)) { display: none; }

/* Sortable order list with move buttons (Flyt op / Flyt ned). */
.order-list { display: grid; gap: 14px; }
.order-list ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.order-item { display: grid; grid-template-columns: 2.2rem minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border: 2px solid var(--line); border-radius: 16px; background: var(--panel); }
.order-item.dragging { opacity: .6; border-style: dashed; }
.order-item.drop-target { border-color: var(--purple); }
/* Flyt op / Flyt ned (user note 28.09): the moved row lights up for a moment
   while the rows slide into place (order_list_controller#showMove). The light
   is a colour fade only, so it also shows with reduced motion. */
.order-item.order-moved { position: relative; z-index: 1; animation: order-moved 1.1s ease-out; }
@keyframes order-moved {
  0%, 35% { border-color: var(--theme-primary, var(--purple)); background: var(--lavender); box-shadow: 0 0 0 4px color-mix(in srgb, var(--theme-primary, var(--purple)) 25%, transparent); }
  100% { border-color: var(--line); background: var(--panel); box-shadow: 0 0 0 0 transparent; }
}
.order-number { font-weight: 800; color: var(--purple-dark); text-align: center; }
.order-text { min-width: 0; overflow-wrap: anywhere; -webkit-hyphens: auto; hyphens: auto; padding: 6px 0; cursor: grab; touch-action: none; }
.order-moves { display: flex; gap: 6px; }
.order-moves .button { min-width: 48px; min-height: 48px; padding: 6px 8px; }
.order-moves .button .luxi-icon { width: 22px; height: 22px; }
.order-moves .order-move-label { font-size: .85rem; }
.order-list ol[hidden], .order-pool .button[hidden] { display: none; }
.order-pool { display: flex; flex-wrap: wrap; gap: 8px; }
.order-pool .button { text-align: left; }
/* Cards with their own read-aloud: the speaker sits beside the text (pool and rows). */
.order-body { display: flex; align-items: center; gap: 4px; min-width: 0; }
.order-body .order-text { flex: 1; }
.order-speech { flex: none; }
.order-speech[hidden], .order-pool-card[hidden] { display: none; }
.order-pool-card { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; min-width: 0; }
.order-pool-card .order-add { min-width: 0; }
.order-speech.icon-speech .spoken-button { width: 48px; height: 48px; }
@media (max-width: 480px) { .order-moves .order-move-label { display: none; } }
/* A card with its own speaker on a phone: the text keeps the row's width and the
   arrows go on a line below, so words are not broken letter by letter (UI audit 29.09). */
@media (max-width: 480px) {
  .order-item:has(.order-speech:not([hidden])) { grid-template-columns: 2.2rem minmax(0, 1fr); row-gap: 2px; }
  .order-item:has(.order-speech:not([hidden])) .order-moves { grid-column: 1 / -1; justify-content: flex-end; }
}

/* Kladde (scratchpad) */
.scratchpad-launch { display: flex; justify-content: center; }
.scratchpad-toggle { position: relative; border-color: var(--purple); color: var(--purple-dark); }
.scratchpad-toggle[aria-expanded="true"] { background: var(--lavender); }
.scratchpad-toggle .luxi-icon { width: 24px; height: 24px; }
.scratchpad-has-content { position: absolute; top: -5px; right: -5px; width: 15px; height: 15px; border-radius: 50%; background: var(--gold, #ffd77d); border: 2px solid var(--panel); }
.scratchpad-sheet { display: flex; flex-direction: column; min-height: 0; background: var(--panel); container-type: inline-size; }
@container (max-width: 700px) { .scratchpad-tool-label { display: none; } }
.scratchpad-sheet[hidden] { display: none !important; }
.scratchpad-handle { flex: 0 0 auto; height: 22px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.scratchpad-handle::before { content: ""; width: 46px; height: 5px; border-radius: 3px; background: #cfc4dc; }
/* The whole question on top of the kladde (note on cbf59033 29.09): shown in full by default, a long one
   scrolls inside the strip (at most about a third of the screen, less when the one keyboard is open);
   the chevron folds it to two lines to give the drawing more room. */
.scratchpad-pinned { flex: 0 1 auto; display: flex; align-items: flex-start; gap: 6px; min-height: 3.4em; max-height: 34dvh; margin: 0 12px 6px; padding: 8px 6px 8px 12px; border-radius: 14px; background: var(--lavender); color: var(--ink); font-weight: 600; overflow: hidden; }
.scratchpad-pinned-text { flex: 1 1 auto; min-width: 0; max-height: 100%; margin: 0; overflow-y: auto; overscroll-behavior: contain; align-self: stretch; }
.scratchpad-pinned.is-folded { min-height: 0; }
.scratchpad-pinned.is-folded .scratchpad-pinned-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scratchpad-pinned-toggle { flex: 0 0 auto; display: grid; place-items: center; width: 40px; height: 40px; margin: -4px 0; padding: 0; border: 0; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; touch-action: manipulation; }
.scratchpad-pinned-toggle .luxi-icon { width: 24px; height: 24px; transform: rotate(180deg); transition: transform .15s ease; }
.scratchpad-pinned.is-folded .scratchpad-pinned-toggle .luxi-icon { transform: none; }
.scratchpad-pinned-context { font-weight: 400; }
.scratchpad-pinned-expression { font-family: Georgia, serif; font-size: 1.3rem; font-weight: 400; white-space: nowrap; }
.scratchpad-tools { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; padding: 0 12px 8px; min-width: 0; }
@media (max-width: 400px) {
  .scratchpad-tools { gap: 3px; padding-inline: 6px; }
  .scratchpad-tool { min-width: 40px; padding-inline: 5px; gap: 3px; font-size: .85rem; }
  .scratchpad-tool .luxi-icon { width: 19px; height: 19px; flex-basis: 19px; }
  .scratchpad-modes { gap: 3px; margin-right: 0; }
}
.scratchpad-modes { display: inline-flex; gap: 4px; margin-right: 4px; }
.scratchpad-spacer { flex: 1; }
.scratchpad-tool { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 44px; min-height: 44px; padding: 6px 9px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.scratchpad-tool[hidden] { display: none; }
.scratchpad-tool .luxi-icon { width: 21px; height: 21px; flex: 0 0 21px; }
.scratchpad-tool[aria-pressed="true"] { background: var(--purple); border-color: var(--purple); color: #fff; }
.scratchpad-tool:disabled { opacity: .4; cursor: default; }
.scratchpad-close { border-color: var(--purple); color: var(--purple-dark); }
.scratchpad-paper { position: relative; flex: 1 1 auto; min-height: 170px; margin: 0 12px 10px; overflow: hidden; border: 1.5px solid var(--line); border-radius: 16px;
  background-color: #fffefb; background-image: linear-gradient(#e3dcef 1px, transparent 1px), linear-gradient(90deg, #e3dcef 1px, transparent 1px); background-size: 26px 26px; background-position: -1px -1px;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
.scratchpad-paper[data-mode="write"] { cursor: text; }
.scratchpad-paper[data-mode="erase"] { cursor: cell; }
.scratchpad-paper canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; pointer-events: none; }
/* Kladde v2 (04.10): everything on the sheet lives in one world layer that zooms and pans. */
.scratchpad-world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; pointer-events: none; }
.scratchpad-world .scratchpad-figure { position: absolute; left: 0; top: 0; width: 364px; height: 312px; object-fit: contain; user-select: none; -webkit-user-select: none; }
/* The set-up calculation (seed): printed signs, one per square, and the rule above the empty result row. */
.scratchpad-seed { position: absolute; left: 0; top: 0; color: #4a3d63; }
.scratchpad-seed-cell { position: absolute; display: grid; place-items: center; width: 26px; height: 26px; font: 700 21px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.scratchpad-seed-rule { position: absolute; height: 3px; margin-top: -1.5px; border-radius: 2px; background: currentColor; }
/* The child's text blocks (Skriv): one sign per square, always on the squares. */
.scratchpad-block { position: absolute; display: grid; width: max-content; color: #302744; }
.scratchpad-block-line { display: flex; height: 26px; min-width: 26px; }
.scratchpad-cell { display: grid; place-items: center; flex: 0 0 26px; width: 26px; height: 26px; font: 600 20px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
/* A stacked fraction (seed and ⅟ in Skriv): numerator, a horizontal bar on the grid line, denominator. */
.scratchpad-seed-rule.is-fraction { height: 2.5px; margin-top: -1.25px; transform: scaleX(.86); }
.scratchpad-fraction { position: absolute; }
.scratchpad-fraction .scratchpad-block-line { justify-content: center; }
.scratchpad-fraction-bar { position: absolute; left: 0; top: 26px; height: 2.5px; margin-top: -1.25px; border-radius: 2px; background: currentColor; transform: scaleX(.86); }
/* A decimal comma/point takes no square: it sits on the grid line between two digits, so digits stay under each other. */
.scratchpad-cell.is-mark { position: relative; flex: 0 0 0; width: 0; overflow: visible; }
.scratchpad-cell.is-mark > span { position: absolute; top: 0; left: 0; display: grid; place-items: center; width: 14px; height: 26px; margin-left: -7px; font-weight: 800; }
.scratchpad-cell.is-empty { box-sizing: border-box; border: 1.5px dashed #b9aed0; border-radius: 3px; transform: scale(.8); }
.scratchpad-fraction.is-active .scratchpad-fraction-part.is-here { background: #ffe9a8; border-radius: 3px; }
.scratchpad-block.is-active { outline: 2px dashed var(--kladde-aim, #c98a00); outline-offset: 1px; border-radius: 3px; background: #fff8e1cc; }
.scratchpad-caret { display: inline-block; align-self: center; width: 2px; height: 22px; margin-left: 1px; background: var(--kladde-aim, #c98a00); }
@media (prefers-reduced-motion: no-preference) { .scratchpad-caret { animation: kladde-caret 1.1s steps(1) infinite; } }
.scratchpad-block-delete { position: absolute; z-index: 2; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 2px solid #fff; border-radius: 50%; background: var(--red, #a74355); color: #fff; cursor: pointer; touch-action: manipulation; box-shadow: 0 2px 6px #0003; }
.scratchpad-block-delete::before { content: ""; position: absolute; inset: -6px; }
.scratchpad-block-delete .luxi-icon { width: 18px; height: 18px; stroke-width: 3; }
.scratchpad-paper [hidden] { display: none !important; }
.scratchpad-corner { position: absolute; top: 6px; right: 6px; z-index: 1; display: flex; gap: 6px; }
.scratchpad-seed-toggle { min-height: 44px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .92); color: var(--ink); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.scratchpad-seed-toggle[aria-pressed="true"] { background: var(--purple); border-color: var(--purple); color: #fff; }
.scratchpad-zoom { position: absolute; right: 6px; bottom: 6px; z-index: 1; display: flex; align-items: center; gap: 2px; padding: 2px; border: 1.5px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .94); }
.scratchpad-zoom-button { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 44px; min-height: 44px; padding: 0 8px; border: 0; border-radius: 11px; background: transparent; color: var(--ink); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.scratchpad-zoom-button:active { background: var(--lavender); }
.scratchpad-zoom-button .luxi-icon { width: 20px; height: 20px; flex: 0 0 20px; }
.scratchpad-zoom-label { min-width: 3.2em; text-align: center; font-size: .8rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
@container (max-width: 380px) { .scratchpad-zoom-fit span { display: none; } }
/* Skriv mode: LUXI's own compact pad, only when asked for (⌨, a tap in the kladde or on the answer). */
.scratchpad-pad { flex: 0 0 auto; padding: 0 12px 10px; }
.scratchpad-pad[hidden] { display: none; }
.scratchpad-pad .pad-key { min-height: 42px; font-size: 1.15rem; background: #fbf9ff; }
.scratchpad-pad .pad-digits, .scratchpad-pad .pad-letters { gap: 5px; }
.scratchpad-pad .pad-row .pad-key { min-height: 40px; }
.scratchpad-paper .scratchpad-keyboard-toggle { position: absolute; left: 6px; bottom: 6px; z-index: 1; background: rgba(255, 255, 255, .94); }
.scratchpad-paper .scratchpad-keyboard-toggle[aria-pressed="true"] { background: var(--purple); }
.scratchpad-paper[data-mode="write"] .scratchpad-hint { bottom: 60px; }
.scratchpad-hint { position: absolute; left: 10px; bottom: 10px; max-width: calc(100% - 220px); min-width: 9rem; margin: 0; font-size: .8rem; line-height: 1.3; color: var(--muted); pointer-events: none; }

/* Phone and portrait: the kladde fills the screen above a fixed answer dock
   (answer + compact pad + Godkend), with a pinned copy of the task on top. */
@media (max-width: 699.98px), (orientation: portrait) {
  .task-panel.scratchpad-open { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; height: 100vh; height: 100dvh; margin: 0; padding: env(safe-area-inset-top) 0 0; border: 0; border-radius: 0; overflow: hidden; overscroll-behavior: contain; }
  .task-panel.scratchpad-open > * { display: none; }
  .task-panel.scratchpad-open > .scratchpad-sheet { display: flex; order: 0; flex: 1 1 auto; min-height: 0; }
  .task-panel.scratchpad-open > .task-body { display: contents; }
  .task-panel.scratchpad-open > .task-body > * { display: none; }
  .task-panel.scratchpad-open > .task-body > .answer-form { display: block; order: 2; flex: 0 1 auto; max-height: 55%; overflow: auto; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--panel); }
  .task-panel.scratchpad-open > .task-feedback:has(.feedback-result-mark) { display: flex; order: 1; height: auto; margin: 0; padding: 4px 12px; gap: 8px; border-top: 1px solid var(--line); }
  .task-panel.scratchpad-open > .task-feedback h2 { font-size: 1rem; margin: 0; }
  .task-panel.scratchpad-open > .task-action-bar:has(.task-actions button:not([hidden]), .task-actions form) { display: block; order: 3; position: static; margin: 0; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-radius: 0; box-shadow: none; background: var(--panel); }
  .task-panel.scratchpad-open .task-action-listening { display: none; }
  .task-panel.scratchpad-open[data-task-state-value] .answer-form .answer-pad:has(.pad-submit) { position: static; width: 100%; max-width: 30rem; margin-inline: auto; padding: 0; border: 0; box-shadow: none; background: none; }
  .task-panel.scratchpad-open .response-hint, .task-panel.scratchpad-open .response-tools, .task-panel.scratchpad-open .response-clear, .task-panel.scratchpad-open .response-fields > legend { display: none; }
  .task-panel.scratchpad-open .response-fields { gap: 6px; }
  .task-panel.scratchpad-open .pad-digits { gap: 6px; }
  .task-panel.scratchpad-open .pad-key { min-height: 46px; font-size: 1.3rem; }
  .task-panel.scratchpad-open .pad-submit span { display: none; }
  .task-panel.scratchpad-open .pad-submit .luxi-icon { width: 28px; height: 28px; }
  .task-panel.scratchpad-open .mode-numeric .response-slot { min-height: 46px; font-size: 1.5rem; }
  .task-panel.scratchpad-open .response-slot { min-height: 48px; }
  .task-panel.scratchpad-open .answer-choices { gap: 8px; }
  /* Brøk/punkt in the dock: compact fields so the kladde keeps its room; the bar stays fixed between them. */
  .task-panel.scratchpad-open .discrete-numbers { gap: .3rem; }
  .task-panel.scratchpad-open .discrete-numbers input.discrete-number-field[type=text][data-field][inputmode] { min-height: 46px; padding: 4px 8px; font-size: 1.4rem; }
  .task-panel.scratchpad-open .fraction-fields { row-gap: .25rem; }
  .task-panel.scratchpad-open .discrete-number-status:empty { display: none; }
  .task-panel.scratchpad-open .discrete-response .button { min-height: 40px; padding-block: 4px; }
}

/* Wide screens (tablet landscape, desktop): task, answers and Godkend on the left, the kladde
   beside them on the right over the whole height (one screen, placering A, user 06.10.2026:
   »Kør med kladden«). The page scrolls on the left; the kladde stays put. */
@media (min-width: 700px) and (orientation: landscape) {
  body:has(.task-panel.scratchpad-open) { --kladde-w: calc((100vw - var(--rail, 0px)) * .6); }
  body:has(.task-panel.scratchpad-open) .main-content { margin-right: var(--kladde-w); }
  .task-panel.scratchpad-open > .scratchpad-sheet { position: fixed; z-index: 20; top: 8px; right: 8px; bottom: 8px; width: calc(var(--kladde-w) - 12px); padding-top: 10px; border: 1.5px solid var(--line); border-radius: 18px; box-shadow: 0 8px 30px #071a2418; }
  .task-panel.scratchpad-open .scratchpad-handle, .task-panel.scratchpad-open .scratchpad-pinned { display: none; }
  .task-panel.scratchpad-open .task-prompt { font-size: clamp(1.05rem, .8vw + .7rem + .8vh, 1.35rem); margin-bottom: 10px; }
  .task-panel.scratchpad-open .math-expression { margin: 10px 0; }
  .task-panel.scratchpad-open .task-feedback { height: auto; min-height: 56px; margin-top: 10px; }
  .task-panel.scratchpad-open .task-image { height: min(22vh, 200px); margin-bottom: 10px; }
  /* The task's picture is in the kladde already: no second copy on the left. */
  .task-panel.scratchpad-open:has(.scratchpad-figure) .task-body .task-image { display: none; }
  .task-panel.scratchpad-open .response-hint { display: none; }
  .task-panel.scratchpad-open .scratchpad-launch { margin-bottom: 8px; }
  .task-panel.scratchpad-open .pad-key { min-height: 44px; }
}
@media (prefers-reduced-motion: no-preference) {
  .scratchpad-sheet { transition: transform .18s ease; }
}
@media (max-width: 699.98px), (orientation: portrait) {
  .task-panel.scratchpad-open:not([data-task-state-value="unanswered"]) .answer-form .answer-pad { display: none; }
}

/* One keyboard in Skriv mode (user decision 27.09): the kladde keyboard types in
   the kladde (gold) or in the answer (purple). The answer's own pad is hidden. */
.task-panel { --kladde-aim: #c98a00; --kladde-aim-soft: #fff1c9; --answer-aim: var(--theme-primary, var(--purple)); }
.task-panel.scratchpad-keyboard .answer-form .answer-pad,
.task-panel.scratchpad-keyboard .answer-form .response-keyboard { display: none !important; }
/* Kladde v2: the keyboard is hidden by default while the kladde is open; the answer keeps only its Godkend.
   A tap on the answer (or tæller/nævner) opens the one keyboard aimed at Svar. */
.task-panel.scratchpad-open .answer-form .answer-pad .pad-key:not(.pad-submit) { display: none; }
.task-panel.scratchpad-open .answer-form .answer-pad .pad-grid:not([hidden]) { display: flex; justify-content: center; }
.task-panel.scratchpad-open .answer-form .answer-pad .pad-row:not(:has(.pad-submit)) { display: none; }
.task-panel.scratchpad-open .answer-form .answer-pad .pad-submit { flex: 1 1 auto; max-width: 16rem; min-height: 48px; }
.task-panel.scratchpad-open .answer-form .answer-pad .pad-submit span { display: inline; }
.kladde-keyboard { --aim: var(--kladde-aim); padding: 8px 12px 10px; border-top: 5px solid var(--aim); background: var(--panel); }
.task-panel[data-typing="answer"] .kladde-keyboard { --aim: var(--answer-aim); }
.kladde-aims { display: flex; gap: 8px; max-width: 30rem; margin: 0 auto 8px; }
.kladde-aim { flex: 1 1 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; min-height: 52px; padding: 0 10px;
  border: 2.5px solid var(--line); border-radius: 14px; background: #fff; color: var(--muted); font: inherit; font-size: 1.15rem; font-weight: 800; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.kladde-aim .luxi-icon { width: 24px; height: 24px; flex: 0 0 24px; }
.kladde-aim[hidden], .kladde-submit[hidden] { display: none; }
.kladde-aim:disabled { opacity: .4; cursor: default; }
.kladde-aim-kladde[aria-pressed="true"] { background: var(--gold, #ffd77d); border-color: var(--kladde-aim); color: #3b2800; box-shadow: 0 0 0 3px var(--kladde-aim-soft); }
.kladde-aim-answer[aria-pressed="true"] { background: var(--answer-aim); border-color: var(--answer-aim); color: #fff; box-shadow: 0 0 0 3px var(--lavender); }
.kladde-aims .kladde-submit { flex: 0 0 auto; min-height: 52px; padding: 0 14px; }
.kladde-hide { flex: 0 0 auto; display: grid; place-items: center; width: 48px; min-height: 52px; padding: 0; border: 1.5px solid var(--line); border-radius: 14px; background: #fff; color: var(--muted); cursor: pointer; touch-action: manipulation; }
.kladde-hide .luxi-icon { width: 24px; height: 24px; }
@container (max-width: 380px) { .kladde-aims .kladde-submit span { display: none; } }
.kladde-keyboard { container-type: inline-size; }
/* Kladde keyboard: × and ÷ share the sign rows; a wide ↵ follows comma and ⅟,
   keeping the numeric layout at four rows on a narrow phone. */
.kladde-keyboard .pad-digits .pad-enter { grid-column: span 4; }
.kladde-keyboard .pad-digits .pad-enter, .kladde-keyboard.scratchpad-pad .pad-digits .pad-enter { min-height: 38px; }
/* ⅟ (Kladde v2): a small stacked fraction — two boxes with a bar between. */
.pad-fraction-glyph { display: inline-grid; gap: 3px; }
.pad-fraction-glyph span { width: 14px; height: 11px; border: 2px solid currentColor; border-radius: 2px; }
.pad-fraction-glyph span + span { position: relative; }
.pad-fraction-glyph span + span::before { content: ""; position: absolute; left: -5px; right: -5px; top: -4px; height: 2.5px; background: currentColor; border-radius: 2px; }
/* Keys the answer does not accept (e.g. letters for a number answer). */
.pad-key.pad-key-blocked { opacity: .22; border-style: dashed; background: repeating-linear-gradient(135deg, #f6f3fa 0 6px, #e8e2f0 6px 12px); }
/* The field being typed in: coloured frame, a "Du skriver her" tag and a visible caret. */
.task-panel[data-typing] .scratchpad-paper { transition: box-shadow .15s ease; }
.task-panel[data-typing="kladde"] .scratchpad-paper { border: 3px solid var(--kladde-aim); box-shadow: 0 0 0 4px var(--kladde-aim-soft); }
.task-panel[data-typing="kladde"] .scratchpad-paper::after,
.task-panel[data-typing="answer"] .answer-form::before { content: "Du skriver her"; font-size: .8rem; font-weight: 800; line-height: 1; padding: 4px 8px; border-radius: 999px; pointer-events: none; }
.task-panel[data-typing="kladde"] .scratchpad-paper::after { position: absolute; top: 6px; left: 50%; z-index: 1; transform: translateX(-50%); background: var(--kladde-aim); color: #fff; }
.task-panel[data-typing="answer"] .answer-form { position: relative; }
.task-panel[data-typing="answer"] .answer-form::before { display: table; margin: 0 auto 6px; background: var(--answer-aim); color: #fff; }
.task-panel[data-typing="answer"] .answer-form .response-fields,
.task-panel[data-typing="answer"] .answer-form .answer-field,
.task-panel[data-typing="answer"] .answer-form .discrete-text { border-radius: 16px; outline: 3px solid var(--answer-aim); outline-offset: 4px; box-shadow: 0 0 0 9px var(--lavender); }
.task-panel[data-typing="answer"] .response-slot[aria-pressed="true"] { border-color: var(--answer-aim); border-width: 3px; }
.task-panel[data-typing="answer"] .response-slot[aria-pressed="true"]::after { content: ""; display: inline-block; width: 3px; height: 1.1em; margin-left: 3px; vertical-align: middle; background: var(--answer-aim); }
.task-panel[data-typing="kladde"] .answer-form { opacity: .8; }
@media (prefers-reduced-motion: no-preference) {
  .task-panel[data-typing="answer"] .response-slot[aria-pressed="true"]::after { animation: kladde-caret 1.1s steps(1) infinite; }
}
@keyframes kladde-caret { 50% { opacity: 0; } }
/* Phone and portrait: kladde, answer, then the one keyboard at the bottom. */
@media (max-width: 699.98px), (orientation: portrait) {
  .task-panel.scratchpad-open > .kladde-keyboard:not([hidden]) { display: block; order: 3; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .task-panel.scratchpad-open.scratchpad-keyboard > .task-action-bar:has(.task-actions button:not([hidden]), .task-actions form) { order: 4; }
  /* Keep a usable writing sheet when the shared keyboard is open. The answer
     stays in a compact, scrollable dock (including long exact-edit text/reset). */
  .task-panel.scratchpad-keyboard .scratchpad-paper { min-height: 170px; }
  .task-panel.scratchpad-keyboard > .scratchpad-sheet { flex-shrink: 0; }
  .task-panel.scratchpad-keyboard > .task-body > .answer-form { flex-shrink: 0; height: 54px; max-height: 54px; padding-block: 3px; }
  .task-panel.scratchpad-keyboard .discrete-text > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .task-panel.scratchpad-keyboard .discrete-text input.discrete-text-field[type=text][inputmode] { min-height: 44px; height: 44px; padding-block: 4px; }
  .task-panel.scratchpad-keyboard .discrete-text textarea.discrete-text-field { min-height: 44px; height: 44px; padding-block: 4px; resize: none; overflow-y: auto; }
  .task-panel.scratchpad-keyboard[data-typing="answer"] .answer-form::before { display: none; }
  .task-panel.scratchpad-keyboard .response-slot { height: 44px; min-height: 44px; padding-block: 2px; line-height: 1.2; }
  .task-panel.scratchpad-keyboard .scratchpad-handle { height: 10px; }
  .task-panel.scratchpad-keyboard .scratchpad-pinned { flex-shrink: 0; height: 44px; max-height: 44px; min-height: 44px; padding-block: 4px; margin-bottom: 4px; }
  .task-panel.scratchpad-keyboard .scratchpad-tools { padding-bottom: 2px; }
  .task-panel.scratchpad-keyboard .scratchpad-paper { margin-bottom: 6px; }
  .task-panel.scratchpad-keyboard > .kladde-keyboard { flex-shrink: 1; min-height: 140px; overflow-y: auto; padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  .task-panel.scratchpad-keyboard .kladde-aims { position: sticky; top: -4px; z-index: 2; background: var(--panel); }
  .task-panel.scratchpad-keyboard .kladde-keyboard .pad-letters { gap: 3px; }
  .task-panel.scratchpad-keyboard .kladde-aims { margin-bottom: 4px; gap: 4px; }
  .task-panel.scratchpad-keyboard .kladde-aim,
  .task-panel.scratchpad-keyboard .kladde-aims .kladde-submit,
  .task-panel.scratchpad-keyboard .kladde-hide { min-height: 44px; }
  .task-panel.scratchpad-keyboard .kladde-keyboard .pad-key { min-height: 44px; }
}
/* Wide screens (side by side): the one keyboard sits under the answer, next to the kladde. */
@media (min-width: 700px) and (orientation: landscape) {
  .task-panel.scratchpad-open > .kladde-keyboard { margin-top: 12px; border: 1px solid var(--line); border-top: 5px solid var(--aim); border-radius: 18px; }
}
.kladde-aims .kladde-submit { background: var(--answer-aim); border-color: var(--answer-aim); color: #fff; font-size: 1rem; }

/* Fixed action bar (user decision 28.09, "ja prøv det!"): the main action –
   Godkend, Prøv igen, Se svar, Næste – is always on screen without scrolling,
   on phone, tablet and desktop. The bar is the task panel's last visible child
   and sticks to the bottom of the viewport; it takes its own place in the flow,
   so nothing ends up hidden behind it once the page is scrolled to the end.
   Tasks with Godkend in the answer pad (talpanel/tastatur) stick the pad itself
   instead, so there is only ever one Godkend on screen. */
.task-panel { --task-surface: #fffefa; }
.task-action-bar {
  position: sticky; bottom: 0; z-index: 4; display: grid; gap: 6px;
  margin: 16px calc(-1 * var(--task-pad)) calc(-1 * var(--task-pad));
  padding: 10px var(--task-pad) calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); border-radius: 0 0 23px 23px;
  background: var(--task-surface); box-shadow: 0 -12px 20px -16px #071a2466;
}
.task-action-bar .task-action-listening { margin-top: 0; }
.task-action-bar .task-action-listening:not(:has(button)) { display: none; }
.task-action-bar:not(:has(button:not([hidden]), form)) { display: none; }
@media (max-width: 430px) {
  .task-action-bar .task-primary-slot, .task-action-bar .task-secondary-slot, .task-action-bar .task-action { height: 76px; }
}
/* The pad with Godkend sticks to the bottom while the answer is open. */
.task-panel[data-task-state-value="unanswered"] .answer-form .answer-pad:has(.pad-submit) {
  position: sticky; bottom: 0; z-index: 4; width: auto; max-width: none;
  margin-inline: calc(-1 * var(--task-pad));
  padding: 10px max(var(--task-pad), calc((100% - var(--pad-width, 30rem)) / 2 + var(--task-pad))) calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--task-surface); box-shadow: 0 -12px 20px -16px #071a2466;
}
/* Focus and scrollIntoView keep a field clear of the bar. */
html:has(.task-action-bar) { scroll-padding-bottom: 170px; }

/* Kladde on coordinate tasks: the task's coordinate system is drawn on the canvas under the strokes. */
.scratchpad-paper.scratchpad-coordinates { background-image: none; }
/* Figure tasks: the task's picture (in the zooming world layer, .scratchpad-world .scratchpad-figure) under the transparent drawing canvas. */
.scratchpad-grid-toggle { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1.5px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .92); color: var(--ink); cursor: pointer; touch-action: manipulation; }
.scratchpad-grid-toggle .luxi-icon { width: 24px; height: 24px; }
.scratchpad-grid-toggle[aria-pressed="true"] { background: var(--purple); border-color: var(--purple); color: #fff; }

/* Pilot feedback "Dårlig opgave" (docs/PILOT_FEEDBACK.md): quiet, small icon,
   44px hit area, beside the progress meter so it never covers the answer pad
   or the kladde. aria-pressed shows the state (filled icon). */
.task-topline { display: flex; align-items: center; gap: 6px; }
.task-topline > .progress-meter { flex: 1 1 auto; }
.task-flag-slot { position: relative; flex: 0 0 auto; margin-left: auto; }
/* »Dårlig opgave« with reasons (UI-gennemgang 17.11, F1; prototype 3): a small box under the thumb. */
.task-flag-pop { position: absolute; z-index: 40; top: calc(100% + 10px); right: -6px; width: min(330px, calc(100vw - 24px));
  display: grid; gap: 10px; padding: 14px; border-radius: 20px; background: var(--panel, #fff); border: 1.5px solid var(--line);
  box-shadow: 0 14px 40px #24101a40; color: var(--ink); text-align: left; font-size: 1rem; line-height: 1.35; }
.task-flag-pop[hidden] { display: none; }
.task-flag-pop::before { content: ""; position: absolute; top: -8px; right: 20px; width: 14px; height: 14px; background: inherit;
  border-left: 1.5px solid var(--line); border-top: 1.5px solid var(--line); transform: rotate(45deg); }
.task-flag-pop-head { display: flex; align-items: center; gap: 8px; }
.task-flag-pop-head h2 { flex: 1; margin: 0; font-size: 17px; line-height: 1.3; }
.task-flag-pop-sub { margin: -4px 0 0; font-size: 14px; color: var(--muted); }
.task-flag-reasons { display: grid; gap: 8px; }
.task-flag-reason { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 8px 12px; border-radius: 14px;
  border: 2px solid var(--line); background: var(--page); color: var(--ink); font: inherit; text-align: left; cursor: pointer; touch-action: manipulation; }
.task-flag-reason b { display: block; font-size: 15px; }
.task-flag-reason small { display: block; font-size: 13px; color: var(--muted); line-height: 1.3; }
.task-flag-box { flex: 0 0 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; border: 2px solid var(--line); background: #fff; color: #fff; }
.task-flag-box .luxi-icon { width: 16px; height: 16px; stroke-width: 3.2; }
.task-flag-reason[aria-pressed="true"] { border-color: var(--theme-primary, var(--purple)); background: var(--theme-wash, var(--lavender)); }
.task-flag-reason[aria-pressed="true"] .task-flag-box { background: var(--theme-primary, var(--purple)); border-color: var(--theme-primary, var(--purple)); }
.task-flag-comment { display: grid; gap: 4px; font-size: 14px; font-weight: 700; color: var(--muted); }
.task-flag-comment textarea { width: 100%; min-height: 52px; padding: 8px 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--page);
  color: var(--ink); font: inherit; font-size: 16px; font-weight: 500; resize: vertical; }
.task-flag-pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-flag-remove { min-height: 44px; padding: 8px 4px; color: var(--muted); }
.task-flag-done { min-height: 48px; padding: 8px 22px; }
.task-flag-error { position: absolute; z-index: 41; top: calc(100% + 4px); right: 0; width: max-content; max-width: min(260px, calc(100vw - 24px));
  margin: 0; padding: 6px 10px; border-radius: 10px; background: #fff1d9; border: 1.5px solid #c58024; color: #70460e; font-size: 13px; font-weight: 700; }
.task-flag-error[hidden] { display: none; }
.task-flag-pop .task-flag-error { position: static; width: auto; max-width: none; }
.task-flag-pop:not([hidden]) ~ .task-flag-error { display: none; }
.task-flag {
  display: inline-grid; place-items: center; width: 44px; height: 44px; margin: -6px -8px -6px 0; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted, #56666b); opacity: .55; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.task-flag .luxi-icon { width: 18px; height: 18px; }
.task-flag:hover, .task-flag:focus-visible { opacity: 1; }
.task-flag:focus-visible { outline: 3px solid var(--theme-primary, #17635f); outline-offset: -3px; }
.task-flag[aria-pressed="true"] { opacity: 1; color: var(--theme-accent, #c65a3a); }
.task-flag[aria-pressed="true"] .luxi-icon { fill: currentColor; }
/* »Vis opgavenummer« (admin page Funktioner): only administrators and test pupils. */
.task-number { flex: 0 0 auto; margin-left: auto; color: var(--muted, #56666b); font-size: 12px; font-variant-numeric: tabular-nums; opacity: .7; white-space: nowrap; }
.task-number + .task-flag-slot { margin-left: 0; }

/* »Rapportér fejl i opgaven« (bruger 06.10): quiet, below the task. */
.task-report { display: block; margin: 12px 0 0; font-size: .875rem; }
.task-report__details > summary { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--muted, #667); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.task-report__form { display: grid; gap: 8px; max-width: 32rem; padding: 4px 4px 8px; }
.task-report__form textarea { width: 100%; min-width: 0; box-sizing: border-box; font: inherit; }
.task-report__form .button { justify-self: start; }
.task-report__sent { margin: 0; padding: 12px 4px; color: var(--muted, #667); }

/* Keep six 44px symbol keys per phone row. Kladde places the decimal point
   beside Mellemrum, so × and ÷ do not add a sixth row in the basic ABC layout. */
.kladde-keyboard .pad-symbols { flex-wrap: wrap; }
.kladde-keyboard .pad-symbols .pad-key { flex: 1 0 44px; min-height: 44px; }
.kladde-keyboard .pad-row-last .pad-symbol { flex: 0 0 44px; min-height: 44px; }
.kladde-keyboard .pad-digits .pad-key { min-height: 44px; }

/* At 320px the open task panel contributes its own padding. Recover enough
   keyboard width for six 44px columns plus their gaps in that real context. */
@media (max-width: 360px) {
  .task-screen .task-panel.scratchpad-open > .kladde-keyboard { padding-inline: 3px; }
}

/* The wide Kladde keyboard shares the task's left column. Reserve its real
   height before laying out the question/answer, including extra punctuation.
   The task stays scrollable above it; short landscape screens can scroll keys. */
@media (min-width: 700px) and (orientation: landscape) {
  .task-screen .task-panel.task-workspace.scratchpad-open.scratchpad-keyboard { display: flex; flex-direction: column; height: calc(100dvh - 18px); min-height: 0; }
  .task-screen .task-panel.scratchpad-open.scratchpad-keyboard > .task-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .task-screen .task-panel.scratchpad-open.scratchpad-keyboard > .kladde-keyboard { flex: 0 0 auto; min-height: 0; max-height: 70%; overflow-y: auto; }
}

/* Tablet and laptop (UI review 20.11.2026, M12 + M15): keys and pieces stayed phone-sized in a narrow strip, and the
   grid, the marking and the text field stood small to the left under a centred question. From 700 px the answer
   stands centred under the question and the keys use the width; on a tall screen they grow in height too (a tablet
   on its side and a laptop have no height to spare: one screen). */
@media (min-width: 700px) {
  .task-screen .answer-pad:has(> .pad-letters) { --pad-width: 44rem; max-width: 44rem; }
  .task-screen .pad-row :is(.pad-letter, .pad-symbol) { max-width: 4.2rem; }
  .task-screen .pad-row :is(.pad-shift, .pad-backspace, .pad-switch) { max-width: 6rem; }
  .task-screen .pad-row .pad-submit { max-width: 11rem; }
  .task-screen .discrete-response :is(.discrete-grid, .mark-grid, .mark-image-wrap, .mark-text, .discrete-text) { margin-inline: auto; }
  .task-screen .discrete-response .discrete-text { width: min(100%, 30rem); }
  .task-screen :is(.discrete-response, .constructed-response:not(.uses-answer-pad)) .response-fields > legend { width: 100%; text-align: center; }
  .task-screen :is(.discrete-response, .constructed-response:not(.uses-answer-pad)) .response-fields > :is(.response-hint, [role="status"]),
  .task-screen .discrete-response .mark-response > :is(.response-hint, [role="status"]) { text-align: center; }
  .task-screen .discrete-response .response-fields > div:has(> [data-operation="reset"]) { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
  .task-screen .discrete-response .response-fields > div[hidden]:has(> [data-operation="reset"]) { display: none; }
  .task-screen .mark-text { font-size: 1.6rem; }
  /* »Ret teksten«: bigger letters are bigger things to tap (M14); how a letter or a word is chosen is unchanged
     (docs/EXACT_EDIT_AB.md). */
  .task-screen .ee-field { font-size: 2.1rem; }
}
@media (min-width: 700px) and (min-height: 900px) {
  .task-screen .pad-row .pad-key { min-height: 60px; }
  .task-screen .pad-row :is(.pad-letter, .pad-symbol) { font-size: 1.55rem; }
  .task-screen .pad-digits .pad-key { min-height: 64px; }
  .task-screen .constructed-response:not(.mode-numeric) .response-slot { min-width: 66px; min-height: 76px; font-size: 2.1rem; }
  .task-screen .response-piece { min-width: 64px; min-height: 66px; font-size: 1.8rem; }
  .task-screen .discrete-grid { max-width: 30rem; }
}
