/* Typing Trainer (/typing-trainer/, js/trainer.js). Uses the site's tokens from site.css. */
.tr-page { max-width: 64rem; }
.tr-loading { padding: var(--s5); text-align: center; color: var(--ink-soft); }
.tr { --tr-bg: #fff; --tr-panel: var(--panel); --tr-ink: var(--ink); --tr-soft: var(--ink-soft); --tr-line: var(--rule-soft); --tr-ok: var(--ink); --tr-todo: #8e97b0; --tr-bad: #c62828; --tr-badbg: #fde3df;
  --tr-fs: 1.75rem; position: relative; background: var(--tr-bg); color: var(--tr-ink); border: 2px solid var(--tr-line); border-radius: var(--radius); padding: var(--s3) var(--s4) var(--s4); margin: var(--s4) 0 var(--s6); }
.tr[hidden] { display: none; }
.tr[data-size="s"] { --tr-fs: 1.375rem; } .tr[data-size="l"] { --tr-fs: 2.25rem; }
html[data-tr-theme="dark"] .tr { --tr-bg: #17191f; --tr-panel: #22252d; --tr-ink: #e8e9ee; --tr-soft: #a3a8b8; --tr-line: #343846; --tr-ok: #e8e9ee; --tr-todo: #6c7286; --tr-bad: #ff7a70; --tr-badbg: #4a2320; }
html[data-tr-theme="dark"] .tr .btn { color: var(--tr-ink); border-color: var(--tr-soft); background: transparent; }
html[data-tr-theme="dark"] .tr .btn-solid { background: #ffd23f; color: #17191f; border-color: #ffd23f; }

/* top bar */
.tr-top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding-bottom: var(--s3); border-bottom: 1px solid var(--tr-line); }
.tr-who { display: inline-flex; align-items: center; gap: 6px; font: 700 1rem var(--font-body); color: var(--tr-ink); background: var(--tr-panel); border: 0; border-radius: 999px; padding: 6px 14px 6px 6px; cursor: pointer; min-height: 44px; }
.tr-av { font-size: 1.4rem; line-height: 1; display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--tr-bg); }
.tr-tabs { display: flex; flex-wrap: wrap; gap: 4px; background: var(--tr-panel); border-radius: 999px; padding: 4px; }
.tr-tab { font: 600 .9375rem var(--font-body); color: var(--tr-soft); background: none; border: 0; border-radius: 999px; padding: 8px 14px; cursor: pointer; min-height: 40px; }
.tr-tab[aria-selected="true"] { background: var(--tr-bg); color: var(--tr-ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.tr-goal { margin-left: auto; font-size: var(--fs-small); color: var(--tr-soft); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.tr-gear { font: 600 .9375rem var(--font-body); color: var(--tr-soft); background: none; border: 0; cursor: pointer; min-height: 40px; }
.tr-kid .tr-adult { display: none !important; }

/* options row */
.tr-opts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); padding: var(--s3) 0 0; font-size: var(--fs-small); }
.tr-opts[hidden] { display: none; }
.tr-seg { display: inline-flex; background: var(--tr-panel); border-radius: 10px; padding: 3px; gap: 2px; }
.tr-seg button { font: 600 .875rem var(--font-body); color: var(--tr-soft); background: none; border: 0; border-radius: 8px; padding: 6px 12px; cursor: pointer; min-height: 36px; }
.tr-seg button[aria-pressed="true"] { background: var(--tr-bg); color: var(--tr-ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.tr-inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.tr select, .tr input[type="number"], .tr input:not([type]), .tr textarea { font: inherit; color: var(--tr-ink); background: var(--tr-bg); border: 2px solid var(--tr-line); border-radius: 8px; padding: 4px 8px; min-height: 38px; }
.tr input[type="number"] { width: 4.5rem; }
.tr-check { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; }
.tr-check input { width: 18px; height: 18px; accent-color: var(--link); }
.tr-link { font: 600 var(--fs-small) var(--font-body); color: var(--link); background: none; border: 0; padding: 4px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.tr-danger { color: var(--tr-bad); }
.tr-note { font-size: var(--fs-small); color: var(--tr-soft); margin: var(--s2) 0; }
.tr kbd { font: 600 .75rem var(--font-body); border: 1px solid var(--tr-line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }
.tr-sub { margin: var(--s3) 0 var(--s2); font-size: .9375rem; color: var(--tr-soft); }
.tr-sub b { color: var(--tr-ink); }
.tr-focus-k { display: inline-block; min-width: 1.6em; text-align: center; background: var(--highlight); color: #1f2a44 !important; border-radius: 6px; padding: 0 4px; }

/* learn: letter progress */
.tr-learnkeys { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 var(--s3); }
.tr-learnkeys[hidden] { display: none; }
.tr-lk { position: relative; width: 2rem; height: 2.2rem; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; text-transform: uppercase; color: var(--tr-todo); background: var(--tr-panel); overflow: hidden; font-size: .9375rem; }
.tr-lk.on { color: var(--tr-ink); border: 1.5px solid var(--tr-line); }
.tr-lk i { position: absolute; left: 0; bottom: 0; height: 4px; background: #2e9d5b; }
.tr-lk.focus { outline: 3px solid var(--highlight); outline-offset: 1px; }

/* typing stage */
.tr-stage { position: relative; outline: none; cursor: text; border-radius: var(--radius); padding: var(--s2) 0 var(--s3); }
.tr-stage[hidden] { display: none; }
.tr-bar { display: flex; justify-content: space-between; align-items: center; min-height: 2rem; }
.tr-live { font-family: var(--font-kid); font-size: 1.375rem; font-weight: 700; color: var(--link); }
html[data-tr-theme="dark"] .tr-live { color: #ffd23f; }
.tr-text { position: relative; font-size: var(--tr-fs); line-height: 1.6; height: calc(var(--tr-fs) * 1.6 * 3); overflow: hidden; color: var(--tr-todo); word-break: keep-all; overflow-wrap: break-word; letter-spacing: .01em; user-select: none; }
.tr-text.tr-mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace; font-size: calc(var(--tr-fs) * .72); height: calc(var(--tr-fs) * .72 * 1.6 * 8); white-space: pre-wrap; }
.tr-text span.ok { color: var(--tr-ok); }
.tr-text span.fix { color: var(--tr-ok); text-decoration: underline wavy var(--tr-bad); text-decoration-thickness: 1px; text-underline-offset: 6px; }
.tr-text span.bad { color: var(--tr-bad); background: var(--tr-badbg); border-radius: 3px; }
.tr-text span.cur { box-shadow: inset 0 -3px 0 var(--link); color: var(--tr-ink); }
html[data-tr-theme="dark"] .tr-text span.cur { box-shadow: inset 0 -3px 0 #ffd23f; }
.tr-text .tr-nl { font-size: .7em; opacity: .55; padding: 0 .2em; }
.tr-text .tr-sp.bad { background: var(--tr-badbg); }
.tr-w { display: inline-block; white-space: nowrap; }
.tr-w span.miss { color: var(--tr-todo); text-decoration: underline var(--tr-bad); }
.tr-w.tr-wbad { text-decoration: underline var(--tr-bad); text-decoration-thickness: 2px; text-underline-offset: 8px; }
.tr-w .x { opacity: .8; }
.tr-caret, .tr-ghost { position: absolute; width: 3px; border-radius: 2px; background: var(--link); transition: left .08s linear, top .08s linear; pointer-events: none; }
html[data-tr-theme="dark"] .tr-caret { background: #ffd23f; }
.tr-ghost { background: var(--tr-todo); opacity: .6; }
.tr-ghost[hidden], .tr-caret[hidden] { display: none; }
.tr-focused .tr-caret { animation: none; }
.tr:not(.tr-focused) .tr-caret { animation: tr-blink 1s steps(2) infinite; }
@keyframes tr-blink { 50% { opacity: 0; } }
.tr-shake { animation: tr-shake .2s; }
@keyframes tr-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.tr-capture { position: absolute; opacity: 0; width: 1px; height: 1px; top: 30%; left: 50%; border: 0; padding: 0; }
.tr-clickhint { position: absolute; left: 0; right: 0; top: calc(2rem + var(--tr-fs) * 1.1); text-align: center; margin: 0; font-weight: 700; color: var(--tr-ink); pointer-events: none; }
.tr-clickhint::before { content: ""; position: absolute; inset: -12px 20%; background: var(--tr-bg); opacity: .92; border-radius: 12px; z-index: -1; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.tr-focused .tr-clickhint { display: none; }
.tr:not(.tr-focused) .tr-text { filter: blur(2px); opacity: .6; }
.tr-hint { margin: var(--s2) 0; min-height: 1.5em; text-align: center; font-weight: 700; font-size: .9375rem; }
.tr-hint[hidden] { display: none; }

/* keyboards */
.tr-kb { display: flex; flex-direction: column; align-items: center; gap: 5px; user-select: none; margin-top: var(--s2); }
.tr-kb[hidden] { display: none; }
.tr-krow { display: flex; gap: 5px; }
.tr-kr1 { margin-left: 1.3rem; } .tr-kr2 { margin-left: 2.1rem; } .tr-kr3 { margin-left: -.6rem; }
.tr-key { width: 2.5rem; height: 2.5rem; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font: 700 .9375rem var(--font-body); color: #1f2a44; border: 1px solid rgba(31,42,68,.18); transition: transform .08s; padding: 0; }
button.tr-key { cursor: pointer; }
.tr-space { width: 15rem; font-weight: 600; font-size: .8125rem; } .tr-shift, .tr-enter { width: 4.2rem; font-size: .75rem; }
.tr-bump { box-shadow: inset 0 -4px 0 rgba(31,42,68,.35); }
.f-lp, .f-rp { background: #f6c1cc; } .f-lr, .f-rr { background: #fbe0a0; } .f-lm, .f-rm { background: #b9e4c4; } .f-li, .f-ri { background: #b4d6f4; } .f-th { background: #dde1ec; }
.tr-key.tr-on { outline: 3px solid var(--tr-ink); outline-offset: 1px; transform: scale(1.1); }
.tr-key.tr-hit { transform: scale(.9); }
.tr-key.tr-miss { background: #ef9a92 !important; }
.tr-kb-pick .tr-key.off { opacity: .35; cursor: default; }
.tr-kb-pick .tr-key.picked { outline: 3px solid var(--tr-ink); outline-offset: 1px; }
.tr-kb-pick .tr-key { width: 2.1rem; height: 2.1rem; font-size: .8125rem; }
.tr-kb-pick .tr-space { width: 11rem; } .tr-kb-pick .tr-shift, .tr-kb-pick .tr-enter { display: none; }
.tr-pickwrap { display: flex; flex-direction: column; }
.tr-heat .tr-key { background: var(--tr-panel); color: var(--tr-ink); }
.tr-heat .h-1 { background: #f19c94; color: #1f2a44; } .tr-heat .h-2 { background: #f8c98a; color: #1f2a44; } .tr-heat .h-3 { background: #d6e8a0; color: #1f2a44; } .tr-heat .h-4 { background: #8fd3a5; color: #1f2a44; }
.tr-heat .h-none { opacity: .55; }

/* results */
.tr-result { padding: var(--s4) 0 var(--s2); }
.tr-result[hidden] { display: none; }
.tr-res-stats { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s6); align-items: flex-end; }
.tr-res-stats div { display: flex; flex-direction: column; }
.tr-res-stats b { font-family: var(--font-kid); font-size: 2.25rem; line-height: 1.1; }
.tr-res-stats .big b { font-size: 4rem; color: var(--link); }
html[data-tr-theme="dark"] .tr-res-stats .big b { color: #ffd23f; }
.tr-res-stats span { font-size: var(--fs-small); color: var(--tr-soft); font-weight: 600; }
.tr-res-msg { font-size: 1.125rem; font-weight: 600; margin: var(--s3) 0; }
.tr-chart svg { width: 100%; height: auto; color: var(--link); overflow: visible; }
html[data-tr-theme="dark"] .tr-chart svg { color: #ffd23f; }
.tr-chart text { font: 600 11px var(--font-body); fill: var(--tr-soft); }
.tr-chart[hidden] { display: none; }
.tr-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }

/* progress */
.tr-progress { padding-top: var(--s3); }
.tr-progress[hidden] { display: none; }
.tr-progress h3 { margin: var(--s5) 0 var(--s2); font-size: 1.125rem; }
.tr-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: var(--s2); margin-top: var(--s3); }
.tr-tile { background: var(--tr-panel); border-radius: 12px; padding: var(--s3); display: flex; flex-direction: column; }
.tr-tile b { font-family: var(--font-kid); font-size: 1.875rem; line-height: 1.1; }
.tr-tile span { font-size: var(--fs-small); color: var(--tr-soft); font-weight: 600; }
.tr-goalrow { display: flex; align-items: center; gap: var(--s3); }
.tr-ring { --p: 0; width: 3.5rem; height: 3.5rem; border-radius: 50%; background: conic-gradient(#2e9d5b calc(var(--p) * 1%), var(--tr-panel) 0); display: inline-grid; place-items: center; position: relative; flex: none; }
.tr-ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--tr-bg); }
.tr-ring b { position: relative; font-size: .8125rem; }
.tr-ring.sm { width: 1.25rem; height: 1.25rem; } .tr-ring.sm::before { inset: 3px; }
.tr-legend { font-size: var(--fs-small); color: var(--tr-soft); display: flex; gap: var(--s3); flex-wrap: wrap; }
.tr-legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; background: currentColor; }
circle.m-learn, .tr-legend .m-learn { fill: #2e9d5b; color: #2e9d5b; } circle.m-practice, .tr-legend .m-practice { fill: #e08a00; color: #e08a00; }
circle.m-test, .tr-legend .m-test { fill: #2f6fd6; color: #2f6fd6; } circle.m-code, .tr-legend .m-code { fill: #8a4fd0; color: #8a4fd0; } circle.m-custom, .tr-legend .m-custom { fill: #c2185b; color: #c2185b; }
.tr-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: var(--s4); }
.tr-bis { margin: 0; padding-left: 1.4rem; } .tr-bis li { margin: 3px 0; } .tr-bis b { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.125rem; margin-right: 8px; }
.tr-fingers { list-style: none; padding: 0; margin: 0; } .tr-fingers li { display: grid; grid-template-columns: 1fr 5rem 3.5rem; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--tr-line); font-size: .9375rem; }
.tr-fingers span { border-radius: 6px; padding: 0 8px; color: #1f2a44; width: fit-content; }
.tr-badges { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: var(--s2); }
.tr-badges li { background: var(--tr-panel); border-radius: 12px; padding: var(--s3); display: flex; flex-direction: column; gap: 2px; opacity: .5; filter: grayscale(1); }
.tr-badges li.got { opacity: 1; filter: none; }
.tr-badges span { font-size: 1.75rem; } .tr-badges small { color: var(--tr-soft); font-size: .8125rem; }
.tr-empty { color: var(--tr-soft); font-size: var(--fs-small); }

/* custom */
.tr-custom { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s3); }
.tr-custom[hidden] { display: none; }
.tr-custom label { font-weight: 700; font-size: var(--fs-small); }
.tr-custom textarea { width: 100%; min-height: 8rem; resize: vertical; }
.tr-custom .btn { align-self: flex-start; }

/* modals */
.tr-modal { position: fixed; inset: 0; background: rgba(15, 20, 35, .5); display: grid; place-items: center; z-index: 50; padding: var(--s3); }
.tr-modal[hidden] { display: none; }
.tr-card { position: relative; background: var(--tr-bg); color: var(--tr-ink); border-radius: var(--radius); padding: var(--s5); width: min(32rem, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.tr-card h2 { margin-top: 0; }
.tr-x { position: absolute; top: 10px; right: 12px; font-size: 1.75rem; line-height: 1; background: none; border: 0; color: var(--tr-soft); cursor: pointer; width: 44px; height: 44px; }
.tr-plist { list-style: none; padding: 0; margin: var(--s3) 0; display: flex; flex-direction: column; gap: 6px; }
.tr-pbtn { width: 100%; display: flex; align-items: center; gap: 10px; font: 700 1.0625rem var(--font-body); color: var(--tr-ink); background: var(--tr-panel); border: 2px solid transparent; border-radius: 12px; padding: 8px 12px; cursor: pointer; text-align: left; }
.tr-pbtn.on { border-color: var(--tr-ink); }
.tr-pbtn small { font-weight: 600; color: var(--tr-soft); }
.tr-pform { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s3); border-top: 1px solid var(--tr-line); padding-top: var(--s3); }
.tr-pform[hidden] { display: none; }
.tr-pform > label:first-child, .tr-label { font-weight: 700; font-size: var(--fs-small); margin: 0; }
.tr-avatars { display: flex; flex-wrap: wrap; gap: 6px; }
.tr-avbtn { font-size: 1.5rem; width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 2px solid transparent; background: var(--tr-panel); cursor: pointer; }
.tr-avbtn.on { border-color: var(--tr-ink); }
.tr-pform .btn { align-self: flex-start; }
.tr-form { display: flex; flex-direction: column; gap: var(--s2); }
.tr-form > label:not(.tr-check) { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); font-weight: 600; }
.tr-file { position: relative; overflow: hidden; } .tr-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.tr-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2a44; color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600; z-index: 60; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 90vw; text-align: center; }
.tr-toast[hidden] { display: none; }
.tr-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }
.tr-kid .tr-text { font-family: var(--font-kid); }

@media (max-width: 640px) {
  .tr { padding: var(--s2) var(--s3) var(--s3); }
  .tr-goal { margin-left: 0; width: 100%; }
  .tr-key { width: 1.85rem; height: 2.1rem; font-size: .8125rem; border-radius: 5px; } .tr-krow, .tr-kb { gap: 3px; }
  .tr-space { width: 9rem; } .tr-shift, .tr-enter { width: 3rem; }
  .tr-kr1 { margin-left: .8rem; } .tr-kr2 { margin-left: 1.3rem; }
  .tr-res-stats .big b { font-size: 3rem; }
}
@media (prefers-reduced-motion: reduce) { .tr-caret, .tr-ghost, .tr-key { transition: none; } .tr-shake { animation: none; } .tr:not(.tr-focused) .tr-caret { animation: none; } }
html[data-tr-theme="dark"] .tr-link { color: #9cc2ff; } html[data-tr-theme="dark"] .tr-link.tr-danger { color: var(--tr-bad); }
