:root {
  --paper: #f7f9f8;
  --canvas: #eaf0ee;
  --ink: #172220;
  --ink-soft: #52615d;
  --groove: #c6d0cc;
  --groove-dark: #aebbb6;
  --pinky: #b52d5a;
  --pinky-dark: #8f2046;
  --pinky-wash: #f5dce5;
  --confirm: #17685c;
  --confirm-wash: #dcece8;
  --error: #a63a32;
  --error-wash: #f5dfdc;
  --key-shadow: #9eaca7;
  --white: #ffffff;
  --display: "Bahnschrift SemiCondensed", "Arial Narrow", "BIZ UDPGothic", sans-serif;
  --body: "BIZ UDPGothic", "Yu Gothic UI", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  --utility: "Bahnschrift", "Segoe UI", sans-serif;
  --radius: 10px;
  --shadow-key: 0 5px 0 var(--key-shadow);
  --shadow-small: 0 3px 0 var(--key-shadow);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 34, 32, 0.025) 1px, transparent 1px),
    var(--canvas);
  background-size: 100% 32px;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button,
input,
select,
dialog {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 16px;
  color: var(--white);
  background: var(--ink);
  border-radius: 4px;
  transform: translateY(-150%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(100% - 40px, 1460px);
  min-height: 100vh;
  margin: 0 auto;
}

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  border-bottom: 1px solid var(--groove-dark);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  padding: 6px;
  margin: 0;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 4px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 25px);
  gap: 3px;
  padding-bottom: 3px;
}

.brand-mark > span {
  display: grid;
  min-height: 28px;
  place-items: center;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--groove-dark);
  border-radius: 4px;
  box-shadow: 0 3px 0 var(--groove-dark);
  font-family: var(--utility);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.brand-mark > span:nth-child(2),
.brand-mark > span:nth-child(3) {
  color: var(--white);
  background: var(--pinky);
  border-color: var(--pinky-dark);
  box-shadow: 0 3px 0 var(--pinky-dark);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-copy strong {
  font-family: var(--utility);
  font-size: 20px;
  letter-spacing: 0.13em;
}

.brand-copy small {
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.topbar-actions {
  display: flex;
  gap: 22px;
  align-items: center;
}

.today-mini {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding-right: 22px;
  border-right: 1px solid var(--groove-dark);
  font-family: var(--utility);
  line-height: 1;
}

.today-mini > span {
  color: var(--ink-soft);
  font-family: var(--body);
  font-size: 12px;
  font-weight: 700;
}

.today-mini strong {
  font-size: 20px;
}

.today-mini small {
  margin-left: 3px;
  color: var(--ink-soft);
  font-size: 11px;
}

.icon-button {
  min-width: 52px;
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--groove-dark);
  border-radius: 5px;
  box-shadow: var(--shadow-small);
  font-size: 12px;
  font-weight: 700;
}

.icon-button:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

.icon-button:active {
  box-shadow: 0 1px 0 var(--key-shadow);
  transform: translateY(2px);
}

.view {
  animation: view-in 260ms ease both;
}

.home-view {
  padding: 48px 0 84px;
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(310px, 0.78fr);
  gap: 20px;
  align-items: stretch;
}

.hero-panel,
.daily-panel {
  background: var(--paper);
  border: 1px solid var(--groove-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow-key);
}

.hero-panel {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 590px;
  overflow: hidden;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  max-width: 850px;
  padding: clamp(48px, 6vw, 92px);
}

.eyebrow {
  margin: 0 0 17px;
  color: var(--pinky);
  font-family: var(--utility);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
  line-height: 1.2;
}

.hero-copy h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(58px, 6.2vw, 100px);
  font-stretch: condensed;
  font-weight: 700;
  letter-spacing: -0.07em;
  line-height: 0.98;
}

.hero-copy h1 span {
  position: relative;
  z-index: 0;
  white-space: nowrap;
}

.hero-copy h1 span::after {
  position: absolute;
  z-index: -1;
  right: -0.04em;
  bottom: 0.04em;
  left: 0.02em;
  height: 0.18em;
  background: var(--pinky-wash);
  border-bottom: 3px solid var(--pinky);
  content: "";
}

.hero-lead {
  max-width: 660px;
  margin: 34px 0 0;
  color: var(--ink-soft);
  font-size: clamp(15px, 1.4vw, 18px);
  font-weight: 600;
  line-height: 1.85;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  align-items: center;
  margin-top: 40px;
}

.primary-button {
  display: inline-flex;
  gap: 36px;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 11px 14px 11px 22px;
  color: var(--white);
  background: var(--pinky);
  border: 1px solid var(--pinky-dark);
  border-radius: 7px;
  box-shadow: 0 5px 0 var(--pinky-dark);
  font-weight: 800;
  line-height: 1.25;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.primary-button > span {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.primary-button small {
  margin-bottom: 3px;
  color: #f8dfe8;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.primary-button kbd {
  display: grid;
  min-width: 44px;
  height: 42px;
  padding: 0 9px;
  place-items: center;
  color: var(--ink);
  background: var(--white);
  border: 1px solid #f5cad9;
  border-radius: 4px;
  box-shadow: 0 2px 0 #f5cad9;
  font-family: var(--utility);
  font-size: 18px;
}

.primary-button:hover {
  background: #c63163;
  transform: translateY(-2px);
}

.primary-button:active {
  box-shadow: 0 2px 0 var(--pinky-dark);
  transform: translateY(3px);
}

.text-button {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding: 4px 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--groove-dark);
  font-size: 14px;
  font-weight: 800;
}

.text-button span {
  color: var(--pinky);
  font-family: var(--utility);
  font-size: 18px;
  transition: transform 140ms ease;
}

.text-button:hover {
  border-bottom-color: var(--pinky);
}

.text-button:hover span {
  transform: translateX(4px);
}

.hero-key-sequence {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 25px;
  align-items: center;
  min-height: 112px;
  padding: 24px clamp(34px, 5vw, 76px);
  color: var(--white);
  background: var(--ink);
}

.sequence-label {
  color: #91a39e;
  font-family: var(--utility);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  writing-mode: vertical-rl;
}

.sequence-keys {
  display: flex;
  gap: 10px;
  align-items: center;
}

.sequence-keys > span {
  color: #91a39e;
  font-family: var(--utility);
  font-size: 12px;
}

.sequence-keys kbd {
  display: grid;
  min-width: 43px;
  height: 43px;
  padding: 0 12px;
  place-items: center;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #71827d;
  border-radius: 4px;
  box-shadow: 0 3px 0 #71827d;
  font-family: var(--utility);
  font-weight: 800;
}

.sequence-keys .wide-key {
  min-width: 76px;
}

.hero-key-sequence p {
  justify-self: end;
  margin: 0;
  color: #bdcac6;
  font-size: 13px;
}

.daily-panel {
  display: flex;
  flex-direction: column;
  padding: 34px;
}

.panel-heading,
.section-heading,
.keyboard-heading,
.dialog-heading {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
}

.panel-heading h2,
.section-heading h2,
.keyboard-heading h2,
.dialog-heading h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 27px;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.panel-heading .eyebrow,
.section-heading .eyebrow,
.keyboard-heading .eyebrow,
.dialog-heading .eyebrow {
  margin-bottom: 8px;
}

.local-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  color: var(--confirm);
  background: var(--confirm-wash);
  border: 1px solid #b6d6ce;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 800;
}

.daily-progress {
  padding: 34px 0;
  margin-top: 28px;
  border-top: 1px solid var(--groove);
  border-bottom: 1px solid var(--groove);
}

.progress-copy {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
}

.progress-copy strong {
  font-family: var(--utility);
  font-size: 46px;
  letter-spacing: -0.04em;
  line-height: 1;
}

.progress-copy small {
  margin-left: 4px;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0;
}

.progress-copy > span {
  max-width: 145px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
}

.progress-track,
.session-progress {
  height: 6px;
  overflow: hidden;
  background: #d5ddda;
  border-radius: 99px;
}

.progress-track span,
.session-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--pinky);
  border-radius: inherit;
  transition: width 360ms ease;
}

.stat-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 0;
  margin: 28px 0 0;
}

.stat-list > div {
  padding: 0 14px;
  border-right: 1px solid var(--groove);
}

.stat-list > div:first-child {
  padding-left: 0;
}

.stat-list > div:last-child {
  padding-right: 0;
  border-right: 0;
}

.stat-list dt {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.stat-list dd {
  margin: 7px 0 0;
  font-family: var(--utility);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.stat-list dd small {
  margin-left: 2px;
  color: var(--ink-soft);
  font-family: var(--body);
  font-size: 10px;
}

.focus-note,
.result-insight {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  padding-top: 25px;
  margin-top: auto;
}

.focus-key {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  color: var(--white);
  background: var(--pinky);
  border: 1px solid var(--pinky-dark);
  border-radius: 5px;
  box-shadow: 0 4px 0 var(--pinky-dark);
  font-family: var(--utility);
  font-size: 21px;
  font-weight: 800;
}

.focus-note small,
.result-insight small {
  display: block;
  margin-bottom: 3px;
  color: var(--pinky);
  font-size: 10px;
  font-weight: 800;
}

.focus-note strong,
.result-insight strong {
  display: block;
  font-size: 14px;
}

.focus-note p,
.result-insight p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.6;
}

.mode-section {
  padding-top: 78px;
}

.section-heading {
  align-items: flex-end;
  margin-bottom: 26px;
}

.section-heading h2 {
  font-size: clamp(30px, 3vw, 43px);
}

.section-heading > p {
  max-width: 460px;
  margin: 0 0 5px;
  color: var(--ink-soft);
  font-size: 13px;
  text-align: right;
}

.mode-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--groove-dark);
  border-left: 1px solid var(--groove-dark);
}

.mode-card {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  min-height: 190px;
  padding: 30px 56px 30px 28px;
  text-align: left;
  background: rgba(247, 249, 248, 0.7);
  border: 0;
  border-right: 1px solid var(--groove-dark);
  border-bottom: 1px solid var(--groove-dark);
  transition:
    background 180ms ease,
    color 180ms ease;
}

.mode-card:hover,
.mode-card:focus-visible {
  z-index: 1;
  color: var(--white);
  background: var(--ink);
}

.mode-index {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--pinky);
  border: 1px solid var(--pinky);
  border-radius: 50%;
  font-family: var(--utility);
  font-size: 12px;
  font-weight: 800;
}

.mode-card:hover .mode-index,
.mode-card:focus-visible .mode-index {
  color: var(--white);
  background: var(--pinky);
}

.mode-card-copy {
  display: flex;
  flex-direction: column;
}

.mode-card-copy small {
  margin-bottom: 5px;
  color: var(--pinky);
  font-size: 10px;
  font-weight: 800;
}

.mode-card-copy strong {
  font-family: var(--display);
  font-size: 23px;
  letter-spacing: -0.02em;
}

.mode-card-copy > span {
  max-width: 430px;
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.7;
}

.mode-card:hover .mode-card-copy > span,
.mode-card:focus-visible .mode-card-copy > span {
  color: #b9c6c2;
}

.mode-tags {
  display: flex;
  gap: 5px;
  align-items: center;
}

.mode-tags kbd {
  display: grid;
  min-width: 33px;
  height: 32px;
  padding: 0 8px;
  place-items: center;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--groove-dark);
  border-radius: 4px;
  box-shadow: 0 2px 0 var(--groove-dark);
  font-family: var(--utility);
  font-size: 11px;
  font-weight: 700;
}

.card-arrow {
  position: absolute;
  top: 20px;
  right: 22px;
  color: var(--pinky);
  font-family: var(--utility);
  font-size: 17px;
}

.footer {
  display: flex;
  justify-content: space-between;
  padding: 25px 0 30px;
  color: var(--ink-soft);
  border-top: 1px solid var(--groove-dark);
  font-family: var(--utility);
  font-size: 10px;
  letter-spacing: 0.08em;
}

/* Practice */
.practice-view {
  min-height: calc(100vh - 88px);
  padding: 28px 0 70px;
}

.session-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 58px;
}

.back-button {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  justify-self: start;
  min-height: 44px;
  padding: 0;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 800;
}

.back-button span {
  color: var(--pinky);
  font-family: var(--utility);
  font-size: 18px;
}

.back-button:hover {
  color: var(--ink);
}

.session-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.25;
}

.session-title small {
  color: var(--pinky);
  font-family: var(--utility);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.session-title strong {
  font-size: 15px;
}

.session-count {
  display: flex;
  gap: 7px;
  align-items: baseline;
  justify-self: end;
  font-family: var(--utility);
}

.session-count strong {
  font-size: 26px;
}

.session-count span {
  color: var(--ink-soft);
  font-size: 12px;
}

.session-progress {
  height: 4px;
  margin: 9px 0 32px;
}

.practice-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.55fr);
  gap: 20px;
  align-items: stretch;
  min-height: 620px;
}

.practice-layout.guide-hidden {
  grid-template-columns: minmax(0, 980px);
  justify-content: center;
}

.practice-layout.guide-hidden .keyboard-panel {
  display: none;
}

.exercise-stage,
.keyboard-panel {
  background: var(--paper);
  border: 1px solid var(--groove-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow-key);
}

.exercise-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: clamp(38px, 6vw, 88px);
  overflow: hidden;
}

.exercise-stage::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 7px;
  height: 100%;
  background: var(--pinky);
  content: "";
}

.challenge-meta {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 34px;
}

.challenge-type,
.ime-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 800;
}

.challenge-type {
  color: var(--pinky);
  background: var(--pinky-wash);
  border: 1px solid #e6b9c9;
}

.ime-status {
  gap: 7px;
  color: var(--ink-soft);
  background: var(--canvas);
  border: 1px solid var(--groove);
}

.ime-status i {
  width: 7px;
  height: 7px;
  background: var(--groove-dark);
  border: 1px solid currentColor;
  border-radius: 50%;
}

.ime-status.is-on {
  color: var(--confirm);
  background: var(--confirm-wash);
  border-color: #b6d6ce;
}

.ime-status.is-on i {
  background: var(--confirm);
}

.ime-status.is-ready {
  color: var(--pinky-dark);
  background: var(--pinky-wash);
  border-color: #e6b9c9;
}

.ime-status.is-ready i {
  background: var(--pinky);
}

.challenge-instruction {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.target-display {
  min-height: 1.6em;
  margin: 0;
  font-family: var(--body);
  font-size: clamp(31px, 3.7vw, 58px);
  font-weight: 700;
  letter-spacing: 0.025em;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.target-char {
  position: relative;
  display: inline;
  color: var(--ink);
  transition:
    color 100ms ease,
    background 100ms ease;
}

.target-char.is-typed {
  color: #596762;
  text-decoration: underline dotted var(--groove-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.target-char.is-current {
  color: var(--pinky-dark);
  background: var(--pinky-wash);
  box-shadow: inset 0 -3px 0 var(--pinky);
}

.target-char.is-wrong {
  color: var(--error);
  background: var(--error-wash);
  box-shadow: inset 0 -3px 0 var(--error);
}

.target-char.is-focus:not(.is-typed) {
  text-decoration: underline;
  text-decoration-color: var(--pinky);
  text-decoration-thickness: 3px;
  text-underline-offset: 7px;
}

.target-reading {
  min-height: 25px;
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-family: var(--utility);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.input-area {
  position: relative;
  margin-top: 42px;
}

.typing-input {
  width: 100%;
  height: 72px;
  padding: 0 126px 0 18px;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--groove-dark);
  border-radius: 6px;
  box-shadow: inset 0 -3px 0 #e2e8e6;
  font-size: 22px;
  font-weight: 700;
  transition:
    border-color 130ms ease,
    box-shadow 130ms ease,
    background 130ms ease;
}

.typing-input:focus {
  border-color: var(--ink);
}

.input-area.is-composing .typing-input {
  background: #f2f7f5;
  border-color: var(--confirm);
  box-shadow: inset 0 -3px 0 var(--confirm);
}

.input-area.is-ready .typing-input {
  background: var(--pinky-wash);
  border-color: var(--pinky);
  box-shadow: inset 0 -3px 0 var(--pinky);
}

.input-area.is-error .typing-input {
  background: var(--error-wash);
  border-color: var(--error);
  box-shadow: inset 0 -3px 0 var(--error);
  animation: input-nudge 170ms ease-in-out 2;
}

.input-end-key {
  position: absolute;
  top: 50%;
  right: 13px;
  display: grid;
  min-width: 88px;
  height: 42px;
  place-items: center;
  color: var(--ink-soft);
  background: var(--canvas);
  border: 1px solid var(--groove);
  border-radius: 4px;
  box-shadow: 0 2px 0 var(--groove);
  font-family: var(--utility);
  font-size: 10px;
  font-weight: 800;
  transform: translateY(-50%);
}

.input-area.is-ready .input-end-key {
  color: var(--white);
  background: var(--pinky);
  border-color: var(--pinky-dark);
  box-shadow: 0 2px 0 var(--pinky-dark);
}

.key-catcher {
  display: grid;
  grid-template-columns: auto minmax(86px, auto) auto;
  gap: 20px;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 148px;
  padding: 20px;
  color: var(--ink-soft);
  background: var(--white);
  border: 2px solid var(--groove-dark);
  border-radius: 7px;
  box-shadow: inset 0 -4px 0 #e2e8e6;
  font-size: 12px;
  font-weight: 700;
}

.key-catcher strong {
  display: grid;
  min-width: 86px;
  min-height: 76px;
  padding: 0 16px;
  place-items: center;
  color: var(--white);
  background: var(--pinky);
  border: 1px solid var(--pinky-dark);
  border-radius: 6px;
  box-shadow: 0 5px 0 var(--pinky-dark);
  font-family: var(--utility);
  font-size: 29px;
}

.key-catcher.is-correct strong {
  background: var(--confirm);
  border-color: #0f4e45;
  box-shadow: 0 2px 0 #0f4e45;
  transform: translateY(3px);
}

.key-catcher.is-error {
  color: var(--error);
  border-color: var(--error);
}

.input-area:has(.key-catcher:not([hidden])) .input-end-key {
  display: none;
}

.feedback-line {
  min-height: 26px;
  margin-top: 16px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.feedback-line.is-success {
  color: var(--confirm);
}

.feedback-line.is-error {
  color: var(--error);
}

.live-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding-top: 25px;
  margin-top: auto;
  border-top: 1px solid var(--groove);
}

.live-metrics > div {
  padding: 0 20px;
  border-right: 1px solid var(--groove);
}

.live-metrics > div:first-child {
  padding-left: 0;
}

.live-metrics > div:last-child {
  padding-right: 0;
  border-right: 0;
}

.live-metrics span {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
}

.live-metrics strong {
  font-family: var(--utility);
  font-size: 27px;
  line-height: 1;
}

.live-metrics small {
  margin-left: 2px;
  color: var(--ink-soft);
  font-size: 11px;
}

.keyboard-panel {
  display: flex;
  flex-direction: column;
  padding: 35px 28px 30px;
  background: #dfe7e4;
}

.keyboard-heading {
  align-items: flex-start;
}

.keyboard-heading h2 {
  font-size: 24px;
}

.hand-status {
  display: grid;
  min-width: 59px;
  height: 28px;
  place-items: center;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--groove-dark);
  border-radius: 3px;
  font-family: var(--utility);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.hand-status.is-active {
  color: var(--white);
  background: var(--pinky);
  border-color: var(--pinky-dark);
}

.keyboard-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(34px, 1fr)) minmax(53px, 1.35fr);
  grid-template-rows: repeat(4, minmax(54px, 1fr));
  gap: 7px;
  width: 100%;
  min-height: 275px;
  margin: auto 0;
  padding: 18px 0 22px;
}

.keyboard-grid kbd,
.key-spacer {
  position: relative;
  display: grid;
  min-width: 0;
  place-items: center;
  color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--groove-dark);
  border-radius: 5px;
  box-shadow: 0 4px 0 var(--groove-dark);
  font-family: var(--utility);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  transition:
    transform 100ms ease,
    box-shadow 100ms ease,
    background 100ms ease,
    color 100ms ease;
}

.keyboard-grid kbd small {
  position: absolute;
  right: 5px;
  bottom: 5px;
  font-size: 7px;
}

.keyboard-grid .focusable-key {
  color: var(--pinky-dark);
  background: #f9edf1;
  border-color: #d69ab0;
  box-shadow: 0 4px 0 #d69ab0;
}

.keyboard-grid .key-enter {
  grid-column: 7;
  grid-row: 2 / span 2;
}

.keyboard-grid .key-wide {
  grid-column: 7;
}

.keyboard-grid .key-shift {
  grid-column: 6 / span 2;
}

.keyboard-grid kbd.is-target {
  z-index: 2;
  color: var(--white);
  background: var(--pinky);
  border-color: var(--pinky-dark);
  box-shadow: 0 5px 0 var(--pinky-dark);
  transform: translateX(-10px) scale(1.04);
}

.keyboard-grid kbd.is-pressed {
  color: var(--white);
  background: var(--confirm);
  border-color: #0f4e45;
  box-shadow: 0 1px 0 #0f4e45;
  transform: translateY(3px);
}

.keyboard-grid kbd.is-error {
  color: var(--error);
  background: var(--error-wash);
  border: 2px double var(--error);
}

.finger-guide {
  display: grid;
  grid-template-columns: 4px 1fr;
  gap: 14px;
  align-items: stretch;
  padding-top: 22px;
  border-top: 1px solid var(--groove-dark);
}

.finger-guide > span {
  background: var(--pinky);
  border-radius: 4px;
}

.finger-guide p {
  margin: 0;
}

.finger-guide strong {
  display: block;
  font-size: 12px;
}

.finger-guide p > span {
  display: block;
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.6;
}

/* Results */
.result-view {
  display: grid;
  min-height: calc(100vh - 88px);
  padding: 55px 0 80px;
  place-items: center;
}

.result-sheet {
  width: min(100%, 910px);
  padding: clamp(36px, 6vw, 78px);
  background: var(--paper);
  border: 1px solid var(--groove-dark);
  border-top: 8px solid var(--pinky);
  border-radius: var(--radius);
  box-shadow: var(--shadow-key);
}

.result-heading {
  max-width: 680px;
}

.result-heading h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(40px, 5vw, 65px);
  letter-spacing: -0.055em;
  line-height: 1.1;
  white-space: pre-line;
}

.result-heading > p:last-child {
  margin: 17px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.result-score {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 45px;
  align-items: end;
  padding: 36px 0;
  margin-top: 34px;
  border-top: 1px solid var(--groove);
  border-bottom: 1px solid var(--groove);
}

.score-main span {
  display: block;
  margin-bottom: 8px;
  color: var(--pinky);
  font-size: 11px;
  font-weight: 800;
}

.score-main strong {
  font-family: var(--utility);
  font-size: clamp(64px, 8vw, 98px);
  letter-spacing: -0.07em;
  line-height: 0.8;
}

.score-main small {
  margin-left: 5px;
  color: var(--ink-soft);
  font-size: 22px;
}

.result-score dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 0;
  margin: 0;
}

.result-score dl > div {
  padding: 0 18px;
  border-right: 1px solid var(--groove);
}

.result-score dl > div:last-child {
  border-right: 0;
}

.result-score dt {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
}

.result-score dd {
  margin: 7px 0 0;
  font-family: var(--utility);
  font-size: 20px;
  font-weight: 800;
}

.result-insight {
  padding: 25px;
  margin-top: 30px;
  background: var(--canvas);
  border: 1px solid var(--groove);
  border-radius: 6px;
}

.result-insight .focus-key {
  width: 50px;
  height: 50px;
  font-size: 17px;
}

.result-insight p {
  max-width: 600px;
  font-size: 12px;
}

.result-actions {
  display: flex;
  gap: 28px;
  align-items: center;
  margin-top: 35px;
}

.primary-button--compact {
  min-width: 170px;
  min-height: 56px;
  padding: 8px 10px 8px 19px;
}

.primary-button--compact kbd {
  min-width: 35px;
  height: 34px;
  font-size: 12px;
}

/* Settings */
.settings-dialog {
  width: min(calc(100% - 32px), 590px);
  max-height: calc(100vh - 32px);
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 9px;
  box-shadow: 0 10px 0 rgba(23, 34, 32, 0.22);
}

.settings-dialog::backdrop {
  background: rgba(23, 34, 32, 0.58);
  backdrop-filter: blur(3px);
}

.settings-dialog form {
  padding: 32px;
}

.dialog-heading {
  align-items: flex-start;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--groove);
}

.dialog-close {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  background: var(--canvas);
  border: 1px solid var(--groove-dark);
  border-radius: 5px;
  font-family: var(--utility);
  font-size: 22px;
}

.setting-row,
.data-setting {
  display: flex;
  gap: 25px;
  align-items: center;
  justify-content: space-between;
  min-height: 84px;
  border-bottom: 1px solid var(--groove);
}

.setting-row > span,
.data-setting > span {
  display: flex;
  flex-direction: column;
}

.setting-row strong,
.data-setting strong {
  font-size: 13px;
}

.setting-row small,
.data-setting small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 10px;
}

.setting-row input[type="checkbox"] {
  position: relative;
  width: 50px;
  height: 28px;
  margin: 0;
  appearance: none;
  background: var(--groove-dark);
  border: 1px solid #95a49f;
  border-radius: 99px;
  cursor: pointer;
  transition: background 140ms ease;
}

.setting-row input[type="checkbox"]::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--paper);
  border: 1px solid #85958f;
  border-radius: 50%;
  content: "";
  transition: transform 140ms ease;
}

.setting-row input[type="checkbox"]:checked {
  background: var(--confirm);
  border-color: #0f4e45;
}

.setting-row input[type="checkbox"]:checked::after {
  transform: translateX(21px);
}

.setting-row select {
  min-width: 94px;
  height: 42px;
  padding: 0 30px 0 12px;
  background: var(--white);
  border: 1px solid var(--groove-dark);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.data-setting button {
  min-height: 40px;
  padding: 0 11px;
  color: var(--error);
  background: transparent;
  border: 1px solid #d8a29d;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
}

.data-setting button:hover {
  color: var(--white);
  background: var(--error);
  border-color: var(--error);
}

.primary-button--dialog {
  width: 100%;
  min-height: 54px;
  margin-top: 28px;
  justify-content: center;
}

.toast {
  position: fixed;
  z-index: 200;
  right: 24px;
  bottom: 24px;
  max-width: min(calc(100% - 48px), 390px);
  padding: 13px 17px;
  color: var(--white);
  background: var(--ink);
  border-left: 5px solid var(--confirm);
  border-radius: 4px;
  box-shadow: 0 6px 20px rgba(23, 34, 32, 0.22);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes input-nudge {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(5px);
  }
}

@media (max-width: 1120px) {
  .home-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(295px, 0.75fr);
  }

  .hero-copy {
    padding: 58px 45px;
  }

  .hero-key-sequence {
    grid-template-columns: auto 1fr;
  }

  .hero-key-sequence p {
    display: none;
  }

  .practice-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .keyboard-panel {
    min-height: 470px;
  }

  .keyboard-grid {
    max-width: 650px;
    min-height: 285px;
    margin: 38px auto;
  }
}

@media (max-width: 850px) {
  .app-shell {
    width: min(100% - 28px, 1460px);
  }

  .home-view {
    padding-top: 28px;
  }

  .home-grid {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    min-height: 540px;
  }

  .daily-panel {
    min-height: 410px;
  }

  .mode-list {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
  }

  .section-heading > p {
    max-width: 310px;
  }

  .practice-layout {
    min-height: 0;
  }

  .exercise-stage {
    min-height: 610px;
    padding: 50px 36px;
  }

  .result-score {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  body {
    background-size: 100% 26px;
  }

  .app-shell {
    width: min(100% - 20px, 1460px);
  }

  .topbar {
    min-height: 74px;
  }

  .brand-mark {
    grid-template-columns: repeat(3, 21px);
  }

  .brand-mark > span {
    min-height: 24px;
    font-size: 10px;
  }

  .brand-copy strong {
    font-size: 17px;
  }

  .brand-copy small,
  .today-mini {
    display: none;
  }

  .icon-button {
    min-width: 50px;
  }

  .home-view {
    padding-bottom: 55px;
  }

  .hero-panel {
    min-height: 0;
  }

  .hero-copy {
    padding: 48px 24px;
  }

  .hero-copy h1 {
    font-size: clamp(34px, 10vw, 58px);
  }

  .hero-copy h1 span {
    white-space: normal;
  }

  .hero-lead {
    margin-top: 27px;
    font-size: 14px;
  }

  .hero-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .primary-button {
    width: 100%;
  }

  .text-button {
    align-self: flex-start;
  }

  .hero-key-sequence {
    grid-template-columns: 1fr;
    gap: 13px;
    padding: 24px;
  }

  .sequence-label {
    writing-mode: horizontal-tb;
  }

  .sequence-keys {
    justify-content: space-between;
  }

  .daily-panel {
    min-height: 430px;
    padding: 25px 22px;
  }

  .stat-list dd {
    font-size: 20px;
  }

  .mode-section {
    padding-top: 60px;
  }

  .section-heading {
    display: block;
  }

  .section-heading > p {
    margin-top: 13px;
    text-align: left;
  }

  .mode-card {
    grid-template-columns: 38px 1fr;
    gap: 15px;
    min-height: 175px;
    padding: 25px 42px 25px 18px;
  }

  .mode-tags {
    display: none;
  }

  .footer {
    display: block;
  }

  .footer span {
    display: block;
  }

  .footer span + span {
    margin-top: 5px;
  }

  .session-header {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .session-title {
    display: flex;
    min-width: 0;
    padding: 0 10px;
  }

  .session-title small {
    display: none;
  }

  .session-title strong {
    max-width: 100%;
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .practice-view {
    padding-top: 16px;
  }

  .session-progress {
    margin-bottom: 20px;
  }

  .exercise-stage {
    min-height: 590px;
    padding: 34px 20px;
  }

  .challenge-meta {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 25px;
  }

  .target-display {
    font-size: clamp(27px, 8.7vw, 39px);
  }

  .input-area {
    margin-top: 30px;
  }

  .typing-input {
    height: 65px;
    padding-right: 89px;
    font-size: 18px;
  }

  .input-end-key {
    right: 9px;
    min-width: 68px;
    height: 38px;
    font-size: 8px;
  }

  .key-catcher {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .key-catcher strong {
    justify-self: center;
  }

  .live-metrics > div {
    padding: 0 10px;
  }

  .live-metrics strong {
    font-size: 22px;
  }

  .keyboard-panel {
    min-height: 420px;
    padding: 27px 15px;
  }

  .keyboard-grid {
    grid-template-columns: repeat(6, minmax(27px, 1fr)) minmax(43px, 1.25fr);
    grid-template-rows: repeat(4, 47px);
    gap: 4px;
    min-height: auto;
    margin: 32px auto;
    padding: 0;
  }

  .keyboard-grid kbd {
    font-size: 10px;
  }

  .keyboard-grid kbd.is-target {
    transform: translateX(-5px) scale(1.03);
  }

  .result-view {
    padding: 25px 0 60px;
  }

  .result-sheet {
    padding: 35px 22px;
  }

  .result-score dl > div {
    padding: 0 10px;
  }

  .result-score dd {
    font-size: 15px;
  }

  .result-insight {
    padding: 19px;
  }

  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .result-actions .text-button {
    align-self: flex-start;
  }

  .settings-dialog form {
    padding: 24px 19px;
  }

  .setting-row,
  .data-setting {
    gap: 14px;
  }

  .data-setting {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .focusable-key,
  .target-char.is-focus,
  .keyboard-grid kbd.is-target {
    outline: 3px solid ButtonText;
    outline-offset: 2px;
  }

  .exercise-stage::after,
  .finger-guide > span {
    background: Highlight;
  }
}
