:root {
  --bg: #eef8ff;
  --bg-deep: #dcefff;
  --card: rgba(255, 255, 255, .94);
  --text: #12304c;
  --muted: #678097;
  --primary: #1597e5;
  --primary-dark: #0574bd;
  --primary-soft: #dff3ff;
  --success: #12805c;
  --success-soft: #e8fff5;
  --danger: #d44258;
  --danger-soft: #fff0f3;
  --warning: #b56a00;
  --line: #cde6f6;
  --code: #0b2337;
  --code-soft: #163b57;
  --shadow: 0 24px 70px rgba(23, 91, 138, .13);
  --shadow-small: 0 12px 34px rgba(23, 91, 138, .09);
  --radius: 26px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(circle at 8% 2%, rgba(62, 180, 255, .26), transparent 27rem),
    radial-gradient(circle at 92% 16%, rgba(124, 213, 255, .24), transparent 29rem),
    linear-gradient(145deg, var(--bg), var(--bg-deep));
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .3;
  background-image:
    linear-gradient(rgba(21, 151, 229, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21, 151, 229, .045) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, #000, transparent 66%);
}

button, a, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1, h2, p { margin-top: 0; }
h1, h2 { letter-spacing: -.045em; }
.hidden { display: none !important; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 12px;
  color: #fff;
  background: var(--text);
  font-weight: 850;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  width: min(1240px, calc(100% - 40px));
  min-height: 82px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { width: 218px; }
.brand img { display: block; width: 100%; height: auto; }
.header-actions { display: flex; align-items: center; gap: 20px; }
.text-link { color: var(--muted); font-size: 14px; font-weight: 850; }
.text-link:hover { color: var(--primary-dark); }

.button {
  min-height: 46px;
  padding: 12px 18px;
  border: 0;
  border-radius: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  line-height: 1;
  transition: transform .17s ease, box-shadow .17s ease, background .17s ease;
}
.button:hover { transform: translateY(-2px); }
.button:active { transform: translateY(0); }
.button-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 12px 25px rgba(21, 151, 229, .25);
}
.button-soft { color: var(--primary-dark); border: 1px solid rgba(21,151,229,.18); background: #e7f6ff; }
.button-plain { color: var(--text); border: 1px solid var(--line); background: #fff; }

main { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 70px; }
.intro {
  padding: 50px 0 34px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 38px;
}
.intro-copy { max-width: 760px; }
.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.intro h1 { margin-bottom: 18px; font-size: clamp(46px, 7vw, 76px); line-height: .96; }
.intro h1 strong {
  color: transparent;
  background: linear-gradient(135deg, var(--primary-dark), #39b7ff);
  background-clip: text;
  -webkit-background-clip: text;
}
.intro p { max-width: 700px; margin-bottom: 0; color: var(--muted); font-size: 18px; line-height: 1.65; }
.intro-tip {
  width: min(390px, 100%);
  padding: 17px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1px solid rgba(21,151,229,.16);
  border-radius: 20px;
  background: rgba(255,255,255,.72);
  box-shadow: var(--shadow-small);
}
.intro-tip > span { font-size: 30px; }
.intro-tip b, .intro-tip small { display: block; }
.intro-tip b { margin-bottom: 4px; font-size: 14px; }
.intro-tip small { color: var(--muted); font-size: 12px; line-height: 1.45; }

.trainer-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.course-panel, .work-panel {
  border: 1px solid rgba(205,230,246,.96);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.course-panel { padding: 18px; position: sticky; top: 18px; }
.work-panel { min-width: 0; padding: clamp(20px, 3vw, 32px); }

.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.mode-button {
  min-width: 0;
  padding: 13px 9px;
  border: 1px solid var(--line);
  border-radius: 17px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 8px;
  color: var(--text);
  background: rgba(247,252,255,.9);
  text-align: left;
}
.mode-button > span {
  grid-row: 1 / 3;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 950;
}
.mode-button b { align-self: end; font-size: 13px; }
.mode-button small { color: var(--muted); font-size: 10px; }
.mode-button.active { color: #fff; border-color: var(--primary); background: linear-gradient(135deg, var(--primary), var(--primary-dark)); box-shadow: 0 10px 22px rgba(21,151,229,.2); }
.mode-button.active > span { color: #fff; background: rgba(255,255,255,.17); }
.mode-button.active small { color: rgba(255,255,255,.76); }

.today-card {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(21,151,229,.2);
  border-radius: 16px;
  background: linear-gradient(145deg, #f2fbff, #fff);
}
.today-card.completed { border-color: #bdebd9; background: linear-gradient(145deg, var(--success-soft), #fff); }
.today-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.today-card-head span { color: var(--primary-dark); font-size: 10px; font-weight: 950; letter-spacing: .06em; text-transform: uppercase; }
.today-card-head b { padding: 4px 7px; border-radius: 999px; color: var(--success); background: var(--success-soft); font-size: 9px; }
.today-card p { margin: 7px 0 9px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.today-card .button { width: 100%; min-height: 34px; padding: 8px 10px; border-radius: 10px; font-size: 10px; }

.library-switch {
  margin-top: 13px;
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #edf7fd;
}
.library-button {
  min-height: 37px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 900;
}
.library-button.active { color: var(--primary-dark); background: #fff; box-shadow: 0 5px 15px rgba(26,91,134,.1); }

.course-heading { margin: 24px 2px 12px; display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.course-heading h2 { margin: 0; font-size: 25px; }
.course-progress {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 11px;
  font-weight: 900;
}
.lesson-list { max-height: min(55vh, 580px); padding-right: 3px; display: grid; gap: 8px; overflow: auto; scrollbar-color: #b7dff5 transparent; }
.lesson-button {
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 15px;
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: var(--text);
  background: transparent;
  text-align: left;
}
.lesson-button:hover { background: #f0f9ff; }
.lesson-button.active { border-color: rgba(21,151,229,.25); background: linear-gradient(135deg, #e5f6ff, #f8fdff); }
.lesson-button.locked { opacity: .67; }
.lesson-button.locked:hover { border-color: #f4d49a; background: #fff8e9; }
.lesson-button.locked .lesson-number { color: #8d6a27; background: #fff1cf; }
.lesson-number {
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 950;
}
.lesson-button.complete .lesson-number { color: var(--success); background: var(--success-soft); }
.lesson-copy { min-width: 0; }
.lesson-copy b, .lesson-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lesson-copy b { font-size: 13px; }
.lesson-copy small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.lesson-record { color: var(--primary-dark); font-size: 10px; font-weight: 900; }
.lesson-record.empty { color: #a5b5c3; }

.practice-heading { margin-bottom: 12px; }
.practice-mode-list { display: grid; gap: 7px; }
.practice-mode-button {
  width: 100%;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  display: grid;
  grid-template-columns: 35px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  color: var(--text);
  background: rgba(249,253,255,.9);
  text-align: left;
}
.practice-mode-button > span {
  grid-row: 1 / 3;
  width: 35px;
  height: 35px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--primary-soft);
  font-size: 17px;
}
.practice-mode-button b { align-self: end; font-size: 13px; }
.practice-mode-button small { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.25; }
.practice-mode-button.active { border-color: rgba(21,151,229,.42); background: linear-gradient(135deg, #e4f6ff, #fff); box-shadow: 0 7px 19px rgba(21,151,229,.09); }
.practice-mode-button.active > span { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.practice-options { margin-top: 13px; }
.practice-options > span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .07em; }
.option-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.option-buttons button {
  min-height: 34px;
  padding: 7px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: #fff;
  font-size: 10px;
  font-weight: 850;
}
.option-buttons button.active { color: #fff; border-color: var(--primary); background: var(--primary); }
.practice-summary { min-height: 34px; margin: 12px 1px 10px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.practice-start-button { width: 100%; min-height: 42px; font-size: 12px; }

.progress-panel { padding-bottom: 2px; }
.progress-summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.progress-summary-grid > div { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #f8fcff; }
.progress-summary-grid b, .progress-summary-grid span { display: block; }
.progress-summary-grid b { color: var(--primary-dark); font-size: 18px; }
.progress-summary-grid span { margin-top: 2px; color: var(--muted); font-size: 8px; font-weight: 850; text-transform: uppercase; }
.progress-block { margin-top: 14px; }
.progress-block h3 { margin: 0 0 7px; font-size: 12px; }
.progress-block-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.progress-block-heading > span { color: var(--muted); font-size: 8px; }
.weak-key-list { display: flex; flex-wrap: wrap; gap: 5px; }
.weak-key-list > b { min-width: 28px; padding: 6px 8px; border: 1px solid #f2bdc6; border-radius: 8px; color: var(--danger); background: var(--danger-soft); font-family: var(--mono); font-size: 10px; text-align: center; }
.typing-history-list, .typing-ranking-list { display: grid; gap: 5px; }
.typing-history-item, .typing-ranking-item { padding: 8px 9px; display: grid; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.typing-history-item { grid-template-columns: minmax(0, 1fr) auto; }
.typing-history-item b, .typing-history-item small { display: block; }
.typing-history-item b { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.typing-history-item small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.typing-history-item > span { color: var(--primary-dark); font-size: 10px; font-weight: 950; }
.typing-ranking-item { grid-template-columns: 24px minmax(0, 1fr) auto; font-size: 9px; }
.typing-ranking-item.me { border-color: rgba(21,151,229,.45); background: var(--primary-soft); }
.typing-ranking-place { color: var(--primary-dark); font-weight: 950; }
.typing-ranking-name { overflow: hidden; font-weight: 850; text-overflow: ellipsis; white-space: nowrap; }
.typing-ranking-points { color: var(--success); font-weight: 950; }
.ranking-rule, .empty-copy { color: var(--muted); font-size: 8px; line-height: 1.4; }
.ranking-rule { margin: 7px 0 0; }

.device-stats { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.device-stats div { min-width: 0; text-align: center; }
.device-stats b, .device-stats span { display: block; }
.device-stats b { color: var(--primary-dark); font-size: 17px; }
.device-stats span { margin-top: 2px; color: var(--muted); font-size: 8px; font-weight: 800; text-transform: uppercase; }

.work-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; }
.lesson-badge {
  display: inline-flex;
  margin-bottom: 9px;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 11px;
  font-weight: 900;
}
.work-heading h2 { margin-bottom: 7px; font-size: clamp(28px, 4vw, 40px); }
.work-heading p { margin-bottom: 0; color: var(--muted); line-height: 1.5; }
.work-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.icon-button {
  min-height: 42px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: #fff;
  font-size: 12px;
  font-weight: 850;
}
.icon-button:hover:not(:disabled) { color: var(--primary-dark); border-color: rgba(21,151,229,.4); }
.icon-button.danger { color: var(--danger); border-color: rgba(212,66,88,.25); background: var(--danger-soft); }
.icon-button.danger:hover:not(:disabled) { color: #ad2439; border-color: rgba(212,66,88,.5); }
.icon-button:disabled { opacity: .48; cursor: not-allowed; }

.live-stats { margin: 24px 0 15px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; }
.live-stat { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: rgba(248,252,255,.9); }
.live-stat b, .live-stat span { display: block; }
.live-stat b { font-size: clamp(19px, 2.7vw, 27px); letter-spacing: -.04em; }
.live-stat span { margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 800; }
.live-stat.primary { color: var(--primary-dark); background: var(--primary-soft); }
.progress-track { height: 7px; margin-bottom: 14px; border-radius: 999px; overflow: hidden; background: #e3eff6; }
.progress-track > div { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #48c1ff); transition: width .15s ease; }

.typing-stage {
  position: relative;
  min-height: 260px;
  padding: 17px clamp(17px, 2.8vw, 27px) 28px;
  border: 2px solid transparent;
  border-radius: 22px;
  overflow: hidden;
  color: #dbefff;
  background:
    radial-gradient(circle at 98% 0%, rgba(58,173,243,.17), transparent 26rem),
    linear-gradient(145deg, var(--code), #0a1d2e);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.045), 0 18px 42px rgba(8,33,53,.16);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.typing-stage.focused { border-color: rgba(67,190,255,.62); box-shadow: 0 0 0 4px rgba(21,151,229,.12), 0 20px 48px rgba(8,33,53,.2); }
.typing-stage.wrong-key { animation: wrong-flash .2s ease; }
@keyframes wrong-flash { 50% { border-color: #ff6d80; box-shadow: 0 0 0 4px rgba(255,84,106,.13); } }
.stage-toolbar { margin-bottom: 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: #8fb0c6; font-size: 11px; font-family: var(--font); font-weight: 800; }
.stage-toolbar span:first-child { display: inline-flex; align-items: center; gap: 7px; }
.stage-toolbar i { width: 7px; height: 7px; border-radius: 50%; background: #7f9aad; }
.typing-stage.focused .stage-toolbar i { background: #45d2a3; box-shadow: 0 0 0 5px rgba(69,210,163,.1); }
.typing-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #7894a8;
  font-family: var(--mono);
  font-size: clamp(17px, 2.15vw, 24px);
  font-weight: 650;
  line-height: 1.82;
  tab-size: 4;
}
.typing-text .correct { color: #eaf8ff; }
.typing-text .current {
  position: relative;
  color: #fff;
  background: rgba(51,179,247,.32);
  border-radius: 3px;
  box-shadow: inset 0 -2px #47c4ff;
}
.typing-text .current.space { min-width: .62em; display: inline-block; }
.typing-text .current.newline::after { content: "↵"; color: #54c9ff; }
.typing-text .pending { color: #718da2; }
.typing-input {
  position: absolute;
  width: 1px;
  height: 1px;
  left: 50%;
  bottom: 12px;
  padding: 0;
  border: 0;
  opacity: .01;
  resize: none;
  pointer-events: none;
}
.start-overlay, .pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  border: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  color: #fff;
  background: rgba(7,28,44,.86);
  backdrop-filter: blur(9px);
  text-align: center;
}
.start-overlay > span, .pause-overlay > span { margin-bottom: 2px; font-size: 38px; }
.start-overlay b, .pause-overlay b { font-size: 20px; }
.start-overlay small { color: #a9c7da; }
.start-overlay:hover { background: rgba(7,28,44,.8); }
.pause-overlay { display: flex; flex-direction: column; }
.pause-overlay .button { margin-top: 8px; }
.typing-hint { margin: 12px 3px 20px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.keyboard-wrap { padding: 17px; border: 1px solid var(--line); border-radius: 20px; background: rgba(247,252,255,.84); }
.keyboard-head { margin-bottom: 13px; display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.keyboard-head b { color: var(--primary-dark); font-weight: 950; }
.keyboard { max-width: 780px; margin: 0 auto; display: grid; gap: 6px; }
.key-row { display: flex; justify-content: center; gap: 5px; }
.key {
  width: clamp(27px, 4.1vw, 45px);
  height: clamp(29px, 4vw, 42px);
  border: 1px solid #c8deeb;
  border-bottom-width: 3px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #49677e;
  background: #fff;
  font-family: var(--mono);
  font-size: clamp(8px, 1.25vw, 11px);
  font-weight: 800;
  text-transform: uppercase;
  transition: .12s ease;
}
.key.wide { width: clamp(44px, 7vw, 76px); }
.key.space-key { width: min(42vw, 320px); }
.key.active { color: #fff; border-color: var(--primary-dark); background: linear-gradient(135deg, var(--primary), var(--primary-dark)); box-shadow: 0 6px 16px rgba(21,151,229,.28); transform: translateY(2px); }
.key.shift-active { color: var(--primary-dark); border-color: #70caff; background: var(--primary-soft); }
.key.finger-left-pinky, .key.finger-right-pinky { border-top-color: #ef8ea0; background: #fff8fa; }
.key.finger-left-ring, .key.finger-right-ring { border-top-color: #d6a463; background: #fffaf2; }
.key.finger-left-middle, .key.finger-right-middle { border-top-color: #7ebd75; background: #f8fff6; }
.key.finger-left-index, .key.finger-right-index { border-top-color: #62aee0; background: #f4fbff; }
.key.finger-thumb { border-top-color: #9b85d7; background: #faf8ff; }
.key.active { color: #fff; border-color: var(--primary-dark); background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }

.result-panel { margin-top: 20px; padding: 22px; border: 1px solid #bdebd9; border-radius: 22px; background: linear-gradient(135deg, #effff8, #fff); }
.result-copy { display: flex; align-items: center; gap: 15px; }
.result-icon { width: 48px; height: 48px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 16px; color: #fff; background: var(--success); font-size: 25px; font-weight: 950; }
.result-copy h2 { margin: 0 0 3px; font-size: 28px; }
.result-copy p { margin: 0; color: var(--muted); }
.result-grid { margin: 18px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.result-grid div { padding: 13px; border: 1px solid rgba(18,128,92,.14); border-radius: 15px; background: rgba(255,255,255,.8); }
.result-grid b, .result-grid span { display: block; }
.result-grid b { color: var(--success); font-size: 25px; }
.result-grid span { color: var(--muted); font-size: 10px; font-weight: 850; text-transform: uppercase; }
.quality-result { margin-bottom: 13px; padding: 12px; display: flex; align-items: center; gap: 11px; border: 1px solid rgba(21,151,229,.18); border-radius: 15px; background: rgba(255,255,255,.78); }
.quality-badge { width: 43px; height: 43px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 14px; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); font-size: 21px; font-weight: 950; }
.quality-result b { display: block; font-size: 13px; }
.quality-result p { margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.35; }
.result-actions { display: flex; flex-wrap: wrap; gap: 9px; }

.method-section { margin-top: 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.method-section > div { padding: 20px; border: 1px solid rgba(205,230,246,.9); border-radius: 22px; background: rgba(255,255,255,.68); }
.method-section span { width: 31px; height: 31px; margin-bottom: 13px; display: grid; place-items: center; border-radius: 10px; color: var(--primary-dark); background: var(--primary-soft); font-weight: 950; }
.method-section b { display: block; margin-bottom: 7px; }
.method-section p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.site-footer { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 22px 0 34px; border-top: 1px solid rgba(142,190,219,.42); display: flex; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 12px; font-weight: 800; }
.site-footer a:hover { color: var(--primary-dark); }
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(360px, calc(100% - 40px));
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--text);
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 850;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }

.access-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.access-modal-backdrop { position: absolute; inset: 0; border: 0; background: rgba(5,25,42,.68); backdrop-filter: blur(7px); }
.access-modal-card { position: relative; z-index: 1; width: min(500px, 100%); padding: 30px; border: 1px solid rgba(255,255,255,.58); border-radius: 25px; background: #fff; box-shadow: 0 30px 90px rgba(4,25,42,.3); }
.access-modal-card h2 { margin-bottom: 9px; font-size: 30px; }
.access-modal-card > p, .access-modal-card li { color: var(--muted); font-size: 13px; line-height: 1.55; }
.access-modal-card ul { margin: 14px 0 20px; padding-left: 20px; }
.access-modal-icon { width: 47px; height: 47px; margin-bottom: 14px; display: grid; place-items: center; border-radius: 15px; background: var(--primary-soft); font-size: 23px; }
.access-modal-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 11px; color: var(--muted); background: #eef7fc; font-size: 23px; }
.access-modal-actions { display: flex; flex-wrap: wrap; gap: 8px; }
body.modal-open { overflow: hidden; }

body.embed-mode {
  min-height: 0;
  background: transparent;
}
body.embed-mode::before,
body.embed-mode .site-header,
body.embed-mode .intro,
body.embed-mode .method-section,
body.embed-mode .site-footer { display: none; }
body.embed-mode main { width: 100%; margin: 0; padding: 0; }
body.embed-mode .trainer-layout { gap: 14px; }
body.embed-mode .course-panel,
body.embed-mode .work-panel { box-shadow: 0 12px 34px rgba(23,91,138,.08); }
body.embed-mode .course-panel { top: 0; }

/* Compact workstation inside the cabinet: the target and keyboard stay visible together. */
@media (min-width: 781px) {
  html.embed-document,
  html.embed-document body {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body.embed-mode main,
  body.embed-mode .trainer-layout {
    height: 100%;
    min-height: 0;
  }

  body.embed-mode .trainer-layout {
    align-items: stretch;
  }

  body.embed-mode .course-panel,
  body.embed-mode .work-panel {
    height: 100%;
    min-height: 0;
  }

  body.embed-mode .course-panel {
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #9dcfea transparent;
  }

  body.embed-mode .work-panel {
    position: relative;
    padding: 16px 19px;
    display: grid;
    grid-template-rows: auto auto auto minmax(190px, 1fr) auto auto;
    overflow: hidden;
  }

  body.embed-mode .work-heading {
    gap: 14px;
  }

  body.embed-mode .lesson-badge {
    margin-bottom: 5px;
    padding: 5px 9px;
  }

  body.embed-mode .work-heading h2 {
    margin-bottom: 3px;
    font-size: clamp(25px, 2.3vw, 34px);
  }

  body.embed-mode .work-heading p {
    font-size: 13px;
    line-height: 1.3;
  }

  body.embed-mode .icon-button {
    min-height: 36px;
    padding: 8px 10px;
    border-radius: 11px;
    font-size: 11px;
  }

  body.embed-mode .live-stats {
    margin: 10px 0 7px;
    gap: 6px;
  }

  body.embed-mode .live-stat {
    padding: 7px 9px;
    border-radius: 12px;
  }

  body.embed-mode .live-stat b {
    font-size: clamp(18px, 2vw, 23px);
  }

  body.embed-mode .live-stat span {
    margin-top: 1px;
    font-size: 8px;
  }

  body.embed-mode .progress-track {
    height: 5px;
    margin-bottom: 7px;
  }

  body.embed-mode .typing-stage {
    height: 100%;
    min-height: 0;
    padding: 11px 17px 14px;
    border-radius: 18px;
  }

  body.embed-mode .stage-toolbar {
    margin-bottom: 8px;
    font-size: 9px;
  }

  body.embed-mode .typing-text {
    font-size: clamp(15px, 1.45vw, 19px);
    line-height: 1.48;
  }

  body.embed-mode .typing-hint {
    margin: 6px 3px 7px;
    font-size: 10px;
    line-height: 1.3;
  }

  body.embed-mode .keyboard-wrap {
    padding: 8px 10px 9px;
    border-radius: 16px;
  }

  body.embed-mode .keyboard-head {
    margin-bottom: 6px;
    font-size: 8px;
  }

  body.embed-mode .keyboard {
    gap: 3px;
  }

  body.embed-mode .key-row {
    gap: 3px;
  }

  body.embed-mode .key {
    width: clamp(25px, 3.4vw, 39px);
    height: clamp(25px, 3vw, 32px);
    border-radius: 6px;
    font-size: clamp(7px, .9vw, 9px);
  }

  body.embed-mode .key.wide {
    width: clamp(42px, 6vw, 66px);
  }

  body.embed-mode .key.space-key {
    width: min(38vw, 270px);
  }

  body.embed-mode .result-panel {
    position: absolute;
    inset: 16px 19px;
    z-index: 8;
    margin: 0;
    overflow-y: auto;
    box-shadow: 0 24px 70px rgba(8, 33, 53, .24);
  }
}

@media (max-width: 1020px) {
  .trainer-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .course-panel { padding: 14px; }
  .device-stats { grid-template-columns: 1fr; gap: 9px; }
  .device-stats div { display: flex; align-items: baseline; justify-content: space-between; text-align: left; }
  .device-stats span { margin: 0; }
  .live-stats { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 780px) {
  .site-header { min-height: 70px; }
  .brand { width: 180px; }
  .text-link { display: none; }
  .header-actions .button { min-height: 40px; padding: 10px 13px; font-size: 12px; }
  .intro { padding: 34px 0 24px; display: grid; }
  .intro h1 { font-size: clamp(42px, 13vw, 62px); }
  .intro p { font-size: 16px; }
  .trainer-layout { grid-template-columns: 1fr; }
  .course-panel { position: static; }
  .lesson-list { max-height: none; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .device-stats { grid-template-columns: repeat(3, 1fr); }
  .device-stats div { display: block; text-align: center; }
  .work-heading { display: grid; }
  .work-actions { width: 100%; }
  .work-actions .icon-button { flex: 1; }
  .typing-stage { min-height: 230px; }
  .keyboard-wrap { display: none; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .method-section { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .site-header, main, .site-footer { width: min(100% - 24px, 1240px); }
  .brand { width: 158px; }
  .intro-tip { width: 100%; }
  .mode-switch { gap: 7px; }
  .lesson-list { grid-template-columns: 1fr; }
  .lesson-button { padding: 10px; }
  .device-stats { grid-template-columns: repeat(3, 1fr); }
  .work-panel { padding: 16px; border-radius: 22px; }
  .live-stats { grid-template-columns: repeat(2, 1fr); }
  .live-stat:last-child { grid-column: 1 / -1; }
  .typing-stage { min-height: 260px; padding: 14px 14px 24px; }
  .typing-text { font-size: 16px; line-height: 1.75; }
  .stage-toolbar { align-items: flex-start; flex-direction: column; }
  .start-overlay { padding: 20px; }
  .result-actions .button { width: 100%; }
  .access-modal-card { padding: 24px 20px; }
  .access-modal-actions .button { width: 100%; }
  .site-footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
