/* KeyBridge styles. System fonts only, so nothing is downloaded (offline). */
:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #17233b;
  --muted: #5b6577;
  --line: #d9d5cb;
  --brand: #1f5f8b;
  --brand-ink: #ffffff;
  --ok: #1d7a46;
  --bad: #c0392b;
  --fix: #b9770e;
  --focus: #f2a900;
  --base: 17px;
  /* finger colours */
  --lp: #f4c7c3; --lr: #f9dfb4; --lm: #fff3b0; --li: #c8ecc4;
  --ri: #bfe3f0; --rm: #cdd5f5; --rr: #e3cdf2; --rp: #f5cde2; --th: #e4e4e4;
}
html[data-size="small"] { --base: 15px; }
html[data-size="large"] { --base: 20px; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: var(--base)/1.5 system-ui, -apple-system, "Segoe UI", Ubuntu, Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.4em; }
h2 { font-size: 1.2em; }
h3 { font-size: 1.05em; }
p { margin: 0 0 .8em; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 20px 24px 48px; }
.wrap.narrow { max-width: 620px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.note { background: #e7f0f6; border-left: 4px solid var(--brand); padding: 10px 14px; border-radius: 6px; }
.err { color: var(--bad); min-height: 1.2em; }

button, .filebtn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 10px 16px; min-height: 44px; border-radius: 8px; cursor: pointer; }
button:hover, .filebtn:hover { border-color: var(--brand); }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.warn { background: var(--bad); border-color: var(--bad); color: #fff; }
button.ghost { background: transparent; border-color: transparent; color: var(--brand); }
button.small { min-height: 32px; padding: 4px 10px; font-size: .85em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.filebtn input { display: none; }

label { display: block; margin-bottom: 14px; font-weight: 600; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
input, select { display: block; width: 100%; margin-top: 6px; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input[type=checkbox] { width: auto; margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.card.big { padding: 24px; }
.card.danger { border-color: #e8b4ae; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-bottom: 18px; }
.bar h1 { margin: 0; text-align: center; }
.bar .who { justify-self: end; color: var(--muted); }
.bar > :first-child { justify-self: start; }

.brand { display: flex; gap: 14px; align-items: center; margin: 24px 0; }
.brand h1 { font-size: 1.8em; margin: 0; }
.brand p { margin: 0; color: var(--muted); }
.logo { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 800; font-size: 1.2em; }

.profiles { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 8px; }
.profile { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; padding: 12px 14px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--ri); font-weight: 700; }
.pin { margin-left: auto; font-size: .75em; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }
.foot { margin-top: 20px; }

.hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.hero .card { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.stat { background: var(--bg); padding: 8px 12px; border-radius: 8px; }

.unit h2 { margin-top: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.lesson { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; text-align: left; gap: 2px 10px; padding: 12px; }
.lid { grid-row: span 2; font-weight: 700; color: var(--brand); }
.stars { color: var(--fix); letter-spacing: 2px; }
.stars.big { font-size: 2.4em; text-align: center; margin: 0; }

/* Typing screen */
.meters { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; margin-bottom: 14px; color: var(--muted); }
.meters b { color: var(--ink); font-size: 1.3em; font-variant-numeric: tabular-nums; }
.target { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 18px 22px; font: 1.45em/1.8 ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", Menlo, monospace; max-height: 8.4em; overflow: hidden; white-space: pre-wrap; word-break: break-word; position: relative; }
.target:focus { border-color: var(--brand); outline: none; }
.target span.ok { color: var(--ok); }
.target span.fixed { color: var(--fix); }
.target span.bad { background: #f6d5d1; }
.target span.cur { background: var(--focus); color: #000; border-radius: 3px; }
.hint { text-align: center; min-height: 1.5em; margin: 10px 0; font-weight: 600; }

.kb { max-width: 820px; margin: 0 auto 10px; display: grid; gap: 6px; user-select: none; }
.kr { display: flex; gap: 6px; justify-content: center; }
.k { flex: 0 0 auto; min-width: 46px; height: 46px; display: grid; place-items: center; border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 7px; background: #fbfbfb; font-size: .9em; transition: transform .08s; }
.k.wide { min-width: 70px; } .k.wider { min-width: 84px; } .k.widest { min-width: 104px; }
.k.space { min-width: 340px; }
.k.f-lp { background: var(--lp); } .k.f-lr { background: var(--lr); } .k.f-lm { background: var(--lm); } .k.f-li { background: var(--li); }
.k.f-ri { background: var(--ri); } .k.f-rm { background: var(--rm); } .k.f-rr { background: var(--rr); } .k.f-rp { background: var(--rp); } .k.f-th { background: var(--th); }
.k.next { outline: 3px solid var(--brand); transform: translateY(-2px); font-weight: 800; }
.k.wrong { outline: 3px solid var(--bad); }
.k[data-k="f"], .k[data-k="j"] { text-decoration: underline; }

/* Results */
.result { text-align: center; }
.level { font-size: 2.2em; font-weight: 800; color: var(--brand); margin: 0 0 10px; }
.nums { display: flex; justify-content: center; gap: 28px; margin: 10px 0 18px; flex-wrap: wrap; }
.nums div { display: grid; }
.nums b { font-size: 2em; font-variant-numeric: tabular-nums; }
.nums span { color: var(--muted); font-size: .85em; }
.nums.wide { justify-content: space-between; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 24px; }
.result .row { justify-content: center; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { font-size: .85em; color: var(--muted); }
.r { text-align: right; font-variant-numeric: tabular-nums; }

.chart { width: 100%; height: auto; }
.chart .axis { stroke: var(--line); }
.chart .l { fill: none; stroke-width: 2.5; }
.chart .l.wpm { stroke: var(--brand); }
.chart .l.acc { stroke: var(--ok); stroke-dasharray: 5 4; }
.chart .d.wpm { fill: var(--brand); }
.chart .lbl { font-size: 13px; }
.chart .lbl.wpm { fill: var(--brand); }
.chart .lbl.acc { fill: var(--ok); }

.keys { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.cap { display: inline-grid; place-items: center; min-width: 40px; height: 40px; border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 7px; font-weight: 700; font-family: ui-monospace, monospace; }
.keys small { color: var(--muted); margin-left: -8px; }

.modal { position: fixed; inset: 0; background: rgba(20, 25, 35, .45); display: grid; place-items: center; padding: 20px; }
.modal .card { max-width: 420px; }
.prose h2 { margin-top: 1em; }

@media (max-width: 760px) {
  .kb { display: none; }
  .bar { grid-template-columns: auto 1fr; }
  .bar .who { grid-column: 1 / -1; justify-self: start; }
}
@media (prefers-reduced-motion: reduce) { .k { transition: none; } }

/* ---- Hands with the active finger highlighted ---- */
.hands { display: block; width: 100%; max-width: 520px; margin: 4px auto 8px; }
.hands.big { max-width: 600px; }
.hands .palm { fill: #f1e2d3; stroke: #c9b29a; stroke-width: 1.5; }
.hands .fg rect { stroke: #c9b29a; stroke-width: 1.5; }
.hands .fg[data-f="lp"] rect { fill: var(--lp); } .hands .fg[data-f="lr"] rect { fill: var(--lr); }
.hands .fg[data-f="lm"] rect { fill: var(--lm); } .hands .fg[data-f="li"] rect { fill: var(--li); }
.hands .fg[data-f="ri"] rect { fill: var(--ri); } .hands .fg[data-f="rm"] rect { fill: var(--rm); }
.hands .fg[data-f="rr"] rect { fill: var(--rr); } .hands .fg[data-f="rp"] rect { fill: var(--rp); }
.hands .fg[data-f="th"] rect { fill: var(--th); }
.hands .fg text { font: 700 15px system-ui, sans-serif; fill: var(--ink); }
.hands .fg.on rect { fill: var(--brand); stroke: #0e3a57; stroke-width: 3; }
.hands .fg.on text { fill: #fff; }
.hands .hl { font: 13px system-ui, sans-serif; fill: var(--muted); }

/* ---- Lesson intro ---- */
.newkeys { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 18px; }
.nk { display: flex; gap: 16px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-left: 8px solid var(--line); border-radius: 12px; padding: 16px; }
.nk p { margin: 4px 0 0; }
.nk.f-lp { border-left-color: var(--lp); } .nk.f-lr { border-left-color: var(--lr); } .nk.f-lm { border-left-color: var(--lm); } .nk.f-li { border-left-color: var(--li); }
.nk.f-ri { border-left-color: var(--ri); } .nk.f-rm { border-left-color: var(--rm); } .nk.f-rr { border-left-color: var(--rr); } .nk.f-rp { border-left-color: var(--rp); }
.cap.lg { min-width: 64px; height: 64px; font-size: 1.8em; flex: none; background: #fff; }
.cap.sm { min-width: 28px; height: 28px; font-size: .85em; vertical-align: middle; background: #fff; }
.tip { border-left: 6px solid var(--brand); }
.intro-visual { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 12px 6px; margin-bottom: 18px; }
.k.new { outline: 3px solid var(--brand); font-weight: 800; transform: translateY(-2px); }
.center-row { justify-content: center; margin-top: 8px; }
.level.sm { font-size: 1.5em; }

/* ---- Step dots ---- */
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; list-style: none; padding: 0; margin: 0 0 14px; counter-reset: st; }
.dots li { counter-increment: st; display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9em; }
.dots li::before { content: counter(st); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); font-weight: 700; font-size: .85em; }
.dots li.now { color: var(--ink); font-weight: 700; }
.dots li.now::before { border-color: var(--brand); color: var(--brand); }
.dots li.done::before { content: "\2713"; background: var(--ok); border-color: var(--ok); color: #fff; }
.dots.big li { font-size: 1em; }
.hint .cap.sm { margin-right: 4px; }
@media (max-width: 760px) { .hands { max-width: 360px; } }
.howto { max-width: 640px; margin: -4px auto 12px; text-align: center; background: #e7f0f6; border-radius: 8px; padding: 8px 14px; }

/* ---- Video guides ---- */
.guide { display: inline-flex; align-items: center; gap: 8px; font-size: .9em; padding: 6px 12px; min-height: 36px; border-color: var(--brand); color: var(--brand); background: #fff; font-weight: 600; vertical-align: middle; }
.play { display: inline-block; width: 0; height: 0; border-style: solid; border-width: 6px 0 6px 10px; border-color: transparent transparent transparent currentColor; }
.bar h1 .guide { margin-left: 8px; font-size: .55em; }
.video-modal { z-index: 10; }
.vcard { width: min(920px, 100%); max-width: none !important; }
.vhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.vhead h2 { margin: 0; }
.vcard video { display: block; width: 100%; border-radius: 8px; background: #000; margin: 10px 0; }
.vlist { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.vitem { width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; text-align: left; padding: 12px 14px; }
.vitem small { display: block; color: var(--muted); }
.vitem .play { color: var(--brand); }
.vnum { display: grid; place-items: center; min-width: 34px; height: 34px; border-radius: 8px; background: var(--brand); color: #fff; font-weight: 700; font-size: .85em; padding: 0 6px; }
.cap.lg.word { font-size: 1em; padding: 0 10px; }
.target span.spc { color: var(--muted); font-size: .8em; padding: 0 2px; }
.target span.spc.ok { color: var(--ok); }
.target span.spc.cur { color: #000; }
.logo-img { width: 72px; height: 72px; border-radius: 18px; box-shadow: 0 6px 18px rgba(15, 61, 94, .25); }
.lengths { border: 0; padding: 0; margin: 4px 0 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.lengths legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.len { margin: 0; font-weight: 600; }
.len > input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.len span { display: inline-grid; place-items: center; min-width: 74px; min-height: 44px; padding: 0 14px; border: 2px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
.len > input:checked + span { border-color: var(--brand); background: var(--brand); color: #fff; }
.len > input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.len.custom span { gap: 6px; display: inline-flex; align-items: center; }
.len.custom input[type=number] { display: inline-block; width: 76px; margin: 0; padding: 4px 8px; min-height: 32px; text-align: center; font-weight: 700; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.len.custom input:checked + span input[type=number] { color: var(--ink); }
#lenErr:empty { display: none; }
/* Hidden box that opens the phone or tablet keyboard while typing */
.touch-in { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; font-size: 16px; }
.touch-tip { font-size: .85em; margin-top: 6px; }
.install-slot:empty { display: none; }
/* Install card (website version) */
.install-card { display: grid; grid-template-columns: 64px 1fr auto; gap: 16px; align-items: start; border-left: 6px solid var(--brand); margin: 16px 0; }
.install-card img { border-radius: 14px; }
.install-card h2 { margin-bottom: 4px; }
.install-card p { margin: 0 0 8px; }
.ic-steps { background: var(--bg); border-radius: 8px; padding: 8px 12px; }
.install-card details { color: var(--muted); font-size: .92em; }
.install-card summary { cursor: pointer; color: var(--brand); font-weight: 600; margin-bottom: 6px; }
.install-card details p { margin: 4px 0; }
.btn-link { color: var(--brand); font-weight: 700; }
@media (max-width: 600px) { .install-card { grid-template-columns: 48px 1fr; } .install-card img { width: 48px; height: 48px; } .ic-close { grid-column: 1 / -1; justify-self: start; } }
