/* Algorithmen-Trainer (/algorithmen-trainer/, assets/js/trainer.js). Every control is at least 44 px high, works from 360 px. */
.tr { max-width: 900px; margin: 0 auto 28px; display: grid; gap: 16px; }
.tr[hidden], .tr [hidden], .tr-nojs[hidden] { display: none !important; }
.tr-nojs { max-width: 900px; margin: 0 auto 24px; }
.tr .btn { min-height: 44px; white-space: normal; text-align: center; }
.tr .btn.sm { min-height: 44px; }
.tr-h { margin: 0 0 12px; font-size: 1.25rem; }
.tr-sets .btn { flex: 1 1 0; min-width: 90px; }
.tr-opts { border: 0; padding: 0; margin: 14px 0 6px; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.tr-opts legend { font-weight: 700; padding: 0; margin-bottom: 4px; }
.tr-radio { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.tr-radio input, .tr-chk input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.tr-sel { margin: 6px 0 4px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--bg); }
.tr-sel summary, .tr-prog summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.tr-sel-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.tr-sel-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 2px 8px; margin-bottom: 12px; }
.tr-chk { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.tr-go { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.tr-go .btn { flex: 1 1 200px; }
.tr-msg:empty { display: none; }
.tr-msg { color: var(--bad); margin: 10px 0 0; }
.tr-warn { background: #fff4e0; color: #7a4a00; border: 1px solid #f1c47a; border-radius: 10px; padding: 10px 14px; margin: 0; }

.tr-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.tr-q { display: grid; grid-template-columns: minmax(180px, 260px) minmax(0, 1fr); gap: 22px; align-items: start; }
.tr-q:focus { outline: none; }
.tr-pic { background: var(--bg3); border-radius: 12px; padding: 12px; }
.tr-pic svg { display: block; width: 100%; height: auto; max-width: 260px; margin: 0 auto; }
.tr-ask { font-size: 1.15rem; margin: 0 0 12px; }
.tr-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tr-choices.alg { grid-template-columns: minmax(0, 1fr); }
.tr-choice { justify-content: flex-start !important; text-align: left !important; min-height: 52px !important; font-size: 1.05rem; }
.tr-choices.alg .tr-choice span { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95rem; overflow-wrap: anywhere; }
.tr-choice kbd { flex: none; }
.tr-choice.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--bg2)); opacity: 1; }
.tr-choice.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--bg2)); opacity: 1; }
.tr-showbtn { margin-top: 12px; width: 100%; }
.tr-fb { margin-top: 14px; border-radius: 12px; padding: 12px 14px; border: 1px solid var(--line); }
.tr-fb.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--bg2)); }
.tr-fb.bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 7%, var(--bg2)); }
.tr-fb p { margin: 0 0 8px; } .tr-fb p:last-child { margin: 0; }
.tr-fb-h { font-weight: 700; }
.tr-alg code { display: inline-block; max-width: 100%; font-weight: 700; font-size: 1.02rem; background: var(--bg3); padding: 6px 10px; border-radius: 8px; overflow-wrap: anywhere; }
.tr-exec { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; }
.tr-exec-time { font-variant-numeric: tabular-nums; font-weight: 700; }
.tr-next { width: 100%; margin-top: 12px; }
.tr-keys { margin: 14px 0 0; }
.tr-quiz { scroll-margin-top: 72px; }
@media (hover: none) and (pointer: coarse) { .tr-keys, .tr-choice kbd, .tr-showbtn kbd { display: none; } }

.tr-prog { padding-top: 4px; padding-bottom: 8px; }
.tr-table { overflow-x: auto; margin: 6px 0 10px; }
.tr-table table { width: 100%; font-size: .92rem; }
.tr-io { display: flex; flex-wrap: wrap; gap: 8px; }
.tr-file { position: relative; overflow: hidden; }
.tr-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.tr-file:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.tr-prose { max-width: 900px; margin: 0 auto; }
.tr-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; align-items: start; }
.tr-cases a { white-space: nowrap; }

@media (max-width: 640px) {
  .tr-q { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .tr-pic svg { max-width: 200px; }
  .tr .card, .tr.card { padding: 14px; }
}
