.practice-topbar,
.mode-bar,
.session-ribbon,
.typing-panel,
.upcoming-panel,
.keyboard-section,
.tip-bar {
  border: 1px solid var(--line-soft);
  background: var(--bg-surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
}

.practice-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  padding: 18px;
  border-radius: var(--radius-xl);
}

.mode-bar,
.session-ribbon {
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.58);
  box-shadow: none;
}

.mode-bar {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-tab,
.option-pill,
.session-ribbon-btn {
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.mode-tab {
  padding: 10px 14px;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-weight: 700;
}

.mode-tab.is-active,
.mode-tab:hover {
  color: var(--accent-primary);
  background: var(--accent-primary-soft);
}

.mode-options-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.option-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.option-pill {
  padding: 9px 12px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text-base);
  font-weight: 700;
}

.option-pill.is-active,
.option-pill:hover {
  border-color: rgba(69, 110, 245, 0.28);
  color: var(--accent-primary);
}

.mode-callout {
  max-width: 360px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.session-ribbon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
}

.eyebrow {
  display: block;
  margin-bottom: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.session-ribbon-copy strong {
  display: block;
  color: var(--text-strong);
  line-height: 1.3;
}

.session-ribbon-btn {
  padding: 12px 15px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.9);
  font-weight: 700;
  color: var(--text-base);
}

.practice-body {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.8fr);
  gap: 22px;
}

.typing-panel,
.upcoming-panel {
  border-radius: var(--radius-xl);
  padding: 24px;
}

.typing-panel {
  display: grid;
  gap: 22px;
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.panel-kicker {
  margin-bottom: 8px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-primary);
}

.panel-heading h1 {
  font-size: clamp(1.6rem, 3vw, 2.45rem);
  line-height: 1.04;
  letter-spacing: -0.04em;
  color: var(--text-strong);
}

.typing-status {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
  font-weight: 700;
  white-space: nowrap;
}

.passage-container {
  position: relative;
  min-height: 255px;
  padding: 28px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 255, 0.96)),
    var(--bg-panel);
  border: 1px solid var(--line-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.passage-text {
  font-family: var(--font-mono);
  font-size: clamp(1.45rem, 2.8vw, 2.35rem);
  line-height: 1.8;
  letter-spacing: -0.03em;
  color: var(--text-muted);
  word-break: break-word;
}

.char {
  position: relative;
  display: inline-block;
  border-radius: 8px;
  transition: color 120ms ease, background-color 120ms ease;
}

.char.is-correct {
  color: var(--text-strong);
}

.char.is-wrong {
  color: var(--danger);
  background: rgba(239, 95, 101, 0.1);
}

.char.is-current {
  color: var(--accent-primary);
}

.char.is-current::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.18em;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: var(--accent-primary);
  animation: caretPulse 1.05s ease-in-out infinite;
}

.char.is-space::before {
  content: ".";
  color: rgba(122, 133, 157, 0.45);
}

.progress-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
}

.progress-label,
.progress-pct,
.micro-label,
.upcoming-title,
.coach-title,
.finger-label {
  font-weight: 700;
}

.progress-label {
  color: var(--text-strong);
}

.progress-unit {
  color: var(--text-muted);
}

.progress-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-soft-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-primary), #6d8bff);
  transition: width 150ms ease;
}

.progress-pct {
  color: var(--text-muted);
}

.micro-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.micro-stat {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.74);
}

.micro-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.micro-stat strong {
  font-size: 1.18rem;
  color: var(--text-strong);
}

.upcoming-panel {
  display: grid;
  gap: 18px;
  align-content: start;
}

.upcoming-block,
.coach-card,
.finger-diagram {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.78);
}

.upcoming-title,
.coach-title {
  margin-bottom: 12px;
  color: var(--text-strong);
}

.upcoming-keys {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.upcoming-key {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line-soft);
  background: var(--bg-soft);
  color: var(--text-strong);
  font-family: var(--font-mono);
  font-weight: 600;
}

.upcoming-key.is-current {
  color: white;
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 10px 24px rgba(69, 110, 245, 0.24);
}

.coach-copy {
  color: var(--text-muted);
  line-height: 1.6;
}

.weak-key-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.weak-tag {
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--weak-soft);
  color: var(--weak);
  font-weight: 800;
}

.hands-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.hand {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  min-height: 120px;
}

.finger {
  flex: 1;
  border-radius: 999px 999px 22px 22px;
  background: linear-gradient(180deg, rgba(69, 110, 245, 0.08), rgba(69, 110, 245, 0.18));
  border: 1px solid rgba(69, 110, 245, 0.12);
  transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.hand-l .f-pinky,
.hand-r .f-pinky {
  height: 62px;
}

.hand-l .f-ring,
.hand-r .f-ring {
  height: 82px;
}

.hand-l .f-middle,
.hand-r .f-middle {
  height: 100px;
}

.hand-l .f-index,
.hand-r .f-index {
  height: 92px;
}

.f-thumb {
  height: 54px;
  align-self: center;
}

.finger.is-active {
  transform: translateY(-4px);
  background: linear-gradient(180deg, rgba(69, 110, 245, 0.22), rgba(69, 110, 245, 0.35));
  box-shadow: 0 12px 24px rgba(69, 110, 245, 0.16);
}

.finger-label {
  margin-top: 14px;
  color: var(--text-muted);
}

.keyboard-section {
  border-radius: var(--radius-xl);
  padding: 18px;
}

.kb-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.kb-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-base);
  font-weight: 600;
}

.ldot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--unused);
}

.ldot.is-correct { background: var(--success); }
.ldot.is-current { background: var(--accent-primary); }
.ldot.is-wrong { background: var(--danger); }
.ldot.is-frequent { background: var(--warning); }
.ldot.is-weak { background: var(--weak); }
.ldot.is-unused { background: var(--unused); }

.kb-meta-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-ctrl {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 700;
}

.toggle-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 46px;
  height: 28px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(69, 110, 245, 0.2);
  transition: background-color 160ms ease;
}

.toggle-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 6px 14px rgba(26, 42, 74, 0.15);
  transform: translateX(18px);
  transition: transform 160ms ease;
}

.toggle-ctrl input:not(:checked) + .toggle-track {
  background: rgba(122, 133, 157, 0.25);
}

.toggle-ctrl input:not(:checked) + .toggle-track .toggle-thumb {
  transform: translateX(0);
}

.icon-btn {
  padding: 10px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--text-base);
  font-weight: 700;
  cursor: pointer;
}

.tip-bar {
  padding: 16px 18px;
  border-radius: 18px;
  text-align: center;
  font-weight: 700;
  color: var(--text-muted);
}

.passage-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(243, 245, 249, 0.82);
  border-radius: inherit;
  backdrop-filter: blur(6px);
}

.overlay-inner {
  padding: 22px 26px;
  border-radius: 22px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.92);
  text-align: center;
  box-shadow: var(--shadow-card);
}

.overlay-inner p {
  margin-bottom: 6px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-strong);
}

.overlay-inner small {
  color: var(--text-muted);
}

@media (max-width: 1180px) {
  .practice-topbar,
  .practice-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .typing-panel,
  .upcoming-panel,
  .keyboard-section {
    padding: 18px;
  }

  .panel-heading,
  .progress-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .panel-heading {
    display: grid;
  }

  .micro-stats {
    grid-template-columns: 1fr 1fr;
  }

  .passage-container {
    min-height: 220px;
    padding: 20px;
  }

  .passage-text {
    font-size: clamp(1.18rem, 5vw, 1.55rem);
    line-height: 1.7;
  }

  .kb-meta-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .kb-meta-right {
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .micro-stats {
    grid-template-columns: 1fr;
  }

  .session-ribbon {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Desktop practice is one compact workspace: passage first, keyboard always in reach. */
@media (min-width: 900px) {
  .app-shell {
    width: min(var(--container), calc(100% - 32px));
    padding: 14px 0 18px;
  }

  .main-content,
  .view.is-active {
    gap: 12px;
  }

  .practice-topbar {
    grid-template-columns: minmax(0, 1fr) 270px;
    gap: 12px;
    padding: 10px;
    border-radius: 20px;
  }

  .mode-bar,
  .session-ribbon {
    min-height: 54px;
    padding: 8px 12px;
    border-radius: 15px;
  }

  .mode-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }

  .mode-tabs,
  .mode-options-area,
  .option-pills {
    flex-wrap: nowrap;
  }

  .mode-tabs {
    gap: 3px;
  }

  .mode-tab {
    padding: 7px 9px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .mode-options-area {
    justify-content: flex-end;
    gap: 8px;
  }

  .option-pills {
    gap: 4px;
  }

  .option-pill {
    padding: 6px 8px;
    font-size: 0.76rem;
  }

  .mode-callout,
  .session-ribbon-copy .eyebrow {
    display: none;
  }

  .session-ribbon-copy strong {
    font-size: 0.78rem;
    line-height: 1.25;
  }

  .session-ribbon-btn {
    padding: 8px 10px;
    font-size: 0.76rem;
    white-space: nowrap;
  }

  .practice-body {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 12px;
  }

  .typing-panel,
  .upcoming-panel {
    padding: 16px;
    border-radius: 20px;
  }

  .typing-panel {
    gap: 12px;
  }

  .panel-kicker {
    display: none;
  }

  .panel-heading h1 {
    font-size: 1rem;
    letter-spacing: -0.02em;
  }

  .typing-status {
    padding: 6px 10px;
    font-size: 0.76rem;
  }

  .passage-container {
    min-height: 172px;
    padding: 20px 22px;
    border-radius: 18px;
  }

  .passage-text {
    font-size: clamp(1.2rem, 1.7vw, 1.72rem);
    line-height: 1.65;
  }

  .progress-row {
    gap: 12px;
    font-size: 0.82rem;
  }

  .micro-stats {
    display: flex;
    gap: 0;
    border-top: 1px solid var(--line-soft);
  }

  .micro-stat {
    flex: 1;
    padding: 8px 12px;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .micro-stat + .micro-stat {
    border-left: 1px solid var(--line-soft);
  }

  .micro-label {
    margin-bottom: 3px;
    font-size: 0.68rem;
  }

  .micro-stat strong {
    font-size: 0.98rem;
  }

  .upcoming-panel {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .upcoming-block,
  .coach-card,
  .finger-diagram {
    padding: 12px;
    border-radius: 14px;
  }

  .upcoming-title,
  .coach-title {
    margin-bottom: 7px;
    font-size: 0.78rem;
  }

  .upcoming-keys {
    gap: 6px;
  }

  .upcoming-key {
    width: 31px;
    height: 31px;
    font-size: 0.76rem;
  }

  .coach-copy {
    font-size: 0.72rem;
    line-height: 1.35;
  }

  .weak-key-tags,
  .finger-diagram {
    display: none;
  }

  .keyboard-section {
    padding: 12px;
    border-radius: 20px;
  }

  .kb-meta-bar {
    min-height: 30px;
    margin-bottom: 9px;
    padding-bottom: 9px;
  }

  .kb-legend {
    gap: 8px 14px;
  }

  .legend-item,
  .toggle-ctrl,
  .icon-btn {
    font-size: 0.7rem;
  }

  .ldot {
    width: 8px;
    height: 8px;
  }

  .toggle-ctrl {
    display: none;
  }

  .kb-meta-right {
    gap: 6px;
  }

  .icon-btn {
    padding: 6px 9px;
    border-radius: 10px;
  }

  .virtual-keyboard {
    gap: 5px;
  }

  .kb-row {
    gap: 5px;
  }

  .kb-key,
  .virtual-keyboard[data-size="compact"] .kb-key {
    min-height: 43px;
    padding: 6px 8px;
    border-radius: 10px;
  }

  .kc-main {
    font-size: 0.98rem;
  }

  .kc-label,
  .kc-s,
  .kc-p {
    font-size: 0.67rem;
  }

  .kc-p {
    font-size: 0.78rem;
  }

  .home-bump {
    bottom: 5px;
    width: 18px;
    height: 2px;
  }

  .space-line {
    height: 2px;
  }

  .tip-bar {
    display: none;
  }
}

@media (min-width: 900px) and (max-height: 780px) {
  .brand-subtitle,
  .session-ribbon,
  .metric-target,
  .micro-stats,
  .coach-card {
    display: none;
  }

  .passage-container {
    min-height: 130px;
  }

  .typing-panel,
  .upcoming-panel {
    padding: 12px;
  }

  .kb-key,
  .virtual-keyboard[data-size="compact"] .kb-key {
    min-height: 38px;
    padding: 5px 7px;
  }
}

body[data-theme="dark"] .practice-topbar,
body[data-theme="dark"] .mode-bar,
body[data-theme="dark"] .session-ribbon,
body[data-theme="dark"] .typing-panel,
body[data-theme="dark"] .upcoming-panel,
body[data-theme="dark"] .keyboard-section,
body[data-theme="dark"] .tip-bar,
body[data-theme="dark"] .upcoming-block,
body[data-theme="dark"] .coach-card,
body[data-theme="dark"] .finger-diagram,
body[data-theme="dark"] .micro-stat,
body[data-theme="dark"] .option-pill,
body[data-theme="dark"] .session-ribbon-btn,
body[data-theme="dark"] .icon-btn {
  background: rgba(25, 34, 51, 0.9);
}

body[data-theme="dark"] .passage-container {
  background: linear-gradient(180deg, rgba(31, 43, 63, 0.98), rgba(25, 35, 52, 0.98));
}
