/* NCLI Typing Lab - final product surface */
.typing-app-container {
  --lab-ink: #142033;
  --lab-muted: #334155;
  --lab-line: #dfe6ef;
  --lab-surface: #ffffff;
  --lab-canvas: #eef3f8;
  --lab-navy: #0d1a2b;
  --lab-cyan: #0ea5e9;
  --lab-indigo: #4f46e5;
  min-height: 100vh;
  color: var(--lab-ink);
  background: var(--lab-canvas);
}

.typing-app-container .typing-topbar {
  background: var(--lab-navy);
  border-bottom-color: #1e344e;
}

.typing-app-container .typing-topbar-inner {
  width: 100%;
  max-width: none;
  min-height: 68px;
  padding-inline: 32px;
}

.typing-app-container .typing-brand-mark {
  width: 36px;
  height: 36px;
  border-color: #285075;
  color: #7dd3fc;
  background: #102b45;
}

.typing-app-container .typing-topbar-context {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  margin-left: 18px;
  padding-left: 18px;
  border-left: 1px solid #29425d;
}

.typing-app-container .typing-context-kicker {
  color: #38bdf8;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .15em;
}

.typing-app-container .typing-topbar-context strong {
  overflow: hidden;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typing-app-container .typing-topbar-metrics {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto;
  padding-left: 22px;
  border-left: 1px solid #29425d;
}

.typing-app-container .typing-topbar-metrics span {
  display: flex;
  min-width: 48px;
  flex-direction: column;
  gap: 2px;
}

.typing-app-container .typing-topbar-metrics small {
  color: #94a3b8;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .1em;
}

.typing-app-container .typing-topbar-metrics b {
  color: #e0f2fe;
  font-family: 'Cascadia Code', 'Courier New', monospace;
  font-size: 15px;
}

.typing-app-container .typing-topnav-link {
  min-height: 68px;
  padding-inline: 15px;
  color: #91a4bb;
  font-size: 11px;
}

.typing-app-container .typing-topnav-link.active,
.typing-app-container .typing-topnav-link:hover {
  color: #f8fafc;
}

.typing-app-container .typing-topnav-link.active::after {
  height: 3px;
  background: #38bdf8;
}

.typing-app-container .typing-topbar-user a {
  color: #7dd3fc;
  font-size: 10px;
  text-decoration: none;
}

.typing-app-container .typing-topbar-user {
  margin-left: 18px;
  white-space: nowrap;
}

.typing-app-container .tp-main-section,
.typing-app-container .tp-main-section.bg-light {
  min-height: calc(100vh - 68px);
  padding: 0 0 32px;
  background: var(--lab-canvas);
}

.typing-app-container .tp-main-section > .container {
  width: 100%;
  max-width: none;
  padding: 0 32px 32px;
}

.typing-app-container .typing-command-bar {
  min-height: 92px;
  margin: 0 -32px 24px;
  padding: 0 32px;
  border-bottom: 1px solid var(--lab-line);
  background: #f7fafd;
}

.typing-app-container .typing-command-bar:has(.typing-metric-strip:only-child) {
  justify-content: flex-end;
  min-height: 42px;
  margin-bottom: 12px;
  border-bottom: 0;
  background: transparent;
}

.typing-app-container .typing-command-kicker { color: #0284c7; }
.typing-app-container .typing-command-copy strong { color: var(--lab-ink); font-size: 18px; }
.typing-app-container .typing-metric-strip b { color: var(--lab-indigo); }
.typing-app-container .typing-metric-strip small { color: #334155; font-weight: 600; }

.typing-app-container .tp-login-banner {
  max-width: none;
  margin: 0 0 18px;
  border-color: var(--lab-line);
  border-radius: 10px;
  background: var(--lab-surface);
  color: var(--lab-muted);
}

.typing-app-container .tp-workspace {
  grid-template-columns: 248px minmax(0, 1fr);
  align-items: stretch;
  gap: 22px;
  min-height: calc(100vh - 220px);
}

.typing-app-container .tp-tabs-wrapper {
  position: sticky;
  top: 84px;
  height: calc(100vh - 110px);
  max-height: none;
  border: 0;
  border-radius: 14px;
  padding: 14px;
  background: var(--lab-navy);
  box-shadow: 0 16px 38px rgba(13, 26, 43, .12);
}

.typing-app-container .tp-nav-intro {
  margin-bottom: 10px;
  padding: 5px 4px 16px;
  border-color: #203750;
}

.typing-app-container .tp-nav-logo { background: #123654; box-shadow: none; }
.typing-app-container .tp-nav-intro strong { color: #f8fafc; font-size: 12px; }
.typing-app-container .tp-nav-intro small { color: #7188a1; }
.typing-app-container .tp-nav-group + .tp-nav-group { border-color: #203750; }
.typing-app-container .tp-nav-group-label { color: #6d849d; }

.typing-app-container .tp-tab {
  min-height: 42px;
  color: #9bb0c6;
  border-radius: 8px;
  font-size: 11px;
}

.typing-app-container .tp-tab i { color: #6f87a0; }
.typing-app-container .tp-tab:hover { color: #e0f2fe; background: #15304a; transform: none; }
.typing-app-container .tp-tab.active,
.typing-app-container .tp-tab.active:hover { color: #f8fafc !important; background: #1b4164 !important; box-shadow: none !important; }
.typing-app-container .tp-tab.active::before { background: #38bdf8; }
.typing-app-container .tp-tab.active i { color: #67e8f9; }

.typing-app-container .tp-nav-tip { margin-top: auto; border-color: #23415e; background: #102b45; color: #9bb0c6; }
.typing-app-container .tp-nav-tip strong { color: #e0f2fe; }

.typing-app-container .tp-panel.active {
  min-height: calc(100vh - 220px);
  padding: 30px;
  border: 1px solid var(--lab-line);
  border-radius: 16px;
  background: var(--lab-surface);
  box-shadow: 0 12px 32px rgba(30, 55, 80, .06);
}

.typing-app-container .panel-title {
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-color: var(--lab-line);
}

.typing-app-container .panel-title h2 { color: var(--lab-ink); font-size: 25px; letter-spacing: -.03em; }
.typing-app-container .panel-title h2 i { color: #0284c7; background: #e0f2fe; }
.typing-app-container .panel-title p { color: var(--lab-muted); }

.typing-app-container .dashboard-summary-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.typing-app-container .summary-card {
  min-height: 102px;
  align-items: flex-start;
  flex-direction: column;
  justify-content: space-between;
  border-color: var(--lab-line);
  border-radius: 12px;
  padding: 14px;
  background: #fbfdff;
  box-shadow: none;
}

.typing-app-container .summary-card:hover { transform: none; border-color: #b9c9da; box-shadow: 0 8px 20px rgba(30, 55, 80, .07); }
.typing-app-container .summary-icon { width: 30px; height: 30px; border-radius: 8px; font-size: 12px; }
.typing-app-container .summary-label { color: #334155; font-size: 8px; font-weight: 700; }
.typing-app-container .summary-value { color: var(--lab-ink); font-size: 18px; }

.typing-app-container .dash-main-grid { grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: 14px; }
.typing-app-container #panel-dashboard .dash-col-left { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; gap: 14px; }
.typing-app-container #panel-dashboard .dash-col-left > .dash-card { min-width: 0; margin: 0; }
.typing-app-container .dash-card { border-color: var(--lab-line); border-radius: 12px; box-shadow: none; }
.typing-app-container .dash-card-header { border-color: var(--lab-line); }
.typing-app-container .dash-card-header h3 { color: var(--lab-ink); }
.typing-app-container .continue-card { background: linear-gradient(135deg, #12385a, #0d1a2b); box-shadow: 0 14px 28px rgba(13, 26, 43, .16); }
.typing-app-container .continue-card .section-tag { color: #075985; background: #e0f2fe; }

.typing-app-container .lessons-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.typing-app-container .lesson-card { border-color: var(--lab-line); border-radius: 12px; background: #fbfdff; box-shadow: none; }
.typing-app-container .lesson-card:hover { transform: translateY(-2px); border-color: #9fb4ca; box-shadow: 0 12px 24px rgba(30, 55, 80, .08); }
.typing-app-container .lesson-card h3 { color: var(--lab-ink); }
.typing-app-container .lesson-card p { color: var(--lab-muted); }

.typing-app-container .practice-header { grid-template-columns: minmax(240px, 1.2fr) minmax(200px, .8fr) repeat(2, 150px); gap: 14px; border-color: var(--lab-line); background: #f8fbfe; }
.typing-app-container #panel-practice > .panel-title { display: none; }
.typing-app-container #panel-practice .practice-header { grid-template-columns: minmax(190px, 1.25fr) minmax(160px, .9fr) minmax(118px, .65fr) minmax(118px, .65fr) minmax(300px, 1.6fr); align-items: center; }
.typing-app-container #panel-practice .typing-stats { display: grid; grid-template-columns: repeat(4, minmax(56px, 1fr)); gap: 8px; }
.typing-app-container #panel-practice .typing-stats .stat-item { min-width: 0; padding: 8px 6px; }
.typing-app-container #panel-practice .practice-header-progress { display: flex; align-items: center; gap: 8px; min-width: 0; }
.typing-app-container #panel-practice .practice-header-progress .progress-bar { flex: 1; }
.typing-app-container .typing-area { background: #f5f9fc; border-color: var(--lab-line); }
.typing-app-container .text-display { min-height: 190px; background: #fff; }
.typing-app-container .typing-practice-layout { grid-template-columns: minmax(0, 1fr) 210px; }
.typing-app-container .typing-control-panel { background: #fff; border-color: var(--lab-line); }

.typing-app-container .game-panel.active { background: #0d1a2b; border-color: #1e344e; }

@media (max-width: 1200px) {
  .typing-app-container .dashboard-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .typing-app-container .lessons-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .typing-app-container #panel-practice .practice-header { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .typing-app-container #panel-practice .lesson-selector { grid-column: span 2; }
  .typing-app-container #panel-practice .practice-info { grid-column: span 2; }
  .typing-app-container #panel-practice .practice-header-progress { grid-column: 1 / -1; }
}

@media (max-width: 980px) {
  .typing-app-container .tp-main-section > .container { padding-inline: 18px; }
  .typing-app-container .typing-command-bar { margin-inline: -18px; padding-inline: 18px; }
  .typing-app-container .tp-workspace { min-height: 0; }
  .typing-app-container .tp-tabs-wrapper { position: sticky; top: 68px; height: auto; background: var(--lab-navy); }
  .typing-app-container .tp-panel.active { min-height: 0; padding: 22px; }
  .typing-app-container .dash-main-grid { grid-template-columns: 1fr; }
  .typing-app-container #panel-dashboard .dash-col-left { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .typing-app-container .typing-topbar-inner { padding-inline: 14px; }
  .typing-app-container .typing-topbar-user { display: none; }
  .typing-app-container .typing-topbar-context { max-width: 190px; margin-left: auto; padding-left: 10px; }
  .typing-app-container .typing-topbar-context strong { font-size: 9px; }
  .typing-app-container .typing-topbar-metrics { gap: 10px; margin-left: 0; padding-left: 10px; }
  .typing-app-container .typing-topbar-metrics span { min-width: 40px; }
  .typing-app-container .typing-topbar-metrics b { font-size: 12px; }
  .typing-app-container .typing-command-bar { margin-bottom: 14px; }
  .typing-app-container .dashboard-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .typing-app-container .lessons-grid { grid-template-columns: 1fr; }
  .typing-app-container #panel-dashboard .dash-col-left { grid-template-columns: 1fr; }
  .typing-app-container #panel-practice .practice-header { grid-template-columns: 1fr 1fr; }
  .typing-app-container #panel-practice .lesson-selector,
  .typing-app-container #panel-practice .practice-info,
  .typing-app-container #panel-practice .practice-header-progress { grid-column: 1 / -1; }
  .typing-app-container .tp-panel.active { padding: 16px; border-radius: 12px; }
  .typing-app-container .panel-title h2 { font-size: 21px; }
}

body.dark .typing-app-container { background: #111827; }
body.dark .typing-app-container .tp-main-section,
body.dark .typing-app-container .tp-main-section.bg-light { background: #111827; }
body.dark .typing-app-container .tp-panel:not(.game-panel).active { border-color: #2a3b52; background: #172235; }
body.dark .typing-app-container .summary-card,
body.dark .typing-app-container .lesson-card,
body.dark .typing-app-container .practice-header,
body.dark .typing-app-container .typing-control-panel { border-color: #2a3b52; background: #1b2a3e; }
body.dark .typing-app-container .panel-title h2,
body.dark .typing-app-container .summary-value,
body.dark .typing-app-container .lesson-card h3 { color: #eef6ff; }

/* Performance and responsive polish: one calm surface, fewer expensive layers. */
.typing-app-container .typing-topbar-inner { min-height: 58px; padding-inline: 24px; }
.typing-app-container .typing-topnav-link { min-height: 58px; }
.typing-app-container .tp-main-section { padding-bottom: 24px; }
.typing-app-container .tp-main-section > .container { padding: 0 24px 24px; }
.typing-app-container .tp-workspace { grid-template-columns: 214px minmax(0, 1fr); gap: 14px; min-height: 0; }
.typing-app-container .tp-tabs-wrapper { top: 70px; height: calc(100vh - 92px); padding: 10px; border-radius: 12px; box-shadow: 0 8px 20px rgba(13,26,43,.12); backdrop-filter: none; }
.typing-app-container .tp-tab { min-height: 36px; }
.typing-app-container .tp-tab.active::before { left: 10px; right: 10px; top: auto; bottom: 0; width: auto; height: 2px; border-radius: 2px; }
.typing-app-container .tp-panel.active { min-height: 0; padding: 24px; border-radius: 12px; box-shadow: none; animation: typing-panel-in 180ms ease-out both; }
.typing-app-container .tp-login-banner { padding: 12px 14px; }
.typing-app-container .tp-guest-banner { color: #334155; background: #f8fbff; border: 1px solid #cbd9e8; }
.typing-app-container .tp-guest-banner strong { color: #0f2740 !important; }
.typing-app-container .tp-guest-banner p { color: #475569 !important; opacity: 1; }
.typing-app-container .tp-guest-banner a { color: #075985 !important; background: #dff3ff; }
.typing-app-container .continue-card { background: #12385a; box-shadow: none; }
.typing-app-container .dash-card, .typing-app-container .summary-card, .typing-app-container .lesson-card { box-shadow: none; }
.typing-app-container .dash-card:hover, .typing-app-container .summary-card:hover, .typing-app-container .lesson-card:hover { transform: none; box-shadow: none; }
.typing-app-container * { backdrop-filter: none !important; }
@keyframes typing-panel-in { from { opacity: .72; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 980px) {
  .typing-app-container .typing-topbar-inner { padding-inline: 16px; }
  .typing-app-container .typing-topbar-context { display: none; }
  .typing-app-container .typing-topnav { display: none; }
  .typing-app-container .tp-main-section > .container { padding-inline: 14px; }
  .typing-app-container .tp-tabs-wrapper { top: 58px; height: auto; padding: 8px; border-radius: 10px; overflow-x: auto; }
  .typing-app-container .tp-tabs { display: flex; width: max-content; min-width: 100%; gap: 4px; }
  .typing-app-container .tp-nav-group { display: contents; }
  .typing-app-container .tp-nav-group-label, .typing-app-container .tp-nav-intro, .typing-app-container .tp-nav-tip { display: none; }
  .typing-app-container .tp-tab { min-height: 40px; padding-inline: 12px; white-space: nowrap; }
  .typing-app-container .tp-panel.active { padding: 18px; }
}
@media (max-width: 560px) {
  .typing-app-container .typing-topbar-inner { min-height: 52px; padding-inline: 12px; }
  .typing-app-container .typing-topbar-metrics { gap: 8px; padding-left: 8px; }
  .typing-app-container .typing-topbar-metrics b { font-size: 12px; }
  .typing-app-container .tp-main-section > .container { padding-inline: 10px; }
  .typing-app-container .tp-panel.active { padding: 14px; border-radius: 10px; }
}

/* Normal theme contrast fix (must remain last in cascade). */
body:not(.dark) .typing-app-container .tp-guest-banner { background: #eef6ff !important; border-color: #b8d3ea !important; box-shadow: 0 6px 16px rgba(30,55,80,.08) !important; }
body:not(.dark) .typing-app-container .tp-guest-banner strong { color: #102a43 !important; }
body:not(.dark) .typing-app-container .tp-guest-banner p { color: #334e68 !important; }
body:not(.dark) .typing-app-container .tp-guest-banner .tp-gb-btn { color: #075985 !important; background: #d7efff !important; border-color: #8fc7e8 !important; }
@media (prefers-reduced-motion: reduce) { .typing-app-container .tp-panel.active { animation: none; } }
.typing-app-container :focus-visible { outline: 2px solid #38bdf8; outline-offset: 2px; }
.typing-app-container .tp-tab:focus-visible { outline-offset: -2px; }
.typing-app-container .typing-module-loading { position: relative; }
.typing-app-container .typing-module-loading::after { content: 'Loading challenge…'; position: absolute; inset: 18px; display: grid; place-items: center; min-height: 72px; border: 1px solid #284766; border-radius: 10px; background: rgba(13,26,43,.94); color: #bae6fd; font-size: 13px; font-weight: 700; letter-spacing: .02em; z-index: 2; }
.typing-app-container .text-display { line-height: 1.8; letter-spacing: .01em; }
.typing-app-container .typing-input, .typing-app-container textarea { caret-color: #0284c7; }
.typing-app-container .stat-item { color: #142033; background: #ffffff; border-color: #dfe6ef; }
.typing-app-container .stat-item .stat-label, .typing-app-container .stat-item .stat-value { color: #142033 !important; opacity: 1; }
.typing-app-container .typing-stats .stat-item { background: #ffffff; }
.typing-app-container .result-card { color: #142033; background: #ffffff; border-color: #dfe6ef; }
.typing-app-container .result-card * { color: #142033 !important; opacity: 1; }
@media (max-width: 980px) {
  .typing-app-container .tp-tabs-wrapper { scrollbar-width: thin; scrollbar-color: #3a6b91 transparent; }
  .typing-app-container .tp-tab.active { scroll-margin-inline: 20px; }
}

/* Final cascade cleanup for dashboard, cards, and dark mode. */
.typing-app-container #panel-dashboard .dashboard-main-column > .dash-main-grid {
  display: block;
  width: 100%;
}

.typing-app-container #panel-dashboard .dashboard-main-column > .dash-main-grid > .dash-col-left {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
}

.typing-app-container #panel-dashboard .dashboard-main-column > .dash-main-grid > .dash-col-left > .dash-card {
  min-width: 0;
  margin: 0;
}

.typing-app-container #panel-dashboard .dashboard-body-grid > .dash-col-right {
  min-height: 100%;
}

.typing-app-container .dashboard-progress-inline,
.typing-app-container .summary-card,
.typing-app-container .lesson-card,
.typing-app-container .practice-header,
.typing-app-container .typing-control-panel,
.typing-app-container .typing-area {
  min-width: 0;
}

.typing-app-container .summary-label,
.typing-app-container .lesson-card p,
.typing-app-container .activity-item,
.typing-app-container .pi-label,
.typing-app-container .pi-count {
  overflow-wrap: anywhere;
}

@media (max-width: 1200px) {
  .typing-app-container #panel-dashboard .dashboard-body-grid {
    grid-template-columns: minmax(0, 1fr) 270px;
  }

  .typing-app-container #panel-dashboard .dashboard-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .typing-app-container #panel-dashboard .dashboard-main-column > .dash-main-grid > .dash-col-left {
    grid-template-columns: 1fr;
  }
}

body.dark .typing-app-container .dashboard-progress-inline {
  border-color: #2a3b52;
  background: #1b2a3e;
}

body.dark .typing-app-container .dashboard-progress-inline b {
  color: #7dd3fc;
}

body.dark .typing-app-container .dashboard-progress-inline em,
body.dark .typing-app-container .dashboard-progress-label {
  color: #9fb4ca;
}

body.dark .typing-app-container .typing-area,
body.dark .typing-app-container .text-display {
  border-color: #2a3b52;
  background: #111c2c;
}

/* 3D and race controls live in the panel heading on desktop. */
.typing-app-container .game-panel > .panel-title {
  display: grid;
  grid-template-columns: minmax(180px, .9fr) auto auto;
  align-items: center;
  gap: 16px;
}

.typing-app-container .game-title-copy {
  min-width: 0;
}

.typing-app-container .game-heading-stats,
.typing-app-container .race-heading-stats {
  display: flex;
  justify-content: center;
  gap: 7px;
}

.typing-app-container .game-heading-stats .game-stat,
.typing-app-container .race-heading-stats .stat-item {
  min-width: 58px;
  padding: 6px 8px;
  border: 1px solid #2b4561;
  border-radius: 8px;
  background: #13263b;
  text-align: center;
}

.typing-app-container .game-heading-stats .game-stat-label,
.typing-app-container .race-heading-stats .stat-label {
  display: block;
  color: #86a2bd;
  font-size: 8px;
}

.typing-app-container .game-heading-stats .game-stat-value,
.typing-app-container .race-heading-stats .stat-value {
  display: block;
  margin-top: 2px;
  color: #e0f2fe;
  font-size: 14px;
}

.typing-app-container .game-heading-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  justify-self: end;
}

.typing-app-container .game-heading-actions label,
.typing-app-container .race-heading-setup label {
  color: #86a2bd;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.typing-app-container .game-heading-actions .lesson-dropdown,
.typing-app-container .race-heading-setup .lesson-dropdown {
  min-height: 32px;
  width: 82px;
}

.typing-app-container .race-heading-setup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.typing-app-container .race-heading-setup .race-setup-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.typing-app-container .race-heading-setup .race-theme-tabs {
  display: flex;
  gap: 3px;
}

.typing-app-container .race-heading-setup .race-theme-btn {
  min-height: 30px;
  padding: 5px 7px;
  border: 1px solid #2b4561;
  border-radius: 7px;
  color: #a6bed5;
  background: #13263b;
  font-size: 9px;
}

.typing-app-container .race-heading-setup .race-theme-btn.active {
  border-color: #f59e0b;
  color: #fff7ed;
  background: #92400e;
}

.typing-app-container .race-heading-guide {
  display: flex;
  grid-column: 1 / -1;
  justify-content: center;
  gap: 8px;
  padding-top: 3px;
}

.typing-app-container .race-heading-guide span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #9bb0c6;
  font-size: 9px;
}

.typing-app-container .race-heading-guide i { color: #f59e0b; }
.typing-app-container .race-heading-guide strong { color: #e2e8f0; }

body.dark .typing-app-container .game-heading-stats .game-stat,
body.dark .typing-app-container .race-heading-stats .stat-item,
body.dark .typing-app-container .race-heading-setup .race-theme-btn {
  border-color: #2b4561;
  background: #13263b;
}

@media (max-width: 1100px) {
  .typing-app-container .game-panel > .panel-title {
    grid-template-columns: minmax(180px, 1fr) auto;
  }

  .typing-app-container .game-heading-stats,
  .typing-app-container .race-heading-stats {
    justify-self: end;
  }

  .typing-app-container .game-heading-actions,
  .typing-app-container .race-heading-setup {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 680px) {
  .typing-app-container .game-panel > .panel-title {
    display: flex;
    align-items: stretch;
    flex-direction: column;
  }

  .typing-app-container .game-heading-stats,
  .typing-app-container .race-heading-stats,
  .typing-app-container .race-heading-setup,
  .typing-app-container .race-heading-guide {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .typing-app-container .game-heading-actions,
  .typing-app-container .race-heading-setup {
    align-self: stretch;
  }
}

body.dark .typing-app-container .typing-input,
body.dark .typing-app-container .lesson-dropdown {
  border-color: #3a4b63;
  background: #111c2c;
  color: #e7edf7;
}

/* Race focus mode: the browser viewport becomes the race screen. */
body.ncli-race-focus {
  overflow: hidden;
}

body.ncli-race-focus .header,
body.ncli-race-focus .footer,
body.ncli-race-focus .typing-topbar,
body.ncli-race-focus .typing-command-bar,
body.ncli-race-focus .tp-login-banner,
body.ncli-race-focus .tp-tabs-wrapper {
  display: none !important;
}

body.ncli-race-focus .typing-app-container {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100vw !important;
  height: 100vh;
  margin: 0 !important;
  overflow: hidden;
}

body.ncli-race-focus .typing-app-container .tp-main-section,
body.ncli-race-focus .typing-app-container .tp-main-section > .container,
body.ncli-race-focus .typing-app-container .tp-workspace,
body.ncli-race-focus .typing-app-container .tp-panels-container {
  width: 100vw !important;
  max-width: none !important;
  height: 100vh;
  min-height: 0;
  margin: 0 !important;
  padding: 0 !important;
}

body.ncli-race-focus .typing-app-container .tp-workspace {
  display: block !important;
}

body.ncli-race-focus .typing-app-container .tp-panel:not(#panel-racing) {
  display: none !important;
}

body.ncli-race-focus .typing-app-container #panel-racing {
  display: flex !important;
  width: 100vw !important;
  height: 100vh;
  min-height: 0;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  padding: 18px 28px;
}

body.ncli-race-focus .typing-app-container #panel-racing > .panel-title {
  flex: 0 0 auto;
  margin-bottom: 12px;
}

body.ncli-race-focus .typing-app-container #panel-racing > .race-container {
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  flex-direction: column;
}

body.ncli-race-focus .typing-app-container #panel-racing .race-track {
  flex: 1 1 auto;
  min-height: 0;
}

body.ncli-race-focus .typing-app-container #panel-racing .race-typing {
  flex: 0 0 auto;
}

@media (max-width: 680px) {
  body.ncli-race-focus .typing-app-container #panel-racing {
    padding: 12px;
  }
}

/* Racing gets a viewport-focused play surface instead of page-scroll behavior. */
.typing-app-container #panel-racing.game-panel.active {
  min-height: calc(100vh - 150px);
}

.typing-app-container #panel-racing .race-container {
  min-height: calc(100vh - 250px);
  display: flex;
  flex-direction: column;
}

.typing-app-container #panel-racing .race-track {
  flex: 1 1 auto;
  min-height: 220px;
}

.typing-app-container #panel-racing .race-typing {
  flex: 0 0 auto;
}

@media (max-width: 980px) {
  .typing-app-container #panel-racing.game-panel.active,
  .typing-app-container #panel-racing .race-container {
    min-height: 0;
  }
}

/* Dark mode surfaces that were still using the legacy light palette. */
.typing-app-container .tp-history,
.typing-app-container .progress-tracker,
.typing-app-container .certificates-container {
  color: var(--lab-ink);
}

.typing-app-container .tp-history-row,
.typing-app-container .ti-body,
.typing-app-container .certificates-container,
.typing-app-container .certificate-card,
.typing-app-container .cert-info-box {
  border-color: var(--lab-line);
}

.typing-app-container .tp-history-row,
.typing-app-container .ti-body,
.typing-app-container .certificate-card {
  background: var(--lab-surface);
}

.typing-app-container .thr-main strong,
.typing-app-container .ti-head strong,
.typing-app-container .certificate-card h3,
.typing-app-container .cert-info-box p {
  color: var(--lab-ink);
}

.typing-app-container .thr-main span,
.typing-app-container .thr-stats,
.typing-app-container .ti-body p,
.typing-app-container .progress-count,
.typing-app-container .certificate-card p {
  color: var(--lab-muted);
}

.typing-app-container .chart-box,
.typing-app-container .tp-chart {
  color: #475569;
}

body.dark .typing-app-container .tp-history-row,
body.dark .typing-app-container .ti-body,
body.dark .typing-app-container .certificates-container,
body.dark .typing-app-container .certificate-card,
body.dark .typing-app-container .cert-info-box,
body.dark .typing-app-container .progress-tracker {
  border-color: #2a3b52;
  background: #1b2a3e;
  color: #e7edf7;
}

body.dark .typing-app-container .tp-history-row,
body.dark .typing-app-container .ti-body,
body.dark .typing-app-container .certificate-card {
  box-shadow: 0 8px 20px rgba(0, 0, 0, .16);
}

body.dark .typing-app-container .thr-main strong,
body.dark .typing-app-container .ti-head strong,
body.dark .typing-app-container .certificate-card h3,
body.dark .typing-app-container .cert-info-box p,
body.dark .typing-app-container .chart-box,
body.dark .typing-app-container .tp-chart {
  color: #e7edf7;
}

body.dark .typing-app-container .thr-main span,
body.dark .typing-app-container .thr-stats,
body.dark .typing-app-container .ti-body p,
body.dark .typing-app-container .progress-count,
body.dark .typing-app-container .certificate-card p,
body.dark .typing-app-container .tp-chart-empty {
  color: #9aa7ba;
}

body.dark .typing-app-container .tp-history-row .thr-stats b {
  color: #7dd3fc;
}

body.dark .typing-app-container .progress-tracker .progress-filters,
body.dark .typing-app-container .progress-tracker .progress-filters select {
  border-color: #2a3b52;
  background: #111c2c;
  color: #e7edf7;
}

body.dark .typing-app-container .certificates-container .cert-info-box {
  background: #172b46;
  border-left-color: #38bdf8;
}

/* Keyboard Warrior instructions are part of the heading, not a separate lower block. */
.typing-app-container #panel-warrior .warrior-panel-heading {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, .9fr) minmax(300px, 1.4fr) auto;
  align-items: center;
  gap: 18px;
}

.typing-app-container #panel-warrior .warrior-heading-instructions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.typing-app-container #panel-warrior .warrior-heading-instructions span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 9px;
  border: 1px solid #334155;
  border-radius: 8px;
  color: #9fb4ca;
  background: #13263b;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.typing-app-container #panel-warrior .warrior-heading-instructions i {
  color: #f43f5e;
}

.typing-app-container #panel-warrior .warrior-intel-grid-top {
  margin: 0 0 14px;
}

.typing-app-container #panel-warrior .warrior-intel-grid-top .warrior-intel-card {
  min-height: 112px;
}

.typing-app-container #panel-warrior .warrior-panel-heading {
  grid-template-columns: minmax(180px, .7fr) minmax(0, 2.3fr);
  align-items: center;
}

.typing-app-container #panel-warrior .warrior-intel-grid-top {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

/* Keep the normal typing keyboard readable outside dark mode too. */
.typing-app-container .tp-keyboard .kb-key {
  border-color: #b8c7d8;
  color: #1e293b;
  background: linear-gradient(180deg, #ffffff, #e7eef6);
  box-shadow: 0 4px 0 #b7c4d2, 0 7px 16px rgba(15, 23, 42, .08);
}

.typing-app-container .tp-keyboard .kb-key.kb-special {
  color: #334155;
  background: linear-gradient(180deg, #f8fafc, #dbe5ef);
}

.typing-app-container .tp-keyboard .kb-key.kb-next {
  color: #1d4ed8;
  border-color: #60a5fa;
  background: linear-gradient(180deg, #dbeafe, #bfdbfe);
  box-shadow: 0 4px 0 #93c5fd, 0 0 0 3px rgba(59, 130, 246, .14);
}

body.dark .typing-app-container #panel-warrior .warrior-heading-instructions span {
  border-color: #334155;
  background: #13263b;
  color: #b6c3d4;
}

@media (max-width: 1100px) {
  .typing-app-container #panel-warrior .warrior-panel-heading {
    grid-template-columns: minmax(220px, 1fr) auto;
  }

  .typing-app-container #panel-warrior .warrior-heading-instructions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .typing-app-container #panel-warrior .warrior-intel-grid-top {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .typing-app-container #panel-warrior .warrior-panel-heading {
    display: flex;
    align-items: stretch;
    flex-direction: column;
  }

  .typing-app-container #panel-warrior .warrior-heading-instructions {
    align-items: stretch;
    flex-direction: column;
  }

  .typing-app-container #panel-warrior .warrior-heading-instructions span {
    white-space: normal;
  }

  .typing-app-container #panel-warrior .warrior-intel-grid-top {
    grid-template-columns: 1fr;
  }
}

/* Coding mode: title, language tabs, lesson selector, then lesson chips. */
.typing-app-container #panel-coding > .panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.typing-app-container #panel-coding .coding-title-copy {
  min-width: 0;
}

.typing-app-container #panel-coding > .panel-title .language-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--lab-line);
  border-radius: 10px;
  background: #f4f7fb;
}

.typing-app-container #panel-coding > .panel-title .lang-tab {
  min-height: 34px;
  border: 0;
  border-radius: 7px;
  padding: 7px 10px;
  color: var(--lab-muted);
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.typing-app-container #panel-coding > .panel-title .lang-tab.active,
.typing-app-container #panel-coding > .panel-title .lang-tab:hover {
  color: #1d4ed8;
  background: #fff;
  box-shadow: 0 2px 8px rgba(30, 55, 80, .08);
}

.typing-app-container #panel-coding > .panel-title .lang-tab i {
  margin-right: 4px;
}

.typing-app-container #panel-coding .coding-container {
  border-color: var(--lab-line);
  border-radius: 12px;
  background: #fbfdff;
  box-shadow: none;
}

.typing-app-container #panel-coding .coding-stats-header {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  border: 0;
}

.typing-app-container #panel-coding .coding-stats-header .stat-item {
  display: flex;
  min-width: 68px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid var(--lab-line);
  border-radius: 8px;
  background: #fff;
}

.typing-app-container #panel-coding .coding-stats-header .stat-label {
  color: var(--lab-muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.typing-app-container #panel-coding .coding-stats-header .stat-value {
  color: #1d4ed8;
  font-size: 14px;
  font-weight: 900;
}

.typing-app-container #panel-coding > .panel-title .coding-stats-header .stat-item {
  border-color: #d5dfeb;
  background: #f8fbfe;
}

.typing-app-container #panel-coding > .panel-title .coding-stats-header {
  margin-left: auto;
  margin-right: 8px;
}

.typing-app-container #panel-coding .coding-lesson-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.typing-app-container #panel-coding .coding-lesson-select-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
}

.typing-app-container #panel-coding .coding-lesson-select-wrap label {
  color: var(--lab-muted);
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.typing-app-container #panel-coding #codingLessonSelect {
  width: 210px;
  min-height: 36px;
}

.typing-app-container #panel-coding .coding-lesson-title {
  margin: 0;
  color: var(--lab-ink);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.typing-app-container #panel-coding .coding-lessons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--lab-line);
}

.typing-app-container #panel-coding .coding-lesson-chip {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 1px solid #d6dfeb;
  color: var(--lab-muted);
  background: #fff;
  font-size: 10px;
  font-weight: 800;
}

.typing-app-container #panel-coding .coding-lesson-chip.is-current {
  border-color: #1060D0;
  color: #fff;
  background: #1060D0;
}

.typing-app-container #panel-coding .coding-lesson-chip.is-done {
  border-color: #86efac;
  color: #15803d;
  background: #f0fdf4;
}

body.dark .typing-app-container #panel-coding > .panel-title .language-tabs,
body.dark .typing-app-container #panel-coding .coding-container {
  border-color: #2a3b52;
  background: #1b2a3e;
}

body.dark .typing-app-container #panel-coding .coding-stats-header {
  border-color: #2a3b52;
}

body.dark .typing-app-container #panel-coding .coding-stats-header .stat-item {
  border-color: #3a4b63;
  background: #111c2c;
}

body.dark .typing-app-container #panel-coding .coding-stats-header .stat-value {
  color: #7dd3fc;
}

body.dark .typing-app-container #panel-coding > .panel-title .lang-tab {
  color: #9aa7ba;
}

body.dark .typing-app-container #panel-coding > .panel-title .lang-tab.active,
body.dark .typing-app-container #panel-coding > .panel-title .lang-tab:hover {
  color: #bfdbfe;
  background: #243954;
}

body.dark .typing-app-container #panel-coding .coding-lesson-title {
  color: #e7edf7;
}

body.dark .typing-app-container #panel-coding .coding-lessons {
  border-color: #2a3b52;
}

body.dark .typing-app-container #panel-coding .coding-lesson-chip {
  border-color: #3a4b63;
  color: #b6c3d4;
  background: #111c2c;
}

@media (max-width: 720px) {
  .typing-app-container #panel-coding > .panel-title,
  .typing-app-container #panel-coding .coding-lesson-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .typing-app-container #panel-coding .coding-stats-header {
    width: 100%;
  }

  .typing-app-container #panel-coding .coding-stats-header .stat-item {
    min-width: 0;
    flex: 1;
    padding-inline: 7px;
  }

  .typing-app-container #panel-coding > .panel-title .language-tabs {
    width: 100%;
  }

  .typing-app-container #panel-coding > .panel-title .lang-tab {
    flex: 1;
  }

  .typing-app-container #panel-coding .coding-lesson-select-wrap {
    align-items: stretch;
    flex-direction: column;
  }

  .typing-app-container #panel-coding #codingLessonSelect {
    width: 100%;
  }

  .typing-app-container #panel-coding .coding-lesson-title {
    text-align: left;
  }
}

/* Dashboard WPM chart has its own light chart-box background in legacy CSS. */
body.dark .typing-app-container #dashWpmChart,
body.dark .typing-app-container .chart-box#dashWpmChart {
  border-color: #2a3b52;
  background: #111c2c !important;
  color: #cbd5e1;
}

body.dark .typing-app-container #dashWpmChart .tp-chart-svg {
  color: #cbd5e1;
}

/* Last responsive pass: keep every dashboard and practice box inside its grid. */
@media (max-width: 980px) {
  .typing-app-container #panel-dashboard .dashboard-body-grid,
  .typing-app-container #panel-dashboard .dashboard-main-column > .dash-main-grid > .dash-col-left {
    grid-template-columns: 1fr;
  }

  .typing-app-container #panel-dashboard .dashboard-body-grid > .dash-col-right {
    display: block;
    width: 100%;
  }

  .typing-app-container #panel-dashboard .activity-card {
    height: auto;
  }
}

@media (max-width: 640px) {
  .typing-app-container #panel-dashboard .dashboard-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .typing-app-container #panel-dashboard .summary-card {
    min-height: 58px;
    padding: 7px 8px;
  }

  .typing-app-container #panel-dashboard .summary-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .typing-app-container #panel-dashboard .summary-value {
    font-size: 13px;
  }

  .typing-app-container #panel-dashboard .summary-label {
    font-size: 6.5px;
  }
}

body.dark .typing-app-container #panel-dashboard .progress-fill,
body.dark .typing-app-container #panel-dashboard .progress-bar .progress-fill {
  background: linear-gradient(90deg, #38bdf8, #818cf8) !important;
  box-shadow: 0 0 10px rgba(56, 189, 248, .3);
}

/* Final workspace columns: left rail, flexible center, fixed right context rail. */
.typing-app-container .tp-workspace {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  width: 100%;
  max-width: none;
  align-items: start;
  gap: 16px;
}

.typing-app-container .tp-tabs-wrapper {
  position: sticky;
  top: 70px;
  width: 224px;
  height: calc(100vh - 88px);
  max-height: none;
  align-self: start;
}

.typing-app-container .tp-panels-container {
  min-width: 0;
  width: 100%;
}

.typing-app-container .tp-panel.active {
  width: 100%;
  max-width: none;
  min-height: calc(100vh - 150px);
}

/* Dashboard: summary and main content use the full center panel; activity stays right. */
.typing-app-container #panel-dashboard .dashboard-summary-grid {
  width: 100%;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 14px;
}

.typing-app-container #panel-dashboard .dashboard-body-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: stretch;
  gap: 16px;
  width: 100%;
}

.typing-app-container #panel-dashboard .dashboard-main-column {
  min-width: 0;
}

.typing-app-container #panel-dashboard .dashboard-body-grid > .dash-col-right {
  position: sticky;
  top: 70px;
  display: flex;
  height: auto;
  min-height: 0;
  align-self: stretch;
}

.typing-app-container #panel-dashboard .dashboard-body-grid > .dash-col-right .activity-card {
  width: 100%;
  min-height: 100%;
}

.typing-app-container #panel-dashboard .panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.typing-app-container #panel-dashboard .dashboard-title-copy {
  min-width: 0;
}

.typing-app-container #panel-dashboard .dashboard-progress-inline {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border: 1px solid var(--lab-line);
  border-radius: 9px;
  background: #f8fbfe;
}

.typing-app-container #panel-dashboard .dashboard-progress-inline > span:not(.dashboard-progress-label) {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.typing-app-container #panel-dashboard .dashboard-progress-inline b {
  color: #1d4ed8;
  font-size: 12px;
}

.typing-app-container #panel-dashboard .dashboard-progress-inline em {
  color: var(--lab-muted);
  font-size: 9px;
  font-style: normal;
}

.typing-app-container #panel-dashboard .dashboard-progress-label {
  color: #0284c7;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.typing-app-container #panel-dashboard .dash-main-grid {
  align-items: stretch;
}

.typing-app-container #panel-dashboard .summary-card {
  min-height: 62px;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 8px 10px;
}

.typing-app-container #panel-dashboard .summary-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  font-size: 10px;
}

.typing-app-container #panel-dashboard .summary-label {
  font-size: 7px;
  letter-spacing: .02em;
}

.typing-app-container #panel-dashboard .summary-value {
  font-size: 15px;
  line-height: 1.1;
}

.typing-app-container #panel-dashboard .summary-card > div:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.typing-app-container #panel-dashboard .dash-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  width: 100%;
  align-items: start;
  gap: 16px;
}

.typing-app-container #panel-dashboard .dash-col-left,
.typing-app-container #panel-dashboard .dash-col-right {
  min-width: 0;
}

.typing-app-container #panel-dashboard .dash-col-right {
  position: sticky;
  top: 70px;
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
}

.typing-app-container #panel-dashboard .activity-card {
  display: flex;
  min-height: 0;
  height: 100%;
  flex: 1 1 auto;
  flex-direction: column;
}

.typing-app-container #panel-dashboard .activity-card .activity-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.typing-app-container #panel-dashboard .dash-card-header h3,
.typing-app-container #panel-dashboard .cc-info h3 {
  font-size: 14px;
}

.typing-app-container #panel-dashboard .dash-card-header,
.typing-app-container #panel-dashboard .cc-header {
  margin-bottom: 10px;
}

.typing-app-container #panel-dashboard .cc-info p,
.typing-app-container #panel-dashboard .activity-item,
.typing-app-container #panel-dashboard .progress-item {
  font-size: 11px;
}

/* Lesson mode: typing canvas remains the flexible center, controls stay on the right. */
.typing-app-container #panel-practice .typing-practice-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 224px;
  align-items: start;
  gap: 16px;
  width: 100%;
}

.typing-app-container #panel-practice .typing-practice-main {
  min-width: 0;
}

.typing-app-container #panel-practice .typing-control-panel {
  position: sticky;
  top: 70px;
  width: 100%;
  align-self: start;
}

@media (max-width: 1200px) {
  .typing-app-container #panel-dashboard .dashboard-summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Hard full-viewport frame. Global .container rules must not create side gutters here. */
.typing-app-container {
  display: block !important;
  width: 100vw !important;
  max-width: none !important;
  min-width: 0 !important;
  margin-left: calc(50% - 50vw) !important;
  margin-right: 0 !important;
  overflow-x: hidden;
}

.typing-app-container .typing-topbar,
.typing-app-container .tp-main-section,
.typing-app-container .tp-main-section.bg-light {
  width: 100vw !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.typing-app-container .typing-topbar-inner,
.typing-app-container .tp-main-section > .container {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.typing-app-container .tp-main-section > .container {
  padding-left: 18px !important;
  padding-right: 18px !important;
}

.typing-app-container .tp-workspace,
.typing-app-container .tp-panels-container,
.typing-app-container .tp-panel.active {
  width: 100% !important;
  max-width: none !important;
}

.typing-app-container .tp-workspace {
  grid-template-columns: 224px minmax(0, 1fr) !important;
}

@media (max-width: 980px) {
  .typing-app-container .tp-workspace {
    display: block !important;
  }

  .typing-app-container .tp-main-section > .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

@media (max-width: 980px) {
  .typing-app-container .tp-workspace {
    display: block;
  }

  .typing-app-container .tp-tabs-wrapper {
    position: sticky;
    top: 54px;
    width: 100%;
    height: auto;
    margin-bottom: 12px;
  }

  .typing-app-container #panel-dashboard .dash-main-grid {
    grid-template-columns: 1fr;
  }

  .typing-app-container #panel-dashboard .dashboard-body-grid {
    grid-template-columns: 1fr;
  }

  .typing-app-container #panel-dashboard .dashboard-body-grid > .dash-col-right {
    position: static;
  }

  .typing-app-container #panel-dashboard .dash-col-right,
  .typing-app-container #panel-practice .typing-control-panel {
    position: static;
  }

  .typing-app-container #panel-dashboard .dash-col-right {
    display: block;
    min-height: 0;
    height: auto;
  }

  .typing-app-container #panel-dashboard .activity-card .activity-list {
    min-height: 0;
  }

  .typing-app-container #panel-dashboard .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .typing-app-container #panel-dashboard .dashboard-progress-inline {
    width: 100%;
  }

  .typing-app-container #panel-practice .typing-practice-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .typing-app-container #panel-dashboard .dashboard-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Single-navigation full-screen layout */
.typing-app-container .typing-topbar-inner {
  min-height: 54px;
  padding-inline: 24px;
}

.typing-app-container .typing-topnav {
  display: none;
}

.typing-app-container .typing-brand-mark {
  width: 30px;
  height: 30px;
}

.typing-app-container .typing-brand strong {
  font-size: 12px;
}

.typing-app-container .typing-brand small {
  font-size: 7px;
}

.typing-app-container .tp-main-section,
.typing-app-container .tp-main-section.bg-light {
  min-height: calc(100vh - 54px);
  padding: 0 0 18px;
}

.typing-app-container .tp-main-section > .container {
  padding: 0 18px 18px;
}

.typing-app-container .typing-command-bar {
  min-height: 66px;
  margin: 0 -18px 14px;
  padding: 0 18px;
}

.typing-app-container .typing-command-copy strong {
  font-size: 15px;
}

.typing-app-container .tp-login-banner {
  margin-bottom: 14px;
}

.typing-app-container .tp-workspace {
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 14px;
  min-height: calc(100vh - 150px);
}

.typing-app-container .tp-tabs-wrapper {
  top: 68px;
  height: calc(100vh - 86px);
  padding: 10px;
}

.typing-app-container .tp-panels-container {
  min-width: 0;
  min-height: calc(100vh - 150px);
}

.typing-app-container .tp-panel.active,
.typing-app-container .tp-panel.game-panel.active {
  min-height: calc(100vh - 150px);
  padding: 26px;
  border-radius: 12px;
}

/* ==========================================================================
   Typing Lab Enhancements: Loading Skeletons, Guest Banner & Quick Guide
   ========================================================================== */

/* Shimmer Loading Skeleton */
@keyframes tp-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.typing-app-container .tp-skeleton-card {
  padding: 18px;
  border-radius: 12px;
  border: 1px solid var(--lab-line);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 180px;
}

.typing-app-container .tp-skeleton-bar {
  border-radius: 6px;
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: tp-shimmer 1.5s infinite linear;
}

.typing-app-container .tp-skeleton-bar.badge { width: 80px; height: 18px; }
.typing-app-container .tp-skeleton-bar.title { width: 75%; height: 20px; }
.typing-app-container .tp-skeleton-bar.desc { width: 100%; height: 40px; }
.typing-app-container .tp-skeleton-bar.btn { width: 100%; height: 36px; margin-top: auto; }

body.dark .typing-app-container .tp-skeleton-card {
  background: #1e293b;
  border-color: #334155;
}

body.dark .typing-app-container .tp-skeleton-bar {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
}

/* Guest Mode Banner */
.typing-app-container .tp-guest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  margin-bottom: 22px;
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.95) 0%, rgba(15, 23, 42, 0.98) 100%);
  border: 1px solid rgba(167, 139, 250, 0.35);
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.18);
}

.typing-app-container .tpg-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(167, 139, 250, 0.16);
  color: #a78bfa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.typing-app-container .tpg-content {
  flex: 1;
}

.typing-app-container .tpg-title {
  margin: 0 0 4px;
  color: #f8fafc;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-app-container .tpg-badge {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.typing-app-container .tpg-text {
  margin: 0;
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.5;
}

.typing-app-container .tpg-benefits {
  color: #94a3b8;
  font-size: 11px;
}

.typing-app-container .tpg-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.typing-app-container .tpg-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  color: #0f172a !important;
  background: #38bdf8;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.typing-app-container .tpg-login-btn:hover {
  background: #7dd3fc;
  transform: translateY(-1px);
}

/* Practice Quick Guide */
.typing-app-container .practice-quick-guide {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  margin-bottom: 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  font-size: 12px;
  color: #334155;
}

body.dark .typing-app-container .practice-quick-guide {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

.typing-app-container .pqg-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.typing-app-container .pqg-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #0284c7;
  color: #ffffff;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.typing-app-container .pqg-sep {
  color: #94a3b8;
  font-size: 15px;
}

/* Ready to Type Glow Animation */
.typing-app-container #typingInput.ready-to-type {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.35) !important;
  animation: tp-pulse-glow 1.8s infinite alternate ease-in-out;
}

@keyframes tp-pulse-glow {
  0% { box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2); }
  100% { box-shadow: 0 0 0 5px rgba(56, 189, 248, 0.45); }
}

/* Visible Focus Outlines */
.typing-app-container .tp-tab:focus-visible,
.typing-app-container button:focus-visible,
.typing-app-container select:focus-visible,
.typing-app-container input:focus-visible,
.typing-app-container a:focus-visible {
  outline: 2px solid #38bdf8 !important;
  outline-offset: 2px !important;
}

/* ==========================================================================
   Responsive Rules: Sticky Horizontal Tabs, Single-Column Practice Layout
   ========================================================================== */

@media (max-width: 980px) {
  .typing-app-container .tp-main-section > .container {
    padding-inline: 12px !important;
  }

  .typing-app-container .typing-command-bar {
    margin-inline: -12px;
    padding-inline: 12px;
  }

  .typing-app-container .tp-workspace {
    display: block !important;
    min-height: 0;
  }

  /* Fully usable touch-scrollable horizontal navigation bar */
  .typing-app-container .tp-tabs-wrapper {
    position: sticky !important;
    top: 54px !important;
    z-index: 25 !important;
    display: block !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 0 14px 0 !important;
    padding: 8px 10px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    white-space: nowrap !important;
    background: var(--lab-navy) !important;
    border-radius: 12px !important;
    box-sizing: border-box !important;
    scrollbar-width: thin !important;
    scrollbar-color: #38bdf8 transparent !important;
  }

  .typing-app-container .tp-tabs-wrapper::-webkit-scrollbar {
    height: 4px;
  }

  .typing-app-container .tp-tabs-wrapper::-webkit-scrollbar-track {
    background: transparent;
  }

  .typing-app-container .tp-tabs-wrapper::-webkit-scrollbar-thumb {
    background: #38bdf8;
    border-radius: 4px;
  }

  .typing-app-container .tp-nav-intro,
  .typing-app-container .tp-nav-tip,
  .typing-app-container .tp-nav-group-label {
    display: none !important;
  }

  .typing-app-container .tp-tabs {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    width: max-content !important;
    min-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .typing-app-container .tp-nav-group {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 6px !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .typing-app-container .tp-nav-group + .tp-nav-group {
    border-top: none !important;
    border-left: 1px solid #203750 !important;
    padding-left: 6px !important;
  }

  .typing-app-container .tp-tab {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    min-height: 38px !important;
    padding: 8px 14px !important;
    font-size: 11px !important;
    border-radius: 8px !important;
  }

  .typing-app-container .tp-panels-container,
  .typing-app-container .tp-panel.active,
  .typing-app-container .tp-panel.game-panel.active {
    min-height: 0;
  }
}

/* Tablet & Mobile Single-Column Lesson Controls & Practice Layout */
@media (max-width: 768px) {
  .typing-app-container #panel-practice .practice-header {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    padding: 14px !important;
  }

  .typing-app-container #panel-practice .lesson-selector,
  .typing-app-container #panel-practice .practice-info,
  .typing-app-container #panel-practice .duration-control,
  .typing-app-container #panel-practice .backspace-control,
  .typing-app-container #panel-practice .typing-stats,
  .typing-app-container #panel-practice .practice-header-progress {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    grid-column: auto !important;
  }

  .typing-app-container #panel-practice .lesson-dropdown {
    width: 100% !important;
  }

  .typing-app-container #panel-practice .typing-stats {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
  }

  .typing-app-container #panel-practice .typing-practice-layout {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .typing-app-container #panel-practice .typing-control-panel {
    position: static !important;
    width: 100% !important;
    margin-top: 10px !important;
  }

  .typing-app-container #panel-practice .practice-buttons {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  .typing-app-container #panel-practice .practice-buttons #finishBtn {
    grid-column: 1 / -1 !important;
  }

  .typing-app-container .dashboard-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .typing-app-container .tp-guest-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px;
  }

  .typing-app-container .tpg-actions {
    width: 100%;
    margin-top: 8px;
  }

  .typing-app-container .tpg-login-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Mobile Devices (390px and below) */
@media (max-width: 480px) {
  .typing-app-container #panel-practice .typing-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
  }

  .typing-app-container #panel-practice .practice-quick-guide {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 12px;
  }

  .typing-app-container #panel-practice .practice-quick-guide .pqg-sep {
    display: none;
  }

  .typing-app-container .typing-topbar-inner {
    padding-inline: 12px;
  }

  .typing-app-container .typing-topbar-user {
    display: none;
  }

  .typing-app-container .tp-panel.active,
  .typing-app-container .tp-panel.game-panel.active {
    padding: 14px;
  }

  .typing-app-container .dashboard-summary-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }

  .typing-app-container .summary-card {
    padding: 10px;
  }
}
